Detector#

class Detector(tframe, dark, ron, qe, pixel_size, gain=1, saturation=65535, roic_glow=0, nmd=(64, 8, 0), lbda_range=None, min_group=2, max_group=64, lbda=10000.0, variance_model='rauscher07', thermaloptics=None, ron_floor=0, shape=[4096, 4096], meta={})[source]#

Bases: object

Near-infrared detector read out in MACC (up-the-ramp) mode.

This class converts incident photon fluxes into integrated detector signals and estimates the associated variance, accounting for the quantum efficiency, gain, read-out noise, dark current, ROIC glow, thermal emission from the surrounding optics and saturation.

Parameters:
  • tframe (float) – Frame (single read) time in seconds.

  • dark (float) – Detector dark current in e-/s/pixel.

  • ron (float) – Read-out noise per frame in e- (RMS).

  • qe (float or callable) – Quantum efficiency in e-/ph, either as a constant or as a function of wavelength (in Angstrom).

  • pixel_size (float) – Physical pixel size in micrometers.

  • gain (float, optional) – Detector gain in ADU/e-. Default is 1.

  • saturation (int, optional) – Saturation level in ADU. Default is 65535.

  • roic_glow (float, optional) – ROIC glow in e-/pixel/frame. Default is 0.

  • nmd (tuple of int, optional) – MACC read-out mode (ngroups, nframes_per_group, ndrops). Default is (64, 8, 0).

  • lbda_range (array_like or None, optional) – Wavelength range [lmin, lmax] seen by the detector, in Angstrom. If None, the first and last values of lbda are used. Default is None.

  • min_group (int, optional) – Minimum number of groups per ramp. Default is 2.

  • max_group (int, optional) – Maximum number of groups per ramp. Default is 64.

  • lbda (float or array_like, optional) – Wavelength(s) in Angstrom at which chromatic quantities (e.g. the QE) are evaluated. Default is 10000.

  • variance_model (str, optional) – Variance model used for noise estimation, "rauscher07" or "kubik16". Default is "rauscher07".

  • thermaloptics (ThermalOptics or None, optional) – Optics whose thermal emission reaches the detector (thermal dark). Default is None (no thermal dark).

  • ron_floor (float, optional) – Read-out noise floor in e-, added in quadrature to the effective read-out noise of the ramp. Default is 0.

  • shape (list of int, optional) – Detector shape in pixels [ny, nx]. Default is [4096, 4096].

  • meta (dict, optional) – Additional metadata. The detector parameters above are stored in it. Default is an empty dict.

Variables:

mutable_parameters (list of str) – Parameters that can be changed after initialization with update.

Methods

electronpers_to_adu

Get the conversion factor from electron flux [e-/s] to signal [ADU].

estimate_pixel_signal

Estimate the measured signal and variance from an incident flux.

estimate_variance

Estimate the variance of the integrated signal of a pixel.

from_config

Initialize the detector from a configuration dictionary.

get_data_volume

Get the data volume produced by a single ramp.

get_effective_dark

Get the total effective dark current.

get_effective_ron

Compute the effective read-out noise of a ramp.

get_pixel_size

Get the pixel size in the specified unit.

get_qe

Get the quantum efficiency.

get_thermal_dark

Get the thermal dark current of a detector pixel.

photonflux_to_adu

Get the conversion factor from photon flux [ph/s] to signal [ADU].

update

Change any mutable parameter of the detector.

update_lbda

Update the wavelength(s) used by chromatic components.

Attributes

dark

Detector dark current in e-/s/pixel.

exposure_time

Total duration of the ramp in seconds, nframes * tframe.

gain

Gain in ADU/e-.

integration_time

Effective integration time in seconds, (n - 1) * tgroup.

lbda

Wavelength(s) in Angstrom at which chromatic quantities are evaluated.

lbda_range

Wavelength range [lmin, lmax] seen by the detector, in Angstrom.

macc

MACC read-out mode as a "N:M:D" string.

max_group

Maximum allowed number of groups per ramp.

meta

Metadata dictionary holding the current detector parameters.

