Tracing#

The specreduce.tracing module provides three Trace classes that are used to define the spatial position (trace) of a spectrum across a 2D detector image: FlatTrace, FitTrace, and ArrayTrace. Each trace class requires the 2D spectral image as input, along with trace-specific parameters that control how the trace is determined.

Flat trace#

FlatTrace assumes that the spectrum follows a straight line across the detector, and is best for well-aligned spectrographs with minimal optical distortion. To initialize a FlatTrace, we need to specify the fixed cross-dispersion pixel position:

trace = specreduce.tracing.FlatTrace(image, trace_pos=6)

(Source code, png, hires.png, pdf)

_images/trace-1.png

FitTrace#

FitTrace fits a polynomial function to automatically detected spectrum positions, and is suitable for typical spectra with smooth, continuous trace profiles. The trace model can be chosen from Chebyshev1D, Legendre1D, Polynomial1D, or Spline1D, and the fitting can be optimized by binning the spectrum along the dispersion axis.

trace = specreduce.tracing.FitTrace(image, bins=10, trace_model=Polynomial1D(3))

(Source code, png, hires.png, pdf)

_images/trace-2.png

The method works by (optionally) binning the 2D spectrum along the dispersion axis, finding the PSF peak position along the cross-dispersion for each bin, and then fitting a 1D polynomial to the cross-dispersion and dispersion axis positions. Binning is optional, and the native image resolution is used by default. Binning can significantly increase the reliability of the fitting with low SNR spectra, and always increases the speed.

The peak detection method can be chosen from max, centroid, and gaussian. Of these methods, max is the fastest but yields an integer pixel precision. Both centroid and gaussian can be used when sub-pixel precision is required, and gaussian, while being the slowest method of the three, is the best option if the data is significantly contaminated by non-finite values.

(Source code, png, hires.png, pdf)

_images/trace-3.png

ArrayTrace#

ArrayTrace uses a pre-defined array of positions for maximum flexibility, and is ideal for complex or unusual trace shapes that are difficult to model mathematically. ArrayTrace initialization requires an array of cross-dispersion pixel positions. The size of the array must match the number of dispersion-axis pixels in the image.

trace = specreduce.tracing.ArrayTrace(image, positions)

(Source code, png, hires.png, pdf)

_images/trace-4.png