pypeit.alignframe module

Module for generating an Alignment image to map constant spatial locations

class pypeit.alignframe.AlignmentSplines(traces, locations, tilts)[source]

Bases: object

build_splines()[source]

Build the interpolation transforms for each slit

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

numpy.ndarray

numpy.floating

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

numpy.ndarray

numpy.integer

Slit spat_id

traces

numpy.ndarray

numpy.floating

Traces of the alignment frame

_bundle()[source]

Override the base class method simply to set the HDU extension name.

_validate()[source]

Validation method that is executed every time a CalibFrame is instantiated.

Ensures:

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 traces

  • det (int, optional) – Detector number

  • qa_path (str, optional) – Directory for QA plots

  • msbpm (numpy.ndarray, optional) – Bad pixel mask image

steps

List of the processing steps performed.

Type:

list

spectrograph

Relevant spectrograph.

Type:

Spectrograph

slits

Slit edge traces.

Type:

SlitTraceSet

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:

dict

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:

numpy.ndarray

property nslits

Return the number of slits. Pulled directly from slits, if it exists.

property nspec

Return the number of spectral elements. Pulled directly from slits, if it exists.

run(show=False)[source]

Main driver for alignment profile tracing

Parameters:

show (bool, optional) – Show the alignment traces?

Return type:

pypeit.alignframe.Alignments

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?