pypeit.images.detector_container module

DataContainer object to hold detector properties.

class pypeit.images.detector_container.DetectorContainer(dataext, specaxis, specflip, spatflip, platescale, saturation, mincounts, nonlinear, numamplifiers, gain, ronoise, det, binning, xgap=None, ygap=None, ysize=None, darkcurr=None, datasec=None, oscansec=None)[source]

Bases: DataContainer

Class to hold a detector properties.

The datamodel attributes are:

Version: 1.0.1

Attribute

Type

Array Type

Description

binning

str

Binning in PypeIt orientation (not the original)

darkcurr

int, float

Dark current (e-/pixel/hour)

dataext

int

Index of fits extension containing data

datasec

numpy.ndarray

str

Either the data sections or the header keyword where the valid data sections can be obtained, one per amplifier. If defined explicitly should be in FITS format (e.g., [1:2048,10:4096]).

det

int, numpy.integer

PypeIt designation for detector number (1-based).

gain

numpy.ndarray

numpy.floating

Inverse gain (e-/ADU). A list should be provided if a detector contains more than one amplifier.

mincounts

int, float

Counts (e-) in a pixel below this value will be ignored as being unphysical.

nonlinear

int, float

Percentage of detector range which is linear (i.e. everything above nonlinear*saturation will be flagged as saturated)

numamplifiers

int

Number of amplifiers

oscansec

numpy.ndarray

str

Either the overscan section or the header keyword where the valid data sections can be obtained, one per amplifier. If defined explicitly should be in FITS format (e.g., [1:2048,10:4096]).

platescale

int, float

arcsec per pixel in the spatial dimension for an unbinned pixel

ronoise

numpy.ndarray

numpy.floating

Read-out noise (e-). A list should be provided if a detector contains more than one amplifier. If any element of this list is <=0, the readout noise will be determined from the overscan regions defined by oscansec.

saturation

int, float

The detector saturation level in ADU/DN

spatflip

bool

If this is True then the spatial dimension will be flipped. PypeIt expects echelle orders to increase with increasing pixel number. I.e., setting spatflip=True can reorder images so that blue orders appear on the left and red orders on the right.

specaxis

int

Spectra are dispersed along this axis. Allowed values are 0 (first dimension for a numpy array shape) or 1 (second dimension for numpy array shape).

specflip

bool

If this is True then the dispersion dimension (specified by the specaxis) will be flipped. PypeIt expects wavelengths to increase with increasing pixel number. If this is not the case for this instrument, set specflip to True.

xgap

int, float

Gap between the square detector pixels (expressed as a fraction of the x pixel size – x is predominantly the spatial axis)

ygap

int, float

Gap between the square detector pixels (expressed as a fraction of the y pixel size – y is predominantly the spectral axis)

ysize

int, float

The size of a pixel in the y-direction as a multiple of the x pixel size (i.e. xsize = 1.0 – x is predominantly the dispersion axis)

_bundle()[source]

Overload base class bundling to select appropriate extension name.

Returns:

List of dictionaries to write to HDUs.

Return type:

list

datamodel = {'binning': {'descr': 'Binning in PypeIt orientation (not the original)', 'otype': <class 'str'>}, 'darkcurr': {'descr': 'Dark current (e-/pixel/hour)', 'otype': (<class 'int'>, <class 'float'>)}, 'dataext': {'descr': 'Index of fits extension containing data', 'otype': <class 'int'>}, 'datasec': {'atype': <class 'str'>, 'descr': 'Either the data sections or the header keyword where the valid data sections can be obtained, one per amplifier. If defined explicitly should be in FITS format (e.g., [1:2048,10:4096]).', 'otype': <class 'numpy.ndarray'>}, 'det': {'descr': 'PypeIt designation for detector number (1-based).', 'otype': (<class 'int'>, <class 'numpy.integer'>)}, 'gain': {'atype': <class 'numpy.floating'>, 'descr': 'Inverse gain (e-/ADU). A list should be provided if a detector contains more than one amplifier.', 'otype': <class 'numpy.ndarray'>}, 'mincounts': {'descr': 'Counts (e-) in a pixel below this value will be ignored as being unphysical.', 'otype': (<class 'int'>, <class 'float'>)}, 'nonlinear': {'descr': 'Percentage of detector range which is linear (i.e. everything above ``nonlinear*saturation`` will be flagged as saturated)', 'otype': (<class 'int'>, <class 'float'>)}, 'numamplifiers': {'descr': 'Number of amplifiers', 'otype': <class 'int'>}, 'oscansec': {'atype': <class 'str'>, 'descr': 'Either the overscan section or the header keyword where the valid data sections can be obtained, one per amplifier. If defined explicitly should be in FITS format (e.g., [1:2048,10:4096]).', 'otype': <class 'numpy.ndarray'>}, 'platescale': {'descr': 'arcsec per pixel in the spatial dimension for an unbinned pixel', 'otype': (<class 'int'>, <class 'float'>)}, 'ronoise': {'atype': <class 'numpy.floating'>, 'descr': 'Read-out noise (e-). A list should be provided if a detector contains more than one amplifier. If any element of this list is <=0, the readout noise will be determined from the overscan regions defined by oscansec.', 'otype': <class 'numpy.ndarray'>}, 'saturation': {'descr': 'The detector saturation level in ADU/DN', 'otype': (<class 'int'>, <class 'float'>)}, 'spatflip': {'descr': 'If this is True then the spatial dimension will be flipped.  PypeIt expects echelle orders to increase with increasing pixel number.  I.e., setting spatflip=True can reorder images so that blue orders appear on the left and red orders on the right.', 'otype': <class 'bool'>}, 'specaxis': {'descr': 'Spectra are dispersed along this axis. Allowed values are 0 (first dimension for a numpy array shape) or 1 (second dimension for numpy array shape).', 'otype': <class 'int'>}, 'specflip': {'descr': 'If this is True then the dispersion dimension (specified by the specaxis) will be flipped.  PypeIt expects wavelengths to increase with increasing pixel number.  If this is not the case for this instrument, set specflip to True.', 'otype': <class 'bool'>}, 'xgap': {'descr': 'Gap between the square detector pixels (expressed as a fraction of the x pixel size -- x is predominantly the spatial axis)', 'otype': (<class 'int'>, <class 'float'>)}, 'ygap': {'descr': 'Gap between the square detector pixels (expressed as a fraction of the y pixel size -- y is predominantly the spectral axis)', 'otype': (<class 'int'>, <class 'float'>)}, 'ysize': {'descr': 'The size of a pixel in the y-direction as a multiple of the x pixel size (i.e. xsize = 1.0 -- x is predominantly the dispersion axis)', 'otype': (<class 'int'>, <class 'float'>)}}

