StandardFitsImageFormatterBase#

class lsst.obs.base.formatters.fitsExposure.StandardFitsImageFormatterBase(file_descriptor: FileDescriptor, *, ref: DatasetRef, write_parameters: Mapping[str, Any] | None = None, write_recipes: Mapping[str, Any] | None = None, **kwargs: Any)#

Bases: FitsImageFormatterBase

Base class interface for image-like storage stored via FITS, written using LSST code.

Notes#

Concrete subclasses must provide at least the ReaderClass attribute.

The provided implementation of readComponent handles only the ‘bbox’, ‘dimensions’, and ‘xy0’ components common to all image-like storage classes. Subclasses with additional components should handle them first, then delegate to super() for these (or, if necessary, delegate first and catch KeyError).

The provided implementation of readFull handles only parameters that can be forwarded directly to the reader class (usually bbox and origin). Concrete subclasses that need to handle additional parameters should generally reimplement without delegating (the implementation is trivial).

This Formatter supports write recipes, and assumes its in-memory type has writeFits and (for write recipes) writeFitsWithOptions methods.

Each StandardFitsImageFormatterBase recipe for FITS compression should define image, mask and variance entries, each of which may contain entries supported by lsst.afw.fits.CompressionOptions.from_mapping (null disables compression).

A very simple example YAML recipe (for the lsst.afw.image.Exposure specialization):

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

Attributes Summary

supported_write_parameters

Parameters understood by this formatter that can be used to control how a dataset is serialized.

Methods Summary

get_image_compression_settings(recipeName)

Retrieve the relevant compression settings for this recipe.

readComponent(component)

Read a component dataset.

readFull()

Read the full dataset (while still accounting for parameters).

validate_write_recipes(recipes)

Validate supplied recipes for this formatter.

write_local_file(in_memory_dataset, uri)

Serialize the image to FITS.

Attributes Documentation

supported_write_parameters: ClassVar[Set[str] | None] = frozenset({'recipe'})#

Parameters understood by this formatter that can be used to control how a dataset is serialized. None indicates that no parameters are supported.

Methods Documentation

get_image_compression_settings(recipeName: str | None) dict#

Retrieve the relevant compression settings for this recipe.

Parameters#

recipeNamestr or None

Label associated with the collection of compression parameters to select.

Returns#

settingsdict

The selected settings.

readComponent(component: str) Any#

Read a component dataset.

Parameters#

componentstr, optional

Component to read from the file.

Returns#

objtyping.Any

In-memory component object.

Raises#

KeyError

Raised if the requested component cannot be handled.

readFull() Any#

Read the full dataset (while still accounting for parameters).

Returns#

objtyping.Any

In-memory component object.

classmethod validate_write_recipes(recipes: Mapping[str, Any] | None) Mapping[str, Any] | None#

Validate supplied recipes for this formatter.

The recipes are supplemented with default values where appropriate.

Parameters#

recipesdict or None

Recipes to validate. Can be empty dict or None.

Returns#

validateddict

Validated recipes. Returns what was given if there are no recipes listed.

Raises#

RuntimeError

Raised if validation fails.

write_local_file(in_memory_dataset: Any, uri: ResourcePath) None#

Serialize the image to FITS.

Parameters#

in_memory_datasetobject

Image to write. Must support a writeFits or writeFitsWithOptions interface.

urilsst.resources.ResourcePath

Location to write the local file.