pypeit.spectrographs.spectrograph module

Defines the abstract Spectrograph class, which is the parent class for all instruments served by PypeIt.

The key functionality of this base class and its derived classes are to provide instrument-specific:

  • file I/O routines

  • detector properties (see DetectorContainer)

  • telescope properties (see TelescopePar)

  • fits header keywords that are collated and injested into a metadata table that it uses throughout the reduction (see PypeItMetaData)

  • header keyword values to check to confirm a fits file has been taken with the selected instrument

  • default methods for automatically determining the type of each exposure that PypeIt was asked to reduce

  • header keywords to use when matching calibration frames to science frames

  • methods used to generate and/or read bad-pixel masks for an exposure

  • default parameters for the reduction algorithms

  • methods to access an archival sky spectrum

class pypeit.spectrographs.spectrograph.Spectrograph[source]

Bases: object

Abstract base class for all instrument-specific behavior in PypeIt.

dispname

Name of the dispersing element.

Type:

str

rawdatasec_img

An image identifying the amplifier that reads each detector pixel.

Type:

numpy.ndarray

oscansec_img

An image identifying the amplifier that reads each detector pixel

Type:

numpy.ndarray

slitmask

Provides slit and object coordinate data for an observation. Not necessarily populated for all spectrograph instantiations.

Type:

SlitMask

primary_hdrext

0-indexed number of the extension in the raw frames with the primary header data.

Type:

int

meta

Instrument-specific metadata model, linking header information to metadata elements required by PypeIt.

Type:

dict

__repr__()[source]

Return a string representation of the instance.

_check_extensions(filename)[source]

Check if this filename has an allowed extension

Parameters:

filename (str, Path) – Input raw fits filename

_check_telescope()[source]

Check the derived class has properly defined the telescope.

allowed_extensions = None

Defines the allowed extensions for the input fits files.

property allowed_mosaics

The list of allowed detector mosaics.

For instruments with no allowed detector mosaics, this must be returned as an empty list.

bpm(filename, det, shape=None, msbias=None)[source]

Generate a default bad-pixel mask.

Parameters:
  • filename (str) – An example file to use to get the image shape. Can be None.

  • det (int, tuple) – 1-indexed detector(s) to read. An image mosaic is selected using a tuple with the detectors in the mosaic, which must be one of the allowed mosaics returned by allowed_mosaics().

  • shape (tuple, optional) – Processed image shape. If filename is None, this must be provided; otherwise, this is ignored.

  • msbias (PypeItImage, optional) – Processed bias frame. If provided, it is used by bpm_frombias() to identify bad pixels.

Returns:

An integer array with a masked value set to 1 and an unmasked value set to 0.

Return type:

numpy.ndarray

bpm_frombias(msbias, bpm_img, thresh=10.0)[source]

Generate a bad-pixel mask from a processed bias frame.

Parameters:
  • msbias (PypeItImage) – Processed bias frame used to identify bad pixels.

  • bpm_img (numpy.ndarray) – Zeroth-order bad pixel mask; i.e., generated using empty_bpm(). Must be the same shape as msbias.

  • thresh (float, optional) – The sigma threshold used to identify bad pixels.

Returns:

An integer array with a masked value set to 1 and an unmasked value set to 0. The shape of the returned image is the same as the provided msbias and bpm_img images.

Return type:

numpy.ndarray

calc_pattern_freq(frame, rawdatasec_img, oscansec_img, hdu)[source]

Calculate the pattern frequency using the overscan region that covers the overscan and data sections. Using a larger range allows the frequency to be pinned down with high accuracy.

Parameters:
  • frame (numpy.ndarray) – Raw data frame to be used to estimate the pattern frequency.

  • rawdatasec_img (numpy.ndarray) – Array the same shape as frame, used as a mask to identify the data pixels (0 is no data, non-zero values indicate the amplifier number).

  • oscansec_img (numpy.ndarray) – Array the same shape as frame, used as a mask to identify the overscan pixels (0 is no data, non-zero values indicate the amplifier number).

  • hdu (astropy.io.fits.HDUList) – Opened fits file.

Returns:

patt_freqs – List of pattern frequencies.

Return type:

list

camera = None

Name of the spectrograph camera or arm. This is used by specdb, so use that naming convention

check_disperser()[source]

Ensure that the disperser is defined.

check_frame_type(ftype, fitstbl, exprng=None)[source]

