nirs4all.synthesis.scattering module

Scattering effects configuration for synthetic NIRS data generation.

This module provides configuration classes for light scattering effects in NIR spectra, including particle size effects and scattering coefficient generation.

Note

For applying scattering effects to spectra, use the operators in nirs4all.operators.augmentation.scattering: - ParticleSizeAugmenter: Particle size-dependent scattering - EMSCDistortionAugmenter: EMSC-style scatter distortions

Key Features:
  • EMSC-style (Extended Multiplicative Scatter Correction) transformations

  • Particle size-dependent scattering simulation

  • Scattering coefficient generation for Kubelka-Munk

  • Sample-to-sample scatter variation

  • Wavelength-dependent scattering (Rayleigh-like)

Physics Background:

Light scattering in particulate samples is complex and depends on: - Particle size relative to wavelength (Mie vs Rayleigh regimes) - Particle shape and surface roughness - Refractive index differences - Packing density

Rather than implementing full Mie theory (computationally expensive and may not match real data), this module uses empirical EMSC-style models that approximate the distortions that chemometric preprocessing corrects.

References

  • Martens, H., Nielsen, J. P., & Engelsen, S. B. (2003). Light scattering and light absorbance separated by extended multiplicative signal correction. Application to near-infrared transmission analysis of powder mixtures. Analytical Chemistry, 75(3), 394-404.

  • Kubelka, P. (1948). New contributions to the optics of intensely light-scattering materials. Part I. JOSA, 38(5), 448-457.

  • Dahm, D. J., & Dahm, K. D. (2007). Interpreting Diffuse Reflectance and Transmittance. NIR Publications.

  • Burger, J., & Geladi, P. (2005). Hyperspectral NIR image regression part I: calibration and correction. Journal of Chemometrics, 19(5‐7), 355-363.

class nirs4all.synthesis.scattering.EMSCConfig(polynomial_order: int = 2, multiplicative_scatter_std: float = 0.15, additive_scatter_std: float = 0.05, include_wavelength_terms: bool = True, wavelength_coef_std: float = 0.02, reference_spectrum: ndarray | None = None)[source]

Bases: object

Configuration for EMSC-style scattering transformation.

EMSC models scattering distortion as: x = a + b*x_ref + d*λ + e*λ² + …

where a, b are multiplicative/additive scatter, and higher terms model baseline curvature due to scattering.

polynomial_order

Order of polynomial for wavelength-dependent scatter.

Type:

int

multiplicative_scatter_std

Std dev of multiplicative scatter factor b.

Type:

float

additive_scatter_std

Std dev of additive scatter offset a.

Type:

float

include_wavelength_terms

Whether to include λ, λ² terms.

Type:

bool

wavelength_coef_std

Std dev of wavelength coefficient.

Type:

float

reference_spectrum

Optional reference spectrum for EMSC.

Type:

numpy.ndarray | None

additive_scatter_std: float = 0.05
include_wavelength_terms: bool = True
multiplicative_scatter_std: float = 0.15
polynomial_order: int = 2
reference_spectrum: ndarray | None = None
wavelength_coef_std: float = 0.02
class nirs4all.synthesis.scattering.ParticleSizeConfig(distribution: ParticleSizeDistribution = <factory>, reference_size_um: float = 50.0, size_effect_strength: float = 1.0, wavelength_exponent: float = 1.5, include_path_length_effect: bool = True, path_length_sensitivity: float = 0.5)[source]

Bases: object

Configuration for particle size effects.

distribution

Particle size distribution parameters.

Type:

nirs4all.synthesis.scattering.ParticleSizeDistribution

reference_size_um

Reference particle size for baseline scattering.

Type:

float

size_effect_strength

How strongly size affects scattering (0-1).

Type:

float

wavelength_exponent

Exponent for wavelength dependence of scattering. - 4.0 = Rayleigh (particles << wavelength) - 0.0 = No wavelength dependence - 1.0-2.0 = Typical for NIR powder samples

Type:

float

include_path_length_effect

Whether particle size affects optical path.

