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
objectsNote 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
specobjs (numpy.ndarray, list, optional) – One or more
SpecObj
objects
- summary
- 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
- Returns
The selected items as either an object,
pypeit.specobj.SpecObj
, orpypeit.specobjs.SpecObjs
, depending on the input 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 ofSpecObj
.
- append_neg(sobjs_neg)[source]
Append negative objects and change the sign of their objids for IR reductions
- Parameters
sobjs_neg (SpecObjs) –
- classmethod from_fitsfile(fits_file, det=None, chk_version=True)[source]
Instantiate from a spec1d FITS file
Also tag on the Header
- Parameters
- Returns
The loaded spectra from the provided fits file.
- Return type
- 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
- 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
- property nobj
Return the number of SpecObj objects
- Returns
int
- remove_sobj(index)[source]
Remove one or more SpecObj by index
- Parameters
index (int, numpy.ndarray) –
- property shape
- property size
- slitorder_objid_indices(slitorder, objid, toler=5)[source]
Return the set of indices matching the input slit/order and the input objid
- Parameters
- Returns
Index value for input slit/order and object ID values for specobjs object.
- Return type
- 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
- version = '1.0.0'
- 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
orlist
, 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 slitsupdate_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
- 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
- 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 (ndarray of bool, optional) – Limit to a subset of the list. True=good
- Returns
Converted list
- Return type
ndarray or Quantity array