spectrochempy.analysis.constraints.Closure
- class Closure(profile, components=None, target=1.0, method='scaling', blocks=None)[source]
Closure (constant sum) constraint.
States that the selected components of a profile must sum to a target value across the constrained axis (typically the concentration rows summing to
1.0).- Parameters
profile (str) –
"C"(concentrations) or"St"(spectra).components (list[int], optional) – Component indices included in the closure.
None(default) means “all components”.target (float or array-like, optional) – Target sum for the selected components. A scalar is applied to every row; an array-like supplies one target per row. Default is
1.0.method (str, optional) – Closure enforcement method. Must be
"scaling"(rescale the selected components to sum to the target while preserving their relative proportions) or"constantSum"(add a constant offset to each selected component so that the sum equals the target). Default is"scaling".
Examples
>>> from spectrochempy import Closure >>> Closure("C") Closure(profile='C', components=None, target=1.0) >>> Closure("C", components=[0, 1], target=100.0) Closure(profile='C', components=[0, 1], target=100.0) >>> import numpy as np >>> Closure("C", target=np.array([1.0, 1.0, 1.0])) Closure(profile='C', components=None, target=array([1., 1., 1.]))
Attributes Summary
Block indices for augmented data (
Nonemeans all blocks).Components in the closure (
None= all).Closure enforcement method (
'scaling'or'constantSum').Short human-readable name of the constraint family.
Canonical profile identifier (
"C"or"St").Target sum for the selected components.
Attributes Documentation
- target
Target sum for the selected components.
- Type
Float or array-like
Examples using spectrochempy.analysis.constraints.Closure