FitsExposureFormatter#

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

Bases: FitsMaskedImageFormatter

Concrete formatter for reading/writing Exposure from/to FITS.

Notes#

This class inherits from FitsMaskedImageFormatter even though lsst.afw.image.Exposure doesn’t inherit from lsst.afw.image.MaskedImage; this is just an easy way to be able to delegate to FitsMaskedImageFormatter.super() for component-handling, and should be replaced with e.g. both calling a free function if that slight type covariance violation ever becomes a practical problem.

Attributes Summary

can_read_from_uri

Declare whether read_from_uri is available to this formatter.

Methods Summary

add_provenance(in_memory_dataset, /, *[, ...])

Add provenance to the dataset.

readComponent(component)

Read a component dataset.

readFull()

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

read_from_uri(uri[, component, expected_size])

Read a dataset from a URI that can be local or remote.

Attributes Documentation

can_read_from_uri: ClassVar[bool] = True#

Declare whether read_from_uri is available to this formatter.

Methods Documentation

add_provenance(in_memory_dataset: Any, /, *, provenance: DatasetProvenance | None = None) Any#

Add provenance to the dataset.

Parameters#

in_memory_datasetobject

The dataset to serialize.

provenanceDatasetProvenance or None, optional

Provenance to attach to dataset.

Returns#

dataset_to_writeobject

The dataset to use for serialization. Can be the same object as given.

Notes#

The base class implementation returns the given object unchanged.

readComponent(component)#

Read a component dataset.

Parameters#

componentstr, optional

Component to read from the file.

Returns#

objcomponent-dependent

In-memory component object.

Raises#

KeyError

Raised if the requested component cannot be handled.

readFull()#

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

Returns#

objcomponent-dependent

In-memory component object.

read_from_uri(uri: ResourcePath, component: str | None = None, expected_size: int = -1) Any#

Read a dataset from a URI that can be local or remote.

Parameters#

urilsst.resources.ResourcePath

URI to use to read the dataset. This URI can be local or remote and can refer to the actual resource or to a locally cached file.

componentstr or None, optional

The component to be read from the dataset.

expected_sizeint, optional

If known, the expected size of the resource to read. This can be -1 indicates the file size is not known.

Returns#

in_memory_datasetobject or NotImplemented

The Python object read from the resource or NotImplemented.

Raises#

FormatterNotImplementedError

Raised if there is no support for direct reads from a, possibly, remote URI.

Notes#

This method is only called if the class property can_read_from_uri is set to True.

It is possible that a cached local file will be given to this method even if it was originally a remote URI. This can happen if the original write resulted in the file being added to the local cache.

If the full file is being read this file will not be added to the local cache. Consider returning NotImplemented in this situation, for example if there are no parameters or component specified, and allowing the system to fall back to calling read_from_local_file (which will populate the cache if configured to do so).