Skip to content

[essreduce] Make default mode for computing wavelengths 'analytical' - #892

Open
nvaytet wants to merge 16 commits into
mainfrom
default-analytical-lut
Open

nvaytet wants to merge 16 commits into
mainfrom
default-analytical-lut

Conversation

@nvaytet

@nvaytet nvaytet commented Nov 19, 2026

Copy link
Copy Markdown
Member

Fixes #863

@nvaytet nvaytet added essimaging Issues for essimaging. essreduce Issues for essreduce. essnmx Issues for essnmx. essreflectometry Issues for essreflectometry. esssans Issues for esssans. essdiffraction Issues for essdiffraction. essspectroscopy Issues for essspectroscopy. labels Nov 19, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cleaned up the docs for frame unwrapping and WFM that were difficult to follow, with many thing duplicated in different notebooks.

Now we use analytical mode everywhere, and we just keep the one notebook that describes the 3 methods.

@nvaytet

nvaytet commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

I had to update the reference reduced result for NMX, after switching to analytical LUT.
This was in a TODO item anyway, so we expected this to change.
There were some small differences in the result, which was also expected.

Figure 1 (40) Figure 1 (41)

@nvaytet
nvaytet marked this pull request as ready for review November 20, 2026 13:03
@jokasimr jokasimr self-assigned this Nov 20, 2026

@jokasimr jokasimr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Just some minor comments on the changes in the WFM notebook.

"source": [
"# Wavelength frame multiplication\n",
"\n",
"Wavelength frame multiplication (WFM) is a technique commonly used at long-pulse facilities to improve the resolution of the results measured at the neutron detectors.\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the explanation for the term WFM go away? Seem useful to have in the introduction.

"\n",
"This is the basis for creating our lookup table."
"As a consistency check, because we actually know the wavelengths of the neutrons we created,\n",
"we can compare the true neutron wavelengths to those we computed above."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this section it would be good if we also display a histogram over error (error := true_wavelength - computed_wavelength), or a histogram over "relative error".

It would be good because that more directly illustrates what we want to demonstrate: Are the wavelength estimates good or not? How good? Are they unbiased? Is the error distribution symmetric? Etc.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. I started adding some plots, but I think I want to finally implement scipp/plopp#201 which would be useful here.
I'll probably go with this syntax plopp.residuals(wfm_computed, reference=true_wavelengths).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that is not what I meant in this case. I didn't mean difference of the histograms, I meant a histogram of the differences (for every event).

That is, we have events with two coordinates true_wavelength and estimated_wavelength, and I'd like to see a histogram of error:=true_wavelength-estimated_wavelength.

Something like this: https://scipp.github.io/ess/reflectometry/user-guide/freia/freia-visualizations.html#Error-of-the-wavelength-estimate

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I made it 2d, as I think it's also interesting to keep the dependence on wavelength

Screenshot_20261120_183449

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you really see the effect of the thickness of the polygons: thicker (more uncertainty) in the middle of the 2 WFM frames, and thinner (more accurate) at the edges of the frames.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

},
"outputs": [],
"source": [
"from ess.powder.types import DspacingBins, Filename, SampleRun, VanadiumRun\n",

@nvaytet nvaytet Nov 20, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It proved too difficult to get this to work with the default analytical wavelength LUT.
The example Geant4 data does not have any chopper info. Instead we relied on the "file" method, but if I want to activate this here, I have to create and register a new workflow just for this notebook to work:

@register_workflow
def DreamGeant4ProtonChargeWorkflowFileLUT() -> sciline.Pipeline:
    """
    Workflow with default parameters for the Dream Geant4 simulation, using
    proton charge for the normalization.
    """
    return DreamGeant4Workflow(run_norm=RunNormalization.proton_charge, wavelength_from="file")

which seems overkill (and I would probably also have to add more workflows for the other normalization modes). This shows a limitation of the method anyway, that you have an explosion of cases if you have more args to create the workflow.

Finally, it is pretty likely that this won't be used much moving forwards, as we are moving towards batch reduction GUIs anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, the solution here was to not execute this notebook when building the docs. We leave it in for now, but it will just look empty.

@nvaytet

nvaytet commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Any more comments @jokasimr ?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

essdiffraction Issues for essdiffraction. essimaging Issues for essimaging. essnmx Issues for essnmx. essreduce Issues for essreduce. essreflectometry Issues for essreflectometry. esssans Issues for esssans. essspectroscopy Issues for essspectroscopy.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default to compute wavelength LUTs on-the-fly, instead of using LUT from file

2 participants