parse_image#

specreduce.parse_image(image: ndarray | NDData | Quantity, disp_axis: int = 1, mask_treatment: Literal['apply', 'ignore', 'propagate', 'zero_fill', 'nan_fill', 'apply_mask_only', 'apply_nan_only'] = 'apply') Spectrum[source]#

Convert all accepted image types to a consistently formatted Spectrum object.

Fills any and all of uncertainty, mask, units, and spectral axis that are missing in the provided image with generic values. Accepted image types are:

Parameters:
image

Input image from which data is extracted. This can be a 2D numpy array, Quantity, or an NDData object.

disp_axis

The index of the image’s dispersion axis. Should not be changed until operations can handle variable image orientations.

mask_treatment

Specifies how to handle masked or non-finite values in the input image. The accepted values are:

  • apply: The image remains unchanged, and any existing mask is combined with a mask derived from non-finite values.

  • ignore: The image remains unchanged, and any existing mask is dropped.

  • propagate: The image remains unchanged, and any masked or non-finite pixel causes the mask to extend across the entire cross-dispersion axis.

  • zero_fill: Pixels that are either masked or non-finite are replaced with 0.0, and the mask is dropped.

  • nan_fill: Pixels that are either masked or non-finite are replaced with nan, and the mask is dropped.

  • apply_mask_only: The image and mask are left unmodified.

  • apply_nan_only: The image is left unmodified, the old mask is dropped, and a new mask is created based on non-finite values.

Returns:
Spectrum