astrocook.mocks.truth module#

Ground truth of a mock spectrum.

class astrocook.mocks.truth.MockComponent(series: str, z: float, logN: float, b: float, btur: float = 0.0)[source]#

Bases: object

One Voigt component.

Parameters:
  • series (str) – A transition (e.g. 'CIV_1548'), a multiplet of STANDARD_MULTIPLETS (e.g. 'CIV') or a comma-separated list of transitions.

  • z (float) – Redshift.

  • logN (float) – Log10 of the column density (cm^-2).

  • b (float) – Doppler parameter (km/s).

  • btur (float, optional) – Turbulent broadening (km/s), added in quadrature to b.

series: str#
z: float#
logN: float#
b: float#
btur: float = 0.0#
__init__(series: str, z: float, logN: float, b: float, btur: float = 0.0) → None#
class astrocook.mocks.truth.EmissionLine(rest_nm: float, amplitude: float, fwhm_kms: float)[source]#

Bases: object

Gaussian emission line added to the continuum (quasar frame).

Parameters:
  • rest_nm (float) – Rest-frame wavelength (nm); observed at rest_nm * (1 + z_em).

  • amplitude (float) – Peak height, in units of the power-law continuum.

  • fwhm_kms (float) – Full width at half maximum (km/s).

rest_nm: float#
amplitude: float#
fwhm_kms: float#
__init__(rest_nm: float, amplitude: float, fwhm_kms: float) → None#
astrocook.mocks.truth.QSO_EMISSION_LINES = [EmissionLine(rest_nm=121.567, amplitude=2.0, fwhm_kms=4000.0), EmissionLine(rest_nm=123.9, amplitude=0.4, fwhm_kms=3000.0), EmissionLine(rest_nm=154.9, amplitude=0.8, fwhm_kms=5000.0)]#

Lyman-alpha + NV and CIV emission, indicative values

class astrocook.mocks.truth.MockTruth(components: ~typing.List[~astrocook.mocks.truth.MockComponent], lam_min_nm: float, lam_max_nm: float, dv_kms: float, resol: float | None = 45000.0, snr: float | None = 50.0, z_em: float = 0.0, seed: int = 0, oversample: int = 5, cont_amplitude: float = 1.0, cont_slope: float = 0.0, cont_ref_nm: float = 500.0, emission_lines: ~typing.List[~astrocook.mocks.truth.EmissionLine] = <factory>, n_spikes: int = 0, spike_amplitude: float = 10.0, lyman_limit: bool = False, noise_floor: float | None = None)[source]#

Bases: object

Everything needed to generate, and later evaluate, a mock spectrum.

The wavelength grid is uniform in velocity (pixel size dv_kms), as for echelle spectrographs. The continuum is a power law cont_amplitude * (lambda / cont_ref_nm) ** cont_slope. The noise is Gaussian, with a signal-to-noise ratio snr per pixel at the continuum level (None: noiseless). With noise_floor = None (the default) the error is the same at any flux, cont / snr; with a value a between 0 and 1 it follows the flux, as for photon noise of the source on a background: sigma = (cont / snr) sqrt(a + (1 - a) F / cont), with F the noiseless flux, so that a is the variance at zero flux relative to the continuum.

resol is the resolving power, either a single value or None (no instrumental broadening). oversample is the number of sub-pixels on which the model is computed before being averaged over each pixel.

emission_lines are added to the continuum (the absorbers absorb them too). With lyman_limit the H I components (those with Lyman lines) also absorb the continuum below their Lyman limit (off by default, so that the mocks made before it are unchanged). n_spikes single-pixel positive spikes of spike_amplitude times the local error are added after the noise, at random positions; their indices are not part of the truth but are reproducible from the seed (see astrocook.mocks.spike_indices()).

components: List[MockComponent]#
lam_min_nm: float#
lam_max_nm: float#
dv_kms: float#
resol: float | None = 45000.0#
snr: float | None = 50.0#
z_em: float = 0.0#
seed: int = 0#
oversample: int = 5#
cont_amplitude: float = 1.0#
cont_slope: float = 0.0#
cont_ref_nm: float = 500.0#
emission_lines: List[EmissionLine]#
n_spikes: int = 0#
spike_amplitude: float = 10.0#
lyman_limit: bool = False#
noise_floor: float | None = None#
to_dict() → dict[source]#
classmethod from_dict(data: dict) → MockTruth[source]#
to_json(path: str) → None[source]#
classmethod from_json(path: str) → MockTruth[source]#
__init__(components: ~typing.List[~astrocook.mocks.truth.MockComponent], lam_min_nm: float, lam_max_nm: float, dv_kms: float, resol: float | None = 45000.0, snr: float | None = 50.0, z_em: float = 0.0, seed: int = 0, oversample: int = 5, cont_amplitude: float = 1.0, cont_slope: float = 0.0, cont_ref_nm: float = 500.0, emission_lines: ~typing.List[~astrocook.mocks.truth.EmissionLine] = <factory>, n_spikes: int = 0, spike_amplitude: float = 10.0, lyman_limit: bool = False, noise_floor: float | None = None) → None#