pypeit.core.tracewave module

Module for methods related to tracing arc/sky lines across a slit/order

pypeit.core.tracewave.arc_tilts_2d_qa(tilts_dspat, tilts, tilts_model, tot_mask, rej_mask, spat_order, spec_order, rms, fwhm, slitord_id=0, setup='A', outfile=None, show_QA=False, out_dir=None)[source]

..todo.. this method needs docs

Parameters:
  • tilts_dspat

  • tilts

  • tilts_model

  • tot_mask

  • rej_mask

  • spat_order

  • spec_order

  • rms

  • fwhm

  • slitord_id

  • setup

  • outfile

  • show_QA

  • out_dir

Returns:

pypeit.core.tracewave.arc_tilts_spat_qa(tilts_dspat, tilts, tilts_model, tilts_spec_fit, tot_mask, rej_mask, spat_order, spec_order, rms, fwhm, setup='A', slitord_id=0, outfile=None, show_QA=False, out_dir=None)[source]

NEEDS A DOC STRING!

pypeit.core.tracewave.arc_tilts_spec_qa(tilts_spec_fit, tilts, tilts_model, tot_mask, rej_mask, rms, fwhm, slitord_id=0, setup='A', outfile=None, show_QA=False, out_dir=None)[source]

Generate a QA plot of the residuals for the fit to the tilts in the spectral direction one slit at a time

pypeit.core.tracewave.fit2tilts(shape, coeff2, func2d, spat_shift=None)[source]

Evaluate the wavelength tilt model over the full image.

Parameters:
  • shape (tuple of ints,) – shape of image

  • coeff2 (numpy.ndarray, float) – result of griddata tilt fit

  • func2d (str) – the 2d function used to fit the tilts

  • spat_shift (float, optional) – Spatial shift to be added to image pixels before evaluation If you are accounting for flexure, then you probably wish to input -1*flexure_shift into this parameter.

Returns:

tilts – Image indicating how spectral pixel locations move across the image. This output is used in the pipeline.

Return type:

numpy.ndarray, float

pypeit.core.tracewave.fit_tilts(trc_tilt_dict, thismask, slit_cen, spat_order=3, spec_order=4, maxdev=0.2, maxiter=100, sigrej=3.0, pad_spec=30, pad_spat=5, func2d='legendre2d', doqa=True, calib_key='test', slitord_id=0, show_QA=False, out_dir=None, minmax_extrap=(150.0, 1000.0))[source]

THIS NEEDS A DOC STRING

Parameters:
  • trc_tilt_dict (dict) – Diciontary containing tilt info

  • slitord_id (int) – Slit ID, spatial; only used for QA

  • all_tilts

  • order

  • yorder

  • func2D

  • maskval

  • setup

  • doqa

  • show_QA

  • minmax_extrap (tuple or list, optional) – Terminate extrapolation beyond measured arc lines at this pixel value below/above last line

  • out_dir

pypeit.core.tracewave.tilts_find_lines(arc_spec, slit_cen, tracethresh=10.0, sig_neigh=5.0, nfwhm_neigh=2.0, only_these_lines=None, fwhm=4.0, nonlinear_counts=10000000000.0, fit_frac_fwhm=1.25, cont_frac_fwhm=1.0, max_frac_fwhm=2.0, cont_samp=30, niter_cont=3, bpm=None, debug_lines=False, debug_peaks=False)[source]

I can’t believe this method has no docs

FILL THIS IN

Parameters:
  • arc_spec

  • slit_cen

  • tracethresh

  • sig_neigh

  • nfwhm_neigh

  • only_these_lines

  • fwhm

  • nonlinear_counts

  • fit_frac_fwhm

  • cont_frac_fwhm

  • max_frac_fwhm

  • cont_samp

  • niter_cont

  • debug_lines

  • debug_peaks

Returns:

Three numpy.ndarray objects are returned with the (1) spatial

and (2) spectral locations for the starting point to trace the line centroids and (3) a good value mask. Locations where the good-value mask is False are locations that were rejected either because the detection wasn’t significant enough or the line was too close to a more-significant, neighboring line.

Return type:

tuple

pypeit.core.tracewave.trace_tilts(arcimg, lines_spec, lines_spat, thismask, slit_cen, inmask=None, gauss=False, fwhm=4.0, spat_order=5, maxdev_tracefit=0.2, sigrej_trace=3.0, max_badpix_frac=0.3, tcrude_nave=5, npca=2, coeff_npoly_pca=2, sigrej_pca=2.0, debug_pca=False, show_tracefits=False)[source]

Use a PCA model to determine the best object (or slit edge) traces for echelle spectrographs.