Check for frames of the provided type.

Parameters:
Returns:

Boolean array with the flags selecting the exposures in fitstbl that are ftype type frames.

Return type:

numpy.ndarray

Raises:

NotImplementedError – Raised by the base class to denote that any derived class has not been properly defined.

check_spectrograph(filename)[source]

Check that the selected spectrograph is the correct one for the input data. NOTE: Not defined for all the spectrographs.

Parameters:

filename (str) – File to use when determining if the input spectrograph is the correct one.

comment = None

A brief comment or description regarding PypeIt usage with this spectrograph.

compound_meta(headarr, meta_key)[source]

Methods to generate metadata requiring interpretation of the header data, instead of simply reading the value of a header card.

Method is undefined in this base class.

Parameters:
Returns:

Metadata value read from the header(s).

Return type:

object

config_independent_frames()[source]

Define frame types that are independent of the fully defined instrument configuration.

This method returns a dictionary where the keys of the dictionary are the list of configuration-independent frame types. The value of each dictionary element can be set to one or more metadata keys that can be used to assign each frame type to a given configuration group. See set_configurations() and how it interprets the dictionary values, which can be None.

Returns:

Dictionary where the keys are the frame types that are configuration-independent and the values are the metadata keywords that can be used to assign the frames to a configuration group.

Return type:

dict

config_specific_par(scifile, inp_par=None)[source]

Modify the PypeIt parameters to hard-wired values used for specific instrument configurations.

Parameters:
  • scifile (str) – File to use when determining the configuration and how to adjust the input parameters.

  • inp_par (ParSet, optional) – Parameter set used for the full run of PypeIt. If None, use default_pypeit_par().

Returns:

The PypeIt parameter set adjusted for configuration specific parameter values.

Return type:

ParSet

configuration_keys()[source]

Return the metadata keys that define a unique instrument configuration.

This list is used by PypeItMetaData to identify the unique configurations among the list of frames read for a given reduction.

Returns:

List of keywords of data pulled from file headers and used to construct the PypeItMetaData object.

Return type:

list

property default_mosaic

Return the default detector mosaic.

For instruments with no allowed detector mosaics, this must be returned as None.

classmethod default_pypeit_par()[source]

Return the default parameters to use for this instrument.

Returns:

Parameters required by all of PypeIt methods.

Return type:

PypeItPar

property dloglam

Return the logarithmic step in wavelength for output spectra.

ech_fixed_format = None

If an echelle spectrograph, this will be set to a boolean indicating whether it is a fixed format or tiltable echelle.

empty_bpm(filename, det, shape=None)[source]

Generate a generic (empty) bad-pixel mask.

Even though they are both optional, either the precise shape for the image (shape) or an example file that can be read to get the shape (filename) must be provided. In the latter, the file is read, trimmed, and re-oriented to get the output shape. If both shape and filename are provided, shape is ignored.

This is the generic function provided in the base class meaning that all pixels are returned as being valid/unmasked.

Parameters:
  • filename (str) – An example file to use to get the image shape. Can be None, but shape must be provided, if so. Note the overhead of this function is large if you filename. You’re better off providing shape, if you know it.

  • det (int) – 1-indexed detector number to use when getting the image shape from the example file.

  • shape (tuple, optional) – Processed image shape. I.e., if the image for this instrument is re-oriented, trimmed, etc, this shape must be that of the re-oriented (trimmed, etc) image. This is required if filename is None, but ignored otherwise.

Returns:

An integer array with a masked value set to 1 and an unmasked value set to 0. The shape of the returned image should be that of a trimmed and oriented PypeIt processed image. This function specifically is the generic method for the base class, meaning that all pixels are returned as unmasked (0s).

Return type:

numpy.ndarray

fit_2d_det_response(det_resp, gpmask)[source]

Perform a 2D model fit to the instrument-specific detector response.

Parameters:
  • det_resp (numpy.ndarray) – An image of the detector response.

  • gpmask (numpy.ndarray) – Good pixel mask (True=good), the same shape as ff_struct.

Returns:

A model fit to the detector response.

Return type:

numpy.ndarray

get_comb_group(fitstbl)[source]

Automatically assign combination groups and background images by parsing known dither patterns.

This method is used in set_combination_groups(), and directly modifies the comb_id and bkg_id columns in the provided table.

This method is not defined for all spectrographs. This base-class implementation simply returns the input table.

Parameters:

