-
Notifications
You must be signed in to change notification settings - Fork 16
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
Spectrum
rebinning
#29
Comments
@thjoshi and @jccurtis might have some thoughts on this. There are many ways one could do this, off the top of my head:
Someone else might know more about what is practically and mathematically desirable. This comment was moved over from #28 and expanded. Thanks @chunhochow for the references and finding a relevant discussion in Knoll, 4th Edition, 18.IV.B. |
Also found this: https://github.com/jhykes/rebin, which claims to implement the (interpolation) routine described in Knoll (4th ed) 18.IV.B. It has a general copyleft license (attribute + copyright notice + disclaimer). |
@thjoshi - I'll put a version of the interpolation |
I'll give it a quick shot tomorrow.
|
If a spectrum is rebinned with arbitrary (unequal) bin widths, you can't assign a calibration curve based on those new bins, right? In contrast to bins that are equal width (in channel or energy) which just scale a variable in the calibration curve. For arbitrary bin widths, it seems to me we would either abandon the idea of a "curve" and just keep track of the bin edges in keV, or remember the original bins that the calibration curve applies to. Looking forward to seeing the GRPP version when you have a chance @jccurtis and the code will help address my questions/thoughts. |
I've created a new branch ( @thjoshi - Please advise if you think usage of this code is inappropriate or poses another conflict. I think we should squash the commits before merging to remove the code which is currently a blatant rip from |
The counts aren't quite lining up. The relative difference in total counts ranges from about 2e-5 to 2e-3. I'm documenting here for reference.
The test is also not passing because of this. At least on my computer - are you getting a passing test @jccurtis? |
@bplimley The test passes for me. I'll need to look at this tomorrow. |
Hmmm, I just ran my tests again and they failed. Some trickery is afoot! |
I just pushed more thorough parametrized tests for |
Yo, negative value for new_edges is the problem. |
I've updated |
I also have a couple more edge cases to flush out which I'll get to next week. |
The overflow/underflow bins sound useful. What would be default? No overflow/underflow? If we are unsure how we want to implement it, we can also make it an issue and postpone it for later. @jccurtis do you want to make a pull request so we can take a look? |
I'll make a couple more additions and then make the PR. I don't want to
burn through Travis builds.
|
I've updated the |
?
becquerel/becquerel/core/rebin.py Lines 63 to 65 in 3d290e9
|
I rewrote @thjoshi / @jccurtis 's code. I need help merging the pytest files though because they've diverged too much and I have no clue what's going on in there. ====== I also looked into stochastic rebinning and the two papers referenced in Knoll. See Mark's comment which is actually inaccurate. There's two stochastic methods here: The paper says that the sao-paolo-method should preserve statistical properties of the bin-counts (e.g. Poisson errors). The deterministic interpolation/Tenzing-Joey's method would give a smaller chi-squared value because the statistical fluctuation is less. I'm not sure/haven't thought out if Mark's method preserves the statistical properties. Or whether the sao-paolo-method solves the moiré issue when the in/out bin widths are different. |
Thanks @chunhochow! I haven't had the time to finish absorbing what you're saying about the methods. But if you have a bunch of rebin code that you are happy with, can you make a pull request? (Despite the impending Travis build crisis, which isn't really a crisis, just run tests yourself before pushing or merging) |
It should probably be cleaned up a bit and tests written before it be pul requested. |
Todo/Moved:
|
@chunhochow @jccurtis when is rebinning coming to Spectrum? I was trying to use Becquerel last week for a project and was quite surprised to find that any form of rebinning wasn't in the primary branch. If additional features come later that makes sense, but in my view there should be a basic functionality already. |
rebin_like(spec)
to use the binning from another spectrumPlease expand on this, I'm not very familiar with rebinning methods or needs.
The text was updated successfully, but these errors were encountered: