Skip to content

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented Jul 4, 2025

See discussion scipp/essimaging#91 (comment) for context.

This should allow more flexible use of run types created in downstream packages, as opposed to only being able to use aliases of the types defined in essreduce.

Downside is that this is now a breaking change (again), which would break all downstream packages that use the Tof workflow 😞
So I am not happy about that, hence the draft. Can we think of an alternative?

There were also other uses of SampleRun in the live submodule here, but I did not modify those, as I am unsure if it is required.

Copy link
Member

@jl-wynen jl-wynen left a comment

Choose a reason for hiding this comment

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

I think this is generally a good idea. The extra flexibility could come in handy. But can we actually use different chopper settings for different runs? Or would that mess with the available wavelength ranges and resolutions in a way that makes the data incompatible?

Would this PR break anything for users or just internally in the downstream packages?

Is there a way to avoid running the simulation twice, once for sample and once for, e.g., vanadium? Without an intermediate file, that is?

@nvaytet
Copy link
Member Author

nvaytet commented Jul 7, 2025

Would this PR break anything for users or just internally in the downstream packages?

This would not break (I mean breakage would be internal) workflows/notebooks where an instrument configuration is used to select the tof LUT (as is done in Dream).
It would break e.g. the Bifrost workflow.

Is there a way to avoid running the simulation twice, once for sample and once for, e.g., vanadium? Without an intermediate file, that is?

Not sure it's easy to do automatically. You'd have to compute the SimulationResults[SampleRun] and then set
wf[SimulationResults[BackgroundRun]] = wf.compute(SimulationResults[SampleRun])
and then the same again for EmptyBeamRun.

Maybe this is a sign that it's turning out to be a bad idea?
I guess when we load the table from a file, the file is loaded multiple times, but this is cheap compared to running the simulation?

@jl-wynen
Copy link
Member

jl-wynen commented Jul 7, 2025

One option would be to have types like GenericSimulationResults and default providers that convert those into SimulationResults[RunType], etc. But this would double the size of the tof graph.

Loading from file is probably fast enough because the tables are fairly small. In practice, that is probably what we would use most of the time, right? We would usually not run a simulation during reduction? So we could just leave it as is and see if we get into performance problems.

@nvaytet
Copy link
Member Author

nvaytet commented Jul 8, 2025

Is there a way to have a function take in DiskChoppers[RunType] where we would loop over all the run types and check that all chopper settings are the same, and then return a single Choppers (or a better name) which does not depend on RunType?

nvaytet added 3 commits July 8, 2025 16:11
…common lut table type which then gets wrapped by the RunType in a second provider
@nvaytet
Copy link
Member Author

nvaytet commented Jul 8, 2025

Is there a way to avoid running the simulation twice, once for sample and once for, e.g., vanadium? Without an intermediate file, that is?

Note that after the update, we can either:

wf = GenericTofWorkflow(tof_lut_provider=TofLutProvider.TOF, ...)
table = wf.compute(TimeOfFlightLookupTable[SampleRun])
for run in (SampleRun, BackgroundRun, OpenRun):
    wf[TimeOfFlightLookupTable[run]] = table
wf = GenericTofWorkflow(tof_lut_provider=TofLutProvider.FILE, ...)
# Compute from simulation is still possible
table = wf.compute(TimeOfFlightLookupTableFromSimulation[SampleRun])
wf[CommonTimeOfFlightLookupTable] = table

But I am still wondering if it might be better to just not really support the TofLutProvider.TOF in the main workflow at all, and instead have it as a separate workflow that can compute a lookup table.

@nvaytet
Copy link
Member Author

nvaytet commented Jul 15, 2025

This is replaced by #253

@nvaytet nvaytet closed this Jul 15, 2025
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