Image

Image reading and processing module

pydantic model ImageModel[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

Show JSON schema
{
   "title": "ImageModel",
   "description": "Pydantic image model class.\n\nParameters\n----------\nsize: List[int]\n    Image shape, FITS style (x comes first)\ndataslice: List[List[int]]\n    Active area slice parameters, FITS style\ndetslice: List[List[int]]\n    Mosaic area slice parameters, FITS style\nmin_max: List[List[float]]\n    Lower and upper intensity cuts for each channel\nheader: dict\n    FITS header dictionary",
   "type": "object",
   "properties": {
      "size": {
         "items": {
            "type": "integer"
         },
         "title": "Size",
         "type": "array"
      },
      "dataslice": {
         "items": {
            "items": {
               "type": "integer"
            },
            "type": "array"
         },
         "title": "Dataslice",
         "type": "array"
      },
      "detslice": {
         "items": {
            "items": {
               "type": "integer"
            },
            "type": "array"
         },
         "title": "Detslice",
         "type": "array"
      },
      "background_level": {
         "items": {
            "type": "number"
         },
         "title": "Background Level",
         "type": "array"
      },
      "background_mad": {
         "items": {
            "type": "number"
         },
         "title": "Background Mad",
         "type": "array"
      },
      "min_max": {
         "items": {
            "items": {
               "type": "number"
            },
            "type": "array"
         },
         "title": "Min Max",
         "type": "array"
      },
      "header": {
         "title": "Header",
         "type": "object"
      }
   },
   "required": [
      "size",
      "dataslice",
      "detslice",
      "background_level",
      "background_mad",
      "min_max",
      "header"
   ]
}

Fields:
field background_level: List[float] [Required]
field background_mad: List[float] [Required]
field dataslice: List[List[int]] [Required]
field detslice: List[List[int]] [Required]
field header: dict [Required]
field min_max: List[List[float]] [Required]
field size: List[int] [Required]
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.