Repository navigation
[ESSREFLECTOMETRY] docs: better ground truth comparison in user guide - #739
Conversation
33c4e08 to
5aaadce
Compare
| "To compare it with this measurement, we smooth it with a kernel whose width varies with $Q$ and uses this run's `Q_resolution` coordinate.\n", | ||
| "This standard deviation includes the wavelength, sample-size, and detector contributions, averaged over the angles contributing to each $Q$ bin.\n", | ||
| "\n", | ||
| "We use [Refl1D's `convolve_sampled`](https://refl1d.readthedocs.io/en/stable/_modules/refl1d/sample/reflectivity.html), which integrates a tabulated ideal curve against a tabulated kernel.\n", |
| " x=q.values[valid.values],\n", | ||
| " dx=half_width.values[valid.values],\n", | ||
| ")\n", | ||
| "smoothed_ground_truth = sc.DataArray(\n", |
There was a problem hiding this comment.
Having the plot in the notebook is great. It's unfortunate that we need so much code to produce it. Can we think of another way?
There was a problem hiding this comment.
Added a helper for smoothing the ideal curve with the resolution of the reduced data.
That let's us remove the code from the notebook.
It's quite special purpose, but I don't think it makes much sense to generalize it more for now.
| coords={ | ||
| 'Q': sc.array(dims='Q', values=[0, *ds[Qcol].values], unit='1/angstrom') | ||
| }, | ||
| coords={'Q': sc.array(dims='Q', values=ds[Qcol].values, unit='1/angstrom')}, |
There was a problem hiding this comment.
What was the reason for this change?
There was a problem hiding this comment.
I think that was a bit of a hack to make the reference curve be displayed as a line instead of as markers in the figures. It should not have been like that to begin with. :/
| Uses a symmetric trapezoid with a Q-dependent width, scaled so that its | ||
| standard deviation matches ``Q_resolution``. The kernel shape is a modelling | ||
| assumption: the standard deviation alone does not determine the response. | ||
| Requires the optional Refl1D package (``pip install refl1d``). |
There was a problem hiding this comment.
I was wondering if we needed to use refl1d or if we could do the same with scipy (which is maybe more common)?
I don't mind either way, it's just adding a dep to the tests/docs builds.
There was a problem hiding this comment.
The feature we're after here that don't exist in scipy is the ability to smooth the signal by a kernel with a width that varies over Q in an irregular way (that is, not constant, not proportional to Q, but possibly different for at every point).

It's nice to have a comparison that takes into account the instrument resolution, because then you can actually see that the results matches what we expect.
This is what the added figure looks like: