devctrl.data.spectrum.transforms.make_const_energy_interval_spectrum#

make_const_energy_interval_spectrum(sdata: ndarray[tuple[Any, ...], dtype[_ScalarT]], columns: list[str], target_threshold=1e-09, round_threshold=1, interpolate_sample_factor=1)[source]#

Return data that has regularly spaced energy intervals and is increasing in energy.

If the data is close to having constant energy spacing, we assume that the variance is in conversion errors (from eV to nm and back) and attempt to round the energies.

If the data is not in constant energy intervals already, it will be interpolated between (E_min, E_max) with the same number of points as the input data.

To determine whether the data has constant intervals, the following metric is used:

E_deviation = sigma(dE) / <dE>**2, where dE is the difference between consecutive energies

Parameters:
  • target_threshold – If E_deviation < target_threshold, the data is assumed to have constant energy intervals

  • round_threshold – If E_deviation < round_threshold, an attempt is made to round make the energies have constant intervals by rounding them. If that fails, interpolation is used. Set to a value < target_threshold to disable rounding attempts and always interpolate.

  • interpolate_sample_factor – When using interpolation, the number of new data points is determined by N * interpolate_sample_factor

  • sdata – spectrum data, 2D array

  • columns – list of column names corresponding to sdata. Must include E, wl or both.

Raises:

RuntimeError – If neither E nor wl columns are provided

Returns:

sdata with columns, but data now has constant energy spacing