FitsGenericFormatter#
- class lsst.obs.base.formatters.fitsGeneric.FitsGenericFormatter(file_descriptor: FileDescriptor, *, ref: DatasetRef, write_parameters: Mapping[str, Any] | None = None, write_recipes: Mapping[str, Any] | None = None, **kwargs: Any)#
Bases:
FormatterV2Interface for reading and writing objects that support the standard afw I/O readFits/writeFits methods.
Attributes Summary
Declare whether
read_from_fileis available to this formatter.Default extension to use when writing a file.
Set of all extensions supported by this formatter.
Methods Summary
add_provenance(in_memory_dataset, /, *[, ...])Add provenance to the dataset.
read_from_local_file(path[, component, ...])Read a dataset from a URI guaranteed to refer to the local file system.
write_local_file(in_memory_dataset, uri)Serialize the in-memory dataset to a local file.
Attributes Documentation
- can_read_from_local_file: ClassVar[bool] = True#
Declare whether
read_from_fileis available to this formatter.
- default_extension: ClassVar[str | None] = '.fits'#
Default extension to use when writing a file.
Can be
Noneif the extension is determined dynamically. Use theget_write_extensionmethod to get the actual extension to use.
- supported_extensions: ClassVar[Set[str]] = frozenset({'.fit', '.fits', '.fits.fz', '.fits.gz', '.fz'})#
Set of all extensions supported by this formatter.
Any extension assigned to the
default_extensionproperty will be automatically included in the list of supported extensions.
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
- read_from_local_file(path: str, component: str | None = None, expected_size: int = -1) Any#
Read a dataset from a URI guaranteed to refer to the local file system.
Parameters#
- path
str Path to a local file that should be read.
- 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 implementation written to read data from a local file.
Notes#
This method will only be called if the class property
can_read_from_local_fileisTrueand other options were not used.- path
- write_local_file(in_memory_dataset: Any, uri: ResourcePath) None#
Serialize the in-memory dataset to a local file.
Parameters#
- in_memory_dataset
object The Python object to serialize.
- uri
ResourcePath The URI to use when writing the file.
Notes#
By default this method will attempt to call
to_bytesand then write these bytes to the file.Raises#
- FormatterNotImplementedError
Raised if the formatter subclass has not implemented this method or has failed to implement the
to_bytesmethod.
- in_memory_dataset