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:
FitsMaskedImageFormatterConcrete formatter for reading/writing
Exposurefrom/to FITS.Notes#
This class inherits from
FitsMaskedImageFormattereven thoughlsst.afw.image.Exposuredoesn’t inherit fromlsst.afw.image.MaskedImage; this is just an easy way to be able to delegate toFitsMaskedImageFormatter.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
Declare whether
read_from_uriis 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_uriis 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_dataset
object The dataset to serialize.
- provenance
DatasetProvenanceorNone, optional Provenance to attach to dataset.
Returns#
- dataset_to_write
object The dataset to use for serialization. Can be the same object as given.
Notes#
The base class implementation returns the given object unchanged.
- in_memory_dataset
- readComponent(component)#
Read a component dataset.
Parameters#
- component
str, optional Component to read from the file.
Returns#
- objcomponent-dependent
In-memory component object.
Raises#
- KeyError
Raised if the requested component cannot be handled.
- component
- 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#
- uri
lsst.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.
- component
strorNone, optional The component to be read from the dataset.
- expected_size
int, optional If known, the expected size of the resource to read. This can be
-1indicates the file size is not known.
Returns#
- in_memory_dataset
objectorNotImplemented 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_uriis set toTrue.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
NotImplementedin this situation, for example if there are no parameters or component specified, and allowing the system to fall back to callingread_from_local_file(which will populate the cache if configured to do so).- uri