min_group

Minimum allowed number of groups per ramp.

mutable_parameters

Mutable parameters (list)

name

Name of the detector ("unknown" if not set in meta).

nframes

Total number of frames in the ramp, n * (m + d) - d.

nmd

MACC read-out mode (n, m, d).

pixel_size

Detector pixel size in micrometers.

qe

Quantum efficiency in e-/ph, as a float or a callable of wavelength.

roic_glow

ROIC glow in e-/pixel/frame.

ron

Detector read-out noise per frame in e- (RMS).

saturation

Saturation level in ADU.

shape

Detector shape in pixels [ny, nx].

tframe

Frame time in seconds.

tgroup

Time between the starts of two groups in seconds, (m + d) * tframe.

thermaloptics

ThermalOptics producing the thermal dark, or None.

variance_model

Name of the variance model ("rauscher07" or "kubik16").

electronpers_to_adu()[source]#

Get the conversion factor from electron flux [e-/s] to signal [ADU].

This is integration_time [s] * gain [ADU/e-].

Returns:

float – Conversion factor in ADU/(e-/s).

estimate_pixel_signal(flux, lbda=None, withdark=False, variance_model='default', saturation='default', cached_thermal=False, npix_per_spaxel=1)[source]#

Estimate the measured signal and variance from an incident flux.

The flux of each voxel is spread over npix_per_spaxel detector pixels; the signal, effective dark (see get_effective_dark, thermal dark included), variance and saturation are computed per pixel, then summed back per voxel. Signals are integrated over integration_time. The number of saturated detector pixels is stored in the nsaturated_detpx attribute.

Parameters:
  • flux (array_like) – Incident flux in ph/s/voxel (arbitrary shape, e.g. (nlbda, ny, nx)).

  • lbda (array_like or None, optional) – Wavelengths in Angstrom used to evaluate the QE, along the first axis of flux. If None, lbda is used. Default is None.

  • withdark (bool, optional) – If True, keep the dark contribution in the output signal (it is always included in the variance and in the saturation test). Default is False.

  • variance_model (str, optional) – Variance model to use ("rauscher07" or "kubik16"). If "default", variance_model is used. Default is "default".

  • saturation (float or str or None, optional) – Saturation level in ADU per pixel. Saturated pixels get a NaN signal and an infinite variance. If "default", saturation is used. If None, saturation is not tested. Default is "default".

  • cached_thermal (bool, optional) – Passed as cached to get_thermal_dark. Default is False.

  • npix_per_spaxel (float, optional) – Number of detector pixels over which the flux of one voxel is spread. Default is 1.

Returns:

Raises:

NotImplementedError – If variance_model is unknown.

estimate_variance(flux, model=None, incl_thermal=True, cached_thermal=False)[source]#

Estimate the variance of the integrated signal of a pixel.

The variance accounts for the photon noise of the input flux and of the effective dark current (see get_effective_dark), and for the read-out noise, given the current MACC mode nmd.

Parameters:
  • flux (array_like) – Incident flux in e-/s/pixel.

  • model (str or None, optional) – Variance model, "rauscher07" (Rauscher et al. 2007, corrected in 2010) or "kubik16" (Kubik et al. 2016). If None, variance_model is used. Default is None.

  • incl_thermal (bool, optional) – If True, include the thermal dark in the dark current. Default is True.

  • cached_thermal (bool, optional) – Passed as cached to get_thermal_dark. Default is False.

Returns:

numpy.ndarray or float – Variance in ADU^2.

Raises:

NotImplementedError – If model is unknown.

classmethod from_config(config, lbda=10000.0, thermaloptics=None)[source]#

Initialize the detector from a configuration dictionary.

