Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally boundary modes when smoothing #126

Open
fzeiser opened this issue May 12, 2020 · 1 comment
Open

Optionally boundary modes when smoothing #126

fzeiser opened this issue May 12, 2020 · 1 comment
Assignees
Labels
feature_request Requestion this feature

Comments

@fzeiser
Copy link
Collaborator

fzeiser commented May 12, 2020

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

@fzeiser fzeiser added the feature_request Requestion this feature label May 12, 2020
@fzeiser fzeiser self-assigned this May 12, 2020
@fzeiser fzeiser changed the title Optionally reflect boundaries when smoothing Optionally boundary modes when smoothing May 14, 2020
@fzeiser
Copy link
Collaborator Author

fzeiser commented May 14, 2020

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
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature_request Requestion this feature
Projects
None yet
Development

No branches or pull requests

1 participant