Skip to content

Commit

Permalink
Warn about velox emd file containing single EDS steam when `sum_EDS_d…
Browse files Browse the repository at this point in the history
…ectectors` is explicitly set to True
  • Loading branch information
ericpre committed Jan 9, 2025
1 parent 85a2d9d commit afdd4ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 7 additions & 6 deletions rsciio/emd/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def file_reader(
first_frame=0,
last_frame=None,
sum_frames=True,
sum_EDS_detectors=True,
sum_EDS_detectors=None,
rebin_energy=1,
SI_dtype=None,
load_SI_image_stack=False,
Expand Down Expand Up @@ -146,11 +146,12 @@ def file_reader(
Velox only: Load each individual EDS frame. The EDS spectrum image will
be loaded with an extra navigation dimension corresponding to the frame
index (time axis).
sum_EDS_detectors : bool, default=True
Velox only: Load the EDS signal as a sum over the signals from all EDS
detectors (default) or, alternatively, load the signal of each individual
EDS detector. In the latter case, a corresponding number of distinct
EDS signals is returned.
sum_EDS_detectors : bool or None, default=None
Velox only with multiple EDS stream: Load the EDS signal as a sum over
the signals from all EDS detectors (``True`` or ``None``) or, alternatively,
load the signal of each individual EDS detector. In the latter case, a
corresponding number of distinct EDS signals is returned. If ``True``
and only a single stream is present, a warning is added to the logger.
rebin_energy : int, default=1
Velox only: Rebin the energy axis by given factor. Useful in combination
with ``sum_frames=False`` to reduce the data size when reading the
Expand Down
14 changes: 11 additions & 3 deletions rsciio/emd/_emd_velox.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(
first_frame=0,
last_frame=None,
sum_frames=True,
sum_EDS_detectors=True,
sum_EDS_detectors=None,
rebin_energy=1,
SI_dtype=None,
load_SI_image_stack=False,
Expand Down Expand Up @@ -577,9 +577,17 @@ def _read_stream(key):
stream = FeiSpectrumStream(spectrum_stream_group[key], self)
return stream

if self.sum_EDS_detectors and len(subgroup_keys) == 1:
# Add warning to logger only when `sum_EDS_detectors` is set to True
# and there is only one stream in the file.
_logger.warning(
"The file contains only one spectrum stream. Use `sum_EDS_detectors=None` "
"(default) if only one stream is expected."
)
if self.sum_EDS_detectors is None:
# Default take the sum.
self.sum_EDS_detectors = True
if self.sum_EDS_detectors:
if len(subgroup_keys) == 1:
_logger.warning("The file contains only one spectrum stream")
# Read the first stream
s0 = _read_stream(subgroup_keys[0])
streams = [s0]
Expand Down

0 comments on commit afdd4ce

Please sign in to comment.