Exposures

class qmostetc.Exposure(spectrograph)

Simulate an exposure

After initialization and filling with target and background (sky) flux, the basic properties for a specified exposure time can be calculated.

Parameters:
spectrographSpectrograph

Spectrograph object, with attributes wavelength, readout_noise, and dark_flux.

Examples

Do a single exposure with just one line, without sky:

>>> import numpy as np
>>> import astropy.units as u
>>> from qmostetc import Spectrograph, Spectrum
>>> spec = Spectrograph.qmost('lrs', 'green')
>>> wl = np.arange(590., 610., 0.01) * u.nm
>>> line = np.zeros(wl.shape) * u.ph / (u.nm * u.s)
>>> line[1000] = 1e3 * u.ph / (u.nm * u.s)
>>> flux = spec.rebin(Spectrum(wl, line))
>>> exposure = Exposure(spec)
>>> exposure.set_target(flux)
>>> tbl = exposure.expose(300*u.s)
>>> print(sorted(tbl.columns.keys()))
['binwidth', 'dark', 'efficiency', 'gain', 'noise', 'ron', 'sky', 'target', 'wavelength']
>>> snr = tbl['target'] / tbl['noise']
>>> print(f'Maximum SNR: {snr.max():.0f}')
Maximum SNR: 18
set_target(flux)

Set target signal.

Parameters:
fluxSpectrum

Photoelectron flux of the target per bin [electron/s], or per wavelength unit [electron/(s nm)].

set_sky(flux)

Set the sky brackground

Parameters:
fluxSpectrum

Photoelectron flux of the target per bin [electron/s], or per wavelength unit [electron/(s nm)].

get_sky(texp)

Return the sky response for a specified exposure time

Parameters:
texpastropy.units.Quantity

Total exposure time [s]

Returns:
astropy.units.Quantity

Resulting sky values [electron], corresponding to the wavelength attribute.

get_target(texp)

Return the target signal response for a specified exposure time

Parameters:
texpastropy.units.Quantity

Total exposure time [s]

Returns:
astropy.units.Quantity

Resulting target values [electron], corresponding to the wavelength attribute.

get_noise(texp, nexp=1)

Return the noise for a specified exposure time

The noise is calculated by the formula \(\sqrt{(N_{obj} + N_{sky} + N_{dark}) ⋅ t_{exp} + N_{ron}^2 ⋅ n_{exp}}\), where all values are in electrons.

Parameters:
texpastropy.units.Quantity

Total exposure time [s]

nexpint

Number of exposures. Defaults to 1.

Returns:
astropy.units.Quantity

Resulting noise [electron], corresponding to the wavelength attribute.

get_bgnoise(texp, nexp=1)

Return the background noise for a specified exposure time

The noise is calculated by the formula \(\sqrt{(N_{sky} + N_{dark}) ⋅ t_{exp} + N_{ron}^2 ⋅ n_{exp}}\), where all values are in electrons.

Parameters:
texpastropy.units.Quantity

Total exposure time [s]

nexpint

Number of exposures. Defaults to 1.

Returns:
astropy.units.Quantity

Resulting noise [electron], corresponding to the wavelength attribute.

get_snr(texp, nexp=1)

Return the signal to noise ratio for a specified exposure time

This is an optimized variant of a get_target()/get_noise() call.

Parameters:
texpastropy.units.Quantity

Total exposure time [s]

nexpint

Number of exposures. Defaults to 1.

Returns:
numpy.ndarray

Resulting SNR per bin, corresponding to the wavelength attribute.

expose(texp, nexp=1, var=None)

Calculate the result of one exposure

This basically scales the target and sky fluxes by the exposure time, adds dark and readout noise, and calculates the signal-to-noise ratio. The result is returned as a astropy.table.QTable by default, or as a astropy.units.Quantity array.

Parameters:
texpastropy.units.Quantity

Total exposure time [s]

nexpint

Number of exposures. Defaults to 1.

varstr or None

Requested column (default None). If this is used, only a single quantity array is returned containing just the values of this column. Allowed values:

  • target: Target signal count [electron]

  • sky: Sky background count [electron]

  • noise: Noise count [electron]

  • bg_noise_flux: Background noise flux [electron/s]

  • snr: Signal to noise ratio

Returns:
astropy.table.QTable (if no columns were specified)

Resulting table with the following columns:

  • wavelength: Left borders of wavelenght bins [nm]

  • binwidth: Wavelength bin width [nm]

  • efficiency: Spectrograph efficiency [electron/photon]

  • gain: Spectrograph gain [electron/adu]

  • target: Target signal count [electron]

  • sky: Sky background count [electron]

  • dark: CCD dark current [electron]

  • ron: CCD readout noise [electron]

  • noise: Noise count [electron]

astropy.units.Quantity (if a specific column was specified)

Resulting array for the requested column

property wavelength

astropy.units.Quantity : Left borders of wavelenght bins [nm]