FitsImageFormatterBase#

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

Bases: FormatterV2

Base class formatter for image-like storage classes stored via FITS.

Notes#

This class makes no assumptions about how many HDUs are used to represent the image on disk, and includes no support for writing. It’s really just a collection of miscellaneous boilerplate common to all FITS image formatters.

Concrete subclasses must implement readComponent, readFull, and write_local_file (even if just to disable them by raising an exception).

Attributes Summary

can_read_from_local_file

Declare whether read_from_local_file is available to this formatter.

checked_parameters

The parameters passed by the butler user, after checking them against the storage class and transforming None into an empty dict (dict).

default_extension

Default extension to use when writing a file.

reader

The reader object that backs this formatter's read operations.

storageClass_dtype

The numpy data type associated with the storage class.

supported_extensions

Set of all extensions supported by this formatter.

unsupported_parameters

Support all parameters.

Methods Summary

readComponent(component)

Read a component dataset.

readFull()

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

read_from_local_file(path[, component, ...])

Read a dataset from a URI guaranteed to refer to the local file system.

Attributes Documentation

can_read_from_local_file: ClassVar[bool] = True#

Declare whether read_from_local_file is available to this formatter.

checked_parameters#

The parameters passed by the butler user, after checking them against the storage class and transforming None into an empty dict (dict).

This is computed on first use and then cached. It should never be accessed when writing. Subclasses that need additional checking should delegate to super and then check the result before returning it.

default_extension: ClassVar[str | None] = '.fits'#

Default extension to use when writing a file.

Can be None if the extension is determined dynamically. Use the get_write_extension method to get the actual extension to use.

reader#

The reader object that backs this formatter’s read operations.

This is computed on first use and then cached. It should never be accessed when writing. Currently assumes a local file.

storageClass_dtype#

The numpy data type associated with the storage class.

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_extension property will be automatically included in the list of supported extensions.

unsupported_parameters: ClassVar[Set[str]] = frozenset({})#

Support all parameters.

Methods Documentation

abstract 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.

abstract readFull() Any#

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

Returns#

objtyping.Any

In-memory component object.

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#

pathstr

Path to a local file that should be read.

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#

lsst.daf.butler.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_file is True and other options were not used.