pypeit.specobjs module
Module for the SpecObjs and SpecObj classes
- class pypeit.specobjs.SpecObjs(specobjs=None, header=None)[source]
Bases:
objectObject to hold a set of
SpecObjobjectsNote 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 moreSpecObjobjectsheader (
Header, optional) – Baseline header to use
- __getattr__(attr)[source]
Overloaded to generate an array of attribute ‘k’ from the
pypeit.specobj.SpecObjobjects.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)
- apply_flux_calib(par, spectrograph, sens, tell=False)[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 classsens (
SensFunc) – PypeIt Sensitivity function classtell (
bool, optional) – If True, apply telluric correction as well. The telluric model comes from the sensitivity function. This is generally only used for std fluxed QA plots.
- flexure_diagnostics()[source]
Print and return the spectral flexure of a spec1d file.
- Returns:
Table with the spectral flexure.
- Return type:
- 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_std(multi_spec_det=None, split_mosaic=False)[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.
split_mosaic (
bool, optional) – If True and the data were reduced as a mosaic, break up the standard star specobj into the different detectors. This is helpful for fluxing when the detectors have different QE. Only applies to MultiSlit data. Default is False.
- 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_uniq_id_indices(uniq_id, order=None)[source]
Return the set of indices matching the unique object identifier. For MultiSlit this is the SPAT_PIXPOS_ID, for Echelle it is the ECH_FRACPOS_ID but the order must also be specified.
- Parameters:
- Returns:
Array of indices with the corresponding object ID. Shape is (nobj,).
- Return type:
- unpack_object(ret_flam=False, log10blaze=False, min_blaze_value=0.001, extract_type='OPT', extract_blaze=False, remove_missing=False)[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
SpecObjsto the relevant indices for the object.- Parameters:
ret_flam (
bool, optional) – If True return the FLAM, otherwise return COUNTS.log10blaze (
bool, optional) – If True return the log10 of the blaze function.min_blaze_value (
float, optional) – Minimum value of the blaze function to consider as good.extract_type (
str, optional) – Extraction type to use. Default is ‘OPT’.extract_blaze (
bool, optional) – If True, extract the blaze function. Default is False.remove_missing (
bool, optional) – If True, remove any missing data (i.e. where the flux is None). Default is False.
- 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
blaze (numpy.ndarray, None): Blaze function
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) – Dictionary with header keywords and values to be added to the primary header of the output file.outfile (str) – Name of the output file
overwrite (bool, optional) – Overwrite the output file if it exists?
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
slitspatnum (
strorlist, 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 slitshistory (
str, optional) – String to be added to the header HISTORY keyword.debug (
bool, optional) – If True, run in debug mode.
- pypeit.specobjs.get_std_trace(detname, std_outfile, chk_version=True)[source]
Returns the trace of the standard.
- Parameters:
- Returns:
Table with the trace of the standard star on the input detector. If this is a MultiSlit reduction, the table will have a single column: TRACE_SPAT. If this is an Echelle reduction, the table will have two columns: ECH_ORDER and TRACE_SPAT. Will be None if
std_outfileis None, or if the selected detector/mosaic is not available in the provided spec1d file, or for SlicerIFU reductions.- Return type: