nirs4all.data.synthetic.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.data.synthetic.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.

detector_type

Type of detector.

Type:

nirs4all.data.synthetic.instruments.DetectorType

temperature_k

Operating temperature in Kelvin.

Type:

float

integration_time_ms

Integration time in milliseconds.

Type:

float

gain

Amplifier gain.

Type:

float

noise_model

Noise model configuration.

Type:

nirs4all.data.synthetic.detectors.NoiseModelConfig

apply_response_curve

Whether to apply spectral response.

Type:

bool

apply_nonlinearity

Whether to apply detector nonlinearity.

Type:

bool

nonlinearity_coefficient

Quadratic nonlinearity coefficient.

Type:

float

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.data.synthetic.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.

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.data.synthetic.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.

detector_type

Type of detector.

Type:

nirs4all.data.synthetic.instruments.DetectorType

wavelengths

Wavelength grid for response curve (nm).

Type:

numpy.ndarray

response

Relative response at each wavelength (0-1).

Type:

numpy.ndarray

peak_wavelength

Wavelength of peak response (nm).

Type:

float

cutoff_wavelength

Long-wavelength cutoff (nm).

Type:

float

short_cutoff

Short-wavelength cutoff (nm).

Type:

float

peak_qe

Peak quantum efficiency (0-1).

Type:

float

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.data.synthetic.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.

shot_noise_enabled

Enable shot (photon) noise.

Type:

bool

thermal_noise_enabled

Enable thermal (Johnson) noise.

Type:

bool

read_noise_enabled

Enable readout noise.

Type:

bool

flicker_noise_enabled

Enable 1/f (flicker) noise.

Type:

bool

quantization_noise_enabled

Enable ADC quantization noise.

Type:

bool

shot_noise_factor

Scaling factor for shot noise.

Type:

float

thermal_noise_factor

Scaling factor for thermal noise.

Type:

float

read_noise_electrons

Read noise in electrons.

Type:

float

flicker_corner_freq

1/f noise corner frequency (Hz).

Type:

float

adc_bits

ADC resolution in bits.

Type:

int

full_scale

Full-scale signal level.

Type:

float

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.data.synthetic.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.data.synthetic.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.data.synthetic.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.data.synthetic.detectors.list_detector_types() List[str][source]

List available detector types.

Returns:

List of detector type names.

nirs4all.data.synthetic.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
... )