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:
FitsImageFormatterBaseBase class interface for image-like storage stored via FITS, written using LSST code.
Notes#
Concrete subclasses must provide at least the
ReaderClassattribute.The provided implementation of
readComponenthandles only the ‘bbox’, ‘dimensions’, and ‘xy0’ components common to all image-like storage classes. Subclasses with additional components should handle them first, then delegate tosuper()for these (or, if necessary, delegate first and catchKeyError).The provided implementation of
readFullhandles only parameters that can be forwarded directly to the reader class (usuallybboxandorigin). 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
writeFitsand (for write recipes)writeFitsWithOptionsmethods.Each
StandardFitsImageFormatterBaserecipe for FITS compression should defineimage,maskandvarianceentries, each of which may contain entries supported bylsst.afw.fits.CompressionOptions.from_mapping(nulldisables compression).A very simple example YAML recipe (for the
lsst.afw.image.Exposurespecialization):lsst.obs.base.fitsExposureFormatter.FitsExposureFormatter: default: image: &default algorithm: GZIP_2 mask: *default variance: *default
Attributes Summary
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.
Noneindicates that no parameters are supported.
Methods Documentation
- get_image_compression_settings(recipeName: str | None) dict#
Retrieve the relevant compression settings for this recipe.
Parameters#
- recipeName
strorNone Label associated with the collection of compression parameters to select.
Returns#
- settings
dict The selected settings.
- recipeName
- readComponent(component: str) Any#
Read a component dataset.
Parameters#
- component
str, optional Component to read from the file.
Returns#
- obj
typing.Any In-memory component object.
Raises#
- KeyError
Raised if the requested component cannot be handled.
- component
- readFull() Any#
Read the full dataset (while still accounting for parameters).
Returns#
- obj
typing.Any In-memory component object.
- obj
- 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#
- recipes
dictorNone 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.
- recipes
- write_local_file(in_memory_dataset: Any, uri: ResourcePath) None#
Serialize the image to FITS.
Parameters#
- in_memory_dataset
object Image to write. Must support a
writeFitsorwriteFitsWithOptionsinterface.- uri
lsst.resources.ResourcePath Location to write the local file.
- in_memory_dataset