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:
objectNear-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 (
floator 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 (
tupleofint, 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 oflbdaare 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 (
floator 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 (
ThermalOpticsorNone, 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 (
listofint, 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 (
listofstr) – Parameters that can be changed after initialization withupdate.
Methods
Get the conversion factor from electron flux [e-/s] to signal [ADU].
Estimate the measured signal and variance from an incident flux.
Estimate the variance of the integrated signal of a pixel.
Initialize the detector from a configuration dictionary.
Get the data volume produced by a single ramp.
Get the total effective dark current.
Compute the effective read-out noise of a ramp.
Get the pixel size in the specified unit.
Get the quantum efficiency.
Get the thermal dark current of a detector pixel.
Get the conversion factor from photon flux [ph/s] to signal [ADU].
Change any mutable parameter of the detector.
Update the wavelength(s) used by chromatic components.
Attributes
Detector dark current in e-/s/pixel.
Total duration of the ramp in seconds,
nframes * tframe.Gain in ADU/e-.
Effective integration time in seconds,
(n - 1) * tgroup.Wavelength(s) in Angstrom at which chromatic quantities are evaluated.
Wavelength range
[lmin, lmax]seen by the detector, in Angstrom.MACC read-out mode as a
"N:M:D"string.Maximum allowed number of groups per ramp.
Metadata dictionary holding the current detector parameters.
Minimum allowed number of groups per ramp.
Mutable parameters (list)
Name of the detector (
"unknown"if not set inmeta).Total number of frames in the ramp,
n * (m + d) - d.MACC read-out mode
(n, m, d).Detector pixel size in micrometers.
Quantum efficiency in e-/ph, as a float or a callable of wavelength.
ROIC glow in e-/pixel/frame.
Detector read-out noise per frame in e- (RMS).
Saturation level in ADU.
Detector shape in pixels
[ny, nx].Frame time in seconds.
Time between the starts of two groups in seconds,
(m + d) * tframe.ThermalOpticsproducing the thermal dark, or None.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_spaxeldetector pixels; the signal, effective dark (seeget_effective_dark, thermal dark included), variance and saturation are computed per pixel, then summed back per voxel. Signals are integrated overintegration_time. The number of saturated detector pixels is stored in thensaturated_detpxattribute.- 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 offlux. If None,lbdais 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_modelis used. Default is"default".saturation (
floatorstrorNone, optional) – Saturation level in ADU per pixel. Saturated pixels get a NaN signal and an infinite variance. If"default",saturationis used. If None, saturation is not tested. Default is"default".cached_thermal (
bool, optional) – Passed ascachedtoget_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:
signal (
numpy.ndarrayorfloat) – Integrated signal in ADU/voxel.variance (
numpy.ndarrayorfloat) – Signal variance in ADU^2/voxel.
- Raises:
NotImplementedError – If
variance_modelis 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 modenmd.- Parameters:
flux (array_like) – Incident flux in e-/s/pixel.
model (
strorNone, optional) – Variance model,"rauscher07"(Rauscher et al. 2007, corrected in 2010) or"kubik16"(Kubik et al. 2016). If None,variance_modelis 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 ascachedtoget_thermal_dark. Default is False.
- Returns:
numpy.ndarrayorfloat– Variance in ADU^2.- Raises:
NotImplementedError – If
modelis 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 withwavelengthandqecolumns,"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 (
floator array_like, optional) – Wavelength(s) in Angstrom. Default is 10000.thermaloptics (
ThermalOpticsorNone, 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 fromconfig), 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
mframes are co-added on board and theddropped frames are never read out, so the volume scales with the number of groupsnof the MACC mode and with the number of detector pixels (shape).- Parameters:
- Returns:
float– The data volume of one ramp, in the requested unit.
See also
slicersim.target.VirtualTarget.get_data_volumeVolume 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 ascachedtoget_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 whichron_floor**2is added.- Parameters:
nmd (
tupleofintorNone, optional) – MACC read-out mode(ngroups, nframes_per_group, ndrops). If None,nmdis used. Default is None.variance_model (
str, optional) – Variance model to use. Only the Rauscher model ("rauscher07") is implemented. If"default",variance_modelis used. Default is"default".ron (
floatorNone, optional) – Read-out noise per frame in e-. If None,ronis 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 ifas_variance=True). 0 ifronis 0.- Raises:
NotImplementedError – If
variance_modelis not a Rauscher model.
- get_qe(lbda=None)[source]#
Get the quantum efficiency.
- Parameters:
lbda (
floator array_like orNone, optional) – Wavelength(s) in Angstrom. If None,lbdais used. Ignored if the QE is a constant. Default is None.- Returns:
floatornumpy.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 itsmeta["dispersed"]), integrated overlbda_rangeand received by one pixel.- Parameters:
thermaloptics (
ThermalOpticsorNone, optional) – Optics emitting the thermal signal. If None,thermalopticsis 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_rangeis used. Default is None.cached (
bool, optional) – If True, store the result (per unit) and reuse it in later calls made withcached=Trueandas_sum=True; the cache is not invalidated when parameters change. Default is False.
- Returns:
floatornumpy.ndarray– Thermal dark current per pixel, inunits. 0 if no thermal optics are available.- Raises:
ValueError – If
unitsis 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 (
floator array_like orNone, optional) – Wavelength(s) in Angstrom used to evaluate the QE (seeget_qe). If None,lbdais used. Default is None.- Returns:
floatornumpy.ndarray– Conversion factor in ADU/(ph/s).
- update(reset_others=False, **kwargs)[source]#
Change any mutable parameter of the detector.
See
mutable_parametersfor the list of accepted names.readout_noiseis accepted as an alias ofron;ngroupandnframe_per_grouponly change the corresponding element ofnmd.lbdais also accepted and passed toupdate_lbda.- Parameters:
reset_others (
bool, optional) – If True, parameters not given inkwargsare 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 (
floator 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
lbdaare 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)
- nframes#
Total number of frames in the ramp,
n * (m + d) - d.
- nmd#
MACC read-out mode
(n, m, d).nis the number of groups,mthe number of frames per group anddthe 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_qeto 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#
ThermalOpticsproducing the thermal dark, or None.
- variance_model#
Name of the variance model (
"rauscher07"or"kubik16").