-
Notifications
You must be signed in to change notification settings - Fork 0
Add loadOptions support for event filtering in BIOSANS and GPSANS #1092
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
Merged
darshdinger
merged 2 commits into
next
from
ewm14352_add_finely_time_slice_with_loadOptions
Feb 5, 2026
Merged
Changes from all commits
Commits
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
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
96 changes: 96 additions & 0 deletions
96
tests/integration/drtsans/mono/biosans/test_loadoptions.py
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,96 @@ | ||
| """Integration tests for loadOptions time filtering in BIOSANS.""" | ||
|
|
||
| import pytest | ||
| from mantid.simpleapi import SumSpectra | ||
| from drtsans.mono.biosans import load_all_files, reduction_parameters | ||
|
|
||
|
|
||
| @pytest.mark.datarepo | ||
| def test_load_with_time_filtering(datarepo_dir): | ||
| """Test that FilterByTimeStart and FilterByTimeStop work correctly in loadOptions.""" | ||
| reduction_input = { | ||
| "instrumentName": "CG3", | ||
| "sample": { | ||
| "runNumber": "1322", | ||
| "transmission": {"runNumber": ""}, | ||
| "loadOptions": { | ||
| "FilterByTimeStart": 0.0, | ||
| "FilterByTimeStop": 10.0, | ||
| }, | ||
| }, | ||
| "background": {"runNumber": "", "transmission": {"runNumber": ""}}, | ||
| "beamCenter": {"runNumber": "1322"}, | ||
| "emptyTransmission": {"runNumber": ""}, | ||
| "configuration": {"useDefaultMask": False}, | ||
| } | ||
|
|
||
| reduction_input = reduction_parameters(reduction_input, "BIOSANS", validate=False) | ||
| loaded = load_all_files(reduction_input, path=datarepo_dir.biosans) | ||
|
|
||
| # Verify sample workspace was loaded | ||
| assert loaded.sample is not None | ||
| assert len(loaded.sample) == 1 | ||
|
|
||
| # Check that workspace was loaded with time filtering | ||
| ws = loaded.sample[0] | ||
| assert ws is not None | ||
| assert ws.getNumberHistograms() > 0 | ||
|
|
||
| # Verify time filtering was applied by checking event count | ||
| ws_summed = SumSpectra(ws) | ||
| assert ws_summed.dataY(0)[0] == 2283 # number of events in the first 10 seconds | ||
|
|
||
|
|
||
| @pytest.mark.datarepo | ||
| def test_load_without_time_filtering_baseline(datarepo_dir): | ||
| """Test loading without time filtering as baseline.""" | ||
| reduction_input = { | ||
| "instrumentName": "CG3", | ||
| "sample": { | ||
| "runNumber": "1322", | ||
| "transmission": {"runNumber": ""}, | ||
| "loadOptions": {}, | ||
| }, | ||
| "background": {"runNumber": "", "transmission": {"runNumber": ""}}, | ||
| "beamCenter": {"runNumber": "1322"}, | ||
| "emptyTransmission": {"runNumber": ""}, | ||
| "configuration": {"useDefaultMask": False}, | ||
| } | ||
|
|
||
| reduction_input = reduction_parameters(reduction_input, "BIOSANS", validate=False) | ||
| loaded = load_all_files(reduction_input, path=datarepo_dir.biosans) | ||
|
|
||
| # Verify sample workspace was loaded | ||
| assert loaded.sample is not None | ||
| assert len(loaded.sample) == 1 | ||
|
|
||
| ws = loaded.sample[0] | ||
| assert ws is not None | ||
| assert ws.getNumberHistograms() > 0 | ||
|
|
||
|
|
||
| @pytest.mark.datarepo | ||
| def test_load_with_partial_time_range(datarepo_dir): | ||
| """Test loading with only FilterByTimeStart specified.""" | ||
| reduction_input = { | ||
| "instrumentName": "CG3", | ||
| "sample": { | ||
| "runNumber": "1322", | ||
| "transmission": {"runNumber": ""}, | ||
| "loadOptions": {"FilterByTimeStart": 5.0}, | ||
| }, | ||
| "background": {"runNumber": "", "transmission": {"runNumber": ""}}, | ||
| "beamCenter": {"runNumber": "1322"}, | ||
| "emptyTransmission": {"runNumber": ""}, | ||
| "configuration": {"useDefaultMask": False}, | ||
| } | ||
|
|
||
| reduction_input = reduction_parameters(reduction_input, "BIOSANS", validate=False) | ||
| loaded = load_all_files(reduction_input, path=datarepo_dir.biosans) | ||
|
|
||
| # Verify sample workspace was loaded successfully with partial time filter | ||
| assert loaded.sample is not None | ||
| assert len(loaded.sample) == 1 | ||
| ws = loaded.sample[0] | ||
| assert ws is not None | ||
| assert ws.getNumberHistograms() > 0 | ||
100 changes: 100 additions & 0 deletions
100
tests/integration/drtsans/mono/gpsans/test_loadoptions.py
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,100 @@ | ||
| """Integration tests for loadOptions time filtering in GPSANS.""" | ||
|
|
||
| import pytest | ||
| from mantid.simpleapi import SumSpectra | ||
| from drtsans.mono.gpsans import load_all_files, reduction_parameters | ||
|
|
||
|
|
||
| @pytest.mark.datarepo | ||
| def test_load_with_time_filtering(datarepo_dir): | ||
| """Test that FilterByTimeStart and FilterByTimeStop work correctly in loadOptions.""" | ||
| reduction_input = { | ||
| "instrumentName": "CG2", | ||
| "sample": { | ||
| "runNumber": "9166", | ||
| "transmission": {"runNumber": ""}, | ||
| "loadOptions": { | ||
| "FilterByTimeStart": 0.0, | ||
| "FilterByTimeStop": 50.0, | ||
| }, | ||
| }, | ||
| "background": {"runNumber": "", "transmission": {"runNumber": ""}}, | ||
| "beamCenter": {"runNumber": "9166"}, | ||
| "emptyTransmission": {"runNumber": ""}, | ||
| "configuration": {"useDefaultMask": False}, | ||
| } | ||
|
|
||
| reduction_input = reduction_parameters(reduction_input, "GPSANS", validate=False) | ||
| loaded = load_all_files(reduction_input, path=datarepo_dir.gpsans) | ||
|
|
||
| # Verify sample workspace was loaded | ||
| assert loaded.sample is not None | ||
| assert len(loaded.sample) == 1 | ||
|
|
||
| # Check that workspace was loaded with time filtering | ||
| ws = loaded.sample[0] | ||
| assert ws is not None | ||
| assert ws.getNumberHistograms() > 0 | ||
|
|
||
| # Verify time filtering was applied by checking event count | ||
| ws_summed = SumSpectra(ws) | ||
| # Verify we have events loaded | ||
| event_count = ws_summed.dataY(0)[0] | ||
| assert event_count > 0, "Should have some events in the filtered range" | ||
| # Note: Actual event count verification would require knowing the exact count | ||
| # for this specific run with the given time filter parameters | ||
|
|
||
|
|
||
| @pytest.mark.datarepo | ||
| def test_load_without_time_filtering_baseline(datarepo_dir): | ||
| """Test loading without time filtering as baseline.""" | ||
| reduction_input = { | ||
| "instrumentName": "CG2", | ||
| "sample": { | ||
| "runNumber": "9166", | ||
| "transmission": {"runNumber": ""}, | ||
| "loadOptions": {}, | ||
| }, | ||
| "background": {"runNumber": "", "transmission": {"runNumber": ""}}, | ||
| "beamCenter": {"runNumber": "9166"}, | ||
| "emptyTransmission": {"runNumber": ""}, | ||
| "configuration": {"useDefaultMask": False}, | ||
| } | ||
|
|
||
| reduction_input = reduction_parameters(reduction_input, "GPSANS", validate=False) | ||
| loaded = load_all_files(reduction_input, path=datarepo_dir.gpsans) | ||
|
|
||
| # Verify sample workspace was loaded | ||
| assert loaded.sample is not None | ||
| assert len(loaded.sample) == 1 | ||
|
|
||
| ws = loaded.sample[0] | ||
| assert ws is not None | ||
| assert ws.getNumberHistograms() > 0 | ||
|
|
||
|
|
||
| @pytest.mark.datarepo | ||
| def test_load_with_partial_time_range(datarepo_dir): | ||
| """Test loading with only FilterByTimeStop specified.""" | ||
| reduction_input = { | ||
| "instrumentName": "CG2", | ||
| "sample": { | ||
| "runNumber": "9166", | ||
| "transmission": {"runNumber": ""}, | ||
| "loadOptions": {"FilterByTimeStop": 30.0}, | ||
| }, | ||
| "background": {"runNumber": "", "transmission": {"runNumber": ""}}, | ||
| "beamCenter": {"runNumber": "9166"}, | ||
| "emptyTransmission": {"runNumber": ""}, | ||
| "configuration": {"useDefaultMask": False}, | ||
| } | ||
|
|
||
| reduction_input = reduction_parameters(reduction_input, "GPSANS", validate=False) | ||
| loaded = load_all_files(reduction_input, path=datarepo_dir.gpsans) | ||
|
|
||
| # Verify sample workspace was loaded successfully with partial time filter | ||
| assert loaded.sample is not None | ||
| assert len(loaded.sample) == 1 | ||
| ws = loaded.sample[0] | ||
| assert ws is not None | ||
| assert ws.getNumberHistograms() > 0 |
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.
Uh oh!
There was an error while loading. Please reload this page.