lezargus.library.container.dispersion module#

Container classes to hold spectral dispersion patterning and pixel locations.

These class serves as a simpler interface for the spectral dispersion, displaying where light should end up on a detector due to dispersive and imaging elements.

Note that the dispersion classes are unique to each instrument and its usage must be done carefully.

class lezargus.library.container.dispersion.SpectreDispersionPattern(dispersion_table: hint.Table)[source]#

Bases: object

The dispersion pattern for SPECTRE.

This dispersion pattern class should only be used for the SPECTRE instrument! Any other instrument is unsupported with this class.

__init__(dispersion_table: hint.Table) None[source]#

Initialize the dispersion pattern class.

This class should not be invoked directly. Please read in a dispersion table file via read_dispersion_table(). The format of the dispersion table is a bit specific, see verify_dispersion_table().

Parameters:

dispersion_table (Astropy Table) – The dispersion table which holds the locations of the dispersive points. If the table doesn’t match the expected format, an error is logged.

Return type:

None

_query_dispersion_table(channel: str, slice_: int, column: str) hint.NDArray[source]#

Query the dispersion table, filtering for the right data.

This is a helper function for querying the dispersion table. It serves mostly to act as a wrapper around the filtering mechanisms as we pull data out of the table. It also has a few checks. We always do all wavelengths.

Parameters:
  • channel (str) – The name of the channel which you are getting the dispersion coordinate for; the map for all three are a little different. Must be one of: visible, nearir, midir.

  • slice (int) – The slice index to indicate which slice you are getting. Must be within 1-36 (or whatever count of slices there are); this is not zero indexed.

  • column (str) –

    The name of the data column of the table you want to query or # filter to. Available options:

    • wavelength: The wavelength column.

    • center_x or center_y: The X or Y data of the center.

    • top_x or top_y: The X or Y data of the top.

    • bottom_x or bottom_y: The X or Y data of the bottom.

    • left_x or left_y: The X or Y data of the left.

    • right_x or right_y: The X or Y data of the right.

Returns:

data – The queried and filtered data from the table. Please note, we do preserve unit objects in the query. As this is an internal function, the known convention of the input table is enough.

Return type:

NDarray

dispersion_table: hint.Table#

The dispersion table detailing the spectral dispersion and pattern of the light on a detector. The format of this table should pass internal checks and so we do not suggest changing this table manually.

get_slice_dispersion_coordinate(channel: str, slice_: int, location: str, wavelength: hint.NDArray) list[tuple[float, float]][source]#

Get the coordinate location on the detector, in linear units.

Note, this function returns the coordinates in meters, consider using py:meth:get_slice_dispersion_pixel for the pixel coordinates.

Parameters:
  • channel (str) – The name of the channel which you are getting the dispersion coordinate for; the map for all three are a little different. Must be one of: visible, nearir, midir.

  • slice (int) – The slice index to indicate which slice you are getting. Must be within 1-36 (or whatever count of slices there are); this is not zero indexed.

  • location (str) –

    The location of the area you want relative to the center of the slice. Acceptable terms:

    • center: The center of the slice.

    • left or right: The direct left and right from the center.

    • top or bottom: The direct top and bottom from the center.

    • top_left or top_right: The top left and right corners.

    • bottom_left or bottom_right: The bottom corners.

  • wavelength (float | NDArray) – The wavelength(s) to get the coordinates for the dispersion for, required as this is to model spectral dispersion using its spatial displacement effects.

Returns:

coordinate_pairs – The list of the (X, Y) coordinate pairs, parallel with the provided wavelength array.

Return type:

list

get_slice_dispersion_pixel(channel: str, slice_: int, location: str, wavelength: hint.NDArray) list[tuple[float, float]][source]#

Get the coordinate location on the detector, in pixels.

Note, this function returns the coordinates in pixel units. We convert from the linear units from the original function py:meth:get_slice_dispersion_coordinate to pixel units based on the pixel scale of each detector within the channel. This is mostly a convenience function and the main function is the predominant source of the documentation.

Parameters:
  • channel (str) – The name of which of the three channels being queried.

  • slice (int) – The slice index, 1-36 inclusive, for the slice being queried.

  • location (str) –

    The location of the area you want relative to the center of the slice. Acceptable terms:

    • center: The center of the slice.

    • left or right: The direct left and right from the center.

    • top or bottom: The direct top and bottom from the center.

    • top_left or top_right: The top left and right corners.

    • bottom_left or bottom_right: The bottom corners.

  • wavelength (float | NDArray) – The wavelength(s) to get the coordinates for the dispersion.

Returns:

pixel_coordinate_pairs – The list of the (X, Y) coordinate pairs in pixel units, parallel with the provided wavelength array.

Return type:

list

midir_pixel_size: float#

The pixel size of the mid IR channel detector, taken from the data constants.

nearir_pixel_size: float#

The pixel size of the near IR channel detector, taken from the data constants.

classmethod read_dispersion_table(filename: str) hint.Self[source]#

Read a dispersion table file and create the dispersion class.

Parameters:

filename (str) – The filename of the dispersion table we are reading in.

Returns:

dispersion_class – The dispersion class.

Return type:

SpectreDispersionPattern

static verify_dispersion_table(table: hint.Table) bool[source]#

Verify that the provided dispersion table has the expected fields.

We pull the required data for dispersion determination from the table, and so the format of the table needs to adhere to specific specifications and assumptions.

Parameters:

table (Astropy Table) – The table we are testing.

Returns:

verification – If True, the table passes all of our verification tests and should be good enough for this class.

Return type:

bool

visible_pixel_size: float#

The pixel size of the visible channel detector, taken from the data constants.