Skip to content

Add event time offset to component reading#97

Merged
nvaytet merged 7 commits intomainfrom
eto-plot
Oct 9, 2025
Merged

Add event time offset to component reading#97
nvaytet merged 7 commits intomainfrom
eto-plot

Conversation

@nvaytet
Copy link
Copy Markdown
Member

@nvaytet nvaytet commented Oct 8, 2025

Can now to results['detector'].eto.plot() to plot the event_time_offset of the neutrons at the component.
event_time_offset is just defined by time-of-arrival modulo source period.

Based on #96

@nvaytet nvaytet changed the base branch from main to ess-instrument-configs October 8, 2025 20:16
Comment thread src/tof/chopper.py Outdated
Comment thread src/tof/detector.py Outdated
Comment thread src/tof/model.py
container[c.name]['data'] = self.source.data.copy(deep=False)
t = birth_time + (c.distance / speed).to(unit=birth_time.unit, copy=False)
container[c.name]['data'].coords['toa'] = t
container[c.name]['data'].coords['eto'] = 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.

Is t ever negative?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I guess in principle, since the user is free to define their own time distribution for a pulse, t could be negative?
It is also possible to edit the data in the source before running the model.
E.g.

source = tof.Source(facility='ESS', neutrons=1_000_000)
source.data.coords['birth_time'] -= sc.scalar(1000, unit='us')

makes a source that starts at -1000 us instead of 0.

Should the eto then be (t - birth_time.min()) % period?
How do we solve the potential case where, if we have low statistics, the first pulse may not have any neutrons at the very start (because of sampling), but the second pulse does. This would attribute the early neutrons in the second pulse to the wrong period?

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.

Not sure, but my point was that mod will give a negative result in those cases, which is not what you want, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not sure I follow the negative result part... -3 % 10 gives 7.
The period will always be positive.

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.

Right, I was mixing things up!

nvaytet and others added 3 commits October 9, 2025 08:40
Co-authored-by: Simon Heybrock <12912489+SimonHeybrock@users.noreply.github.com>
Co-authored-by: Simon Heybrock <12912489+SimonHeybrock@users.noreply.github.com>
Base automatically changed from ess-instrument-configs to main October 9, 2025 08:01
@nvaytet nvaytet merged commit fa24fff into main Oct 9, 2025
4 checks passed
@nvaytet nvaytet deleted the eto-plot branch October 9, 2025 11:29
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.

2 participants