Provides the class data model. This is undefined in the abstract class and should be overwritten in the derived classes.

The format of the datamodel needed for each implementation of a DataContainer derived class is as follows.

The datamodel itself is a class attribute (i.e., it is a member of the class, not just of an instance of the class). The datamodel is a dictionary of dictionaries: Each key of the datamodel dictionary provides the name of a given datamodel element, and the associated item (dictionary) for the datamodel element provides the type and description information for that datamodel element. For each datamodel element, the dictionary item must provide:

  • otype: This is the type of the object for this datamodel item. E.g., for a float or a numpy.ndarray, you would set otype=float and otype=np.ndarray, respectively.

  • descr: This provides a text description of the datamodel element. This is used to construct the datamodel tables in the pypeit documentation.

If the object type is a numpy.ndarray, you should also provide the atype keyword that sets the type of the data contained within the array. E.g., for a floating point array containing an image, your datamodel could be simply:

datamodel = {'image' : dict(otype=np.ndarray, atype=float, descr='My image')}

More advanced examples are given in the top-level module documentation.

Currently, datamodel components are restricted to have otype that are tuple, int, float, numpy.integer, numpy.floating, numpy.ndarray, or astropy.table.Table objects. E.g., datamodel values for otype cannot be dict.

static get_det_str(det)[source]

Return a string identifier for the detector. Currently a zero-padded two character string with the detector number.

Parameters:

det (int) – 1- indexed detector number.

Returns:

String representation of the detector number used in constructing the detector name.

Return type:

str

static get_name(det)[source]

Return a string identifier for the detector. Currently, e.g., DET01 for det=1.

Parameters:

det (int) – 1- indexed detector number.

Returns:

Detector name.

Return type:

str

property name

Return a string identifier for the detector. This is a simple wrapper for get_name() using det.

name_prefix = 'DET'

Prefix for the name of the detector.

nonlinear_counts(datasec_img=None, apply_gain=True)[source]

Return the ADU/DN or counts at which the detector response becomes non-linear.

Parameters:
  • datasec_img (numpy.ndarray, optional) – An image identifying the amplifier used to read each pixel in the detector data section. If provided, the returned object is an image giving the non-linear counts for each pixel.

  • apply_gain (bool, optional) – Apply gain in the calculation. I.e., convert the value to counts. If only a float is returned, (i.e. datasec_img is not provided), the mean of the gains for all amplifiers is used.

Returns:

Counts at which the detector response becomes nonlinear. If datasec_img is provided, an image of the same shape is returned with the pixel-specific nonlinear-count threshold.

Return type:

float, numpy.ndarray

one_row_table = True

Force the full datamodel to be encapsulated into an astropy.table.Table with a single row when written to disk. Beware that this requires that this is possible! See, e.g., DetectorContainer.

static parse_name(name)[source]

Parse the string identifier of the detector into its integer index.

Parameters:

name (str) – Detector name. Assumed to have been created by get_name().

Returns:

The parsed detector number. For example, returns 2 when the name is DET02.

Return type:

int

version = '1.0.1'

Provides the string representation of the class version.

This is currently put to minimal use so far, but will used for I/O verification in the future.

Each derived class should provide a version to guard against data model changes during development.