Skip to content

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented Feb 6, 2026

See discussion here: scipp/essdiffraction#236 (comment)

Instead of hard-coding the error threshold on the LUTs saved to disk, we mask later, in the GenericTofWorkflow.
The LookupTableRelativeErrorThreshold is now a parameter of the main GenericTofWorkflow instead of the workflow that builds the table, and can be set by the user.

This means that scientists can control what threshold they want to apply.
We set a default value on the workflow so that we don't break existing workflows and notebooks.

@nvaytet nvaytet requested a review from SimonHeybrock February 6, 2026 11:10
"pulse_stride",
"distance_resolution",
"time_resolution",
"error_threshold",
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that the table may or may not have a error_threshold coord. If it does not, trying to remove it using drop_coords would raise. So we filter it out here.


# Default parameters
wf[PulseStrideOffset] = None
wf[LookupTableRelativeErrorThreshold] = 1.0
Copy link
Member Author

Choose a reason for hiding this comment

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

Should the default be something like np.inf?

Comment on lines +26 to 30
ErrorLimitedTofLookupTable,
LookupTableRelativeErrorThreshold,
MonitorLtotal,
PulseStrideOffset,
TimeOfFlightLookupTable,
Copy link
Member

Choose a reason for hiding this comment

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

Do we worry about inconsistent naming, TimeOfFlightLookupTable vs LookupTableRelativeErrorThreshold etc.?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean should LookupTableRelativeErrorThreshold be changed to TofLookupTableRelativeErrorThreshold?

As it's sort of a new param we are adding to the GenericTofWorkflow, now would probably be the best time to make the change.

As for TimeOfFlightLookupTable vs TofLookupTable, this has already been changed and the old TimeOfFlightLookupTable is kept as an alias for retro-compatibility.

Comment on lines +416 to +419
# TODO: The error threshold could be made dependent on the time-of-flight or
# distance, instead of being a single value for the whole table.
da = table.array
relative_error = sc.stddevs(da.data) / sc.values(da.data)
Copy link
Member

Choose a reason for hiding this comment

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

Is da.data guaranteed to be positive?

Copy link
Member Author

Choose a reason for hiding this comment

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

The data will either be time-of-flight or wavelength, so yes they will always be positive.


# Default parameters
wf[PulseStrideOffset] = None
wf[LookupTableRelativeErrorThreshold] = 1.0
Copy link
Member

Choose a reason for hiding this comment

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

Why this (new) default?

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 don't know, it seems to have worked fine for the 3 examples (v20, dream, ordin) that I tried.
But as I mention above in a comment, I was wondering if it should just be Inf as a default value...

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.

2 participants