trinidi.util#

Some util functions.

Functions

energy2time(energy, flight_path_length)

Convert energy to time-of-flight of the neutron.

no_nan_divide(x, y)

Return x/y, with 0 instead of NaN where y is 0.

time2energy(time, flight_path_length)

Convert time-of-flight to energy of the neutron.

trinidi.util.time2energy(time, flight_path_length)[source]#

Convert time-of-flight to energy of the neutron.

\[E = \frac{1}{2} m \left( \frac{L}{t} \right) \; ,\]

where \(E\) is the energy, \(m\) is the mass, \(t\) is the time-of-flight of the neutron, and \(L\) is the flight path length.

Parameters:
  • time – Time-of-flight in \(\mathrm{μs}\).

  • flight_path_length – flight path length in \(\mathrm{m}\).

Returns:

Energy of the neutron in \(\mathrm{eV}\).

trinidi.util.energy2time(energy, flight_path_length)[source]#

Convert energy to time-of-flight of the neutron.

\[t = L \sqrt{ \frac{m}{2 E} }\]

where \(E\) is the energy, \(m\) is the mass, \(t\) is the time-of-flight of the neutron, and \(L\) is the flight path lenghth.

Parameters:
  • energy – Energy of the neutron in \(\mathrm{eV}\).

  • flight_path_length – flight path length in \(\mathrm{m}\).

Returns:

Time-of-flight in \(\mathrm{μs}\).

trinidi.util.no_nan_divide(x, y)[source]#

Return x/y, with 0 instead of NaN where y is 0.

Parameters:
  • x – Numerator.

  • y – Denominator.

Returns:

x / y with 0 wherever y == 0.