Units, quantities, and masks
SpectroChemPy exposes selected Pint and NumPy objects unchanged so that unit-aware and masked data interoperate with their originating libraries. This page documents their role in the SpectroChemPy API. The units and masks guide provides verified examples of construction, conversion, masking, plotting, and raw-array access.
Units and quantities
scp.urThe Pint unit registry configured and used by SpectroChemPy. It owns the units of public
QuantityandUnitobjects and includes SpectroChemPy definitions and formatters. Use the single public registry rather than constructing another registry for values intended to interact withNDDataset.scp.UnitThe original Pint Unit class. A unit describes dimensionality and scale but carries no magnitude.
scp.Unit("cm^-1")constructs a unit attached toscp.ur.scp.QuantityThe
Quantityclass generated byscp.ur. It combines a magnitude with a unit.scp.Quantity(value, "cm")andvalue * scp.ur.cmare the recommended public constructions. A quantity does not carryNDDatasetdimensions, coordinates, metadata, or history.scp.DimensionalityErrorThe original Pint DimensionalityError, raised for incompatible unit operations and conversions. Keeping the exact class permits callers to catch errors raised by both SpectroChemPy and Pint.
SpectroChemPy does not wrap or subclass these objects for documentation. Their Python
help() output therefore remains Pint’s documentation. The user guide above is the
project-specific behavioral reference.
Masks and masked-array interoperability
scp.MASKEDThe original NumPy masked sentinel. Assign it to a dataset selection to exclude those values without deleting their positions or coordinates.
scp.NOMASKThe original NumPy nomask sentinel returned by
NDDataset.maskwhen no value is excluded. UseNDDataset.remove_masks()to clear an existing dataset mask through the public API.scp.MaskedArrayandscp.MaskedConstantThe original NumPy masked-array interoperability types.
masked_dataandNDDataset.to_array()may returnMaskedArrayobjects, andscp.MASKEDis aMaskedConstant. Normal spectroscopy workflows should retainNDDatasetso that units, coordinates, metadata, and mask semantics stay together.
help() for these exact objects continues to show NumPy documentation. The
SpectroChemPy-specific accessors and information retained by each conversion are
documented in the units and masks guide.