Open fzeiser opened 4 years ago
The current smoothing is similar to mode=constant
(with filling value 0) but the kernel is always normalized to 1, such that we don't "loose" counts to the channel below ch0. See mode info o gaussian_filter1d:
mode{‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional
The mode parameter determines how the input array is extended beyond its boundaries. Default is ‘reflect’. Behavior for each valid value is as follows: ‘reflect’ (d c b a | a b c d | d c b a) The input is extended by reflecting about the edge of the last pixel. ‘constant’ (k k k k | a b c d | k k k k) The input is extended by filling all values beyond the edge with the same constant value, defined by the cval parameter. ‘nearest’ (a a a a | a b c d | d d d d) The input is extended by replicating the last pixel. ‘mirror’ (d c b | a b c d | c b a) The input is extended by reflecting about the center of the last pixel. ‘wrap’ (a b c d | a b c d | a b c d) The input is extended by wrapping around to the opposite edge.
The differences many come up when we imagine that we have a spectrum, but just between 1 and 5 MeV, which we want to smooth with the detector resolution -> how are the edges treated. I think it might make most sense to treat it as ‘nearest (a a a a | a b c d | d d d d)’ or, ig 5 MeV is at exactly the full energy, it should be yet another option: (a a a a | a b c d | 0 0 0 0)
If one just looks at the values, it resembles more the "reflect" option
Add an option to reflect boundaries when smoothing, such that a matrix which is cut at Ex=Ex_min does not "loose" counts out of the window; analogously to scipy.ndimage.gaussian_filter1d