Normalization¶
spectrakit.normalize.normalize_snv ¶
Apply Standard Normal Variate normalization.
Centers each spectrum to zero mean and unit variance. Removes multiplicative scatter effects common in diffuse reflectance data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intensities
|
ndarray
|
Spectral intensities, shape (W,) or (N, W). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
SNV-normalized intensities, same shape as input. |
Raises:
| Type | Description |
|---|---|
SpectrumShapeError
|
If input is not 1-D or 2-D. |
EmptySpectrumError
|
If input has zero elements. |
Source code in src/spectrakit/normalize/snv.py
spectrakit.normalize.normalize_minmax ¶
Scale intensities to the [0, 1] range per spectrum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intensities
|
ndarray
|
Spectral intensities, shape (W,) or (N, W). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Min-max normalized intensities, same shape. |
Raises:
| Type | Description |
|---|---|
SpectrumShapeError
|
If input is not 1-D or 2-D. |
EmptySpectrumError
|
If input has zero elements. |
Source code in src/spectrakit/normalize/minmax.py
spectrakit.normalize.normalize_area ¶
Normalize spectra so that the area under each curve equals 1.
Uses the trapezoidal rule for integration. If wavenumbers are not provided, assumes unit spacing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intensities
|
ndarray
|
Spectral intensities, shape (W,) or (N, W). |
required |
wavenumbers
|
ndarray | None
|
X-axis values, shape (W,). Used for proper integration spacing. None assumes unit spacing. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Area-normalized intensities, same shape. |
Raises:
| Type | Description |
|---|---|
SpectrumShapeError
|
If input is not 1-D or 2-D. |
EmptySpectrumError
|
If input has zero elements. |
Source code in src/spectrakit/normalize/area.py
spectrakit.normalize.normalize_vector ¶
Normalize each spectrum to unit L2 norm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intensities
|
ndarray
|
Spectral intensities, shape (W,) or (N, W). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
L2-normalized intensities, same shape. |
Raises:
| Type | Description |
|---|---|
SpectrumShapeError
|
If input is not 1-D or 2-D. |
EmptySpectrumError
|
If input has zero elements. |