Skip to content
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

Use time-of-flight workflow in Dream data reduction #125

Merged
merged 40 commits into from
Feb 20, 2025
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
fa91262
incorporate tof computation in dream reduction workflow
nvaytet Jan 15, 2025
6ec89f9
start making a wrapper provider
nvaytet Jan 16, 2025
ad70023
use the tof workflow in the dream reduction
nvaytet Jan 27, 2025
4f2ef80
start fixing tests
nvaytet Jan 27, 2025
0b57f54
mask zero counts in monitors to avoid infinite values everywhere in d…
nvaytet Jan 29, 2025
85f984d
use nanmin as bin edges can be nan after tof lookup
nvaytet Jan 29, 2025
6b34a2c
update more tests
nvaytet Jan 29, 2025
5d4c819
fix last tests
nvaytet Jan 30, 2025
3150b42
update essreduce version and add tof to deps
nvaytet Jan 30, 2025
2c5aa16
add tof to nightly deps
nvaytet Jan 30, 2025
9a83342
update deps
nvaytet Jan 30, 2025
3bdb149
fix language in notebook
nvaytet Jan 30, 2025
3f83797
add dummy tof provider for powgen to skip the tof workflow step
nvaytet Jan 30, 2025
e214f05
fix powgen tests
nvaytet Jan 30, 2025
3c7e826
fix dream notebook
nvaytet Jan 30, 2025
5927e57
add tof where it was missing
nvaytet Jan 30, 2025
7b145e1
make tof a runtime dependency
nvaytet Jan 31, 2025
0164cf9
explain better in assemble data and make it robust to more pulses
nvaytet Jan 31, 2025
5ff4ec8
merge NaN step in workflow and remove dummy provider in powgen
nvaytet Jan 31, 2025
f245f0e
remove left over providers from __init__
nvaytet Jan 31, 2025
e87d443
fix workflow by removing DetectorData
nvaytet Jan 31, 2025
d7c8ec0
start using new version of tof workflow after update
nvaytet Feb 13, 2025
e8a3267
use correct choppers and make Ltotal separate for detectors and monitors
nvaytet Feb 14, 2025
95147fb
static analysis
nvaytet Feb 14, 2025
ebcefaa
switch to using a filename parameter instead of having to load the ta…
nvaytet Feb 14, 2025
a274a34
fix dream geant4 tests
nvaytet Feb 14, 2025
b55f608
bump essreduce version
nvaytet Feb 17, 2025
bbabb72
merge main branch and update deps to get latest essreduce
nvaytet Feb 17, 2025
6ebbd44
fix init file
nvaytet Feb 17, 2025
7a814df
fix workflow widgets notebook
nvaytet Feb 17, 2025
579d87b
fix metadata stuff from new scippneutron
nvaytet Feb 17, 2025
1e36615
fix orcid_id in tests
nvaytet Feb 17, 2025
55ec664
update type in POWGEN notebook
nvaytet Feb 17, 2025
a9bc401
Merge branch 'main' into tof-workflow
nvaytet Feb 18, 2025
017d31c
fix dependency files
nvaytet Feb 18, 2025
ead136d
Merge branch 'main' into tof-workflow
nvaytet Feb 19, 2025
f2e9894
move notebook to create tof lookup table and add comment about how ta…
nvaytet Feb 20, 2025
b134104
Apply suggestions from code review
nvaytet Feb 20, 2025
85597b8
Merge branch 'tof-workflow' of github.com:scipp/essdiffraction into t…
nvaytet Feb 20, 2025
5c4b3f8
Apply automatic formatting
pre-commit-ci-lite[bot] Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/ess/dream/io/geant4.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,16 @@ def assemble_detector_data(
da.bins.coords["tof"] = da.bins.coords["tof"].to(unit="us")

period = (1.0 / sc.scalar(14.0, unit="Hz")).to(unit="us")
# Bin the data into bins with a 71ms period
da = da.bin(tof=sc.arange("tof", 3) * period)
# Bin the data into bins with a 71ms period.
npulses = int((da.bins.coords["tof"].max() / period).value)
da = da.bin(tof=sc.arange("tof", npulses + 1) * period)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
npulses = int((da.bins.coords["tof"].max() / period).value)
da = da.bin(tof=sc.arange("tof", npulses + 1) * period)
npulses = int((da.bins.coords["tof"].max() / period).ceil().value)
da = da.bin(tof=sc.arange("tof", npulses) * period)

So that npulses actually is the number of pulses. Without this, I think [:npulses] below is incorrect.

# Add a event_time_zero coord for each bin, but not as bin edges,
# as all events in the same pulse have the same event_time_zero, hence the `[:2]`
# We need to pick a start time. The actual value does not matter. We chose the
# random date of Friday, November 1, 2024 8:40:34.078
da.coords["event_time_zero"] = (
sc.scalar(1730450434078980000, unit="ns").to(unit="us") + da.coords["tof"]
Copy link
Member

Choose a reason for hiding this comment

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

What is this number?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a random date in the past. The actual value does not matter.
I added a comment.

)[:2]
)[:npulses]
# Remove the meaningless tof coord at the top level
del da.coords["tof"]
da = da.rename_dims(tof="event_time_zero")
Expand Down