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:
FindObjectsChild 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.FiberFindObjects(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:
FindObjectsChild of FindObjects for fiber-fed spectrographs.
For fiber spectrographs, each fiber IS the object — there is no need for peak-detection object finding. This class creates one SpecObj per fiber within each block-slit, using reference fiber positions from the spectrograph.
Follows the IDL Binospec pipeline approach (Fabricant et al. 2025, Section 6) for sky subtraction: extract all fibers, divide by the globally-normalized fiber flat correction, then fit a 2D B-spline sky model (wavelength + spatial Legendre polynomial) to the dedicated sky fibers and subtract from all fibers.
See parent doc string for Args and Attributes.
- static _attach_fiber_throughput(sobjs, fiber_flatimages, spectrograph, det)[source]
Combine flat-derived and static per-fiber throughput.
The flat field contributes the geometric/transmission ratio; the static
fiber_illumination.fitsvector (when the spectrograph supplies one) is a refinement that captures per-fiber variations the lamp cannot due to illumination effects. Both are multiplied together and stashed on each SpecObj as a single scalar so the sky-model build and the post-extraction division apply the same value.
- _broaden_sky_per_fiber(sobjs, threshold_pix=0.2)[source]
Gaussian-convolve each fiber’s predicted 1D sky to its observed LSF.
Reads the per-fiber LSF sigma stored on
sobj.fiber_lsf_sigma_pixby_measure_fiber_lsf(). Reference sigma is the median over science fibers (the dominant population in the joint bspline fit, so the model sits closest to their LSF). Each fiber whose own sigma exceeds the reference is broadened bysqrt(sig_fiber^2 - sig_ref^2)in row-index space (one row = one spectral pixel), only applied abovethreshold_pix(default 0.2 px, matches the IDL pipeline).scipy.ndimage.gaussian_filter1dis flux-preserving so per-fiber total sky counts are conserved.
- _fiber_apertures_within_slit(sobjs)[source]
Check that every fiber’s boxcar aperture stays in own slit / gap.
Returns
Truewhen, for every fiber and every spectral row, the integer aperture columns are either inside the fiber’s own slit or in an unassigned pixel (slitmask == -1, i.e. inter-block gap). If even one fiber crosses into a different slit, the vectorized boxcar’s “global mask only” assumption breaks and the caller should fall back to the per-fiber loop. For Binospec IFU with ~70 px inter-block gaps and ~4 px apertures this is always true; the check is the cheap guard that keeps the fast path safe for future fiber spectrographs.
- _fiber_global_skysub(sobjs)[source]
Fit one 2D bspline to throughput-normalized fiber spectra, predict per-fiber sky, and stamp it into a per-pixel 2D
SKYMODEL.We use the boxcar-extracted
BOX_COUNTS(aperture sums per row), divide by each fiber’s scalar throughput so all fibers share a common surface, and fit a single 2D bspline in(wavelength, normalized spat_pos)with a Legendre polynomial along the spatial axis (npoly=2). Each fiber’s predicted 1D sky spectrum is then evaluated, re-scaled by its throughput to recover detector counts, and the per-row sum is distributed across the fiber’s aperture using the empirical spatial profile derived from the flat field.The fit runs as two passes with per-fiber wavelength refinement in between. The per-block wavelength solution carries ~0.2 px (1 sigma) of per-fiber offset that the joint bspline can’t resolve and that shows up as dipole residuals on bright OH lines. After the first-pass fit, each fiber’s
BOX_WAVEis shifted to the Delta-lambda that minimises chi2 against the bspline model on the line wings (see_refine_fiber_wavelengths()), then the joint fit is re-run.By default the fit is joint over dedicated sky fibers and all science fibers, relying on the iterative sigma rejection in
iterfit()(asymmetric, tighter on the upper side) to down-weight pixels that contain real source flux. Two[reduce][skysub]parameters control which fibers contribute:joint_fit_use_sci(defaultTrue) – whenFalse, only fibers whoseMASKDEF_OBJNAMEstarts withSKYare used (legacy behaviour).sci_exclude_radius(defaultNone) – when set and the joint fit is enabled, any science fiber whose on-sky position lies within this radius (in arcsec) of the IFU geometric centre is dropped from the fit. Use this to exclude inner science fibers most likely to contain source flux while retaining fibers away from the source for additional sky background information.
- Parameters:
sobjs (
SpecObjs) – One SpecObj per fiber withBOX_WAVE,BOX_COUNTS,BOX_COUNTS_IVAR,fiber_throughputandSPAT_PIXPOSpopulated.BOX_COUNTS_SKYis set on each SpecObj as a side effect;BOX_WAVEis updated in place with the per-fiber wavelength refinement.- Returns:
sky_model – Sky model in detector counts, shape
self.sciImg.image.shape.- Return type:
- _fit_fiber_sky_bspline(sobjs, use_sci, excl_r, sci_xy, bsp, label='')[source]
Collect throughput-normalised fiber spectra and fit one 2D bspline.
Used by
_fiber_global_skysub()for both the first-pass fit on as-extractedBOX_WAVEand the second-pass fit on per-fiber refined wavelengths.- Returns:
result –
(sset, wave_min, wave_max, outmask)on success, orNoneif there are no good fiber inputs oriterfitraises.- Return type:
tuple or None
- _get_sci_fiber_xy(sobjs)[source]
Look up on-sky (x, y) in arcsec for each science fiber.
Used by
_fiber_global_skysub()to optionally exclude science fibers within a configured radius of an IFU geometric center from the joint sky fit.Relies on the spectrograph exposing
load_sky_layout()(returningtargetx, targetyarrays in arcsec) andget_science_fiber_layout_indices(det, fiber_ids, fiber_types). Spectrographs that do not implement these get an empty mapping and no exclusion is applied.
- _load_fiber_flatimages()[source]
Load
FiberFlatImagesfrom the calibrations directory.Uses the
calib_dirstored on the slits object (inherited fromCalibFrame) to search for files matching theFiberFlat_*.fitspattern.- Returns:
fiber_flatimages – Loaded fiber flat calibration, or
Noneif no file is found.- Return type:
FiberFlatImagesor None
- _load_flatimg()[source]
Load the processed flat image used to build empirical fiber profiles.
- Returns:
flatimg – Processed flat image in detector-pixel space, or
Noneif no matching flat calibration is available.- Return type:
numpy.ndarray or None
- _measure_fiber_lsf(sobjs, sset, wave_min, wave_max, n_lines=5)[source]
Per-fiber spectral LSF sigma (in pixels) from the arc-line FWHM.
Uses
sobj.BOX_FWHM(wavecal-derived spectral FWHM in Angstroms, already populated along each fiber’s trace). For each fiber, samplesBOX_FWHMat the brightest sky lines in the joint bspline model and converts FWHM_AA -> sigma_pix via the local dispersionmedian(diff(BOX_WAVE)).Per-fiber empirical estimators (2nd-moment / Gaussian fit on
BOX_COUNTS) were tried first and discarded – they are biased high by OH-line wings/blending and have 40-50% within-type scatter, swamping the real ~10% per-type LSF gap.BOX_FWHMis per-block-slit (wavecal granularity), which collapses this to a per-type measurement – adequate because the sky/sci LSF gap comes from the fiber aperture size , which is uniform within a fiber type.- Returns:
n_measured – Number of fibers for which a usable LSF sigma was measured and stored on
sobj.fiber_lsf_sigma_pix(pixels). Fibers without a usable value are left withfiber_lsf_sigma_pix = None.- Return type:
- _preextract_fibers(sobjs)[source]
Boxcar-extract every fiber from the un-subtracted image.
Populates
BOX_WAVE,BOX_COUNTS,BOX_COUNTS_IVARandBOX_MASKon each fiber SpecObj using a zero sky input, so the sky-model fit operates on aperture-summed sky counts in detector units. These BOX_* fields are subsequently overwritten byFiberExtractonsciimg - skymodel.Fast path: single
moment1d()call per boxcar quantity with the per-fiber traces stacked into a(nspec, nfib)column array, replacing one round trip throughextract_boxcar()per fiber. Bit-identical to the legacy per-fiber loop, ~30x faster.Two preconditions guard the fast path, with a fallback to the per-fiber loop if either fails:
Uniform
BOX_R_PIXacross fibers, so a single scalar boxcar width can be used.moment1daccepts a per-elementwidtharray, but it sizes its integration column grid to the minimum aperture width across all elements (moment.py, thenp.amin(i2-i1)term), so a varyingwidthwould silently truncate the wider apertures rather than reproduce the per-fiber boxcars. The loop fallback uses correct per-fiber scalar widths.No aperture crosses into a different block-slit, which would break the fast path’s single global-mask assumption (never happens for Binospec’s ~70 px inter-block gaps; see
_fiber_apertures_within_slit()).
- _preextract_fibers_loop(sobjs)[source]
Per-fiber fallback for
_preextract_fibers().Preserves the original per-fiber
gpm & ~other_slitmask and handles non-uniformBOX_R_PIX. Used when the vectorized fast path’s preconditions fail.
- _refine_fiber_traces(sobjs, search_radius=4.0)[source]
Snap each fiber’s trace to the nearest peak in the flat field.
The static reference-profile fiber positions, even after the bulk cross-correlation shift, can be off by 2-3 px due to optical distortion or mechanical effects that a single global shift can’t capture. Left uncorrected, apertures can miss their real peaks and leave large per-pixel sky-subtraction residuals.
For each fiber:
detect peaks in the flat-field spatial profile within its block-slit
pick the peak nearest the current
SPAT_PIXPOSsub-pixel-refine that peak with a parabolic fit on the three flat samples around it
update
TRACE_SPAT,SPAT_PIXPOS, andSPAT_PIXPOS_ID
Fibers whose nearest detected peak lies more than
search_radiuspx away (dead fibers, masked regions, or anything pathological) are left at their bulk-shifted positions.- Parameters:
sobjs (
SpecObjs) – One SpecObj per fiber.search_radius (
float, optional) – Maximum allowed shift in spatial pixels. Defaults to 4.0 – comfortably larger than the worst per-block offsets observed (~3 px on DET02), but small enough to avoid snapping onto a neighbouring fiber’s peak (inter-fiber spacing ~6.6 px).
- _refine_fiber_wavelengths(sobjs, sset, wave_min, wave_max, search_pix=1.5, probe_pix=0.05, relinearize_pix=0.3, min_npts=100)[source]
Per-fiber wavelength refinement against the first-pass bspline.
For spectrographs with many fibers, performing a full wavelength calibration for each fiber is very time-consuming. As an optimization, fibers that are closely spaced are grouped into “blocks” and share a common wavelength solution derived from the arc lines. Tilt-fitting is used to capture the intra-block variation, but the per-block solution still leaves ~0.2 px (1 sigma) of per-fiber offset within a block. Pooling fibers with mismatched wavelengths smears the bspline at sharp OH lines and shows up as a dipole residual on each fiber’s bright lines.
For each fiber, let
base_ibe the joint bspline evaluated at the fiber’s wavelengths andr_i = data_i - base_ithe residual of the throughput-corrected counts against that model. Locally linearize the bspline in pixel-shiftDelta-pvia a one-sided finite difference of widthprobe_pix:dbase/dp = (base(lambda + probe*dlam) - base) / probe. Minimizing the weighted chi2chi2(Delta-p) = sum_i w_i^2 (r_i - Delta-p * dbase/dp_i)^2
in closed form gives
Delta-p = sum w_i^2 dbase/dp_i r_i / sum w_i^2 (dbase/dp_i)^2,
where
w_i^2 = (dbase/dp_i)^2 * ivar_i– the same gradient-weighted norm the legacy grid scan used (continuum rows contribute nothing; line wings dominate; source flux on sci fibers averages out because dbase/dp swaps sign across each line peak). If the first-pass shift exceedsrelinearize_pixthe linearization is repeated centered on the new estimate; one Newton step is enough for the largest shifts seen in practice (<= 0.7 px with knot spacing ~0.8 px). The whole solve costs 2–4 bspline evaluations per fiber instead of the 60+ required by a grid scan.- Parameters:
sobjs (
SpecObjs) – Fiber SpecObjs from the first pass;BOX_WAVEis updated in place.sset (
bspline) – First-pass bspline.wave_min (float) – Valid wavelength range for the bspline.
wave_max (float) – Valid wavelength range for the bspline.
search_pix (float, optional) – Maximum allowed
|Delta-p|; the solve is clipped to this.probe_pix (float, optional) – Pixel offset used for the finite-difference derivative.
relinearize_pix (float, optional) – If
|Delta-p|from the first solve exceeds this, re-linearize around the new estimate and re-solve.min_npts (int, optional) – Skip fibers with fewer good rows than this.
- static _solve_fiber_shift(sset, wave, data, ivar, x2, dlam, probe_pix, center)[source]
Closed-form weighted-least-squares solve for the per-fiber pixel shift
Delta-p.Let
base_ibe the reference bsplinessetevaluated at rowiof the fiber’s good rows (at pixel offsetcenter),dbase/dp_iits one-sided finite-difference pixel derivative (stepprobe_pix), andr_i = data_i - base_ithe model residual. The solve returns theDelta-pthat minimizessum_i w_i^2 (r_i - Delta-p * dbase/dp_i)^2with gradient weightsw_i^2 = (dbase/dp_i)^2 * ivar_i, i.e.Delta-p = sum_i w_i^2 dbase/dp_i r_i / sum_i w_i^2 (dbase/dp_i)^2. ReturnsNoneif the model has no gradient on this fiber (e.g. continuum-only after masking) or the system is otherwise ill-conditioned.- Parameters:
sset (
bspline) – The reference (joint) bspline being refined against.wave (
numpy.ndarray) – Per-row wavelength of the fiber’s boxcar spectrum (good rows only).data (
numpy.ndarray) – Throughput-corrected per-row counts.ivar (
numpy.ndarray) – Throughput-corrected per-row inverse variance.x2 (
numpy.ndarray) – Normalized spatial coordinate fed tosset.valuefor the Legendre dependence.dlam (float) – Local wavelength dispersion (A / pixel).
probe_pix (float) – Finite-difference step (in pixels) used to estimate
dbase/dp.center (float) – Pixel offset (relative to the input
wave) at which to linearize.
- Returns:
The closed-form Delta-p that adds to
centerto give the estimated shift, orNoneif the solve was degenerate.- Return type:
float or None
- _stamp_skymodel_uniform(sobjs)[source]
Build a 2D SKYMODEL by stamping per-row sky totals uniformly.
Fallback when an empirical flat profile is unavailable. For each fiber, every pixel in the row’s aperture gets
sky_spec[row] / n_aperture_pixels; the per-row sum still equalssky_spec[row]so boxcar extraction recovers the correct sky.
- 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]
Create one SpecObj per fiber within each block-slit.
For each pseudo-slit, uses fiber positions from the spectrograph’s reference profile to create SpecObjs at known fiber locations. FWHM and BOX_R_PIX are set from inter-fiber spacing so adjacent boxcar apertures touch but don’t overlap.
- Parameters:
image (numpy.ndarray) – Image to search for objects from. Shape
(nspec, nspat).ivar (numpy.ndarray) – Inverse variance of
image.std_trace (astropy.table.Table, optional) – Ignored for fiber reductions.
manual_extract_dict (
dict, optional) – Ignored for fiber reductions.show_peaks (
bool, optional) – Ignored for fiber reductions.show_fits (
bool, optional) – Ignored for fiber reductions.show_trace (
bool, optional) – Ignored for fiber reductions.show (
bool, optional) – Show QA plots.save_objfindQA (
bool, optional) – Ignored for fiber reductions.neg (
bool, optional) – Ignored for fiber reductions.debug (
bool, optional) – Ignored for fiber reductions.
- Returns:
- get_platescale(slitord_id=None)[source]
Return the platescale in binned pixels for the current detector.
Define get_platescale here (rather than inherit it) so the class is self-contained: the base
FindObjects.get_platescaleis an unimplemented stub, and the inheritedFindObjects.create_skymask()calls this method.
- run(std_trace=None, show_peaks=False, show_skysub_fit=False)[source]
Primary code flow for fiber object finding and 2D sky model build.
For fiber spectrographs each fiber IS the object – no peak detection is needed. We boxcar-pre-extract every fiber, fit one cross-detector 2D bspline to the throughput-normalized sky-fiber sums, predict a 1D sky spectrum per fiber, and stamp it into a 2D
SKYMODELweighted by the empirical flat profile. StandardFiberExtractthen runs onsciimg - skymodel.Build wavelength image (if not already available).
Load
FiberFlatImagesfor the per-fiber throughput scalars.Create one
SpecObjper fiber viafind_objects_pypeline.Attach a per-fiber throughput scalar to each
SpecObj.Boxcar pre-extract every fiber from the un-subtracted image so the sky-model fit has aperture-summed counts and a wavelength solution to evaluate against.
Fit a 2D bspline (wave + Legendre in normalized spatial position) to the throughput-normalized sky-fiber spectra, project per-fiber predictions, and distribute via the empirical flat profile to build the per-pixel 2D
SKYMODEL.
- Parameters:
std_trace (astropy.table.Table, optional) – Ignored for fiber reductions.
show_peaks (
bool, optional) – Ignored for fiber reductions.show_skysub_fit (
bool, optional) – Ignored for fiber reductions.
- Returns:
initial_sky (numpy.ndarray) – Per-pixel sky model in detector counts.
sobjs_obj (
SpecObjs) – List of objects found (one per fiber).
- 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:
objectBase 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 theSlicerIFUFindObjectschild 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.
- Variables:
ivarmodel (numpy.ndarray) – Model of inverse variance
objimage (numpy.ndarray) – Model of object
skyimage (numpy.ndarray) – Final model of sky
initial_sky (numpy.ndarray) – Initial sky model after first pass with global_skysub()
global_sky (numpy.ndarray) – Fit to global sky
skymask (numpy.ndarray) – Mask of the sky fit
outmask (numpy.ndarray) – Final output mask
extractmask (numpy.ndarray) – Extraction mask
slits (
SlitTraceSet)sobjs_obj (
pypeit.specobjs.SpecObjs) – Objects foundspat_flexure_shift (
float)tilts (numpy.ndarray) – WaveTilts images generated on-the-spot
waveimg (numpy.ndarray) – WaveImage image generated on-the-spot
slitshift (numpy.ndarray) – Global spectral flexure correction for each slit (in pixels) Currently only used with the IFU
vel_corr (
float) – Relativistic reference frame velocity correction (e.g. heliocentyric/barycentric/topocentric)
- 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
FindObjectssubclass 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=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
SlitTraceSetattributes 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:
FindObjectsChild 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:
MultiSlitFindObjectsChild 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=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