Coverage for python/lsst/daf/butler/formatters/fitsExposureFormatter.py : 78%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This file is part of daf_butler. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Interface for reading and writing Exposures to and from FITS files. """
"""Read the image, mask, or variance component of an Exposure.
Parameters ---------- fileDescriptor : `FileDescriptor` Identifies the file to read and parameters to be used for reading. component : `str`, optional Component to read from the file. Always one of "image", "variance", or "mask".
Returns ------- image : `~lsst.afw.image.Image` or `~lsst.afw.image.Mask` In-memory image, variance, or mask component. """ # TODO: could be made more efficient *if* Exposure type objects # held the class objects of their components.
"""Read all header metadata directly into a PropertyList.
Parameters ---------- fileDescriptor : `FileDescriptor` Identifies the file to read and parameters to be used for reading.
Returns ------- metadata : `~lsst.daf.base.PropertyList` Header metadata. """ from lsst.afw.image import readMetadata return readMetadata(fileDescriptor.location.path)
"""Remove metadata entries that are parsed into components.
This is only called when just the metadata is requested; stripping entries there forces code that wants other components to ask for those components directly rather than trying to extract them from the metadata manually, which is fragile. This behavior is an intentional change from Gen2.
Parameters ---------- metadata : `~lsst.daf.base.PropertyList` Header metadata, to be modified in-place. """ # TODO: make sure this covers everything, by delegating to something # that doesn't yet exist in afw.image.ExposureInfo. from lsst.afw.image import bboxFromMetadata from lsst.afw.geom import makeSkyWcs bboxFromMetadata(metadata) # always strips makeSkyWcs(metadata, strip=True)
"""Read a component held by ExposureInfo.
Parameters ---------- fileDescriptor : `FileDescriptor` Identifies the file to read and parameters to be used for reading. component : `str`, optional Component to read from the file.
Returns ------- obj : component-dependent In-memory component object. """
"""Read the full Exposure object.
Parameters ---------- fileDescriptor : `FileDescriptor` Identifies the file to read and parameters to be used for reading. parameters : `dict`, optional If specified a dictionary of slicing parameters that overrides those in ``fileDescriptor`.
Returns ------- exposure : `~lsst.afw.image.Exposure` Complete in-memory exposure. """ raise KeyError("Unrecognized parameter key(s): {}".format(parameters.keys() - self.parameters))
"""Read data from a file.
Parameters ---------- fileDescriptor : `FileDescriptor` Identifies the file to read, type to read it into and parameters to be used for reading. component : `str`, optional Component to read from the file. Only used if the `StorageClass` for reading differed from the `StorageClass` used to write the file.
Returns ------- inMemoryDataset : `object` The requested data as a Python object. The type of object is controlled by the specific formatter.
Raises ------ ValueError Component requested but this file does not seem to be a concrete composite. KeyError Raised when parameters passed with fileDescriptor are not supported. """ md = self.readMetadata(fileDescriptor) self.stripMetadata(md) return md else: raise ValueError("Storage class inconsistency ({} vs {}) but no" " component requested".format(fileDescriptor.readStorageClass.name, fileDescriptor.storageClass.name))
"""Write a Python object to a file.
Parameters ---------- inMemoryDataset : `object` The Python object to store. fileDescriptor : `FileDescriptor` Identifies the file to read, type to read it into and parameters to be used for reading.
Returns ------- path : `str` The `URI` where the primary file is stored. """ # Update the location with the formatter-preferred file extension
"""Return the path that would be returned by write, without actually writing.
Parameters ---------- location : `Location` The location to simulate writing to. """ |