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()
[2]:
folded_dat = nx.data.Fold(dat, 512+37, flip = 'right')
plt.plot(folded_dat)
plt.xlabel('index')
plt.ylabel('value')
plt.show()
[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