Parameters:
  • arcimg (numpy.ndarray, float (nspec, nspat)) – Image of arc or sky that will be used for tracing tilts.

  • lines_spec (numpy.ndarray, float (nlines,)) – Array containing arc line centroids along the center of the slit for each arc line that will be traced. This is in pixels in image coordinates.

  • lines_spat (numpy.ndarray, float (nlines,)) – Array contianing the spatial position of the center of the slit along which the arc was extracted. This is is in pixels in image coordinates.

  • thismask (numpy.ndarray, boolean (nspec, nsapt)) – Boolean mask image specifying the pixels which lie on the slit/order to search for objects on. The convention is: True = on the slit/order, False = off the slit/order. This must be the same size as the arcimg.

  • inmask (float ndarray, default = None, optional) – Input mask image.

  • gauss (bool, default = False, optional) – If true the code will trace the arc lines usign Gaussian weighted centroiding (trace_gweight) instead of the default, which is flux weighted centroiding (trace_fweight)

  • fwhm (float, optional) – Expected FWHM of the arc lines.

  • spat_order (int, default = None, optional) – Order of the legendre polynomial that will be fit to the tilts.

  • maxdev_tracefit (float, default = 1.0, optional) – Maximum absolute deviation for the arc tilt fits during iterative trace fitting expressed in units of the fwhm.

  • sigrej_trace (float, default = 3.0, optional) – From each line we compute a median absolute deviation of the trace from the polynomial fit. We then analyze the distribution of maximxum absolute deviations (MADs) for all the lines, and reject sigrej_trace outliers from that distribution.

  • max_badpix_frac (float, default = 0.30, optional) – Maximum fraction of total pixels that can be masked by the trace_gweight algorithm (because the residuals are too large) to still be usable for tilt fitting.

  • tcrude_nave (int, default = 5, optional) – Trace crude is used to determine the initial arc line tilts, which are then iteratively fit. Trace crude can optionally boxcar smooth the image (along the spatial direction of the image, i.e. roughly along the arc line tilts) to improve the tracing.

  • npca (int, default = 1, optional) – Tilts are initially traced and then a PCA is performed. The PCA is used to determine better crutches for a second round of improved tilt tracing. This parameter is the order of that PCA and determined how much the tilts behavior is being compressed. npca = 0 would be just using the mean tilt. This PCA is only an intermediate step to improve the crutches and is an attempt to make the tilt tracing that goes into the final fit more robust.

  • coeff_npoly_pca (int, default = 1, optional) – Order of polynomial fits used for PCA coefficients fitting for the PCA described above.

  • sigrej_pca (float, default = 2.0, optional) – Significance threhsold for rejection of outliers from fits to PCA coefficients for the PCA described above.

  • show_tracefits (bool, default = False, optional) – If true the fits will be shown to each arc line trace by iter_fitting.py

Returns:

trace_tilts_dict – See trace_tilts_work() for a complete description

Return type:

dict

pypeit.core.tracewave.trace_tilts_work(arcimg, lines_spec, lines_spat, thismask, slit_cen, inmask=None, gauss=False, tilts_guess=None, fwhm=4.0, spat_order=3, maxdev_tracefit=0.02, sigrej_trace=3.0, max_badpix_frac=0.3, tcrude_maxerr=1.0, tcrude_maxshift=3.0, tcrude_maxshift0=3.0, tcrude_nave=5, show_tracefits=False)[source]

Use a PCA model to determine the best object (or slit edge) traces for echelle spectrographs.

Parameters:
  • arcimg (numpy.ndarray float (nspec, nspat)) – Image of arc or sky that will be used for tracing tilts.

  • lines_spec (numpy.ndarray float (nlines,)) – Array containing arc line centroids along the center of the slit for each arc line that will be traced. This is in pixels in image coordinates.

  • lines_spat (numpy.ndarray float (nlines,)) – Array contianing the spatial position of the center of the slit along which the arc was extracted. This is is in pixels in image coordinates.

  • thismask (numpy.ndarray boolean (nspec, nsapt)) – Boolean mask image specifying the pixels which lie on the slit/order to search for objects on. The convention is: True = on the slit/order, False = off the slit/order. This must be the same size as the arcimg.

  • inmask (float numpy.ndarray default = None, optional) – Input mask image.

  • gauss (bool, default = False, optional) – If true the code will trace the arc lines usign Gaussian weighted centroiding (trace_gweight) instead of the default, which is flux weighted centroiding (trace_fweight)

  • tilts_guess (float numpy.ndarray default = None, optional) – A guess for the tilts used for running this tilt tracing in an iterative manner. If the tilts_guess is not None, it should be an array containing the tilts from a previous iteration which will be used as a crutch for the tracing of the tilts. The default is None, which is how this code is run on a first iteration. In that case the crutces are determined via trace_crude, and then the flux (or Gaussian) weighted tracing is performed.

  • fwhm (float, optional) – Expected FWHM of the arc lines.

  • spat_order (int, default = None, optional) – Order of the legendre polynomial that will be fit to the tilts.

  • maxdev_tracefit (float, default = 0.2, optional) – Maximum absolute deviation for the arc tilt fits during iterative trace fitting expressed in units of the fwhm.

  • sigrej_trace (float, default = 3.0, optional) – From each line we compute a median absolute deviation of the trace from the polynomial fit. We then analyze the distribution of maximxum absolute deviations (MADs) for all the lines, and reject sigrej_trace outliers from that distribution.

  • max_badpix_frac (float, default = 0.20, optional) – Maximum fraction of total pixels that can be masked by the trace_gweight algorithm (because the residuals are too large) to still be usable for tilt fitting.

  • tcrude_maxerr (float, default = 1.0, optional) – maxerr parameter for trace crude

  • tcrude_maxshift (float, default = 3.0, optional) – maxshift parameter for trace crude

  • tcrude_maxshift0 (float, default = 3.0, optional) – maxshift0 parameter for trace crude

  • tcrude_nave (int, default = 5, optional) – Trace crude is used to determine the initial arc line tilts, which are then iteratively fit. Trace crude can optionally boxcar smooth the image (along the spatial direction of the image, i.e. roughly along the arc line tilts) to improve the tracing.

  • show_tracefits (bool, default = False, optional) – If true the fits will be shown to each arc line trace by iterative_fitting

Returns:

results_dict

with keys
  • nspec=

  • nspat=

  • nsub=

  • nlines=

  • nuse=

  • spat_min=

  • spat_max=

  • do_crude=

  • fwhm=

  • use_tilt=

  • tilts_sub_spat=

  • tilts_sub_fit=

  • tilts_mad=

  • tilts_spec=

  • tilts_spat=

  • tilts_dspat=

  • tilts=

  • tilts_fit=

  • tilts_err=

  • tilts_bpm=

  • tilts_mask=

Return type:

dict