oslocyclotronlab / ompy_Archive_Sept2019

Archived version om ompy as of 27. Sept 2019 -- Please use this instead:
https://github.com/oslocyclotronlab/ompy/
GNU General Public License v3.0
0 stars 1 forks source link

Still a bug in gauss smoothing #20

Closed fzeiser closed 5 years ago

fzeiser commented 5 years ago

Issue by fzeiser Friday Jul 12, 2019 at 12:44 GMT Originally opened as https://github.com/oslocyclotronlab/ompy/issues/20


Issue by fzeiser Thursday Jul 11, 2019 at 16:20 GMT Originally opened as https://github.com/jorgenem/ompy/issues/16


The proposed bugfix in commit 28f523b0aa13bd61b3beac1921f2ee3cbc77e231 only changed the problem. If you now repeatedly do a gauss smoothing, it shifts the peak to the right (higher energies):

Screenshot at 2019-07-11 18-18-37

Peak at 50 is shifted after smoothing (orange line) to the right. The green line is the gaussian.

E_array = np.linspace(0, 200., 201*2)
counts_array = np.zeros(len(E_array))
counts_array[100] = 1
counts_array_smoothed = ompy.gauss_smoothing(counts_array, E_array, 2*np.ones(len(E_array)))
for i in range(20):
    counts_array_smoothed = ompy.gauss_smoothing(counts_array_smoothed, E_array, 2*np.ones(len(E_array)))

gaussian = ompy.gaussian(E_array,mu=50.0, sigma=1)
gaussian /= gaussian.sum()

f, ax = plt.subplots(1)
ax.plot(E_array, counts_array)
ax.plot(E_array, counts_array_smoothed)
ax.plot(E_array, gaussian, "o")

print("sum(counts_array) = ", counts_array.sum())
print("sum(counts_array_smoothed) = ", counts_array_smoothed.sum())
fzeiser commented 5 years ago

Comment by fzeiser Friday Jul 12, 2019 at 12:44 GMT


Comment by fzeiser Friday Jul 12, 2019 at 06:51 GMT


I got a temp fix using gaussian_fiter1d; it's something about the truncation. I'll continue to work on it at Blindern.