Parameters:
  • config (dict) –

    Configuration dictionary containing detector parameters (e.g. the [detector] section of a configuration file). It must contain:

    • "nmd" or "readout_mode": MACC read-out mode,

    • "ron" or "readout_noise": read-out noise per frame [e-],

    • "dark": dark current [e-/s/pixel],

    • "tframe": frame time [s],

    • "QE": quantum efficiency, either a float or the name of an ECSV file with wavelength and qe columns,

    • "pixel_size": pixel size [micrometer].

    Optional keys are "shape", "max_group", "min_group", "roic_glow" [e-/pixel/frame], "gain" [ADU/e-] and "variance_model". Other keys are ignored.

  • lbda (float or array_like, optional) – Wavelength(s) in Angstrom. Default is 10000.

  • thermaloptics (ThermalOptics or None, optional) – Optics whose thermal emission reaches the detector. Default is None.

Returns:

Detector – The detector instance.

Warns:

UserWarning – If both "nmd" and "readout_mode" are given ("readout_mode" is then ignored and removed from config), or if neither is given.

get_data_volume(units='GB', nbit_record=16)[source]#

Get the data volume produced by a single ramp.

Only the recorded groups contribute: within a group the m frames are co-added on board and the d dropped frames are never read out, so the volume scales with the number of groups n of the MACC mode and with the number of detector pixels (shape).

Parameters:
  • units (str, optional) – Unit of the returned volume. Must be a known astropy data unit (e.g. "bit", "byte", "MB", "GB"). Default is "GB".

  • nbit_record (int, optional) – Number of bits recorded per pixel and per group. Default is 16.

Returns:

float – The data volume of one ramp, in the requested unit.

See also

slicersim.target.VirtualTarget.get_data_volume

Volume for a full exposure.

get_effective_dark(cached_thermal=False, incl_thermal=True)[source]#

Get the total effective dark current.

This is the sum of the detector dark current (dark), the ROIC glow (roic_glow / tframe) and, optionally, the thermal dark from the surrounding optics (get_thermal_dark).

Parameters:
  • cached_thermal (bool, optional) – Passed as cached to get_thermal_dark. Default is False.

  • incl_thermal (bool, optional) – If True, include the thermal dark. Default is True.

Returns:

float – Total effective dark current in e-/s/pixel.

get_effective_ron(nmd=None, variance_model='default', ron=None, as_variance=False)[source]#

Compute the effective read-out noise of a ramp.

Following Rauscher et al. (2007), the read-out noise variance of the up-the-ramp fit is 12 (n - 1) / (m n (n + 1)) * ron**2, to which ron_floor**2 is added.

Parameters:
  • nmd (tuple of int or None, optional) – MACC read-out mode (ngroups, nframes_per_group, ndrops). If None, nmd is used. Default is None.

  • variance_model (str, optional) – Variance model to use. Only the Rauscher model ("rauscher07") is implemented. If "default", variance_model is used. Default is "default".

  • ron (float or None, optional) – Read-out noise per frame in e-. If None, ron is used. Default is None.

  • as_variance (bool, optional) – If True, return the variance (e-^2) instead of the standard deviation (e-). Default is False.

Returns:

float – Effective read-out noise of the ramp in e- (or its variance in e-^2 if as_variance=True). 0 if ron is 0.

Raises:

NotImplementedError – If variance_model is not a Rauscher model.

get_pixel_size(unit='micrometer')[source]#

Get the pixel size in the specified unit.

Parameters:

unit (str, optional) – Unit for the pixel size. Must be a known astropy length unit. Default is "micrometer".

Returns:

float – Pixel size in the specified unit.

get_qe(lbda=None)[source]#

Get the quantum efficiency.

Parameters:

lbda (float or array_like or None, optional) – Wavelength(s) in Angstrom. If None, lbda is used. Ignored if the QE is a constant. Default is None.

Returns:

float or numpy.ndarray – Quantum efficiency in e-/ph.

get_thermal_dark(thermaloptics=None, as_sum=True, units='ph/s', lbda_range=None, cached=False)[source]#

Get the thermal dark current of a detector pixel.

This is the thermal emission of the non-dispersed optical elements of thermaloptics (those flagged False in its meta["dispersed"]), integrated over lbda_range and received by one pixel.

