-
Notifications
You must be signed in to change notification settings - Fork 1
Full beamline time-of-flight lookup table #308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| lut_wf[time_of_flight.NumberOfSimulatedNeutrons] = 10_000 | ||
| lut_wf[time_of_flight.LtotalRange] = ( | ||
| sc.scalar(0.0, unit="m"), | ||
| sc.scalar(20.0, unit="m"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using 0 here raised the "No simulation reading found for distance -0.2m." error
| # according to which component reading to use, we simply loop over distances one | ||
| # by one here. | ||
| for dist in distances: | ||
| # Find the correct simulation reading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could optimize here instead of starting the search from the beginning every time, but not sure the added complexity (probably involving keeping track of an index for the relevant component reading) is worth the (probably minimal) performance gain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop runs once for every chopper setting, and the loop is over all pixels?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the loop is over all pixels?
No the loop is over all distances in the table. Typically, about 200-400 points in the distance dimension in the table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| The chopper parameters used in the simulation (if any). | ||
| """ | ||
|
|
||
| readings: dict[str, BeamlineComponentReading] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear what this str is from the docstrings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated docstring to be clearer.
| # according to which component reading to use, we simply loop over distances one | ||
| # by one here. | ||
| for dist in distances: | ||
| # Find the correct simulation reading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop runs once for every chopper setting, and the loop is over all pixels?
|
Some more things I found with Claude: Potential Issues1. Hardcoded time_unit = "us"The old code used the input's unit: 2. Breaking API change not called out
4. Deleted chunking test
Minor observations
|
We ensure unit conversions are done at the relevant places in the downstream code that uses the table (in
True, but so far, there is no other code out there doing this. Only tables built with
This is a detail in the docs to create educational figures, and not something the users will ever do themselves. So I think we can live with that change.
This was just testing that running with more neutrons did not raise an error. The test never clearly checked any details about the chunked processing. It was basically not a good test (it's exactly the same test as the previous one, but with more neutrons in the simulation). Now, we process the data one distance at a time, so basically we are doing even finer chunking (before the chunks would be something like 20 distances at a time). But I see no use in having a test for this, as there is no longer any branching in the code: we always use chunking. |
SimonHeybrock
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Some monitors can be placed between choppers and even before the first choppers.
Until now, we only covered a range of distances in the tof lookup table that started after the last chopper in the cascade.
This PR generalizes the mechanism so we can build LUTs for the full beamline range.

For Odin, it now looks as follows:
Note that the
SimulationResultsclass has changed, it is now a dict of event readings at various places along the beamline. Each reading is now essentially what theSimulationResultsused to be before.Note however that despite this change, no updates to the workflow that computes a LUT were necessary (e.g. notebooks for Odin and Dream).
The only small difference (apart from widening the
LtotalRange) is that it is likely that we need to increase theLookupTableRelativeErrorThresholdparameter in these notebooks, as the mixing of wavelengths is high at small distances, before the first choppers.