pypeit.find_objects module
Main driver class for object finding, global skysubtraction and skymask construction
- class pypeit.find_objects.EchelleFindObjects(sciImg, slits, spectrograph, par, objtype, **kwargs)[source]
Bases:
FindObjects
Child of Reduce for Echelle reductions
See parent doc string for Args and Attributes
- find_objects_pypeline(image, ivar, std_trace=None, show=False, show_peaks=False, show_fits=False, show_trace=False, save_objfindQA=False, neg=False, debug=False, manual_extract_dict=None)[source]
Pipeline specific find objects routine
- Parameters:
image (numpy.ndarray) – Image to search for objects from. This floating-point image has shape (nspec, nspat) where the first dimension (nspec) is spectral, and second dimension (nspat) is spatial.
std_trace (astropy.table.Table, optional) – Table with the trace of the standard star on the input detector, which is used as a crutch for tracing. For Echelle reduction, the table has two columns: ECH_ORDER and TRACE_SPAT. The shape of each row must be (nspec,). If None, the slit boundaries are used as the crutch.
manual_extract_dict (
dict
, optional) – Dict guiding the manual extractionshow_peaks (
bool
, optional) – Generate QA showing peaks identified by object findingshow_fits (
bool
, optional) – Generate QA showing fits to tracesshow_trace (
bool
, optional) – Generate QA showing traces identified. Requires an open ginga RC modules windowsave_objfindQA (
bool
, optional) – Save to disk (png file) QA showing the object profileneg (
bool
, optional) – Is this a negative image?show (
bool
, optional)debug (
bool
, optional)
- Returns:
- class pypeit.find_objects.FindObjects(sciImg, slits, spectrograph, par, objtype, wv_calib=None, waveTilts=None, tilts=None, initial_skymask=None, bkg_redux=False, find_negative=False, std_redux=False, show=False, clear_ginga=True, basename=None, manual=None)[source]
Bases:
object
Base class used to find objects and perform global sky subtraction for science or standard-star exposures.
- Parameters:
sciImg (
PypeItImage
) – Image to reduce.slits (
SlitTraceSet
) – Object providing slit traces for the image to reduce.spectrograph (
Spectrograph
) – PypeIt Spectrograph classpar (
PypeItPar
) – Reduction parameters classobjtype (
str
) – Specifies object being reduced. Should be ‘science’, ‘standard’, or ‘science_coadd2d’.wv_calib (
WaveCalib
, optional) – This is only used for theSlicerIFUFindObjects
child when a joint sky subtraction is requested.waveTilts (
WaveTilts
, optional) – Calibration frame with arc/sky line tracing of the wavelength tilt. Only waveTilts or tilts is needed (not both).tilts (numpy.ndarray, optional) – Tilts frame produced by
fit2tiltimg()
for given a spatial flexure. Only waveTilts or tilts is needed (not both).initial_skymask (numpy.ndarray, optional) – Boolean array that selects (array elements are True) image pixels in sky regions. If provided, the 2nd pass on the global sky subtraction is omitted.
bkg_redux (
bool
, optional) – If True, the sciImg has been subtracted by a background image (e.g. standard treatment in the IR)find_negative (
bool
, optional) – If True, the negative objects are foundstd_redux (
bool
, optional) – If True, the object being extracted is a standard star, so that the reduction parameters can be adjusted accordingly.show (
bool
, optional) – Show plots along the way?clear_ginga (
bool
, optional) – Clear the ginga window before showing the object finding results.basename (
str
, optional) – Base name for output filesmanual (
ManualExtractionObj
, optional) – Object containing manual extraction instructions/parameters.
- ivarmodel
Model of inverse variance
- Type:
- objimage
Model of object
- Type:
- skyimage
Final model of sky
- Type:
- initial_sky
Initial sky model after first pass with global_skysub()
- Type:
- global_sky
Fit to global sky
- Type:
- skymask
Mask of the sky fit
- Type:
- outmask
Final output mask
- Type:
- extractmask
Extraction mask
- Type:
- slits
- Type:
- sobjs_obj
Objects found
- Type:
- tilts
WaveTilts images generated on-the-spot
- Type:
- waveimg
WaveImage image generated on-the-spot
- Type:
- slitshift
Global spectral flexure correction for each slit (in pixels)
- Type:
- vel_corr
Relativistic reference frame velocity correction (e.g. heliocentyric/barycentric/topocentric)
- Type:
- create_skymask(sobjs_obj)[source]
Creates a skymask from a SpecObjs object
- Parameters:
sobjs_obj (
pypeit.specobjs.SpecObjs
) – Objects for which you would like to create the mask- Returns:
Boolean image with shape \((N_{\rm spec}, N_{\rm spat})\) indicating which pixels are usable for global sky subtraction. True = usable for sky subtraction, False = should be masked when sky subtracting.
- Return type:
- find_objects(image, ivar, std_trace=None, show_peaks=False, show_fits=False, show_trace=False, show=False, save_objfindQA=True, manual_extract_dict=None, debug=False)[source]
Single pass at finding objects in the input image
If self.find_negative is True, do a search for negative objects too
- Parameters:
image (numpy.ndarray) – Image to search for objects from. This floating-point image has shape (nspec, nspat) where the first dimension (nspec) is spectral, and second dimension (nspat) is spatial.
std_trace (astropy.table.Table, optional) – Table with the trace of the standard star on the input detector, which is used as a crutch for tracing. For MultiSlit reduction, the table has a single column: TRACE_SPAT. For Echelle reduction, the table has two columns: ECH_ORDER and TRACE_SPAT. The shape of each row must be (nspec,). For SlicerIFU reduction, std_trace is None. If None, the slit boundaries are used as the crutch.
show_peaks (
bool
, optional) – Generate QA showing peaks identified by object findingshow_fits (
bool
, optional) – Generate QA showing fits to tracesshow_trace (
bool
, optional) – Generate QA showing traces identified. Requires an open ginga RC modules windowshow (
bool
, optional) – Show all the QAsave_objfindQA (
bool
, optional) – Save to disk (png file) QA showing the object profilemanual_extract_dict (
dict
, optional) – This is only used by 2D coadddebug (
bool
, optional) – Show debugging plots?
- Returns:
- find_objects_pypeline(image, ivar, std_trace=None, show_peaks=False, show_fits=False, show_trace=False, show=False, save_objfindQA=False, neg=False, debug=False, manual_extract_dict=None)[source]
Dummy method for object finding. Overloaded by class specific object finding.
Returns:
- classmethod get_instance(sciImg, slits, spectrograph, par, objtype, wv_calib=None, waveTilts=None, tilts=None, initial_skymask=None, bkg_redux=False, find_negative=False, std_redux=False, show=False, clear_ginga=True, basename=None, manual=None)[source]
Instantiate and return the
FindObjects
subclass appropriate for the provided spectrograph.For argument descriptions, see
FindObjects
.
- get_platescale(slitord_id=None)[source]
Return the platescale in binned pixels for the current detector/echelle order
Over-loaded by the children
- Parameters:
slitord_id (
int
, optional) – slit spat_id (MultiSlitFindObjects
,SlicerIFUFindObjects
) or ech_order (EchelleFindObjects
) value.- Returns:
plate scale in binned pixels
- Return type:
- global_skysub(skymask=None, bkg_redux_sciimg=None, update_crmask=True, previous_sky=None, show_fit=False, show=False, show_objs=False, objs_not_masked=False, reinit_bpm: bool = True)[source]
Perform global sky subtraction, slit by slit
Wrapper to skysub.global_skysub
- Parameters:
skymask (numpy.ndarray, optional) – A 2D image indicating sky regions (1=sky)
bkg_redux_sciimg (
PypeItImage
) – PypeIt image of the science image before background subtraction if self.bkg_redux is True, otherwise None. It’s used to generate a global sky model without bkg subtraction.update_crmask (bool, optional) – Update the crmask in the science image
show_fit (bool, optional) – Show the sky fits?
show (bool, optional) – Show the sky image generated?
show_objs (bool, optional) – If show=True, show the objects on the sky image?
previous_sky (numpy.ndarray, optional) – Sky model estimate from a previous run of global_sky Used to generate an improved estimated of the variance
objs_not_masked (bool, optional) – Set this to be True if there are objects on the slit/order that are not being masked by the skymask. This is typically the case for the first pass sky-subtraction before object finding, since a skymask has not yet been created.
reinit_bpm (
bool
, optional) – If True (default), the bpm is reinitialized to the initial bpm Should be False on the final run in case there was a failure upstream and no sources were found in the slit/order
- Returns:
image of the the global sky model
- Return type:
- initialize_slits(slits, initial=False)[source]
Gather all the
SlitTraceSet
attributes that we’ll use here inFindObjects
- Parameters:
slits (
SlitTraceSet
) – SlitTraceSet object containing the slit boundaries that will be initialized.initial (
bool
, optional) – Use the initial definition of the slits. If False, tweaked slits are used.
- run(std_trace=None, show_peaks=False, show_skysub_fit=False)[source]
Primary code flow for object finding in PypeIt reductions
- Parameters:
std_trace (astropy.table.Table, optional) – Table with the trace of the standard star on the input detector, which is used as a crutch for tracing. For MultiSlit reduction, the table has a single column: TRACE_SPAT. For Echelle reduction, the table has two columns: ECH_ORDER and TRACE_SPAT. The shape of each row must be (nspec,). For SlicerIFU reduction, std_trace is None. If None, the slit boundaries are used as the crutch.
show_peaks (
bool
, optional) – Show peaks in find_objects methodsshow_skysub_fit (
bool
, optional) – Show the fits for the global sky subtraction
- Returns:
initial_sky (numpy.ndarray) – Initial global sky model
sobjs_obj (
SpecObjs
) – List of objects found
- show(attr, image=None, global_sky=None, showmask=False, sobjs=None, chname=None, slits=False, clear=False)[source]
Show one of the internal images
Todo
This docstring is incomplete!
- Parameters:
attr (str) –
- String specifying the image to show. Options are:
global – Sky model (global)
sci – Processed science image
rawvar – Raw variance image
modelvar – Model variance image
crmasked – Science image with CRs set to 0
skysub – Science image with global sky subtracted
image – Input image
image (ndarray, optional) – User supplied image to display
- class pypeit.find_objects.MultiSlitFindObjects(sciImg, slits, spectrograph, par, objtype, **kwargs)[source]
Bases:
FindObjects
Child of Reduce for Multislit and Longslit reductions
See parent doc string for Args and Attributes
- find_objects_pypeline(image, ivar, std_trace=None, manual_extract_dict=None, show_peaks=False, show_fits=False, show_trace=False, show=False, save_objfindQA=False, neg=False, debug=False)[source]
Pipeline specific find objects routine
- Parameters:
image (numpy.ndarray) – Image to search for objects from. This floating-point image has shape (nspec, nspat) where the first dimension (nspec) is spectral, and second dimension (nspat) is spatial.
std_trace (astropy.table.Table, optional) – Table with the trace of the standard star on the input detector, which is used as a crutch for tracing. For MultiSlit reduction, the table has a single column: TRACE_SPAT. The shape of each row must be (nspec,). If None, the slit boundaries are used as the crutch.
manual_extract_dict (
dict
, optional) – Dict guiding the manual extractionshow_peaks (
bool
, optional) – Generate QA showing peaks identified by object findingshow_fits (
bool
, optional) – Generate QA showing fits to tracesshow_trace (
bool
, optional) – Generate QA showing traces identified. Requires an open ginga RC modules windowshow (
bool
, optional) – Show all the QAsave_objfindQA (
bool
, optional) – Save to disk (png file) QA showing the object profileneg (
bool
, optional) – Is this a negative image?debug (
bool
, optional) – Show debugging plots?
- Returns:
- class pypeit.find_objects.SlicerIFUFindObjects(sciImg, slits, spectrograph, par, objtype, **kwargs)[source]
Bases:
MultiSlitFindObjects
Child of Reduce for SlicerIFU reductions
See parent doc string for Args and Attributes
- apply_relative_scale(scaleImg)[source]
Apply a relative scale to the science frame (and correct the varframe, too)
- Parameters:
scaleImg (numpy.ndarray) – scale image to divide the science frame by
- calculate_flexure(global_sky)[source]
Convenience function to calculate the flexure of an IFU. The flexure is calculated by cross-correlating the sky model of a reference slit with an archival sky spectrum. This gives an “absolute” flexure correction for the reference slit in pixels. Then, the flexure for all other slits is calculated by cross-correlating the sky model of each slit with the sky model of the reference slit. This gives a “relative” flexure correction for each slit in pixels. The relative flexure is then added to the absolute flexure to give the total flexure correction for each slit in pixels.
- Parameters:
global_sky (ndarray) – Sky model
- Returns:
new_slitshift – The flexure in pixels
- Return type:
ndarray
- global_skysub(skymask=None, bkg_redux_sciimg=None, update_crmask=True, previous_sky=None, show_fit=False, show=False, show_objs=False, objs_not_masked=False, reinit_bpm: bool = True)[source]
Perform global sky subtraction. This SlicerIFU-specific routine ensures that the edges of the slits are not trimmed, and performs a spatial and spectral correction using the sky spectrum, if requested. See Reduce.global_skysub() for parameter definitions.
See base class method for description of parameters.
- Parameters:
reinit_bpm (
bool
, optional) – If True (default), the bpm is reinitialized to the initial bpm Should be False on the final run in case there was a failure upstream and no sources were found in the slit/order