Trace Format#
Load spectral extraction traces for 2D spectroscopy.
Overview#
The Trace format is used for importing spectral trace definitions that specify how to extract 1D spectra from 2D spectroscopic images. Traces define the path along which the spectrum should be extracted, accounting for curvature or tilt in the spectrum.
Usage#
import jdaviz
from specreduce.tracing import FlatTrace, FitTrace
jd = jdaviz.show('specviz2d')
# Load a trace object directly
trace = FlatTrace(spectrum2d, trace_pos=25)
jd.load(trace, data_label='My Trace')
Data Requirements#
The data must be a specreduce.tracing.Trace object or one of its subclasses:
Supported Trace Types#
FlatTrace: A horizontal trace at a constant pixel position
FitTrace: A trace fit to the data using polynomial, Legendre, Chebyshev, or spline models
ArrayTrace: A trace defined by an array of pixel positions
Each trace object must reference the 2D spectrum data it applies to and define the extraction path.
Supported File Formats#
Trace objects are Python objects created using the specreduce package and cannot
be directly loaded from files. They must be:
Created programmatically using
specreduce.tracingclassesGenerated by the Spectral Extraction plugin and exported
Loaded as Python objects in a notebook or script
Working with Traces#
Traces are typically created in the Spectral Extraction plugin or programmatically:
from specreduce.tracing import FitTrace
from astropy.modeling import models
# Create a polynomial fit trace
trace = FitTrace(spectrum2d, guess=27,
trace_model=models.Polynomial1D(degree=2))
# Load into Specviz2D
specviz2d.load(trace, data_label='polynomial_trace')
Once loaded, traces appear in the 2D spectrum viewer and can be used for spectral extraction.
UI Access#
See Also#
2D Spectral Extraction - Creating and using traces for extraction
specreduce documentation - Details on trace types