Folding

[1]:
import nexus as nx
import numpy as np
import matplotlib.pyplot as plt

def gauss(x, offset):
  return np.exp(-1/2*(x-offset)**2/0.1*2)

arr = np.linspace(-8, 8, 1000)

dat = gauss(arr, -4) + gauss(arr, 4.6)

plt.plot(dat)
plt.xlabel('index')
plt.ylabel('value')
plt.show()
../../_images/tutorial_data_nb_folding_1_0.png
[2]:
folded_dat = nx.data.Fold(dat, 512+37, flip = 'right')

plt.plot(folded_dat)
plt.xlabel('index')
plt.ylabel('value')
plt.show()
../../_images/tutorial_data_nb_folding_2_0.png
[3]:
# in veriosn 1
folded_dat, folding_point, _ = nx.data.AutoFold(dat,
                                             flip = 'right',
                                             # factor = 1,       # interpolation factor
                                             # method = "linear"   # or "cubic", "PChip", "Akima" -  interpolation method
                                             )

# in verison 2
folded_dat, folding_point, list_additional_data = nx.data.AutoFold(dat,
                                             flip = 'right',
                                             # factor = 1,       # interpolation factor
                                             # method = "linear"   # or "cubic", "PChip", "Akima" -  interpolation method
                                             )

print("folding_point {}".format(folding_point))

plt.plot(folded_dat)
plt.xlabel('index')
plt.ylabel('value')
plt.show()
folding_point 37.0
../../_images/tutorial_data_nb_folding_3_1.png