pypeit.multislit_flexure module

Module for flexure routines

class pypeit.multislit_flexure.MultiSlitFlexure(s1dfile=None, PYP_SPEC=None, nslits=None, det=None, SN=None, slitid=None, mn_wv=None, fit_slope=None, fit_b=None, fit_los=None, objra=None, objdec=None, maskdef_id=None, rms_arc=None, resid_sky=None, indiv_fit_slope=None, indiv_fit_b=None, indiv_fit_los=None)[source]

Bases: DataContainer

Class to perform multi-detector flexure analysis.

Based on code written by Marla Geha for DEIMOS.

The datamodel attributes are:

Version: 1.1.0

Attribute

Type

Array Type

Description

PYP_SPEC

str

PypeIt spectrograph name

SN

numpy.ndarray

numpy.floating

S/N (ndet, nslits)

det

numpy.ndarray

int, numpy.integer

Integer identifiers for the detector or mosaic (ndet, nslits)

fit_b

numpy.ndarray

numpy.floating

Fitted b value(nslits)

fit_los

numpy.ndarray

numpy.floating

Fitted line width(nslits)

fit_slope

numpy.ndarray

numpy.floating

Fitted slope (nslits)

indiv_fit_b

numpy.ndarray

numpy.floating

Same as above but for b (nslits)

indiv_fit_los

numpy.ndarray

numpy.floating

Same as above but for line width (nslits)

indiv_fit_slope

numpy.ndarray

numpy.floating

Fits to each slit individually (nslits)

is_msc

numpy.ndarray

int, numpy.integer

Flag that the “det” is the mosaic ID (ndet, nslits)

maskdef_id

numpy.ndarray

numpy.integer

Mask ID (nslits)

mn_wv

numpy.ndarray

numpy.floating

Mininum wavelength of the slit [Ang] (nslits)

ndet

int

Number of detectors per spectrum

nslits

int

Number of slits

objdec

numpy.ndarray

numpy.floating

Object DEC (nslits)

objra

numpy.ndarray

numpy.floating

Object RA (nslits)

resid_sky

numpy.ndarray

numpy.floating

Residuals of flexure model on sky lines (nslits)

rms_arc

numpy.ndarray

numpy.floating

RMS of fit (ndet, nslits)

s1dfile

str

spec1d filename

slitid

numpy.ndarray

numpy.floating

Slit ID (nslits)

_bundle()[source]

Override the base class method simply to set the HDU extension name.

datamodel = {'PYP_SPEC': {'descr': 'PypeIt spectrograph name', 'otype': <class 'str'>}, 'SN': {'atype': <class 'numpy.floating'>, 'descr': 'S/N (ndet, nslits)', 'otype': <class 'numpy.ndarray'>}, 'det': {'atype': (<class 'int'>, <class 'numpy.integer'>), 'descr': 'Integer identifiers for the detector or mosaic (ndet, nslits)', 'otype': <class 'numpy.ndarray'>}, 'fit_b': {'atype': <class 'numpy.floating'>, 'descr': 'Fitted b value(nslits)', 'otype': <class 'numpy.ndarray'>}, 'fit_los': {'atype': <class 'numpy.floating'>, 'descr': 'Fitted line width(nslits)', 'otype': <class 'numpy.ndarray'>}, 'fit_slope': {'atype': <class 'numpy.floating'>, 'descr': 'Fitted slope (nslits)', 'otype': <class 'numpy.ndarray'>}, 'indiv_fit_b': {'atype': <class 'numpy.floating'>, 'descr': 'Same as above but for b (nslits)', 'otype': <class 'numpy.ndarray'>}, 'indiv_fit_los': {'atype': <class 'numpy.floating'>, 'descr': 'Same as above but for line width (nslits)', 'otype': <class 'numpy.ndarray'>}, 'indiv_fit_slope': {'atype': <class 'numpy.floating'>, 'descr': 'Fits to each slit individually (nslits)', 'otype': <class 'numpy.ndarray'>}, 'is_msc': {'atype': (<class 'int'>, <class 'numpy.integer'>), 'descr': 'Flag that the "det" is the mosaic ID (ndet, nslits)', 'otype': <class 'numpy.ndarray'>}, 'maskdef_id': {'atype': <class 'numpy.integer'>, 'descr': 'Mask ID (nslits)', 'otype': <class 'numpy.ndarray'>}, 'mn_wv': {'atype': <class 'numpy.floating'>, 'descr': 'Mininum wavelength of the slit [Ang] (nslits)', 'otype': <class 'numpy.ndarray'>}, 'ndet': {'descr': 'Number of detectors per spectrum', 'otype': <class 'int'>}, 'nslits': {'descr': 'Number of slits', 'otype': <class 'int'>}, 'objdec': {'atype': <class 'numpy.floating'>, 'descr': 'Object DEC (nslits)', 'otype': <class 'numpy.ndarray'>}, 'objra': {'atype': <class 'numpy.floating'>, 'descr': 'Object RA (nslits)', 'otype': <class 'numpy.ndarray'>}, 'resid_sky': {'atype': <class 'numpy.floating'>, 'descr': 'Residuals of flexure model on sky lines (nslits)', 'otype': <class 'numpy.ndarray'>}, 'rms_arc': {'atype': <class 'numpy.floating'>, 'descr': 'RMS of fit (ndet, nslits)', 'otype': <class 'numpy.ndarray'>}, 's1dfile': {'descr': 'spec1d filename', 'otype': <class 'str'>}, 'slitid': {'atype': <class 'numpy.floating'>, 'descr': 'Slit ID (nslits)', 'otype': <class 'numpy.ndarray'>}}

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.

fit_mask_surfaces()[source]

Fit 2D model to linear flexure models from each slit as a function of RA, DEC.

init(spectrograph, par)[source]

Initialize this and that about the slits, par, spectrograph e.g. RA, DEC, S/N

Parameters:
internals = ['flex_par', 'spectrograph', 'specobjs', 'sobj_idx', 'sky_table', 'pmodel_m', 'pmodel_b', 'pmodel_l']

A list of strings identifying a set of internal attributes that are not part of the datamodel.

measure_sky_lines()[source]

Main method to analyze the sky lines for all the slits

qa_plots(plot_dir, root)[source]

Generate QA plots

Parameters:
  • plot_dir (str) – Top-lvel folder for QA QA/ is generated beneath this, as needed

  • root (str) – Root for output files

update_fit()[source]

Update fits for each slit based on 2D model

version = '1.1.0'

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.

pypeit.multislit_flexure.sky_em_residuals(wave, flux, ivar, sky_waves, plot=False, noff=5.0, nfit_min=20)[source]

Calculate residuals and other metrics for a set of input sky emission lines.

Parameters:
  • wave (numpy.ndarray) – Wavelengths (in air!)

  • flux (numpy.ndarray) – Fluxes

  • ivar (numpy.ndarray) – Inverse variance

  • sky_waves (numpy.ndarray) – Skyline wavelengths (in air!)

  • plot (bool, optional) – If true, plot the residuals

  • noff (int, optional) – Range in Ang to analyze labout emission line. Defaults to 5.

  • nfit_min (int, optional) – Minimum number of pixels required to do a fit. Defaults to 20.

Returns:

tuple of numpy.ndarray – sky line wavelength of good lines, wavelength offset,

error in wavelength offset, sky line width, error in sky line width