This commit is contained in:
voulot_d
2017-05-30 17:28:37 +02:00
parent a65efe7076
commit 202cf3bb79
7 changed files with 110 additions and 32 deletions

View File

@@ -13,11 +13,13 @@ def hfitoff(data, xdeg):
xrad = xdeg / 180 * np.pi
optimize_func = lambda x: x[0] * np.sin(xrad + x[1]) + x[2] - data
fit_amplitude, fit_phase, fit_offset = leastsq(optimize_func, [guess_amplitude, guess_phase, guess_offset])[0]
if fit_amplitude < 0:
fit_amplitude = -fit_amplitude
fit_phase = fit_phase - np.pi
fit_xdeg = np.linspace(start, end, 100)
fit_data = fit_amplitude * np.sin(fit_xdeg / 180 * np.pi + fit_phase) + fit_offset
ph_crest = 90 - fit_phase / np.pi * 180
xdeg_max = xdeg[np.argmax(data)]
if start <= ph_crest <= end:
return (fit_amplitude, fit_phase, fit_offset, True, ph_crest, fit_xdeg, fit_data)
else:
return (fit_amplitude, fit_phase, fit_offset, False, xdeg_max, fit_xdeg, fit_data)
fit_phase_deg = fit_phase / np.pi * 180
ph_crest = 90 - fit_phase_deg
if ph_crest > 180:
ph_crest = ph_crest - 360
return (fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_xdeg, fit_data)

View File

@@ -3,7 +3,7 @@ from jeputils import *
def hfitoff(data, xdeg):
ret = call_jep("CPython/hfitoff", "hfitoff", [to_npa(data),to_npa(xdeg)])
print ret
return (ret[0], ret[1], ret[2],ret[3], ret[4], ret[5].data,ret[6].data)
return (ret[0], ret[1], ret[2],ret[3], ret[4].data,ret[5].data)
def gfitoff(x, y, off=None, amp=None, com=None, sigma=None):
ret = call_jep("CPython/gfitoff", "gfitoff", [to_npa(x), to_npa(y), off, amp, com, sigma])