-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add binned_histogram
#84
Conversation
TODO's on this include:
|
This sounds relevant to @ddahlbom |
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 looks great. Thanks for the PR.
I do think DataRetrieval.jl
is the right place for it. We may expand this into a folder with more fine-grained divisions in the future.
I was a bit skeptical on the call as to whether all the components should be stored in a single covector (as opposed to explicitly treating q and omega separately, as in the rest of the code), but it does result in cleaner code even if there are no relativistic transformations.
I guess you'll have to write a different binned_histogram(sw:SpinWaveTheory, ...)
. Out of curiosity, what will be the approach there? Will you perform some kind of sampling/integration over the bins?
I put some (trivial) comments in the code.
|
||
# Integrate over one or more axes of the histogram by setting the number of bins | ||
# in that axis to 1 | ||
function integrate_params!(params::BinningParameters;axis) |
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.
Perhaps integrate_parameters!
, since "parameters" is written out in full elsewhere. Or maybe integrate_axes!
is more precise. That it is operating on binning parameters is implied by the argument type.
end | ||
|
||
# Support numbins as a (virtual) property, even though only the binwidth is stored | ||
Base.getproperty(params::BinningParameters, sym::Symbol) = sym == :numbins ? round.(Int64,(params.binend .- params.binstart) ./ params.binwidth) : getfield(params,sym) |
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 a neat pattern. I hadn't seen it before.
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.
Yep! One slight issue is that code like params.numbins[4] = 1
doesn't work how you would expect (it's a no-op). I don't know if that's a deal breaker for this interface, but it's papered over by integrate_params!
currently.
|
||
# This places one histogram bin around each possible Sunny scattering vector. | ||
# This is the finest possible binning without creating bins with zero scattering vectors in them. | ||
function unit_res_binning_parameters(sf::StructureFactor) |
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.
I know these function names are getting long, but maybe write out resolution
in full.
Additional TODO on this, per discussion: need to incorporate broadening into the inner histogram loop, same as LSWT code. |
- Updated FeI2 example to include binning - Added Binning Tutorial as an example (maybe this should go in a subfolder?) - Added energy broadening for binned data - Added `connected_path_bins` for making spaghetti plots while recording the binning parameters for each subplot (for use in Mantid)
The correct calculation involves integrating over bins.
@ddahlbom Currently, the binned intensities functions (linear and spherical) do not handle the form factors, contractors, and possibly |
@Lazersmoke Sure, that sounds great. Just let us know when when you're done making the final touches. I'd be happy to incorporate the rest of the |
Added a few lines to the powder averaging tutorial to demonstrate it. Improved documentation for `BinningParameters` Updated binning tutorial to be more in line with other examples, e.g. speed and plotting library is now Makie.
OK, the final touches are done :) I've added examples of binned version to the FeI2 and powder averaging tutorials. Some of the plotting is a bit rough around the edges. There's a remaining question about the exact behavior of the "partial bins" at the far edge of the histogram, sometimes the behavior is possibly not quite correct, but the issue is that it's a bit under-specified what should be done in that case. Mantid has a bunch of options on like every function call that specify what to do with them, seems like. It shouldn't be a big issue for most use cases. Remaining items for @ddahlbom and co:
|
Thanks @Lazersmoke ! This is a great addition. I'll take a closer look at the code soon. If there are any changes that seem like they should be made before merging, I will comment here. (I suppose we may want to merge sooner rather than later to keep things in sync. I can complete the remaining tasks after this is integrated.) |
This isn't finished/polished yet (opening this PR to track progress).
This is the alternative interface to
intensities
which is designed to more closely align with what Mantid/Horace output. In particular, the new typeBinningParameters
is supposed to be isomorphic to the data Mantid uses to describe an "MDHistoWorkspace".Example usage:
The resulting intensity histogram looks something like this: