-
Notifications
You must be signed in to change notification settings - Fork 1
Use generic workflow to compute time of flight. #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
YooSunYoung
wants to merge
12
commits into
main
Choose a base branch
from
generic-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4cb7995
Use generic workflow.
YooSunYoung 6bf8310
Update input file pattern retrieval routine.
YooSunYoung 26c8987
Fix origin of detector.
YooSunYoung 488f108
Calculate fast/slow axis.
YooSunYoung 0813b1f
Calculate fast/slow axis.
YooSunYoung 503397e
Update configuration option titles.
YooSunYoung b28ce63
Use location spec to retrieve transformation vector of crystal.
YooSunYoung 69a26e8
Ltotal configurable instead of reading them from files.
YooSunYoung 618e6c5
Hardcode detector names in the workflow.
YooSunYoung 45f450b
Initialize workflow using workflow config object in the earlier step.
YooSunYoung 53abd0d
Remove unused helper function.
YooSunYoung d5e9ec7
Use min/max to find the tof bin edges boundaries.
YooSunYoung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Copyright (c) 2025 Scipp contributors (https://github.com/scipp) | ||
| import enum | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
| from .types import Compression | ||
|
|
||
|
|
||
| class InputConfig(BaseModel): | ||
| # Add title of the basemodel | ||
| model_config = {"title": "Input Configuration"} | ||
| # File IO | ||
| input_file: list[str] = Field( | ||
| title="Input File", | ||
| description="Path to the input file. If multiple file paths are given," | ||
| " the output(histogram) will be merged(summed) " | ||
| "and will not save individual outputs per input file. ", | ||
| ) | ||
| swmr: bool = Field( | ||
| title="SWMR Mode", | ||
| description="Open the input file in SWMR mode", | ||
| default=False, | ||
| ) | ||
| # Detector selection | ||
| detector_ids: list[int] = Field( | ||
| title="Detector IDs", | ||
| description="Detector indices to process", | ||
| default=[0, 1, 2], | ||
| ) | ||
| # Chunking options | ||
| iter_chunk: bool = Field( | ||
| title="Iterate in Chunks", | ||
| description="Whether to process the input file in chunks " | ||
| " based on the hdf5 dataset chunk size. " | ||
| "It is ignored if hdf5 dataset is not chunked. " | ||
| "If True, it overrides chunk-size-pulse and chunk-size-events options.", | ||
| default=False, | ||
| ) | ||
| chunk_size_pulse: int = Field( | ||
| title="Chunk Size Pulse", | ||
| description="Number of pulses to process in each chunk. " | ||
| "If 0 or negative, process all pulses at once.", | ||
| default=0, | ||
| ) | ||
| chunk_size_events: int = Field( | ||
| title="Chunk Size Events", | ||
| description="Number of events to process in each chunk. " | ||
| "If 0 or negative, process all events at once." | ||
| "If both chunk-size-pulse and chunk-size-events are set, " | ||
| "chunk-size-pulse is preferred.", | ||
| default=0, | ||
| ) | ||
|
|
||
|
|
||
| class TimeBinUnit(enum.StrEnum): | ||
| ms = 'ms' | ||
| us = 'us' | ||
| ns = 'ns' | ||
|
|
||
|
|
||
| class TimeBinCoordinate(enum.StrEnum): | ||
| event_time_offset = 'event_time_offset' | ||
| time_of_flight = 'time_of_flight' | ||
|
|
||
|
|
||
| class WorkflowConfig(BaseModel): | ||
| # Add title of the basemodel | ||
| model_config = {"title": "Workflow Configuration"} | ||
| time_bin_coordinate: TimeBinCoordinate = Field( | ||
| title="Time Bin Coordinate", | ||
| description="Coordinate to bin the time data.", | ||
| default=TimeBinCoordinate.event_time_offset, | ||
| ) | ||
| nbins: int = Field( | ||
| title="Number of Time Bins", | ||
| description="Number of Time bins", | ||
| default=50, | ||
| ) | ||
| min_time_bin: int | None = Field( | ||
| title="Minimum Time", | ||
| description="Minimum time edge of [time_bin_coordinate] in [time_bin_unit].", | ||
| default=None, | ||
| ) | ||
| max_time_bin: int | None = Field( | ||
| title="Maximum Time", | ||
| description="Maximum time edge of [time_bin_coordinate] in [time_bin_unit].", | ||
| default=None, | ||
| ) | ||
| time_bin_unit: TimeBinUnit = Field( | ||
| title="Unit of Time Bins", | ||
| description="Unit of time bins.", | ||
| default=TimeBinUnit.ms, | ||
| ) | ||
| tof_lookup_table_file_path: str | None = Field( | ||
| title="TOF Lookup Table File Path", | ||
| description="Path to the TOF lookup table file. " | ||
| "If None, the lookup table will be computed on-the-fly.", | ||
| default=None, | ||
| ) | ||
| tof_simulation_min_wavelength: float = Field( | ||
| title="TOF Simulation Minimum Wavelength", | ||
| description="Minimum wavelength for TOF simulation in Angstrom.", | ||
| default=1.8, | ||
| ) | ||
| tof_simulation_max_wavelength: float = Field( | ||
| title="TOF Simulation Maximum Wavelength", | ||
| description="Maximum wavelength for TOF simulation in Angstrom.", | ||
| default=3.6, | ||
| ) | ||
| tof_simulation_min_ltotal: float = Field( | ||
| title="TOF Simulation Minimum Ltotal", | ||
| description="Minimum total flight path for TOF simulation in meters.", | ||
| default=150.0, | ||
| ) | ||
| tof_simulation_max_ltotal: float = Field( | ||
| title="TOF Simulation Maximum Ltotal", | ||
| description="Maximum total flight path for TOF simulation in meters.", | ||
| default=170.0, | ||
| ) | ||
|
Comment on lines
+111
to
+120
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This range is from the mcstas simulation that Aaron was working on right now. |
||
| tof_simulation_seed: int = Field( | ||
| title="TOF Simulation Seed", | ||
| description="Random seed for TOF simulation.", | ||
| default=42, # No reason. | ||
| ) | ||
|
|
||
|
|
||
| class OutputConfig(BaseModel): | ||
| # Add title of the basemodel | ||
| model_config = {"title": "Output Configuration"} | ||
| # Log verbosity | ||
| verbose: bool = Field( | ||
| title="Verbose Logging", | ||
| description="Increase output verbosity.", | ||
| default=False, | ||
| ) | ||
| # File output | ||
| output_file: str = Field( | ||
| title="Output File", | ||
| description="Path to the output file.", | ||
| default="scipp_output.h5", | ||
| ) | ||
| compression: Compression = Field( | ||
| title="Compression", | ||
| description="Compress option of reduced output file.", | ||
| default=Compression.BITSHUFFLE_LZ4, | ||
| ) | ||
|
|
||
|
|
||
| class ReductionConfig(BaseModel): | ||
| """Container for all reduction configurations.""" | ||
|
|
||
| inputs: InputConfig | ||
| workflow: WorkflowConfig = Field(default_factory=WorkflowConfig) | ||
| output: OutputConfig = Field(default_factory=OutputConfig) | ||
|
|
||
| @property | ||
| def _children(self) -> list[BaseModel]: | ||
| return [self.inputs, self.workflow, self.output] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were there any modifications here or was the code moved only?