pypeit.alignframe module
Module for generating an Alignment image to map constant spatial locations
- class pypeit.alignframe.AlignmentSplines(traces, locations, tilts)[source]
Bases:
object
- transform(slitnum, spatpix, specpix)[source]
Convenience function to return the spatial offset in pixels from the spatial center of the slit.
- Parameters:
slitnum (int) – Slit number
spatpix (numpy.ndarray) – Detector pixel coordinate (spatial direction)
specpix (numpy.ndarray) – Detector pixel coordinate (spectral direction)
- Returns:
spl_transform – The spatial offset (measured in pixels) from the center of the slit.
- Return type:
numpy.ndarray
- class pypeit.alignframe.Alignments(alignframe=None, nspec=None, nalign=None, nslits=None, traces=None, PYP_SPEC=None, spat_id=None)[source]
Bases:
CalibFrame
Calibration frame holding result of slit alignment processing.
All of the items in the datamodel are required for instantiation, although they can be None (but shouldn’t be)
The datamodel attributes are:
Version: 1.1.0
Attribute
Type
Array Type
Description
PYP_SPEC
str
PypeIt spectrograph name
alignframe
Processed, combined alignment frames
nalign
int
Number of alignment traces in each slit
nslits
int
The number of slits
nspec
int
The number of spectral elements
spat_id
Slit spat_id
traces
Traces of the alignment frame
- _validate()[source]
Validation method that is executed every time a
CalibFrame
is instantiated.Ensures:
calib_type
anddatamodel
are defined, andany members of
datamodel
of the base class are also members of the derived class.
- calib_file_format = 'fits'
The extension and file format of the output file. Should be
'fits'
or'fits.gz'
(for gzipped output).
- calib_type = 'Alignment'
The type of the calibration frame, primarily used to set the name of the output file.
- datamodel = {'PYP_SPEC': {'descr': 'PypeIt spectrograph name', 'otype': <class 'str'>}, 'alignframe': {'atype': <class 'numpy.floating'>, 'descr': 'Processed, combined alignment frames', 'otype': <class 'numpy.ndarray'>}, 'nalign': {'descr': 'Number of alignment traces in each slit', 'otype': <class 'int'>}, 'nslits': {'descr': 'The number of slits', 'otype': <class 'int'>}, 'nspec': {'descr': 'The number of spectral elements', 'otype': <class 'int'>}, 'spat_id': {'atype': <class 'numpy.integer'>, 'descr': 'Slit spat_id ', 'otype': <class 'numpy.ndarray'>}, 'traces': {'atype': <class 'numpy.floating'>, 'descr': 'Traces of the alignment frame', 'otype': <class 'numpy.ndarray'>}}
Default datamodel for any
CalibFrame
. Derived classes should instantiate their datamodels by first inheriting from the base class. E.g.:class ArcFrame(CalibFrame): datamodel = {**CalibFrame.datamodel, ...}
- is_synced(slits)[source]
Confirm the slits in the alignment are the same as that in SlitTraceSet
Barfs if not
- Parameters:
slits (
pypeit.slittrace.SlitTraceSet
)
- show(slits=None)[source]
Simple wrapper for
show_alignment()
.- Parameters:
slits (
pypeit.slittrace.SlitTraceSet
, optional) – Slit properties, including traces.
- version = '1.1.0'
Provides the string representation of the class version.
This is currently put to minimal use so far, but will used for I/O verification in the future.
Each derived class should provide a version to guard against data model changes during development.
- class pypeit.alignframe.TraceAlignment(rawalignimg, slits, spectrograph, alignpar, det=1, qa_path=None, msbpm=None)[source]
Bases:
object
Class to guide the determination of the alignment traces
- Parameters:
rawalignimg (
PypeItImage
) – Align image, created by the AlignFrame class. Can be None.slits (
SlitTraceSet
) – Slit edge traces. Can be None.spectrograph (
Spectrograph
) – The Spectrograph instance that sets the instrument used to take the observations. Can be None.alignpar (
AlignPar
) – The parameters used for the align tracesdet (
int
, optional) – Detector numberqa_path (
str
, optional) – Directory for QA plotsmsbpm (numpy.ndarray, optional) – Bad pixel mask image
- spectrograph
Relevant spectrograph.
- Type:
- slits
Slit edge traces.
- Type:
- build_traces(show_peaks=False, debug=False)[source]
Main routine to generate the align profile traces in all slits
- Parameters:
show_peaks (bool, optional) – Generate QA showing peaks identified by alignment profile tracing
show_trace (bool, optional) – Generate QA showing traces identified. Requires an open ginga RC modules window. Launch with
ginga --modules=RC,SlitWavelength &
debug (bool, optional) – Debug the alignment tracing algorithm
- Returns:
self.align_dict
- Return type:
- generate_traces(align_prof)[source]
Generate a dictionary containing all of the information from the profile fitting
- Parameters:
align_prof (
dict
) – Dictionary of SpecObjs classes (one for each slit)- Returns:
align_traces – Spatial traces (3D array of shape [nspec, ntraces, nslits])
- Return type:
- pypeit.alignframe.show_alignment(alignframe, align_traces=None, slits=None, clear=False)[source]
Show one of the class internals
- Parameters:
alignframe (numpy.ndarray) – Image to be plotted (i.e. the align frame)
align_traces (list, optional) – The align traces
slits (
pypeit.slittrace.SlitTraceSet
, optional) – properties of the slits, including traces.clear (bool, optional) – Clear the plotting window in ginga?