Skip to content

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented Apr 28, 2025

We build on top of the GenericNexusWorkflow to add the computation of time-of-flight for the neutron data.

See scipp/essimaging#81 for an example of how this is used in instrument reduction workflows.

The graph is the following. Important thing to note is that Ltotal is extracted from the calibrated beamline, not from the detector data, meaning that it is not extracted/computed again every time new streaming events come in.
tbl-tof-wf

@nvaytet nvaytet requested a review from SimonHeybrock April 28, 2025 12:08


class CalibratedBeamline(sciline.Scope[RunType, sc.DataArray], sc.DataArray):
class CalibratedDetectorBeamline(sciline.Scope[RunType, sc.DataArray], sc.DataArray):
Copy link
Member

Choose a reason for hiding this comment

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

We spoke the other day about not breaking downstream and notebooks anymore by renaming (unless really necessary). Is this necessary? Is the new name better?

Copy link
Member Author

@nvaytet nvaytet Apr 30, 2025

Choose a reason for hiding this comment

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

You are right, this would break

  • essspectroscopy
  • beamlime
  • essdiffraction
  • esssans

See code search here.
I'll revert.

Comment on lines 503 to 507
This is performed separately and after :py:func:`get_calibrated_monitor` to avoid
as false dependency of, e.g., the reshaped detector numbers on the sample position.
The latter can change during a run, e.g., for a rotating sample. The detector
numbers might be used, e.g., to mask certain detector pixels, and should not depend
on the sample position.
Copy link
Member

Choose a reason for hiding this comment

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

This does not apply here? Is there thus any reason to not perform this in get_calibrated_monitor? Would avoid the extra type and the "need" to rename CalibratedBeamline.

_prune_type_vars(wf, run_types=run_types, monitor_types=monitor_types)

return wf
from ..utils import prune_type_vars
Copy link
Member

Choose a reason for hiding this comment

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

Why the import here?

monitor_types: Iterable[sciline.typing.Key] | None = None,
) -> sciline.Pipeline:
""" """
wf = GenericNeXusWorkflow()
Copy link
Member

Choose a reason for hiding this comment

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

I think this may be slow unless you forward the run_types etc.? Not sure if you then need to prune again, or if there is a better way.

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 opted for pruning twice.

@SimonHeybrock
Copy link
Member

Wondering about this bit:
image

Why do we need the All* types? Can loading the choppers be incorporated into the NeXusComponentLocationSpec and NeXusComponent? Or can the All* types be replaced by a more chopper-specific name, as it seems that is the only thing used?

@SimonHeybrock
Copy link
Member

Looking at
image
it seems that branching / feeding PulsePeriod and PulseStride into both TimeOfFlightLookupTable and DetectorTofData is error prone. Is there a risk that the wrong table is used? Can the branching be avoided?

@nvaytet
Copy link
Member Author

nvaytet commented Apr 30, 2025

Is there a risk that the wrong table is used? Can the branching be avoided?

Are you thinking of a case where for example you loaded the lookup table from a file, and then set PulseStride=2 even if the lookup table was created for a PulseStride=1?

@SimonHeybrock
Copy link
Member

Is there a risk that the wrong table is used? Can the branching be avoided?

Are you thinking of a case where for example you loaded the lookup table from a file, and then set PulseStride=2 even if the lookup table was created for a PulseStride=1?

Yes, something like that.

@nvaytet
Copy link
Member Author

nvaytet commented Apr 30, 2025

Why do we need the All* types? Can loading the choppers be incorporated into the NeXusComponentLocationSpec and NeXusComponent? Or can the All* types be replaced by a more chopper-specific name, as it seems that is the only thing used?

I am not sure, would be best to discuss this in person/over a call.

@nvaytet
Copy link
Member Author

nvaytet commented Apr 30, 2025

Is there a risk that the wrong table is used? Can the branching be avoided?

Are you thinking of a case where for example you loaded the lookup table from a file, and then set PulseStride=2 even if the lookup table was created for a PulseStride=1?

Yes, something like that.

So maybe we should store the PulsePeriod and the PulseStride inside the table (as extra coordinates, or turn it into a dataclass)?



def assemble_beamline(
def assemble_detector_beamline(
Copy link
Member

Choose a reason for hiding this comment

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

Can also revert this rename.

Comment on lines 538 to 545
def extract_detector_ltotal(
detector_beamline: CalibratedBeamline[RunType],
) -> DetectorLtotal[RunType]:
"""
Extract Ltotal from the detector data.
"""
graph = scn.conversion.graph.beamline.beamline(scatter=True)
return DetectorLtotal[RunType](
Copy link
Member

Choose a reason for hiding this comment

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

I suppose what this really does is the naive straight-line approximation to Ltotal based on basic component positions. I guess the idea is to swap out this provider if something more sophisticated is needed? Maybe the nature of the approximation should be reflected in the names and docstrings?

@SimonHeybrock
Copy link
Member

Why do we need the All* types? Can loading the choppers be incorporated into the NeXusComponentLocationSpec and NeXusComponent? Or can the All* types be replaced by a more chopper-specific name, as it seems that is the only thing used?

I am not sure, would be best to discuss this in person/over a call.

Conclusion from call: Turns out this was unrelated to this change.

@nvaytet nvaytet merged commit cdf9568 into main May 2, 2025
4 checks passed
@nvaytet nvaytet deleted the generic-tof-wf branch May 2, 2025 12:26
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