Parameters:
  • thermaloptics (ThermalOptics or None, optional) – Optics emitting the thermal signal. If None, thermaloptics is used. Default is None.

  • as_sum (bool, optional) – If True, return the sum of the contributions of all optical elements. Otherwise, return one value per element. Default is True.

  • units (str, optional) – Output units, either "ph/s" or "e/s" (alias "e-/s"). In the latter case, the QE is applied. Default is "ph/s".

  • lbda_range (array_like or None, optional) – Wavelength range [lmin, lmax] in Angstrom. If None, lbda_range is used. Default is None.

  • cached (bool, optional) – If True, store the result (per unit) and reuse it in later calls made with cached=True and as_sum=True; the cache is not invalidated when parameters change. Default is False.

Returns:

float or numpy.ndarray – Thermal dark current per pixel, in units. 0 if no thermal optics are available.

Raises:

ValueError – If units is not one of the accepted values.

photonflux_to_adu(lbda=None)[source]#

Get the conversion factor from photon flux [ph/s] to signal [ADU].

This is integration_time [s] * QE [e-/ph] * gain [ADU/e-].

Parameters:

lbda (float or array_like or None, optional) – Wavelength(s) in Angstrom used to evaluate the QE (see get_qe). If None, lbda is used. Default is None.

Returns:

float or numpy.ndarray – Conversion factor in ADU/(ph/s).

update(reset_others=False, **kwargs)[source]#

Change any mutable parameter of the detector.

See mutable_parameters for the list of accepted names. readout_noise is accepted as an alias of ron; ngroup and nframe_per_group only change the corresponding element of nmd. lbda is also accepted and passed to update_lbda.

Parameters:
  • reset_others (bool, optional) – If True, parameters not given in kwargs are reset to their initial values. Default is False.

  • **kwargs – Mutable parameters to update. Parameters set to None are ignored.

Warns:

UserWarning – If a given parameter is not mutable (it is then ignored).

update_lbda(lbda)[source]#

Update the wavelength(s) used by chromatic components.

Parameters:

lbda (float or array_like) – Wavelength(s) in Angstrom.

dark#

Detector dark current in e-/s/pixel.

The total effective dark current, including the ROIC glow and the thermal dark, is given by get_effective_dark.

exposure_time#

Total duration of the ramp in seconds, nframes * tframe.

gain#

Gain in ADU/e-.

integration_time#

Effective integration time in seconds, (n - 1) * tgroup.

This is the time between the first and last groups, used to convert fluxes into integrated signals.

lbda#

Wavelength(s) in Angstrom at which chromatic quantities are evaluated.

lbda_range#

Wavelength range [lmin, lmax] seen by the detector, in Angstrom.

If not specified at initialization, the first and last values of lbda are used.

macc#

MACC read-out mode as a "N:M:D" string.

max_group#

Maximum allowed number of groups per ramp.

meta#

Metadata dictionary holding the current detector parameters.

min_group#

Minimum allowed number of groups per ramp.

mutable_parameters = ['ngroup', 'nframe_per_group', 'nmd', 'tframe', 'max_group', 'ron', 'gain', 'qe', 'dark', 'saturation', 'variance_model', 'ron_floor', 'roic_glow']#

Mutable parameters (list)

name#

Name of the detector ("unknown" if not set in meta).

nframes#

Total number of frames in the ramp, n * (m + d) - d.

nmd#

MACC read-out mode (n, m, d).

n is the number of groups, m the number of frames per group and d the number of dropped frames between groups.

pixel_size#

Detector pixel size in micrometers.

qe#

Quantum efficiency in e-/ph, as a float or a callable of wavelength.

Use get_qe to evaluate it at the current wavelength(s) lbda.

roic_glow#

ROIC glow in e-/pixel/frame.

This is the additional signal induced by each read of the ROIC.

ron#

Detector read-out noise per frame in e- (RMS).

saturation#

Saturation level in ADU.

shape#

Detector shape in pixels [ny, nx].

tframe#

Frame time in seconds.

tgroup#

Time between the starts of two groups in seconds, (m + d) * tframe.

thermaloptics#

ThermalOptics producing the thermal dark, or None.

variance_model#

Name of the variance model ("rauscher07" or "kubik16").