nirs4all.synthesis.detectors module

Detector simulation for synthetic NIRS data generation.

This module provides detailed simulation of NIR detector characteristics including spectral response curves, noise models, and nonlinearity effects.

Key Features:
  • Detector spectral response curves (Si, InGaAs, PbS, etc.)

  • Shot noise, thermal noise, read noise, and 1/f noise models

  • Detector nonlinearity simulation

  • Temperature-dependent behavior

References

  • Rogalski, A. (2002). Infrared Detectors: An Overview. Infrared Physics & Technology, 43(3-5), 187-210.

  • Vincent, J. D., Hodges, S., Vampola, J., Stegall, M., & Pierce, G. (2015). Fundamentals of Infrared and Visible Detector Operation and Testing. Wiley.

  • Burns, D. A., & Ciurczak, E. W. (2007). Handbook of Near-Infrared Analysis. CRC Press.

class nirs4all.synthesis.detectors.DetectorConfig(detector_type: DetectorType = DetectorType.INGAAS, temperature_k: float = 293.0, integration_time_ms: float = 100.0, gain: float = 1.0, noise_model: NoiseModelConfig = <factory>, apply_response_curve: bool = True, apply_nonlinearity: bool = False, nonlinearity_coefficient: float = 0.02)[source]

Bases: object

Complete detector configuration.

Variables:
apply_nonlinearity: bool = False
apply_response_curve: bool = True
detector_type: DetectorType = 'ingaas'
gain: float = 1.0
integration_time_ms: float = 100.0
noise_model: NoiseModelConfig
nonlinearity_coefficient: float = 0.02
temperature_k: float = 293.0
class nirs4all.synthesis.detectors.DetectorSimulator(config: DetectorConfig | None = None, random_state: int | None = None)[source]

Bases: object

Simulate detector effects on NIR spectra.

Applies detector spectral response, noise models, and nonlinearity to synthetic spectra.

Variables:
  • config – Detector configuration.

  • rng – Random number generator.

Example

>>> config = DetectorConfig(detector_type=DetectorType.INGAAS)
>>> simulator = DetectorSimulator(config, random_state=42)
>>> spectra_out = simulator.apply(spectra, wavelengths)
apply(spectra: ndarray, wavelengths: ndarray, base_signal_level: float = 1.0) → ndarray[source]

Apply detector effects to spectra.

Parameters:
  • spectra – Input spectra (n_samples, n_wavelengths).

  • wavelengths – Wavelength array (nm).

  • base_signal_level – Reference signal level for noise scaling.

Returns:

Spectra with detector effects applied.

class nirs4all.synthesis.detectors.DetectorSpectralResponse(detector_type: DetectorType, wavelengths: ndarray, response: ndarray, peak_wavelength: float, cutoff_wavelength: float, short_cutoff: float, peak_qe: float = 0.7)[source]

Bases: object

Spectral response curve for a detector.

Defines the wavelength-dependent sensitivity (quantum efficiency) of the detector.

Variables:
  • detector_type (nirs4all.synthesis.instruments.DetectorType) – Type of detector.

  • wavelengths (numpy.ndarray) – Wavelength grid for response curve (nm).

  • response (numpy.ndarray) – Relative response at each wavelength (0-1).

  • peak_wavelength (float) – Wavelength of peak response (nm).

  • cutoff_wavelength (float) – Long-wavelength cutoff (nm).

  • short_cutoff (float) – Short-wavelength cutoff (nm).

  • peak_qe (float) – Peak quantum efficiency (0-1).

cutoff_wavelength: float
detector_type: DetectorType
get_response_at(wavelengths: ndarray) → ndarray[source]

Get detector response at specified wavelengths.

Parameters:

wavelengths – Wavelengths to evaluate (nm).

Returns:

Detector response at each wavelength.

peak_qe: float = 0.7
peak_wavelength: float
response: ndarray
short_cutoff: float
wavelengths: ndarray
class nirs4all.synthesis.detectors.NoiseModelConfig(shot_noise_enabled: bool = True, thermal_noise_enabled: bool = True, read_noise_enabled: bool = True, flicker_noise_enabled: bool = False, quantization_noise_enabled: bool = False, shot_noise_factor: float = 1.0, thermal_noise_factor: float = 1.0, read_noise_electrons: float = 50.0, flicker_corner_freq: float = 100.0, adc_bits: int = 16, full_scale: float = 3.0)[source]

Bases: object

Configuration for detector noise model.

Variables:
  • shot_noise_enabled (bool) – Enable shot (photon) noise.

  • thermal_noise_enabled (bool) – Enable thermal (Johnson) noise.

  • read_noise_enabled (bool) – Enable readout noise.

  • flicker_noise_enabled (bool) – Enable 1/f (flicker) noise.

  • quantization_noise_enabled (bool) – Enable ADC quantization noise.

  • shot_noise_factor (float) – Scaling factor for shot noise.

  • thermal_noise_factor (float) – Scaling factor for thermal noise.

  • read_noise_electrons (float) – Read noise in electrons.

  • flicker_corner_freq (float) – 1/f noise corner frequency (Hz).

  • adc_bits (int) – ADC resolution in bits.

  • full_scale (float) – Full-scale signal level.

adc_bits: int = 16
flicker_corner_freq: float = 100.0
flicker_noise_enabled: bool = False
full_scale: float = 3.0
quantization_noise_enabled: bool = False
read_noise_electrons: float = 50.0
read_noise_enabled: bool = True
shot_noise_enabled: bool = True
shot_noise_factor: float = 1.0
thermal_noise_enabled: bool = True
thermal_noise_factor: float = 1.0
nirs4all.synthesis.detectors.get_default_noise_config(detector_type: DetectorType) → NoiseModelConfig[source]

Get default noise model configuration for a detector type.

Parameters:

detector_type – Type of detector.

Returns:

NoiseModelConfig with appropriate defaults.

nirs4all.synthesis.detectors.get_detector_response(detector_type: DetectorType) → DetectorSpectralResponse[source]

Get spectral response curve for a detector type.

Parameters:

detector_type – Type of detector.

Returns:

DetectorSpectralResponse object.

nirs4all.synthesis.detectors.get_detector_wavelength_range(detector_type: DetectorType) → tuple[float, float][source]

Get the effective wavelength range for a detector type.

Parameters:

detector_type – Type of detector.

Returns:

Tuple of (min_wavelength, max_wavelength) in nm.

nirs4all.synthesis.detectors.list_detector_types() → list[str][source]

List available detector types.

Returns:

List of detector type names.

nirs4all.synthesis.detectors.simulate_detector_effects(spectra: ndarray, wavelengths: ndarray, detector_type: DetectorType = DetectorType.INGAAS, include_response: bool = True, include_noise: bool = True, random_state: int | None = None) → ndarray[source]

Apply detector effects to spectra with simple API.

Parameters:
  • spectra – Input spectra (n_samples, n_wavelengths).

  • wavelengths – Wavelength array (nm).

  • detector_type – Type of detector to simulate.

  • include_response – Whether to apply spectral response.

  • include_noise – Whether to apply noise.

  • random_state – Random seed.

Returns:

Spectra with detector effects applied.

Example

>>> spectra_out = simulate_detector_effects(
...     spectra, wavelengths,
...     detector_type=DetectorType.PBS
... )