fitstbl (astropy.table.Table) – The table with the metadata for all the frames.

Returns:

modified fitstbl.

Return type:

astropy.table.Table

get_datacube_bins(slitlength, minmax, num_wave)[source]

Calculate the bin edges to be used when making a datacube.

Parameters:
  • slitlength (int) – Length of the slit in pixels

  • minmax (numpy.ndarray) – An array with the minimum and maximum pixel locations on each slit relative to the reference location (usually the centre of the slit). Shape must be \((N_{\rm slits},2)\), and is typically the array returned by get_radec_image().

  • num_wave (int) –

    Number of wavelength steps. Given by::

    int(round((wavemax-wavemin)/delta_wave))

Returns:

Three 1D numpy.ndarray providing the bins to use when constructing a histogram of the spec2d files. The elements are \((x,y,\lambda)\).

Return type:

tuple

get_det_id(det)[source]

Return an identifying index for the detector or mosaic.

Parameters:

det (int, tuple) – The 1-indexed detector number(s). If a tuple, it must include detectors designated as a viable mosaic for spectrograph; see allowed_mosaics().

Returns:

Unique index for the detector or mosaic.

Return type:

int

get_det_name(det)[source]

Return a name for the detector or mosaic.

This is a simple wrapper for pypeit.images.detector_container.DetectorContainer.get_name() or pypeit.images.mosaic.Mosaic.get_name(), depending on the type of det.

Parameters:

det (int, tuple) – The 1-indexed detector number(s). If a tuple, it must include detectors designated as a viable mosaic for spectrograph; see allowed_mosaics().

Returns:

Name for the detector or mosaic.

Return type:

str

get_detector_par(det, hdu=None)[source]

Read/Set the detector metadata.

This method is needed by some instruments that require the detector metadata to be interpreted from the output files. This method is undefined in the base class.

get_echelle_angle_files()[source]

Pass back the files required to run the echelle method of wavecalib

Returns:

List of files

Return type:

list

get_headarr(inp, strict=True)[source]

Read the header data from all the extensions in the file.

Parameters:
  • inp (str, Path, astropy.io.fits.HDUList) – Name of the file to read or the previously opened HDU list. If None, the function will simply return None.

  • strict (bool, optional) – Function will fault if fits.getheader() fails to read any of the headers. Set to False to report a warning and continue.

Returns:

A list of astropy.io.fits.Header objects with the extension headers. If strict is False and inp is a file name to be opened, the function will return None if fits_open() faults for any reason.

Return type:

list

get_lamps(fitstbl)[source]

Extract the list of arc lamps used from header.

This method is not defined for all spectrographs. This base-class method raises an exception.

get_lamps_status(headarr)[source]

Return a string containing the information on the lamp status.

Parameters:

headarr (list) – A list of 1 or more astropy.io.fits.Header objects.

Returns:

A string that uniquely represents the lamp status.

Return type:

str

get_maskdef_slitedges(ccdnum=None, filename=None, debug=None, binning: str | None = None, trc_path: str | None = None)[source]

Provides the slit edges positions predicted by the slitmask design.

This method is not defined for all spectrographs. This base-class method raises an exception. This may be because use_maskdesign has been set to True for a spectrograph that does not support it.

Parameters:
  • trc_path (str, optional) – Path to the first trace file used to generate the trace flat

  • binning (str, optional) – spec,spat binning of the flat field image

  • filename (str or list, optional) – Name of the file holding the mask design info or the maskfile and wcs_file in that order

  • debug (bool, optional) – Debug

  • ccdnum (int, optional) – detector number

get_meta_value(inp, meta_key, required=False, ignore_bad_header=False, usr_row=None, no_fussing=False)[source]

Return meta data from a given file (or its array of headers).

