Skip to content

[ESSDIFFRACTION] feat: add workflow using lookup tables for pulse shaping modes#647

Merged
jokasimr merged 15 commits into
mainfrom
add-pulse-shaping-choppers
Jun 23, 2026
Merged

[ESSDIFFRACTION] feat: add workflow using lookup tables for pulse shaping modes#647
jokasimr merged 15 commits into
mainfrom
add-pulse-shaping-choppers

Conversation

@jokasimr

@jokasimr jokasimr commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added the essdiffraction Issues for essdiffraction. label Jun 22, 2026
@github-actions github-actions Bot changed the title feat: add workflow using lookup tables for pulse shaping modes [ESSDIFFRACTION] feat: add workflow using lookup tables for pulse shaping modes Jun 22, 2026
@jokasimr jokasimr requested a review from jl-wynen June 23, 2026 07:22
Comment thread packages/essdiffraction/src/ess/beer/beamline.py Outdated
Comment thread packages/essdiffraction/src/ess/beer/beamline.py Outdated
List of ESS BEER choppers for the selected pulse-shaping mode.

We make the chopper information available in this way as loading it directly from
the NeXus files is currently not available for these simulated BEER data.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should the function have a name that clarifies this to avoid people accidentally using it over chopper info from files? Something like simulation_choppers or default_choppers?

unit=wavelength_estimate.unit
)
).to(unit='s')
).to(unit='s') + sc.scalar(2.86, unit='ms').to(unit='s') / 2

Copy link
Copy Markdown
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? And why did you add it now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because I noticed that in the beer McStas model the t event data value (time of detection) is modified by a offset value that is half a ess pulse width. This makes the source pulse centered around t=0 in the McStas model. To convert that t value to event_time_offset with the convention that we expect (event_time_offset=0 corresponds to the start of a pulse) I now add the same offset to event_time_offset when loading McStas data. And to keep the results unchanged we have to shift the time here by the same offset.

I think this makes more sense than the old version. The t0_estimate is supposed to be the time a "nominal" wavelength neutron reaches the wavelength defining chopper. But that time is not defined unless we also specify a "nominal" time the neutron was created at the source. Before this change that time was 0, now it is source_pulse_width / 2, this is more in line with the conventions I'm used to.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok. Can you add this explanation to the code? It's hard to find in a GH comment.

)
def __getattr__(name: str):
"""Return attributes from the replacement :mod:`ess.beer.mcstas` module."""
return getattr(_mcstas, name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you raise a deprecation warning?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did anything change in this file? The diff isn't usable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Two things changed:

  1. In the load_beer_mcstas function the definition of event_time_offset changed. Now a small offset of pulse_width/2 is added, so that we have the convention that the source pulse starts at event_time_offset=0. The frame_cutoff_time was also shifted correspondingly.
  2. New providers needed for the lookup table frame unwrapping workflows are added after line 530 in the file.

# But that is different from the convention that we have for
# `event_time_offset`. We expect `event_time_offset=0` to correspond
# to the start of a pulse.
# To fix this, half a pulse width is added to `t`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please also add a short comment (maybe with a link to this one) in the other place where you add the offset.

@jokasimr jokasimr Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nah I don't think that is necessary because the logic there is completely natural when we work with the standard convention that the start of the pulse is event_time_offset=0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But it uses a 'magic' number. I'd like to at least have an explanation what that number represents.

@jokasimr jokasimr requested a review from jl-wynen June 23, 2026 11:09
@jokasimr jokasimr force-pushed the add-pulse-shaping-choppers branch from 7d5d7da to 38bbbfc Compare June 23, 2026 11:17
@jokasimr jokasimr enabled auto-merge June 23, 2026 13:14
@jokasimr jokasimr added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit 51ffec6 Jun 23, 2026
6 checks passed
@jokasimr jokasimr deleted the add-pulse-shaping-choppers branch June 23, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

essdiffraction Issues for essdiffraction.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[essdiffraction, BEER] Lookup table support for pulse shaping modes

2 participants