Skip to content

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented Jan 19, 2026

Add the ability to compute WavelengthDetector and WavelengthMonitor to GenericTofWorkflow.

This can be overridden in downstream packages:

  • diffraction: the provider either adds more coordinates than just wavelength
  • SANS: the wavelengthDetector type is different WavelengthDetector[RunType, Numerator]

but it is still useful to have a default implementation here (for e.g. livedata)

@nvaytet nvaytet requested a review from SimonHeybrock January 19, 2026 20:03
Copy link
Member

@SimonHeybrock SimonHeybrock left a comment

Choose a reason for hiding this comment

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

Two questions aside from comments below:

  • Should downstream packages that compute this differently remove/prune this do avoid confusion if they use a different domain type, do avoid users computing the false one?
  • Could the TOF lookup produce wavelength directly to avoid the extra intermediate step?

return ToaDetector[RunType](result)


def detector_wavalength_data(
Copy link
Member

Choose a reason for hiding this comment

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

Spelling

Total length of the flight path from the source to the detector.
"""
return WavelengthDetector[RunType](
detector_data.assign_coords(Ltotal=ltotal).transform_coords(
Copy link
Member

Choose a reason for hiding this comment

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

I thought this is (or should) already be added when computing TOF?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't add the Ltotal coord on the TofDetector.
We just add source_position and sample_position in the coord transform graph and compute Ltotal from that, but it doesn't make it in the output (see https://github.com/scipp/essreduce/blob/main/src/ess/reduce/time_of_flight/eto_to_tof.py#L335)

source_position and sample_position don't make it either in the output.
This was what we did during the Scipp retreat (before that, I think we were adding these coords to the output).

It does mean that now, if you have a data array which is the TofDetector, you can't compute wavelength from just that. It is no longer self-contained.

Should we add the coords back in?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure about our reasoning in October. Wouldn't you think it is conceptually sensible and safer to add it as a coord? I don't think the positions are necessary, but TOF only makes sense with a known Ltotal, right? In a sense they form a pair.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree. I'll add Ltotal then!

Comment on lines 534 to 535
ltotal: DetectorLtotal[RunType],
graph: CoordTransformGraph,
Copy link
Member

Choose a reason for hiding this comment

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

Feels a bit odd to have both of these here. If both ltotal and tof is given by the inputs, why do we need a transform graph? Does passing it here give a false promise that the wavelength computation can be influenced via the graph? It might lead to surprising bugs if the graph does some special flightpath correction but then gets silently ignored.

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 we instead forget about the graph and transform coords and compute the wavelength manually using the formula?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, or import the underlying function, not the entire graph?

@nvaytet
Copy link
Member Author

nvaytet commented Jan 20, 2026

Should downstream packages that compute this differently remove/prune this do avoid confusion if they use a different domain type, do avoid users computing the false one?

Good question, I am not sure how best to do this actually.

Could the TOF lookup produce wavelength directly to avoid the extra intermediate step?

Did you mean just compute wavelength and not have a TofDetector? Or did you mean just have a provider that computes it from the lookup, without going via the TofDetector, where the end graph would allow you to compute both TofDetector and WavelengthDetector, where both these nodes would be connected to the same parents?

@SimonHeybrock
Copy link
Member

SimonHeybrock commented Jan 20, 2026

Should downstream packages that compute this differently remove/prune this do avoid confusion if they use a different domain type, do avoid users computing the false one?

Good question, I am not sure how best to do this actually.

Could the TOF lookup produce wavelength directly to avoid the extra intermediate step?

Did you mean just compute wavelength and not have a TofDetector? Or did you mean just have a provider that computes it from the lookup, without going via the TofDetector, where the end graph would allow you to compute both TofDetector and WavelengthDetector, where both these nodes would be connected to the same parents?

The latter. TofDetector might be not needed in practice (except for debugging). But I am not suggesting to change it here and now, this was just a thought.

@nvaytet nvaytet requested a review from SimonHeybrock January 20, 2026 19:40
@SimonHeybrock
Copy link
Member

Just the question about Ltotal remaining: Why is the TOF workflow not settings this as a coord on TofDetector? It was used to compute another coord, so I would think it belongs there to ensure consistency?

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