Parameters:
  • inp (str, Path, astropy.io.fits.Header, list) – Input filename, an astropy.io.fits.Header object, or a list of astropy.io.fits.Header objects. If None, function simply returns None without issuing any warnings/errors, unless required is True.

  • meta_key (str, list) – A (list of) string(s) with the keywords to read from the file header(s).

  • required (bool, optional) – The metadata are required and must be available. If it is not, the method will raise an exception. Metadata requirements can be globally defined and/or frame-type specific for each spectrograph, which will override any value given here. See the required and required_ftype keyword in self.meta[meta_key].

  • ignore_bad_header (bool, optional) – PypeIt expects certain metadata values to have specific datatypes. If the keyword finds the appropriate data but it cannot be cast to the correct datatype, this parameter determines whether or not the method raises an exception. If True, the incorrect type is ignored. It is recommended that this be False unless you know for sure that PypeIt can proceed appropriately. This flag takes precedence over required; i.e., if ignore_bad_header is True, required is ignored.

  • usr_row (astropy.table.Table, optional) – A single row table with the user-supplied frametype. This is used to determine if the metadata value is required for each frametype. Must contain a columns called frametype; everything else is ignored.

  • no_fussing (bool, optional) – No type checking or anything. Just pass back the first value retrieved. This is mainly for bound pairs of meta, e.g. ra/dec.

Returns:

Value recovered for (each) keyword. Can be None.

get_mosaic_par()[source]

Return the hard-coded parameters needed to construct detector mosaics.

get_rawimage(raw_file, det)[source]

Read raw images and generate a few other bits and pieces that are key for image processing.

Warning

  • When reading multiple detectors for a mosaic, this function expects all detector arrays to have exactly the same shape.

Parameters:
  • raw_file (str, Path) – File to read

  • det (int, tuple) – 1-indexed detector(s) to read. An image mosaic is selected using a tuple with the detectors in the mosaic, which must be one of the allowed mosaics returned by allowed_mosaics().

Returns:

  • detector_par (DetectorContainer, Mosaic) – Detector metadata parameters for one or more detectors.

  • raw_img (numpy.ndarray) – Raw image for this detector. Shape is 2D if a single detector image is read and 3D if multiple detectors are read. E.g., the image from the first detector in the tuple is accessed using raw_img[0].

  • hdu (astropy.io.fits.HDUList) – Opened fits file

  • exptime (float) – Exposure time in seconds.

  • rawdatasec_img (numpy.ndarray) – Data (Science) section of the detector as provided by setting the (1-indexed) number of the amplifier used to read each detector pixel. Pixels unassociated with any amplifier are set to 0. Shape is identical to raw_img.

  • oscansec_img (numpy.ndarray) – Overscan section of the detector as provided by setting the (1-indexed) number of the amplifier used to read each detector pixel. Pixels unassociated with any amplifier are set to 0. Shape is identical to raw_img.

get_slitmask(filename)[source]

Empty for base class. See derived classes.

get_wcs(hdr, slits, platescale, wave0, dwv, spatial_scale=None)[source]

Construct/Read a World-Coordinate System for a frame.

This is undefined in the base class.

Parameters:
  • hdr (astropy.io.fits.Header) – The header of the raw frame. The information in this header will be extracted and returned as a WCS.

  • slits (SlitTraceSet) – Slit traces.

  • platescale (float) – The platescale of an unbinned pixel in arcsec/pixel (e.g. detector.platescale).

  • wave0 (float) – The wavelength zeropoint.

  • dwv (float) – Change in wavelength per spectral pixel.

  • spatial_scale (float, None, optional) – The spatial scale (units=arcsec/pixel) of the WCS to be used. This variable is fixed, and is independent of the binning. If spatial_scale is set, it will be used for the spatial size of the WCS and the platescale will be ignored. If None, then the platescale will be used.

Returns:

The world-coordinate system.

Return type:

astropy.wcs.WCS

header_name = None

Name of the spectrograph camera or arm from the Header. Usually the INSTRUME card.

idname(ftype)[source]

Return the idname for the selected frame type for this instrument.

Parameters:

ftype (str) – Frame type, which should be one of the keys in FrameTypeBitMask.

Returns:

The value of idname that should be available in the PypeItMetaData instance that identifies frames of this type.

Return type:

str

Raises:

NotImplementedError – Raised by the base class to denote that any derived class has not been properly defined.

init_meta()[source]

Define how metadata are derived from the spectrograph files.

That is, this associates the PypeIt-specific metadata keywords with the instrument-specific header cards using meta.

list_detectors(mosaic=False)[source]

List the names of the detectors in this spectrograph.

This is primarily used average_maskdef_offset() to measure the mean offset between the measured and expected slit locations.

Detectors separated along the dispersion direction should be ordered along the first axis of the returned array. For example, Keck/DEIMOS returns:

dets = np.array([['DET01', 'DET02', 'DET03', 'DET04'],
                 ['DET05', 'DET06', 'DET07', 'DET08']])

