Skip to content

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented May 5, 2025

@nvaytet nvaytet requested review from SimonHeybrock and jl-wynen May 5, 2025 12:40
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.

Looks good, just some minor comments.

"DREAM_simple_pwd_workflow/Cave_TOF_Monitor_van_can.dat": "md5:e63456c347fb36a362a0b5ae2556b3cf", # noqa: E501
"DREAM_simple_pwd_workflow/Cave_TOF_Monitor_vana_inc_coh.dat": "md5:701d66792f20eb283a4ce76bae0c8f8f", # noqa: E501
"DREAM-high-flux-tof-lookup-table.h5": "md5:404145a970ed1188e524cba10194610e", # noqa: E501
"DREAM-high-flux-tof-lookup-table.h5": "md5:1b95a359fa7b0d8b4277806ece9bf279", # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

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

Is this the 2d table?

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, with additional coords (I think I updated the notebook that generates it?)

return ReducerSoftwares(
[
Software.from_package_metadata('essdiffraction'),
# Software.from_package_metadata('essdiffraction'),
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Left over from local development.
It's an issue for me because of the way I locally 'installed' our packages (using symbolic links instead of a pip install).
I'll change it back.

@nvaytet
Copy link
Member Author

nvaytet commented May 8, 2025

The issue with the docs build is apparently when I insert this provider

Without it, no error in the docs.
I don't understand what is going on. The get_possible_outputs should be sorting a tuple with strings, there shouldn't be an issue.
If I print the content of get_possible_outputs, before it tries to sort it, I get a long list of types, but there is no _GenericAlias anywhere in that list... 🤔

@SimonHeybrock
Copy link
Member

The issue with the docs build is apparently when I insert this provider

Without it, no error in the docs. I don't understand what is going on. The get_possible_outputs should be sorting a tuple with strings, there shouldn't be an issue. If I print the content of get_possible_outputs, before it tries to sort it, I get a long list of types, but there is no _GenericAlias anywhere in that list... 🤔

No generic type?

Comment on lines 234 to 237
def load_tof_lookup_table(
filename: TimeOfFlightLookupTableFilename,
) -> TimeOfFlightLookupTable:
return TimeOfFlightLookupTable(sc.io.load_hdf5(filename))
Copy link
Member

Choose a reason for hiding this comment

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

Is this still used? If so, why is there no such provider in essreduce?

"""Monitor data with time-of-flight coordinate."""


TimeOfFlightLookupTableFilename = NewType("TimeOfFlightLookupTableFilename", str)
Copy link
Member

Choose a reason for hiding this comment

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

Is this not generic across instruments? Why not define in essreduce?

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, let's do that

Copy link
Member Author

@nvaytet nvaytet May 9, 2025

Choose a reason for hiding this comment

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

So you can either load a lookup table from file, or build it from a simulation.

I'm assuming that the default should be that you want to load the table from a file (this is what most people will want to do).
What would be a convenient way to switch between this mode, and building from simulation?

At the moment, i'm having to know which provider to import and then insert in the workflow, as done in the tests here: https://github.com/scipp/essdiffraction/pull/160/files#diff-397d502aff143b028a421a4e43ded449baae3d8b2ae6711bee74734d7aa1c9e5R146

Is this ok for now? It's not many lines of code, but knowing the import path is annoying. Should I add that particular provider to the __init__ of the time_of_flight submodule to make it more accessible?

Copy link
Member

Choose a reason for hiding this comment

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

When computing the LUT, don't you actually need a whole bunch of extra bits in the pipeline, such as loading choppers?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm yes. It seems that in the test here I've stopped the workflow at the SimulationResults, which is computed once, without reading choppers from the files.

However, in the TBL workflow in essimaging, I'm using the choppers from the file in a provider to make the SimulationResults: https://github.com/scipp/essimaging/blob/main/src/ess/tbl/conversion.py#L66
Looking at that provider, I'm thinking I should probably also read the source_position from the nexus file.

So we would need to insert at least these two providers. Should we make 2 different workflows? One that loads lookup table from file, and one that builds it on-the-fly?

Copy link
Member

Choose a reason for hiding this comment

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

You can also consider adding a keyword argument so this can be selecting on workflow creation.

Copy link
Member Author

Choose a reason for hiding this comment

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

That would probably be convenient. However, does this mean I now have 6 cases instead of the 3 here?

@register_workflow
def DreamGeant4MonitorHistogramWorkflow() -> sciline.Pipeline:
    """
    Workflow with default parameters for the Dream Geant4 simulation, using a
    histogrammed monitor for the normalization.
    """
    return DreamGeant4Workflow(run_norm=RunNormalization.monitor_histogram)


@register_workflow
def DreamGeant4MonitorIntegratedWorkflow() -> sciline.Pipeline:
    """
    Workflow with default parameters for the Dream Geant4 simulation, using
    integrated counts of the monitor for the normalization.
    """
    return DreamGeant4Workflow(run_norm=RunNormalization.monitor_integrated)


@register_workflow
def DreamGeant4ProtonChargeWorkflow() -> sciline.Pipeline:
    """
    Workflow with default parameters for the Dream Geant4 simulation, using
    proton charge for the normalization.
    """
    return DreamGeant4Workflow(run_norm=RunNormalization.proton_charge)

Won't this grow exponentially?
I guess this is mostly for the widgets, it doesn't really affect the rest if I add an argument to the underlying DreamGeant4Workflow?

Copy link
Member

Choose a reason for hiding this comment

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

You are right that some things are a bit too inflexible right now. Maybe we need to support workflow (creation) parameters in the widgets?

Copy link
Member Author

@nvaytet nvaytet left a comment

Choose a reason for hiding this comment

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

Looks good.
Again, can't approve.
Note that dependencies will need updating again after we release essreduce==25.05.1.

@SimonHeybrock SimonHeybrock marked this pull request as ready for review May 14, 2025 12:22
@SimonHeybrock SimonHeybrock enabled auto-merge May 14, 2025 12:22
@SimonHeybrock
Copy link
Member

Updated essreduce, should be good to go if builds pass.

@SimonHeybrock SimonHeybrock merged commit c4aefdc into main May 15, 2025
4 checks passed
@SimonHeybrock SimonHeybrock deleted the use-generic-tof-wf branch May 15, 2025 08:20
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.

4 participants