Type:

bool

path_length_sensitivity

How strongly size affects path length.

Type:

float

distribution: ParticleSizeDistribution
include_path_length_effect: bool = True
path_length_sensitivity: float = 0.5
reference_size_um: float = 50.0
size_effect_strength: float = 1.0
wavelength_exponent: float = 1.5
class nirs4all.synthesis.scattering.ParticleSizeDistribution(mean_size_um: float = 50.0, std_size_um: float = 15.0, min_size_um: float = 5.0, max_size_um: float = 200.0, distribution: str = 'lognormal')[source]

Bases: object

Particle size distribution parameters.

Models particle size as a log-normal distribution, which is common for ground/milled samples in NIR analysis.

mean_size_um

Mean particle size in micrometers.

Type:

float

std_size_um

Standard deviation of particle size in micrometers.

Type:

float

min_size_um

Minimum particle size (lower truncation).

Type:

float

max_size_um

Maximum particle size (upper truncation).

Type:

float

distribution

Type of distribution (‘lognormal’, ‘normal’, ‘uniform’).

Type:

str

distribution: str = 'lognormal'
max_size_um: float = 200.0
mean_size_um: float = 50.0
min_size_um: float = 5.0
sample(n_samples: int, rng: Generator) ndarray[source]

Sample particle sizes from the distribution.

std_size_um: float = 15.0
class nirs4all.synthesis.scattering.ScatteringCoefficientConfig(baseline_scattering: float = 1.0, wavelength_exponent: float = 1.0, particle_size_factor: float = 0.5, sample_variation: float = 0.15, wavelength_reference_nm: float = 1500.0)[source]

Bases: object

Configuration for scattering coefficient (S) generation.

For Kubelka-Munk reflectance, we need both absorption (K) and scattering (S) coefficients. This config controls S(λ) generation.

baseline_scattering

Base scattering coefficient value.

Type:

float

wavelength_exponent

Exponent for wavelength dependence. S(λ) ∝ λ^(-exponent)

Type:

float

particle_size_factor

How strongly particle size affects S.

Type:

float

sample_variation

Sample-to-sample variation in S.

Type:

float

wavelength_reference_nm

Reference wavelength for normalization.

Type:

float

baseline_scattering: float = 1.0
particle_size_factor: float = 0.5
sample_variation: float = 0.15
wavelength_exponent: float = 1.0
wavelength_reference_nm: float = 1500.0
class nirs4all.synthesis.scattering.ScatteringEffectsConfig(model: ScatteringModel = ScatteringModel.EMSC, particle_size: ParticleSizeConfig = <factory>, emsc: EMSCConfig = <factory>, scattering_coefficient: ScatteringCoefficientConfig = <factory>, enable_particle_size: bool = True, enable_emsc: bool = True)[source]

Bases: object

Combined configuration for all scattering effects.

model

Which scattering model to use.

Type:

nirs4all.synthesis.scattering.ScatteringModel

particle_size

Particle size effect configuration.

Type:

nirs4all.synthesis.scattering.ParticleSizeConfig

emsc

EMSC-style transformation configuration.

Type:

nirs4all.synthesis.scattering.EMSCConfig

scattering_coefficient

Scattering coefficient generation config.

Type:

nirs4all.synthesis.scattering.ScatteringCoefficientConfig

enable_particle_size

Whether to apply particle size effects.

Type:

bool

enable_emsc

Whether to apply EMSC-style transformation.

Type:

bool

emsc: EMSCConfig
enable_emsc: bool = True
enable_particle_size: bool = True
model: ScatteringModel = 'emsc'
particle_size: ParticleSizeConfig
scattering_coefficient: ScatteringCoefficientConfig
class nirs4all.synthesis.scattering.ScatteringModel(value)[source]

Bases: str, Enum

Available scattering models.

EMSC = 'emsc'
KUBELKA_MUNK = 'kubelka_munk'
MIE_APPROX = 'mie_approx'
POLYNOMIAL = 'polynomial'
RAYLEIGH = 'rayleigh'