Image

Image reading and processing module

class ImageModel(*, size: List[int], dataslice: List[List[int]], detslice: List[List[int]], background_level: List[float], background_mad: List[float], min_max: List[List[float]], header: dict)[source]

Bases: BaseModel

Pydantic image model class.

Parameters:
  • size (List[int]) -- Image shape, FITS style (x comes first)

  • dataslice (List[List[int]]) -- Active area slice parameters, FITS style

  • detslice (List[List[int]]) -- Mosaic area slice parameters, FITS style

  • min_max (List[List[float]]) -- Lower and upper intensity cuts for each channel

  • header (dict) -- FITS header dictionary

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'background_level': FieldInfo(annotation=List[float], required=True), 'background_mad': FieldInfo(annotation=List[float], required=True), 'dataslice': FieldInfo(annotation=List[List[int]], required=True), 'detslice': FieldInfo(annotation=List[List[int]], required=True), 'header': FieldInfo(annotation=dict, required=True), 'min_max': FieldInfo(annotation=List[List[float]], required=True), 'size': FieldInfo(annotation=List[int], required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class Image(hdu: ImageHDU, minmax: Tuple[float] | None = None)[source]

Bases: object

Class for the individual images that can be part of a mosaic.

Parameters:
  • header (Header) -- Image header.

  • data (ndarray) -- Image data

  • extnum (int) -- Position in mosaic or Extension number (for Multi-Extension FITS files).

  • minmax (tuple[float,float], optional) -- Default intensity cuts.

get_model() ImageModel[source]

Return a Pydantic model of the image

Returns:

model (ImageModel) -- Pydantic model instance of the image

get_header_string() str[source]

Get the image header as a string.

Returns:

header (str) -- Image header string.

parse_2dslice(str: str) List[int] | None[source]

Parse a string representation of a 2D slice.

Parameters:

str (str) -- Input string.

Returns:

tile (tuple[int,int,int,int]) -- 4-tuple representing the slice parameters or 4-tuple of Nones if not found.

compute_geometry(start: Tuple[int, int], shape: Tuple[int, int, int]) None[source]

Compute geometry parameters related to the image position in a mosaic.

Parameters:
  • start (Tuple[int, int]) -- Position of starting point in mosaic (Python style).

  • shape (Tuple[int, int, int]) -- Shape of the mosaic (Python style).

compute_background(skip: int = 15) tuple[ndarray, ndarray][source]

Return background level and median absolute deviation of every image channel.

Parameters:

skip (int, optional) -- Number of lines skipped after each line analyzed.

Returns:

  • background_level (~numpy.ndarray) -- Background level for every channel.

  • background_mad (~numpy.ndarray) -- Background median absolute deviation for every channel.

compute_minmax(background_level: ndarray, background_mad: ndarray, nmadmin: float = -2.0, nmadmax: float = 400.0) ndarray[source]

Return matrix of "appropriate" intensity cuts for displaying the image.

Parameters:
  • background_level (ndarray) -- Background level for every channel.

  • background_mad (ndarray) -- Background median absolute deviation for every channel.

  • grey (float, optional) -- Lower intensity cut above background in units of Maximum Absolute Deviations.

  • nmad (float, optional) -- Upper intensity cut above background in units of Maximum Absolute Deviations.

Returns:

minmax (~numpy.ndarray) -- Intensity cuts for displaying the image.