Skip to content
Snippets Groups Projects
Commit 0819a3ae authored by Wout De Nolf's avatar Wout De Nolf
Browse files

read_concatenated_xas: handle NaNs with masked arrays

parent 9671524f
No related branches found
No related tags found
1 merge request!172Multi xas with nans2
Pipeline #222230 passed
......@@ -4,6 +4,7 @@ from typing import Tuple, Dict, Any
import pint
import numpy
import numpy.ma
from est import settings
from est.io.information import InputInformation
......@@ -40,7 +41,7 @@ def read_concatenated_xas(
if information.skip_concatenated_n_spectra:
ramp_slices = ramp_slices[information.skip_concatenated_n_spectra :]
interpolated_spectra = numpy.zeros(
interpolated_spectra = numpy.ma.masked_all(
(len(energy), len(ramp_slices), 1), dtype=raw_spectra.dtype
)
for i, ramp_slice in enumerate(ramp_slices):
......@@ -49,12 +50,15 @@ def read_concatenated_xas(
if information.skip_concatenated_n_points:
raw_spectrum_i[: information.skip_concatenated_n_points] = numpy.nan
raw_spectrum_i[-information.skip_concatenated_n_points :] = numpy.nan
interpolated_spectra[:, i, 0] = numpy.interp(
spectrum_i = numpy.interp(
energy,
raw_energy_i,
raw_spectrum_i,
left=numpy.nan,
right=numpy.nan,
)
interpolated_spectra[:, i, 0] = numpy.ma.masked_array(
spectrum_i, mask=~numpy.isfinite(spectrum_i)
)
return interpolated_spectra, energy * information.energy_unit, config
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment