Skip to content

SANS Q Resolution stored as generic function #360

Description

@wpotrzebowski

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}{L_2})^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}{L_2}$
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

Activity

  1. SimonHeybrock commented on Mar 5, 2024

    @SimonHeybrock
    Member

    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.

  2. wpotrzebowski commented on Mar 6, 2024

    @wpotrzebowski
    Author
  3. nvaytet commented on Mar 7, 2024

    @nvaytet
    Member

    Looking at the equation:

    1. Can you define: $R_{1}$, $R_{2}$, $\Delta R$, $\sigma_{\rm{moderator}}$ ?

    2. 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}$?

    3. 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?

  4. wpotrzebowski commented on Mar 11, 2024

    @wpotrzebowski
    Author

    Notes related to transformations of equations
    TOF_resolution_notes

  5. nvaytet commented on Mar 18, 2024

    @nvaytet
    Member

    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?

  6. wpotrzebowski commented on Mar 19, 2024

    @wpotrzebowski
    Author

    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

  7. changed the title [-][DRAFT] SANS Q Resolution stored as generic function[/-] [+]SANS Q Resolution stored as generic function[/+] on Mar 19, 2024
  8. olihammond commented on Nov 7, 2024

    @olihammond

    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.

  9. self-assigned this
    on Nov 7, 2024
  10. SimonHeybrock commented on Nov 7, 2024

    @SimonHeybrock
    Member

    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.

  11. transferred this issue fromscipp/esssanson Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions