-
-
Notifications
You must be signed in to change notification settings - Fork 56
Irregular rebinning function and Analysis Subpackage#726
Conversation
This just moves the rebin code, but the rebin method remains in NDCube.
133d184 to
c2923aa
Compare
settwi
commented
Jun 13, 2024
Hey Dan this looks really good. I especially like the option to propagate uncertainties (and presumably other metadata, too?). It will save us headaches in other applications.
Occasionally it is nice to do some interpolation of bins, too, like when binning a spectral response down from fine photon bins to coarser count bins, or to "directly" compare data from different instruments with different energy bins. For histograms you want to conserve the "flux" in each bin and the simplest way to do it is just a proportional interpolation. For photon count or flux data I reckon this approach makes sense.
I made a gist a while back to do an interpolating rebinning which has proved useful a few times. Might be nice to add a similar functionality to ndcube. Maybe "rebin_interpolated" or something like that. "Normal" rebinning is just a subset of the interpolating version, but it might make sense to specialize the implementations to save on computation time.
@samaloney
samaloney
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is GREAT! I still need to actually try it out but just figured get these down now.
Co-authored-by: Shane Maloney <maloneys@tcd.ie>
DanRyanIrish
commented
Jun 14, 2024
Hi @settwi. Thanks for the comments. I definitely agree with the use-cases you pointed out. From a technical perspective, I think they are already served by NDCube.reproject_to, assuming you generate the new WCS separately, which, I grant, can be a more cumbersome API. I am right though? Is there a difference between rebin_interpolated and reproject_to other than a more restrictive and hence more friendly API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DanRyanIrish
commented
Jul 1, 2024
We should consider whether rebin_by_edges should be rebin_by_corners to be consistent with the axis_world_coords(corners=True) API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should wrap this to maintain the signature. Perhaps we could use this: https://docs.python.org/3/library/functools.html#functools.wraps to avoid the copy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cadair can you elaborate on this? From the example in that link it looks like it's serving the wrong direction to the one we need...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using extra coords as a way to do this is a bit "weird" using table coordinate directly might be more applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this require extra code to parse whether it should be a QuantityTableCoordinate, TimeTableCoordinate, etc.? If so, ExtraCoords already does this for us.
Hello 👋, Thanks for your contribution to ndcube!
I have marked this pull request as stale because there hasn't had any activity in five months. If you are still working on this, or if it's waiting on a maintainer to look at it then please let us know and we will keep it open. Please add a comment with: @sunpy/ndcube-developers to get someone's attention.
If nobody comments on this pull request for another month, it will be closed.
Hello again 👋, We want to thank you again for your contribution to ndcube!
This pull request has had no activity since my last reminder, so I am going to close it. If at any time you want to come back to this please feel free to reopen it! If you want to discuss this, please add a comment with: @sunpy/ndcube-developers and someone will get back to you soon.
PING for sunkit-spex and potentially radiospectra
Uh oh!
There was an error while loading. Please reload this page.
PR Description
Following the structure outline by #725, this PR creates an
analysissubpackage and arebinmodule. Included in therebinmodule is the implementation of therebinmethod, which now simply calls therebinfunction.However, crucially, it also includes a
rebin_by_edgesfunction, which allows users to rebin anNDCubewhich irregular bin sizes along an axis. This is a very important functionality for certain analyses, e.g. solar X-ray imaging spectroscopy.Due to technical limitations,
ndcubecan currently only support this if the WCS axes are independent, and so is not within the scope of anNDCubemethod. However, if this limitation is overcome in the future, anNDCube.rebin_by_edgesmethod can be implemented as a wrapper around this function.To Do
NDCube.rebin. Explicitly list out inputs, rather than using*argsand `**kwargs``.rebin_by_edgesTo Consider
rebin_by_edgestorebin_by_corners