Skip to content

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented Jul 8, 2025

This is an alternative to #251 .

Instead of having one tof LUT per RunType, we have a single LUT, which is loaded from file.
This will be the main mode of operation for production workflows.

If one wishes to compute the LUT on-the-fly, using tof, we now have to use a separate workflow that is designed to do just this. The TofLutWorkflow is used to compute TimeOfFlightLookupTable, and the result of this is then set on the GenericTofWorkflow, bypassing the provider that loads the table from file.

I don't think that having different LUT for different runs is a good idea in practice (@jokasimr pointed out that different chopper settings would change the distribution of neutrons, which would make different measurements incompatible in most cases).
If it turns out we do need this in the future, we could always add a wrapper provider that turns TimeOfFlightLookupTable into TimeOfFlightLookupTable[RunType].
Inserting a custom LUT for a single run can then still be done via

table = lut_wf.compute(TimeOfFlightLookupTable)
wf[TimeOfFlightLookupTable[SampleRun]] = table

@nvaytet nvaytet requested a review from jl-wynen July 8, 2025 21:52
@nvaytet nvaytet changed the title Use a second dedicated workflow to compute tof LUT Use a dedicated workflow to compute tof LUT Jul 8, 2025
)


def TofLutWorkflow():
Copy link
Member Author

@nvaytet nvaytet Jul 9, 2025

Choose a reason for hiding this comment

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

Any suggestions for a better name are welcome 😄

Copy link
Member

Choose a reason for hiding this comment

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

You could spell it out. E.g., TofLookupTableWorkflow or even TimeOfFlightLookupTableWorkflow. But I think the former is good enough. People typically know what 'tof' means but not 'lut'. Also, we spell out LookupTable elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm also thinking of renaming TimeOfFlightLookupTable to TofLookupTable, as part of the naming standardization and freeze (e.g. https://github.com/scipp/ess-project/issues/38).

"We can see from the workflow diagram that we are still missing the simulated neutrons that are used to build the lookup table.\n",
"By default, the workflow tries to load a `TimeOfFlightLookupTable` from a file.\n",
"\n",
"In this notebook, instead of using such a pre-prepare file,\n",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"In this notebook, instead of using such a pre-prepare file,\n",
"In this notebook, instead of using such a pre-prepared file,\n",

Or better 'pre-made' to have less repitition.

"source": [
"### Building the time-of-flight lookup table\n",
"\n",
"We use the `tof` module to propagate a pulse of neutrons through the chopper system to the detectors,\n",
Copy link
Member

Choose a reason for hiding this comment

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

Please link to tof here.

)


def TofLutWorkflow():
Copy link
Member

Choose a reason for hiding this comment

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

You could spell it out. E.g., TofLookupTableWorkflow or even TimeOfFlightLookupTableWorkflow. But I think the former is good enough. People typically know what 'tof' means but not 'lut'. Also, we spell out LookupTable elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

Did you change any functions here or did you only move code into this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Only moved code.

@nvaytet nvaytet merged commit 3a652d1 into main Jul 14, 2025
4 checks passed
@nvaytet nvaytet deleted the tof-lut-helper branch July 14, 2025 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants