Skip to content

Add energy_transfer to coord transform graphs from wavelength#677

Merged
nvaytet merged 10 commits intomainfrom
graphs-from-wavelength
Mar 4, 2026
Merged

Add energy_transfer to coord transform graphs from wavelength#677
nvaytet merged 10 commits intomainfrom
graphs-from-wavelength

Conversation

@nvaytet
Copy link
Member

@nvaytet nvaytet commented Mar 2, 2026

This is step 1 towards using wavelength in reduction workflows instead of tof

We add the missing steps to compute energy_transfer from wavelength rather than tof.
Wavelength will now be the primary coordinate we work from for ESS instruments.
It will be computed from lookup tables in essreduce.

We also fix a bug in the time_at_sample function which assumed that all neutrons had left the pulse at exactly t=0.

@nvaytet nvaytet requested a review from jl-wynen March 2, 2026 19:03
'energy': _kernels.energy_from_wavelength,
'energy_transfer': _kernels.energy_transfer_from_energies,
'incident_energy': _kernels.incident_energy_from_wavelength,
'final_energy': _kernels.final_energy_from_wavelength,
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need these in the elastic graph? This seems to invite mistakes from not overriding these functions correctly.

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 makes a disconnected graph.
Screenshot_20260303_093840

You still need to correctly connect the initial and final wavelengths.
As I thought those were the quantities that are known at the instrument (rather than the energies), it seemed convenient to be able to compute energies and energy transfer from the graph without having to manually construct it?

Or are you just saying this should be a separate graph that is not part of the elastic graph?

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 also probably makes sense that they are not part of the elastic graph if they represent inelastic processes....

Copy link
Member

Choose a reason for hiding this comment

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

I missed that they use incident_wavelength and final_wavelength. It looks good to me now that they are in the inelastic workflows. Then we can remove those frunctions from ESSspectroscopy.

dtype = _common_dtype(incident_energy, final_energy)
e_i = incident_energy.to(dtype=dtype, copy=False)
e_f = final_energy.to(dtype=dtype, unit=e_i.unit, copy=False)
return sc.to_unit(e_i - e_f, 'meV', copy=False)
Copy link
Member

Choose a reason for hiding this comment

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

You already convert units above. Can you change these conversions such that e_i - e_f is always meV so we don't need a third pass over the array for that conversion?

@nvaytet nvaytet merged commit e2685ff into main Mar 4, 2026
5 checks passed
@nvaytet nvaytet deleted the graphs-from-wavelength branch March 4, 2026 15:13
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