scopesim.effects.spectral_trace_list.SpectralTraceList#

class scopesim.effects.spectral_trace_list.SpectralTraceList(**kwargs)#

Bases: Effect

List of spectral trace geometries for the detector plane.

Should work in concert with an ApertureList (or ApertureMask) object and a DetectorList object

Spectral trace patterns are to be kept in a fits.HDUList with one or more fits.BinTableHDU extensions, each one describing the geometry of a single trace. The first extension should be a BinTableHDU connecting the traces to the correct Aperture and ImagePlane objects.

The fits.HDUList objects can be loaded using one of these two keywords:

  • filename: for on disk FITS files, or

  • hdulist: for in-memory fits.HDUList objects

The format and contents of the extensions in the HDUList (FITS file) object is listed below

Input Data Format#

A trace list FITS file needs the following extensions:

  • 0 : PrimaryHDU [header]

  • 1 : BinTableHDU [header, data] : Overview table of all traces

  • 2..N : BinTableHDU [header, data] : Trace tables. One per spectral trace

EXT 0 : PrimaryHDU#

Required Header Keywords:

  • ECAT : int : Extension number of overview table. Normally 1

  • EDATA : int : Extension number of first Trace table. Normally 2

No data is required in this extension

EXT 1 : BinTableHDU : Overview of traces#

No special header keywords are required in this extension

Required Table columns:

  • description : str : identifier of each trace

  • extension_id : int : which extension is each trace in

  • aperture_id : int : which aperture matches this trace (e.g. MOS / IFU)

  • image_plane_id : int : on which image plane is this trace projected

EXT 2 : BinTableHDU : Individual traces#

Required header keywords: - EXTNAME : must be identical to the description in EXT 1

Recommended header keywords: - DISPDIR : “x” or “y” : dispersion axis. If not present, Scopesim tries

to determine this automatically; this may be unreliable in some cases.

Required Table columns: - wavelength : float : [um] : wavelength of monochromatic aperture image - s : float : [arcsec] : position along aperture perpendicular to trace - x : float : [mm] : x position of aperture image on focal plane - y : float : [mm] : y position of aperture image on focal plane

__init__(**kwargs)#

Methods

__init__(**kwargs)

apply_to(obj, **kwargs)

Interface between FieldOfView and SpectralTraceList.

get_from_meta(item)

info()

Print basic information on the effect, notably the description.

make_spectral_traces()

Return a dictionary of spectral traces read in from a file.

plot([wave_min, wave_max, axes])

Plot every spectral trace in the spectral trace list.

rectify_cube(hdulist)

Rectify traces and combine into a cube.

rectify_traces(hdulist[, xi_min, xi_max, ...])

Create rectified 2D spectra for all traces in the list.

report([filename, output, rst_title_chars])

For Effect objects, generates a report based on the data and meta-data.

update_meta()

Update fov related meta values.

Attributes

data

display_name

footprint

Return the footprint of the entire SpectralTraceList.

image_plane_header

Create and return header for the ImagePlane.

include

meta_string

report_plot_include

report_table_include

required_keys

table

z_order

apply_to(obj, **kwargs)#

Interface between FieldOfView and SpectralTraceList.

This is called twice: 1. During setup of the required FieldOfView objects, the SpectralTraceList is asked for the source space volumes that it requires (spatial limits and wavelength limits). 2. During “observation” the method is passed a single FieldOfView object and applies the mapping to the image plane to it. The FieldOfView object is associated to one SpectralTrace from the list, identified by meta[“trace_id”].

property footprint#

Return the footprint of the entire SpectralTraceList.

property image_plane_header#

Create and return header for the ImagePlane.

info() None#

Print basic information on the effect, notably the description.

make_spectral_traces()#

Return a dictionary of spectral traces read in from a file.

plot(wave_min=None, wave_max=None, axes=None, **kwargs)#

Plot every spectral trace in the spectral trace list.

Parameters:
  • wave_min (float, optional) – Minimum wavelength, if any. If None, value from_currsys is used.

  • wave_max (float, optional) – Maximum wavelength, if any. If None, value from_currsys is used.

  • axes (matplotlib axes, optional) – The axes object to use for the plot. If None (default), a new figure with one axes will be created.

  • **kwargs (dict) – Any other parameters passed along to the plot method of the individual spectral traces.

Returns:

fig – DESCRIPTION.

Return type:

matplotlib figure

rectify_cube(hdulist)#

Rectify traces and combine into a cube.

rectify_traces(hdulist, xi_min=None, xi_max=None, interps=None, **kwargs)#

Create rectified 2D spectra for all traces in the list.

This method creates an HDU list with one extension per spectral trace, i.e. it essentially treats all traces independently. For the case of an IFU where the traces correspond to spatial slices for the same wavelength range, use method rectify_cube (not yet implemented).

Parameters:
  • hdulist (str or fits.HDUList) – The result of scopesim readout()

  • xi_min (float [arcsec]) – Spatial limits of the slit on the sky. This should be taken from the header of the hdulist, but this is not yet provided by scopesim. For the time being, these limits must be provided by the user.

  • xi_max (float [arcsec]) – Spatial limits of the slit on the sky. This should be taken from the header of the hdulist, but this is not yet provided by scopesim. For the time being, these limits must be provided by the user.

  • interps (list of interpolation functions) – If provided, there must be one for each image extension in hdulist. The functions go from pixels to the images and can be created with, e.g. RectBivariateSpline.

report(filename=None, output='rst', rst_title_chars='*+', **kwargs)#

For Effect objects, generates a report based on the data and meta-data.

This is to aid in the automation of the documentation process of the instrument packages in the IRDB.

Note

If the Effect can generate a plot, this will be saved to disc

Parameters:
  • filename (str, optional) – Where to save the RST file

  • output (str, optional) – [“rst”, “latex”] Output file format

  • rst_title_chars (2-str, optional) – Two unique characters used to denote rst subsection headings. Options: = - ` : ‘ “ ~ ^ _ * + # < >

  • parameters (Additional)

  • ---------------------

  • **kwargs (Either from the self.meta["report"] dictionary or via)

  • "report_table_include" (False)

  • "report_table_caption"

  • "report_plot_caption"

  • "report_plot_include" (False)

  • "report_plot_file_formats" (["png"]) – Multiple formats can be saved. The last entry is used for the RST.

  • "report_plot_filename" (None) – If None, uses self.meta[“name”] as the filename

  • "file_description" (str) – Taken from the header of a file, if available

  • "class_description" (str) – Taken from the docstring of the subclass

  • "changes_str" (list of str) – Take from the header of a file, if available

Returns:

rst_str – The full reStructureText string

Return type:

str

Notes

The format of the RST output is as follows:

<ClassType>: <effect name>
**************************
File Description: <description for file meta data>
Class Description: <description from class docstring>
Changes: <list of changes from file meta data>

Data
++++
.. figure:: <Figure_name>.png
    If the <Effect> object contains a ``.plot()`` function, add
    plot and write it to disc
Figure caption

Table caption
Table
    If the <Effect> object contains a ``.table()`` function, add
    a pprint version of the table

Meta-data
+++++++++
::
    A code block print out of the ``.meta`` dictionary
update_meta()#

Update fov related meta values.

The values describe the full extent of the spectral trace volume in wavelength and space