Closed Lazersmoke closed 1 month ago
Thanks Sam, this looks like a really nice start. I will need to spend some time digesting it. We should also collect feedback from people who used binning in 0.6.
I don't want to conflict with the changes in progress, but here are some unit tests! This tests the codepath involving constructing a QGrid followed by specify_transverse_binning, and also using unit_resolution_binning_parameters, but there is no load_nxs test.
It also resulted in a nice graphic :)
In Sunny v0.7, there are
QGrid{2}
s andQPath
s. These each contain slightly less information than is needed to fully specify the regions of Q-space which the data comes from. In particular, you can have multiple transverse binning configurations (blue box, orange box) which are centered on exactly the sameQPath
(red Xs), see image:This PR adds
specify_transverse_binning
which "upgrades" aQGrid{2}
orQPath
into the correspondingBinningParameters
, taking the extra information about the transverse binning as input. This function should be used in conjunction withintegrate_axes!
andenergy_resolve!
to further add energy-binning information or to integrate out unneeded axes.It also adds
binned_intensities
, which does the following:SampledCorrelations
could possibly contribute to a givenBinningParameters
histogramQPoints
and uses the existingintensities(...)
function to compute the intensitiesres
with typeBinnedIntensities
, which is this:Then, the user can call
plot_intensities
to get a plot with automatically determined axes and axes labels (supports the cases where all but up to two dimensions are integrated out currently). By default, this dividesdata
bycounts
to best match the idea of a continuous S(q,w) as used by the other intensities types. As an example, here's how you would modify the Example#2 to pick a transverse binning direction and plot:The two plots (not shown) are identical up to an overall scale because transverse binning didn't matter in this case.
Note: The momentum axis labels of these plots are different from the non-binned case; they describe the real-space direction of dispersion represented by each axis. This gives a slightly different set of information than the [H,K,L] labels when fewer than three axes are displayed, but this is often the more relevant information in situations where you care about transverse binning effects anyway. This becomes important in the case where things are not orthogonal:
Notice the axes labels are NOT [H,0,0] and [K,K,0], even though that's how the q-grid was specified. If I told you that the transverse binning direction was
+ 1.0 dz
, then you could infer the HKL labels from the given real-space information, but not knowing that and just looking at the plot you couldn't infer that. Instead, you get to know that the x-axis has to do with dispersion in the-b+a
real-space direction, which is not something you can know from the HKL labels directly (unless you also knew that [0,0,L] was the third direction).The PR also un-comments and cleans up a few internal binning methods used by
binned_intensities
to better support the static case (where energy is integrated out). Static and dynamic correlations should be fully supported!This PR should be thought of as a reference implementation/problem statement for what's missing in terms of binning support from
QGrid
, rather than a finished product, so happy for any edits or suggestions :)