such that all the bluest detectors are in dets[0], and the slits found in detectors 1 and 5 are just from the blue and red counterparts of the same slit.

Parameters:

mosaic (bool, optional) – Is this a mosaic reduction? It is used to determine how to list the detector, i.e., ‘DET’ or ‘MSC’.

Returns:

The list of detectors in a numpy.ndarray. If the array is 2D, there are detectors separated along the dispersion axis.

Return type:

numpy.ndarray

property loglam_minmax

Return the base-10 logarithm of the first and last wavelength for ouput spectra.

mask_to_pixel_coordinates(x=None, y=None, wave=None, order=1, filename=None, corners=False)[source]

Predict detector pixel coordinates for a given set of slit-mask coordinates.

This method is not defined for all spectrographs. This base-class method raises an exception. This may be because use_maskdesign has been set to True for a spectrograph that does not support it.

meta_data_model = {'airmass': {'comment': 'Airmass', 'dtype': <class 'float'>}, 'amp': {'comment': 'Amplifier used', 'dtype': <class 'str'>}, 'arm': {'comment': 'Name of arm (e.g. NIR for X-Shooter)', 'dtype': <class 'str'>}, 'binning': {'comment': '"spectral,spatial" binning', 'dtype': <class 'str'>}, 'calpos': {'comment': 'Position of calibration system (KCWI)', 'dtype': <class 'str'>}, 'cenwave': {'comment': 'Central wavelength of the disperser', 'dtype': <class 'float'>, 'rtol': 0.0}, 'datasec': {'comment': 'Data section (windowing)', 'dtype': <class 'str'>}, 'dateobs': {'comment': 'Observation date', 'dtype': <class 'str'>}, 'dec': {'comment': '(J2000) DEC in decimal degrees', 'dtype': <class 'float'>}, 'dec_off': {'comment': 'Dither offset in DEC', 'dtype': <class 'float'>}, 'decker': {'comment': 'Slit/mask/decker name', 'dtype': <class 'str'>}, 'decker_secondary': {'comment': 'Partial Slitmask/decker name. It differs from decker. This is currently only needed for the reduction of some MOSFIRE masks, which use calibrations taken with a partially different decker name than the one used for the associated science frames.', 'dtype': <class 'str'>}, 'detector': {'comment': 'Name of detector', 'dtype': <class 'str'>}, 'dichroic': {'comment': 'Beam splitter', 'dtype': <class 'str'>}, 'dispangle': {'comment': 'Angle of the disperser', 'dtype': <class 'float'>, 'rtol': 0.0}, 'dispname': {'comment': 'Disperser name', 'dtype': <class 'str'>}, 'dither': {'comment': 'Dither amount in arcsec', 'dtype': <class 'float'>}, 'dithoff': {'comment': 'Dither offset', 'dtype': <class 'float'>}, 'dithpat': {'comment': 'Dither pattern', 'dtype': <class 'str'>}, 'dithpos': {'comment': 'Dither position', 'dtype': <class 'str'>}, 'echangle': {'comment': 'Echelle angle', 'dtype': <class 'float'>}, 'exptime': {'comment': 'Exposure time (s)', 'dtype': <class 'float'>}, 'filter1': {'comment': 'First filter in optical path', 'dtype': <class 'str'>}, 'frameno': {'comment': 'Frame number provided by instrument software', 'dtype': <class 'str'>}, 'hatch': {'comment': 'Position of instrument hatch', 'dtype': <class 'str'>}, 'humidity': {'comment': 'Humidity at observation time (as a percentage, not a fraction)', 'dtype': <class 'float'>}, 'idname': {'comment': 'Instrument supplied frametype (e.g. bias)', 'dtype': <class 'str'>}, 'instrument': {'comment': 'Header supplied instrument name', 'dtype': <class 'str'>}, 'lampshst01': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst02': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst03': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst04': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst05': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst06': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst07': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst08': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst09': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst10': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst11': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst12': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst13': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst14': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst15': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst16': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst17': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst18': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst19': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampshst20': {'comment': 'Status of a lamp shutter (e.g closed/open)', 'dtype': <class 'str'>}, 'lampstat01': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat02': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat03': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat04': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat05': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat06': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat07': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat08': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat09': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat10': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat11': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat12': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat13': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat14': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat15': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat16': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat17': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat18': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat19': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'lampstat20': {'comment': 'Status of a given lamp (e.g off/on)', 'dtype': <class 'str'>}, 'mirror': {'comment': 'Position of an instrument mirror (e.g. IN or OUT)', 'dtype': <class 'str'>}, 'mjd': {'comment': 'Observation MJD; Read by astropy.time.Time format=mjd', 'dtype': <class 'float'>}, 'mode': {'comment': 'Observing mode', 'dtype': <class 'str'>}, 'object': {'comment': 'Alternative object name (cf. target)', 'dtype': <class 'str'>}, 'obstime': {'comment': 'Observation time', 'dtype': <class 'str'>}, 'oscansec': {'comment': 'Overscan section (windowing)', 'dtype': <class 'str'>}, 'parangle': {'comment': 'Parallactic angle (units.radian)', 'dtype': <class 'float'>}, 'posang': {'comment': 'Position angle of the observation (degrees, positive is East from North)', 'dtype': <class 'float'>}, 'pressure': {'comment': 'Pressure (units.pascal) at observation time', 'dtype': <class 'float'>}, 'ra': {'comment': '(J2000) RA in decimal degrees', 'dtype': <class 'float'>}, 'ra_off': {'comment': 'Dither offset in RA', 'dtype': <class 'float'>}, 'seq_expno': {'comment': 'Number of exposure in observing sequence', 'dtype': <class 'int'>}, 'slitlength': {'comment': 'Slit length, used only for long slits', 'dtype': <class 'float'>}, 'slitwid': {'comment': 'Slit width, sometimes distinct from decker', 'dtype': <class 'float'>}, 'target': {'comment': 'Name of the target', 'dtype': <class 'str'>}, 'temperature': {'comment': 'Temperature (units.K) at observation time', 'dtype': <class 'float'>}, 'utc': {'comment': 'UTC of observation', 'dtype': <class 'str'>}, 'xd': {'comment': 'Cross disperser (e.g. red or blue for HIRES)', 'dtype': <class 'float'>}, 'xdangle': {'comment': 'Cross disperser angle', 'dtype': <class 'float'>}}

Metadata model that is generic to all spectrographs.

meta_key_map()[source]

Print the mapping of the pypeit-specific metadata keywords to the header cards used for this spectrograph.

Note

Metadata keys with header cards that are None have no simple mapping between keyword and header card; their values are set by some combination of header keywords as defined by compound_meta() specific to each spectrograph.

modify_config(row, cfg)[source]

Modify the configuration dictionary for a given frame. This method is used in set_configurations() to modify in place the configuration requirement to assign a specific frame to the current setup.

This method is not defined for all spectrographs.

Parameters:
  • row (astropy.table.Row) – The table row with the metadata for one frame.

  • cfg (dict) – Dictionary with metadata associated to a specific configuration.

Returns:

modified dictionary with metadata associated to a specific configuration.

Return type:

dict

name = None

The name of the spectrograph. See Spectrographs for the currently supported spectrographs.

ndet = None

Number of detectors for this instrument.

property norders

Number of orders for this spectograph. Should only defined for echelle spectrographs, and it is undefined for the base class.

order_platescale(order_vec, binning=None)[source]

Return the platescale for each echelle order.

This routine is only defined for echelle spectrographs, and it is undefined in the base class.

Parameters:
  • order_vec (numpy.ndarray) – The vector providing the order numbers.

  • binning (str, optional) – The string defining the spectral and spatial binning.

Returns:

An array with the platescale for each order provided by order.

Return type:

numpy.ndarray

property order_spat_pos

Return the expected spatial position of each echelle order.

This is for fixed-format echelle spectrographs (e.g. X-Shooter) And is measured 1/2 way up the chip (spectral) and in normalized units (0-1)

Returns:

An array with values. The length of the provided array much match self.norders

Return type:

numpy.ndarray

property orders

Return the order number for each echelle order.

Returns:

An array with values. Order number. Must have lenght of self.norders

Return type:

numpy.ndarray

orient_image(detector_par, rawimage)[source]

Orient the image into the PypeIt configuration: (spectral, spatial).

Parameters:
Returns:

Re-oriented image.

Return type:

numpy.ndarray

parse_spec_header(header)[source]

Parses an input header for key spectrograph items.

Parameters:

header (astropy.io.fits.Header) – Fits header read from a file.

Returns:

Dictionary with the metadata read from header.

Return type:

dict

pypeit_file_keys()[source]

Define the list of keys to be output into a standard PypeIt file.

Returns:

The list of keywords in the relevant PypeItMetaData() instance to print to the PypeIt Reduction File.

Return type:

list

pypeline = 'MultiSlit'

String used to select the general pipeline approach for this spectrograph.

static ql_par()[source]

Return the list of parameters specific to quick-look reduction of science frames for this spectrograph.

The following parameters are set by default for any spectrograph. Derived classes may override this function.

Returns:

Dictionary with a form that matches PypeItPar with the parameters to be set.

Return type:

dict

ql_supported = False

Flag that PypeIt code base has been sufficiently tested with data from this spectrograph in quicklook mode that it is officially supported by the development team.

raw_header_cards()[source]

Return additional raw header cards to be propagated in downstream output files for configuration identification.

The list of raw data FITS keywords should be those used to populate the configuration_keys() or are used in config_specific_par() for a particular spectrograph, if different from the name of the PypeIt metadata keyword.

This list is used by subheader_for_spec() to include additional FITS keywords in downstream output files.

Returns:

List of keywords from the raw data files that should be propagated in output files.

Return type:

list

raw_is_transposed(detector_par)[source]

Check if raw image files are transposed with respect to the PypeIt convention.

Indicates that reading raw files with astropy.io.fits yields an image with the spatial dimension along the first axis of the 2D array. This means that the image must be transposed to match the PypeIt convention of having the spectral dimension along the first axis.

Parameters:

detector_par (DetectorContainer) – Detector-specific metadata.

Returns:

Flag that transpose is required.

Return type:

bool

same_configuration(configs, check_keys=True)[source]

Check if a set of instrument setup/configurations are all the same, within the tolerance set for this spectrograph for each configuration key.

Parameters:
  • configs (dict, array-like) – A list or dictionary of configuration parameters. Each list or dictionary element must be a dictionary with the values for the configuration-defining metadata parameters for this spectrograph.

  • check_keys (bool, optional) – Check that the keys in each configuration match the expected keys defined by configuration_keys(). If False, the keys are set by the first configuration in configs, not those returned by configuration_keys().

Returns:

Flag that all configurations in the list are the same.

Return type:

bool

scattered_light_archive(binning, dispname)[source]

Archival model parameters for the scattered light. These are based on best fits to currently available data.

Parameters:
  • binning (str, optional) – Comma-separated binning along the spectral and spatial directions; e.g., 2,1

  • dispname (str, optional) – Name of the disperser

Returns:

  • x0 (numpy.ndarray) – A 1D array containing the best-fitting model parameters

  • bounds (tuple) – A tuple of two elements, containing two numpy.ndarray of the same length as x0. These two arrays contain the lower (first element of the tuple) and upper (second element of the tuple) bounds to consider on the scattered light model parameters.

select_detectors(subset=None)[source]

Vet and return a set of valid detectors or detector mosaics for this spectrograph.

By default, the method returns a list selecting all the detectors individually. A subset can be selected using one of the following .. method:: - If subset is a string, it is assumed that you’re selecting a

set of detector and spatial pixel coordinate combinations needed to reduce a single slit; see slitspatnum in the PypeItPar Keywords. The string is parsed into the list of relevant detectors.

- If ``subset`` is a list, integer, or tuple, it is parsed into a

set of single detector or detector mosaics to reduce.

Parameters:

subset (int, tuple, list, str, optional) – An object used select a subset of detectors to reduce. See description above. Note detectors are 1-indexed.

Returns:

List of unique detectors or detector mosaics to be reduced.

Return type:

list

Raises:
  • PypeItError – Raised if any of the detectors or detector mosaics

  • specified by subset are invalid.

slit_minmax(slit_spat_pos, binspectral=1)[source]

Adjust the minimum and maximum spectral pixel expected for the spectral range of each echelle order by accounting for the spectral binning.

Parameters:
  • slit_spat_pos (float, numpy.ndarray) – Spatial position of each slit/order normalized by the full spatial extent of the detector.

  • binspectral (int, optional) – Number of pixels binned in the spectral direction.

Returns:

The minimum and maximum (binned) pixel that includes the valid spectra of each slit/order.

Return type:

numpy.ndarray

spec1d_match_spectra(sobjs)[source]

Match up slits in a SpecObjs object.

This typically done across multiple detectors; see pypeit.specrographs.keck_deimos.spec1d_match_spectra().

Parameters:

sobjs (SpecObjs) – Spec1D objects

Returns:

Arrays that provide the indices of slits matched across multiple detectors.

Return type:

tuple

property spec_min_max

Return the minimum and maximum spectral pixel expected for the spectral range of each order.

subheader_for_spec(row_fitstbl, raw_header, extra_header_cards=None, allow_missing=False)[source]

Generate a dict that will be added to the Header of spectra files generated by PypeIt (e.g. SpecObjs).

Parameters:
  • row_fitstbl (dict-like) – Typically an astropy.table.Row or astropy.io.fits.Header with keys defined by define_core_meta().

  • raw_header (astropy.io.fits.Header) – Header that defines the instrument and detector, meaning that the header must contain the INSTRUME and DETECTOR header cards. If provided, this must also contain the header cards provided by extra_header_cards.

  • extra_header_cards (list, optional) – Additional header cards from raw_header to include in the output dictionary. Can be an empty list or None.

  • allow_missing (bool, optional) – Ignore any keywords returned by define_core_meta() are not present in row_fitstbl. Otherwise, raise PypeItError.

Returns:

Dictionary with data to include an output fits header file or table downstream.

Return type:

dict

supported = False

Flag that PypeIt code base has been sufficiently tested with data from this spectrograph that it is officially supported by the development team.

telescope = None

Instance of TelescopePar providing telescope-specific metadata.

tweak_standard(wave_in, counts_in, counts_ivar_in, gpm_in, meta_table, log10_blaze_function=None)[source]

This routine is for performing instrument/disperser specific tweaks to standard stars so that sensitivity function fits will be well behaved. For example, masking second order light. For instruments that don’t require such tweaks it will just return the inputs, but for isntruments that do this function is overloaded with a method that performs the tweaks.

Parameters:
  • wave_in (numpy.ndarray) – Input standard star wavelengths (float, shape = (nspec,))

  • counts_in (numpy.ndarray) – Input standard star counts (float, shape = (nspec,))

  • counts_ivar_in (numpy.ndarray) – Input inverse variance of standard star counts (float, shape = (nspec,))

  • gpm_in (numpy.ndarray) – Input good pixel mask for standard (bool, shape = (nspec,))

  • meta_table (dict) – Table containing meta data that is slupred from the SpecObjs object. See unpack_object() for the contents of this table.

  • log10_blaze_function (numpy.ndarray or None) – Input blaze function to be tweaked, optional. Default=None.

Returns:

  • wave_out (numpy.ndarray) – Output standard star wavelengths (float, shape = (nspec,))

  • counts_out (numpy.ndarray) – Output standard star counts (float, shape = (nspec,))

  • counts_ivar_out (numpy.ndarray) – Output inverse variance of standard star counts (float, shape = (nspec,))

  • gpm_out (numpy.ndarray) – Output good pixel mask for standard (bool, shape = (nspec,))

  • log10_blaze_function_out (numpy.ndarray or None) – Output blaze function after being tweaked.

update_edgetracepar(par)[source]

This method is used in pypeit.edgetrace.EdgeTraceSet.maskdesign_matching() to update EdgeTraceSet parameters when the slitmask design matching is not feasible because too few slits are present in the detector.

This method is not defined for all spectrographs.

Parameters:

par (pypeit.par.pypeitpar.EdgeTracePar) – The parameters used to guide slit tracing.

Returns:

pypeit.par.pypeitpar.EdgeTracePar The modified parameters used to guide slit tracing.

url = None

Reference url

valid_configuration_values()[source]

Return a fixed set of valid values for any/all of the configuration keys.

Method is undefined for the base class.

Returns:

A dictionary with any/all of the configuration keys and their associated discrete set of valid values. If there are no restrictions on configuration values, None is returned.

Return type:

dict

validate_det(det)[source]

Validate the detector(s) provided.

Parameters:

det (int, tuple) – Selection of 1-indexed detector(s). An image mosaic is selected using a tuple with the detectors in the mosaic, which must be one of the allowed mosaics returned by allowed_mosaics().

Returns:

Returns the number of detectors and a tuple with the validated detectors. If det is provided as a single integer, the latter is just a one-element tuple. Otherwise, it is identical to the input det tuple, assuming the validation was successful.

Return type:

tuple

validate_metadata()[source]

Validates the definitions of the Spectrograph metadata by making a series of comparisons to the metadata model defined by pypeit.core.meta.define_core_meta() and meta.