Spectral Transforms¶
spectrakit.transform.transform_kubelka_munk ¶
Convert diffuse reflectance to Kubelka-Munk units.
Applies the transformation: K/S = (1 - R)^2 / (2R)
where R is the diffuse reflectance (0 to 1 scale). This linearizes the relationship between concentration and spectral response for diffuse reflectance measurements.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reflectance
|
ndarray
|
Diffuse reflectance values in [0, 1], shape
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Kubelka-Munk values (K/S), 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/transform/kubelka_munk.py
spectrakit.transform.transform_atr_correction ¶
transform_atr_correction(
intensities: ndarray,
wavenumbers: ndarray,
n_crystal: float = DEFAULT_N_CRYSTAL,
n_sample: float = DEFAULT_N_SAMPLE,
angle: float = DEFAULT_ANGLE,
) -> np.ndarray
Apply ATR path-length correction to infrared spectra.
Corrects for the wavenumber-dependent penetration depth in ATR measurements. The effective path length in ATR varies with wavenumber, making peaks at lower wavenumbers appear stronger. This correction normalizes for that effect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
intensities
|
ndarray
|
ATR spectral intensities, shape |
required |
wavenumbers
|
ndarray
|
Wavenumber axis in cm^-1, shape |
required |
n_crystal
|
float
|
Refractive index of the ATR crystal. Common values: diamond = 2.4, ZnSe = 2.4, Ge = 4.0. |
DEFAULT_N_CRYSTAL
|
n_sample
|
float
|
Refractive index of the sample. Typical organic samples: 1.4-1.6. |
DEFAULT_N_SAMPLE
|
angle
|
float
|
Angle of incidence in degrees. |
DEFAULT_ANGLE
|
Returns:
| Type | Description |
|---|---|
ndarray
|
ATR-corrected intensities, same shape as input. |
Raises:
| Type | Description |
|---|---|
SpectrumShapeError
|
If input is not 1-D or 2-D. |
EmptySpectrumError
|
If input has zero elements. |
ValueError
|
If physics parameters are invalid (non-positive refractive indices, angle outside (0, 90), or angle below the critical angle for the given crystal/sample pair). |