lightcurvelynx.noise_models.base_noise_models
Noise models are used to simulate the noise in bandflux measurements for a given set of observations in an ObsTable. They extract information about the instrument and observing conditions from the ObsTable and then apply noise to the input bandflux measurements.
Each noise model uses a given set of parameters with given units from the ObsTable. Users adding new observation parameters should derive the necessary parameters in the necessary units in the ObsTable’s _derive_noise_columns method.
Alternatively users can create new noise models that use different input parameter/unit combinations.
Classes
An abstract baseclass noise model for simulating bandflux measurements. |
|
A noise model that simulates photon noise for bandflux measurements |
|
A noise model that simulates photon noise for bandflux measurements |
|
A noise model that simulates photon noise for bandflux measurements with a |
|
A noise model that simulates photon noise from only the five-sigma depth information. |
Module Contents
- class FluxNoiseModel[source]
Bases:
abc.ABCAn abstract baseclass noise model for simulating bandflux measurements.
- property required_values[source]
List of column names that must be present in the ObsTable for this noise model to work.
- abstractmethod apply_noise(bandflux, *, obs_table=None, indices=None, rng=None, **kwargs)[source]
Compute the noise parameters for given observations in an ObsTable and apply noise to the input bandflux.
- Parameters:
bandflux (array_like of float) – Source bandflux in energy units, e.g. nJy.
obs_table (ObsTable, optional) – Table containing the observation parameters, including all parameters needed to compute the noise.
indices (array_like of int, optional) – Indices of the observations in the ObsTable to which noise should be applied.
rng (np.random.Generator, optional) – The random number generator to use for applying noise. If None, a default generator will be used.
**kwargs – Additional parameters for the noise model.
- Returns:
flux (array_like) – The updated flux measurements after applying noise, in the same units as the input bandflux.
flux_err (array_like) – The bandflux measurement error used for applying noise, in the same units as the input bandflux.
- check_compatibility(obs_table, fail_on_incompatible=False)[source]
Check if the noise model is compatible with the given ObsTable.
- Parameters:
obs_table (ObsTable) – The observation table to check for compatibility.
fail_on_incompatible (bool, optional) – If True, raise a ValueError if the noise model is not compatible with the ObsTable. If False, simply return False in that case. Default is False.
- Returns:
True if the noise model is compatible with the ObsTable, False otherwise.
- Return type:
bool
- class ConstantFluxNoiseModel(noise_level)[source]
Bases:
FluxNoiseModelA noise model that simulates photon noise for bandflux measurements sampled from a normal distribution with a constant standard deviation. This class is primarily meant for testing purposes.
- noise_level[source]
The (constant) standard deviation of the noise to apply to the bandflux measurements, in the same units as the input bandflux.
- Type:
float
- apply_noise(bandflux, *, rng=None, **kwargs)[source]
Compute the noise parameters for given observations in an ObsTable and apply noise to the input bandflux.
- Parameters:
bandflux (array_like of float) – Source bandflux in energy units, e.g. nJy.
rng (np.random.Generator, optional) – The random number generator to use for applying noise. If None, a default generator will be used.
**kwargs – Additional parameters for the noise model.
- Returns:
flux (array_like) – The updated flux measurements after applying noise, in the same units as the input bandflux.
flux_err (array_like) – The bandflux measurement error used for applying noise, in the same units as the input bandflux.
- class PoissonFluxNoiseModel[source]
Bases:
FluxNoiseModelA noise model that simulates photon noise for bandflux measurements with a Poisson noise level that are extracted from values in an ObsTable.
This noise model uses the following values from the ObsTable: - dark_current: Mean dark current (electrons per pixel per second). - exptime: The total exposure time for the observation (seconds). - nexposure: The number of exposures (optional, default is 1). - psf_footprint: Point spread function effective area (pixel^2). - read_noise: Standard deviation of the readout electrons per pixel per exposure. - sky_bg_e: Sky background (electrons / pixel^2). - zp: The photometric zero point (nJy / electron). - zp_err_mag: The uncertainty in the photometric zero point in magnitudes (optional, default is 0.0). Users should ensure that the necessary parameters (in the correct units) are derived in the ObsTable’s _derive_noise_columns method.
- compute_flux_error(bandflux, obs_table, indices)[source]
Compute the flux error for the given bandflux and observation parameters.
- Parameters:
bandflux (array_like of float) – Source bandflux in nJy.
obs_table (ObsTable) – Table containing the observation parameters needed to compute the noise.
indices (array_like of int) – Indices of the observations in the ObsTable for which to compute the noise.
- Returns:
flux_err – The standard deviation of the bandflux measurement error (in nJy)
- Return type:
array_like
- apply_noise(bandflux, *, obs_table=None, indices=None, rng=None, **kwargs)[source]
Compute the noise parameters for given observations in an ObsTable and apply noise to the input bandflux.
- Parameters:
bandflux (array_like of float) – Source bandflux in energy units, e.g. nJy.
obs_table (ObsTable, optional) – Table containing the observation parameters, including all parameters needed to compute the noise.
indices (array_like of int, optional) – Indices of the observations in the ObsTable to which noise should be applied.
rng (np.random.Generator, optional) – The random number generator to use for applying noise. If None, a default generator will be used.
**kwargs – Additional parameters for the noise model.
- Returns:
flux (array_like) – The updated flux measurements after applying noise, in the same units as the input bandflux.
flux_err (array_like) – The bandflux measurement error used for applying noise, in the same units as the input bandflux.
- class GivenNoiseModel[source]
Bases:
FluxNoiseModelA noise model that simulates photon noise for bandflux measurements with a given (per-row) noise level.
This noise model uses the following values from the ObsTable: - bandflux_error: The standard deviation of the noise to apply to the bandflux measurements (nJy).
- apply_noise(bandflux, *, obs_table=None, indices=None, rng=None, **kwargs)[source]
Compute the noise parameters for given observations in an ObsTable and apply noise to the input bandflux.
- Parameters:
bandflux (array_like of float) – Source bandflux in energy units, e.g. nJy.
obs_table (ObsTable, optional) – Table containing the observation parameters, including all parameters needed to compute the noise.
indices (array_like of int, optional) – Indices of the observations in the ObsTable to which noise should be applied.
rng (np.random.Generator, optional) – The random number generator to use for applying noise. If None, a default generator will be used.
**kwargs – Additional parameters for the noise model.
- Returns:
flux (array_like) – The updated flux measurements after applying noise, in the same units as the input bandflux.
flux_err (array_like) – The bandflux measurement error used for applying noise, in the same units as the input bandflux.
- class FiveSigmaDepthNoiseModel[source]
Bases:
FluxNoiseModelA noise model that simulates photon noise from only the five-sigma depth information.
This noise model uses the following values from the ObsTable: - five_sigma_depth: The five-sigma depth in AB magnitudes.
Note
This noise model is not as accurate as the PoissonFluxNoiseModel, but it can be used when only the five-sigma depth is available in the ObsTable.
- apply_noise(bandflux, *, obs_table=None, indices=None, rng=None, **kwargs)[source]
Compute the noise parameters for given observations in an ObsTable and apply noise to the input bandflux.
- Parameters:
bandflux (array_like of float) – Source bandflux in energy units, e.g. nJy.
obs_table (ObsTable, optional) – Table containing the observation parameters, including all parameters needed to compute the noise.
indices (array_like of int, optional) – Indices of the observations in the ObsTable to which noise should be applied.
rng (np.random.Generator, optional) – The random number generator to use for applying noise. If None, a default generator will be used.
**kwargs – Additional parameters for the noise model.
- Returns:
flux (array_like) – The updated flux measurements after applying noise, in the same units as the input bandflux.
flux_err (array_like) – The bandflux measurement error used for applying noise, in the same units as the input bandflux.