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

blocks

Block indices for augmented data (None means all blocks).

components

Components in the closure (None = all).

method

Closure enforcement method ('scaling' or 'constantSum').

name

Short human-readable name of the constraint family.

profile

Canonical profile identifier ("C" or "St").

target

Target sum for the selected components.

Attributes Documentation

blocks

Block indices for augmented data (None means all blocks).

Type

list[int] or None

components

Components in the closure (None = all).

Type

list[int] or None

method

Closure enforcement method ('scaling' or 'constantSum').

Type

str

name

Short human-readable name of the constraint family.

Type

str

profile

Canonical profile identifier ("C" or "St").

Type

str

target

Target sum for the selected components.

Type

Float or array-like

Examples using spectrochempy.analysis.constraints.Closure