Open wpotrzebowski opened 9 months ago
Most likely some differences, but it may be worth comparing to the implementation in https://github.com/scipp/essreflectometry/blob/main/src/essreflectometry/amor/resolution.py for reflectometry, at least to align naming, etc.
Looking at the equation:
Can you define: $R{1}$, $R{2}$, $\Delta R$, $\sigma_{\rm{moderator}}$ ?
I don't really understand the units: the term inside the square brackets is dimensionless maybe? (if $R$ is a radius?), the last term is units of $Q^{2}$ and the front multiplier is $1/\lambda^{2}$, so units of $1/\lambda^{4}$?
I actually don't really get why we have the $1/\lambda^{2}$ term at all, I would have expected $\sigma_{Q} / Q$ to be dimensionless?
Also, the equation seems to differ from what is in the Mantid docs? There, I don't understand why they add the tof resolution to the wavelength resolution, it doesn't seem to make much sense. You either have your data as a function of wavelength or tof, not both at the same time?
Notes related to transformations of equations
So in your equations above, $\sigma_{Q} / Q$ is dimensionless.
Now I looked again and it seems I made a mistake, the $1/\lambda^2$ is not multiplying everything, it is only the first part of the equation. So if you divide both sides of the equation by $Q^2$, then you are left with $1/(\lambda^2 Q^2)$ which is indeed dimensionless.
Regarding
Also, the equation seems to differ from what is in the Mantid docs? There, I don't understand why they add the tof resolution to the wavelength resolution, it doesn't seem to make much sense. You either have your data as a function of wavelength or tof, not both at the same time?
I found https://docs.mantidproject.org/v3.9.0/algorithms/TOFSANSResolutionByPixel-v1.html which is more in agreement with the original equation you posted above?
Yes, sorry I provided initially wrong link. It should this one https://docs.mantidproject.org/nightly/algorithms/TOFSANSResolutionByPixel-v1, which I belive provides the same equation as from v3.9.0
I found https://docs.mantidproject.org/v3.9.0/algorithms/TOFSANSResolutionByPixel-v1.html which is more in agreement with the original equation you posted above?
The implementation Neil mentioned above should be an appropriate baseline for our HC. Then, we simply need the output stored in the nxcansas as an additional dQ/Q column, for the corresponding bin centres.
Extra info from chat: We may (at least initially) simply use the maximum (across pixels contributing to any given Q-bin) Q-resolution.
Note to self: Don't forget to exclude masked pixels.
Executive summary
Implement Q SANS resolution as a per q function and store it to NXCanSAS format
Context and background knowledge
In time-of-flight SANS the resolution curves from all the wavelengths contributing to a particular Q value are averaged together, weighted by the number of neutrons detected at each wavelength. Since the resolution width is inversely proportional to wavelength this often gives a curve that is noticeably sharper in the peak and broader in the tails than a simple Gaussian.
Therefore, we need a q resolution description beyond a single value
Inputs
We need individual terms contributing to https://docs.mantidproject.org/nightly/algorithms/TOFSANSResolutionByPixel-v1 $\Delta\lambda$ values are found from the wavelength binning. For event mode $\Delta\lambda$ is very small however in practice one introduces binning from monitors or set event time bins before rebinning into user-provided wavelength steps. In any event, one should choose the largest value.
Methodology
The SANS resolution using Mildener-Carpenter approximation is defined as
$(\sigma_Q )^2 = \frac{4\pi^2}{12\lambda^2} [ 3(\frac{R_1}{L_1})^2 + 3(\frac{R_2}{L_3})^2 + (\frac{\Delta R}{L2})^2 ] + Q^2(\frac{\sigma{\lambda}}{\lambda})^2$ where L1 and L2 are the collimation length and sample-to-detector distance respectively and $\frac{1}{L_3} = \frac{1}{L_1} + \frac{1}{L2}$ and the overall effective standard deviation in wavelength is defined as: $(\sigma{\lambda})^2 = (\Delta \lambda )^2 / 12 + (\sigma_{moderator})^2$
$\Delta\lambda$ is the wavelength bin width used when histogramming the data (either using monitor time bins or specifically set event time bins). $\Delta R$ is the detector resolution (virtual ring width on the detector (mm)). For LOKI this parameter will depend on the sample-detector distance and how many pixels per straw will be taken into account. $R1$ and $R2$ are source and sample apertures in mm. ($\Delta R$, $R1$ and $R2$ should be passed from instrument control to metadata).
$\delta {moderator} $ is moderator time spread (microseconds) as a function of wavelength (Angstroms). At ISIS it is measured at LET (and probably on others instruments too). It is however not entirerly clear how this will be done at ESS but it should be assumed that this function will be supplied in metadata.
The resolution equation above is an approximation assuming that each of the terms is approximated by Gaussian distribution. This approach however can be extended by defining the Q resolution as a convolution of resolution kernels (schematically):
$r{sample-apperture}*r{binning}r_{detector-pixelation}r{TOF}*r{wavelength}$
The convolution of kernels can be then performed using e.g.
np.convolve
as demonstrated in the attached notebook. The wavelength independent terms won't change for given Q and can be calculated in advance and cached as a function, however for a wavelength-dependent term the range of wavelength contribution to a given q should be taken into account and convolution of multiple wavelength resolution should be computed.Outputs
Save to NXCanSAS format. Placeholder /entry/data/q/resolutions and /entry/data/q/resolutions_descriptions
Which interfaces are required?
Python module / function
Test cases
At minimum, generated resolution function FWHM should be compared with dQ value from Milldener-Carpenter equation
Comments
No response