lsst.obs.base  21.0.0-12-ge5f8019+e3fa360c9c
Public Member Functions | Static Public Attributes | List of all members
lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter Class Reference
Inheritance diagram for lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter:
lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase lsst.obs.base.formatters.fitsExposure.FitsImageFormatter lsst.obs.base.formatters.fitsExposure.FitsMaskedImageFormatter lsst.obs.base.formatters.fitsExposure.FitsMaskFormatter

Public Member Functions

def metadata (self)
 
def readMetadata (self)
 
def stripMetadata (self)
 
def readComponent (self, component, parameters=None)
 
def readFull (self, parameters=None)
 
def read (self, component=None)
 
def write (self, inMemoryDataset)
 
def getImageCompressionSettings (self, recipeName)
 
def validateWriteRecipes (cls, recipes)
 

Static Public Attributes

 supportedExtensions = frozenset({".fits", ".fits.gz", ".fits.fz", ".fz", ".fit"})
 
string extension = ".fits"
 
 supportedWriteParameters = frozenset({"recipe"})
 
dictionary unsupportedParameters = {}
 

Detailed Description

Interface for reading and writing Exposures to and from FITS files.

This Formatter supports write recipes.

Each ``FitsExposureFormatter`` recipe for FITS compression should
define ``image``, ``mask`` and ``variance`` entries, each of which may
contain ``compression`` and ``scaling`` entries. Defaults will be
provided for any missing elements under ``compression`` and
``scaling``.

The allowed entries under ``compression`` are:

* ``algorithm`` (`str`): compression algorithm to use
* ``rows`` (`int`): number of rows per tile (0 = entire dimension)
* ``columns`` (`int`): number of columns per tile (0 = entire dimension)
* ``quantizeLevel`` (`float`): cfitsio quantization level

The allowed entries under ``scaling`` are:

* ``algorithm`` (`str`): scaling algorithm to use
* ``bitpix`` (`int`): bits per pixel (0,8,16,32,64,-32,-64)
* ``fuzz`` (`bool`): fuzz the values when quantising floating-point values?
* ``seed`` (`int`): seed for random number generator when fuzzing
* ``maskPlanes`` (`list` of `str`): mask planes to ignore when doing
  statistics
* ``quantizeLevel`` (`float`): divisor of the standard deviation for
  ``STDEV_*`` scaling
* ``quantizePad`` (`float`): number of stdev to allow on the low side (for
  ``STDEV_POSITIVE``/``NEGATIVE``)
* ``bscale`` (`float`): manually specified ``BSCALE``
  (for ``MANUAL`` scaling)
* ``bzero`` (`float`): manually specified ``BSCALE``
  (for ``MANUAL`` scaling)

A very simple example YAML recipe:

.. code-block:: yaml

    lsst.obs.base.fitsExposureFormatter.FitsExposureFormatter:
      default:
        image: &default
          compression:
            algorithm: GZIP_SHUFFLE
        mask: *default
        variance: *default

Definition at line 36 of file fitsExposure.py.

Member Function Documentation

◆ getImageCompressionSettings()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.getImageCompressionSettings (   self,
  recipeName 
)
Retrieve the relevant compression settings for this recipe.

Parameters
----------
recipeName : `str`
    Label associated with the collection of compression parameters
    to select.

Returns
-------
settings : `dict`
    The selected settings.

Definition at line 299 of file fitsExposure.py.

◆ metadata()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.metadata (   self)
The metadata read from this file. It will be stripped as
components are extracted from it
(`lsst.daf.base.PropertyList`).

Definition at line 94 of file fitsExposure.py.

◆ read()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.read (   self,
  component = None 
)
Read data from a file.

Parameters
----------
component : `str`, optional
    Component to read from the file. Only used if the `StorageClass`
    for reading differed from the `StorageClass` used to write the
    file.

Returns
-------
inMemoryDataset : `object`
    The requested data as a Python object. The type of object
    is controlled by the specific formatter.

Raises
------
ValueError
    Component requested but this file does not seem to be a concrete
    composite.
KeyError
    Raised when parameters passed with fileDescriptor are not
    supported.

Definition at line 237 of file fitsExposure.py.

◆ readComponent()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.readComponent (   self,
  component,
  parameters = None 
)
Read a component held by the Exposure.

Parameters
----------
component : `str`, optional
    Component to read from the file.
parameters : `dict`, optional
    If specified, a dictionary of slicing parameters that
    overrides those in ``fileDescriptor``.

Returns
-------
obj : component-dependent
    In-memory component object.

Raises
------
KeyError
    Raised if the requested component cannot be handled.

Reimplemented in lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.

Definition at line 144 of file fitsExposure.py.

◆ readFull()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.readFull (   self,
  parameters = None 
)
Read the full Exposure object.

Parameters
----------
parameters : `dict`, optional
    If specified a dictionary of slicing parameters that overrides
    those in ``fileDescriptor``.

Returns
-------
exposure : `~lsst.afw.image.Exposure`
    Complete in-memory exposure.

Reimplemented in lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.

Definition at line 214 of file fitsExposure.py.

◆ readMetadata()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.readMetadata (   self)
Read all header metadata directly into a PropertyList.

Returns
-------
metadata : `~lsst.daf.base.PropertyList`
    Header metadata.

Definition at line 103 of file fitsExposure.py.

◆ stripMetadata()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.stripMetadata (   self)
Remove metadata entries that are parsed into components.

This is only called when just the metadata is requested; stripping
entries there forces code that wants other components to ask for those
components directly rather than trying to extract them from the
metadata manually, which is fragile.  This behavior is an intentional
change from Gen2.

Parameters
----------
metadata : `~lsst.daf.base.PropertyList`
    Header metadata, to be modified in-place.

Reimplemented in lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.

Definition at line 115 of file fitsExposure.py.

◆ validateWriteRecipes()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.validateWriteRecipes (   cls,
  recipes 
)
Validate supplied recipes for this formatter.

The recipes are supplemented with default values where appropriate.

TODO: replace this custom validation code with Cerberus (DM-11846)

Parameters
----------
recipes : `dict`
    Recipes to validate. Can be empty dict or `None`.

Returns
-------
validated : `dict`
    Validated recipes. Returns what was given if there are no
    recipes listed.

Raises
------
RuntimeError
    Raised if validation fails.

Definition at line 336 of file fitsExposure.py.

◆ write()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.write (   self,
  inMemoryDataset 
)
Write a Python object to a file.

Parameters
----------
inMemoryDataset : `object`
    The Python object to store.

Reimplemented in lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.

Definition at line 275 of file fitsExposure.py.

Member Data Documentation

◆ extension

string lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.extension = ".fits"
static

Definition at line 85 of file fitsExposure.py.

◆ supportedExtensions

lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.supportedExtensions = frozenset({".fits", ".fits.gz", ".fits.fz", ".fz", ".fit"})
static

Definition at line 84 of file fitsExposure.py.

◆ supportedWriteParameters

lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.supportedWriteParameters = frozenset({"recipe"})
static

Definition at line 87 of file fitsExposure.py.

◆ unsupportedParameters

dictionary lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.unsupportedParameters = {}
static

Definition at line 90 of file fitsExposure.py.


The documentation for this class was generated from the following file: