pypeit.specobjs module

Module for the SpecObjs and SpecObj classes

class pypeit.specobjs.SpecObjs(specobjs=None, header=None)[source]

Bases: object

Object to hold a set of SpecObj objects

Note that this class overloads:

  • __getitem__ to allow one to pull an attribute or a portion of the SpecObjs list

  • __setattr__ to force a custom assignment method

  • __getattr__ to generate an array of attribute ‘k’ from the specobjs.

Parameters:
summary

Summary table (?)

Type:

astropy.table.Table

__getattr__(attr)[source]

Overloaded to generate an array of attribute ‘k’ from the pypeit.specobj.SpecObj objects.

First attempts to grab data from the Summary table, then the list

__getitem__(item)[source]

Overload to allow one to pull an attribute or a portion of the SpecObjs list

Parameters:

item (str, int, slice) –

Returns:

The selected items as either an object, pypeit.specobj.SpecObj, or pypeit.specobjs.SpecObjs, depending on the input item.

__setattr__(item, value)[source]

Define a custom assignment method.

Parameters:
  • item (str) – Item to set

  • value (object) – Value of the item

add_sobj(sobj)[source]

Append one or more SpecObj to the existing set.

Parameters:

sobj (SpecObj, SpecObjs, list, numpy.ndarray) – One or more SpecObj objects to append. If a list or array, the elements of these must be instances of SpecObj.

append_neg(sobjs_neg)[source]

Append negative objects and change the sign of their objids for IR reductions

Parameters:

sobjs_neg (SpecObjs) –

apply_flux_calib(par, spectrograph, sens)[source]

Flux calibrate the object spectra (sobjs) using the provided sensitivity function (sens).

Parameters:
  • par (FluxCalibratePar) – Parset object containing parameters governing the flux calibration.

  • spectrograph (Spectrograph) – PypeIt Spectrograph class

  • sens (SensFunc) – PypeIt Sensitivity function class

copy()[source]

Generate a copy of self

Return type:

SpecObjs

classmethod from_fitsfile(fits_file, det=None, chk_version=True)[source]

Instantiate from a spec1d FITS file

Also tag on the Header

Parameters:
  • fits_file (str) – The name of the fits file to read.

  • det (str, optional) – The string identifier for a detector or mosaic used to select the loaded spectra. If None, all spectra are loaded.

  • chk_version (bool, optional) – If False, allow a mismatch in datamodel to proceed

Returns:

The loaded spectra from the provided fits file.

Return type:

SpecObjs

get_extraction_groups(model_full_slit=False) List[List[int]][source]
Returns:

A list of extraction groups, each of which is a list of integer

object indices that should be extracted together by core.skysub.local_skysub_extract

Return type:

List[List[int]]

get_std(multi_spec_det=None)[source]

Return the standard star from this SpecObjs. For MultiSlit this will be a single specobj in SpecObjs container, for Echelle it will be the standard for all the orders.

Parameters:

multi_spec_det (list) – If there are multiple detectors arranged in the spectral direction, return the sobjs for the standard on each detector.

Returns:

SpecObj or SpecObjs or None

make_neg_pos()[source]

Purge negative objects from specobjs for IR reductions

name_indices(name)[source]

Return the set of indices matching the input slit/order

Parameters:

name (str) – The name of the object

Returns:

Array of indices with the corresponding name. Shape is (nobj,).

Return type:

numpy.ndarray

property nobj

Return the number of SpecObj objects

Returns:

int

purge_neg()[source]

Purge negative objects from specobjs for IR reductions

ready_for_fluxing()[source]
remove_sobj(index)[source]

Remove one or more SpecObj by index

Parameters:

index (int, numpy.ndarray) –

set_names()[source]

Simple method to (re)set the names of all the SpecObj

property shape
property size
slitorder_indices(slitorder)[source]

Return the set of indices matching the input slit/order

Parameters:

slitorder (int) –

Return type:

int

slitorder_objid_indices(slitorder, objid, toler=5)[source]

Return the set of indices matching the input slit/order and the input objid

Parameters:
  • slitorder (int) – Order/Spatial pixel value for slit of interest.

  • objid (int) – ID value for object of interest.

  • toler (int, optional) – Tolerance for slit spatial pixel values used for slit identification. Default = 5

Returns:

Index value for input slit/order and object ID values for specobjs object.

Return type:

int

unpack_object(ret_flam=False, extract_type='OPT')[source]

Utility function to unpack the sobjs for one object and return various numpy arrays describing the spectrum and meta data. The user needs to already have trimmed the SpecObjs to the relevant indices for the object.

Parameters:

ret_flam (bool, optional) – If True return the FLAM, otherwise return COUNTS.

Returns:

Returns the following where all numpy arrays returned have shape (nspec, norders) for Echelle data and (nspec,) for Multislit data.

  • wave (numpy.ndarray): Wavelength grids

  • flux (numpy.ndarray): Flambda or counts

  • flux_ivar (numpy.ndarray): Inverse variance (of Flambda or counts)

  • flux_gpm (numpy.ndarray): Good pixel mask. True=Good

  • meta_spec (dict:) Dictionary containing meta data. The keys are defined by spectrograph.parse_spec_header()

  • header (astropy.io.header object): header from spec1d file

Return type:

tuple

version = '1.0.0'
write_info(outfile, pypeline)[source]

Write a summary of items to an ASCII file

Parameters:
  • outfile (str) – Output filename

  • pypeline (str) – PypeIt pipeline mode

write_to_fits(subheader, outfile, overwrite=True, update_det=None, slitspatnum=None, history=None, debug=False)[source]

Write the set of SpecObj objects to one multi-extension FITS file

Parameters:
  • subheader (dict) –

  • outfile (str) –

  • overwrite (bool, optional) –

  • slitspatnum (str or list, optional) – Restricted set of slits for reduction. If provided, do not clobber the existing file but only update the indicated slits. Useful for re-running on a subset of slits

  • update_det (int or list, optional) – If provided, do not clobber the existing file but only update the indicated detectors. Useful for re-running on a subset of detectors

pypeit.specobjs.get_std_trace(detname, std_outfile, chk_version=True)[source]

Returns the trace of the standard.

Parameters:
  • det (int, tuple) – 1-indexed detector(s) to process.

  • std_outfile (str) – Filename with the standard star spec1d file. Can be None.

Returns:

Trace of the standard star on input detector. Will be None if std_outfile is None, or if the selected detector/mosaic is not available in the provided spec1d file.

Return type:

numpy.ndarray

pypeit.specobjs.lst_to_array(lst, mask=None)[source]

Simple method to convert a list to an array

Allows for a list of Quantity objects

Parameters:
  • lst – list Should be number or Quantities

  • mask (numpy.ndarray, optional) – Boolean array used to limit to a subset of the list. True=good

Returns:

Converted list

Return type:

numpy.ndarray, astropy.units.Quantity