22 __all__ = (
"FitsRawFormatterBase",)
24 from abc
import ABCMeta, abstractmethod
26 from astro_metadata_translator
import ObservationInfo
29 from lsst.daf.butler.formatters.fitsExposureFormatter
import FitsExposureFormatter
34 """Abstract base class for reading and writing raw data to and from 41 """`~astro_metadata_translator.MetadataTranslator` to translate 42 metadata header to `~astro_metadata_translator.ObservationInfo`. 46 _observationInfo =
None 49 """Read just the image component of the Exposure. 53 image : `~lsst.afw.image.Image` 54 In-memory image component. 56 return lsst.afw.image.ImageU(self.fileDescriptor.location.path)
59 """Read just the mask component of the Exposure. 61 May return None (as the default implementation does) to indicate that 62 there is no mask information to be extracted (at least not trivially) 63 from the raw data. This will prohibit direct reading of just the mask, 64 and set the mask of the full Exposure to zeros. 68 mask : `~lsst.afw.image.Mask` 69 In-memory mask component. 74 """Read just the variance component of the Exposure. 76 May return None (as the default implementation does) to indicate that 77 there is no variance information to be extracted (at least not 78 trivially) from the raw data. This will prohibit direct reading of 79 just the variance, and set the variance of the full Exposure to zeros. 83 image : `~lsst.afw.image.Image` 84 In-memory variance component. 89 """Remove metadata entries that are parsed into components. 95 """Construct a VisitInfo from ObservationInfo. 99 visitInfo : `~lsst.afw.image.VisitInfo` 100 Structured metadata about the observation. 102 return MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(self.
observationInfo)
105 """Construct a SkyWcs from metadata. 109 wcs : `~lsst.afw.geom.SkyWcs` 110 Reversible mapping from pixel coordinates to sky coordinates. 112 from lsst.afw.geom
import makeSkyWcs
113 return makeSkyWcs(self.metadata, strip=
True)
116 """Construct a Filter from metadata. 120 filter : `~lsst.afw.image.Filter` 121 Object that identifies the filter for this image. 123 raise NotImplementedError(
"Must be implemented by subclasses.")
126 """Read the image, mask, or variance component of an Exposure. 130 component : `str`, optional 131 Component to read from the file. Always one of "image", 132 "variance", or "mask". 136 image : `~lsst.afw.image.Image` or `~lsst.afw.image.Mask` 137 In-memory image, variance, or mask component. 139 if component ==
"image":
141 elif component ==
"mask":
143 elif component ==
"variance":
147 """Read a component held by ExposureInfo. 149 The implementation provided by FitsRawFormatter provides only "wcs" 150 and "visitInfo". When adding support for other components, subclasses 151 should delegate to `super()` for those and update `readFull` with 156 component : `str`, optional 157 Component to read from the file. 161 obj : component-dependent 162 In-memory component object. 164 if component ==
"filter":
166 elif component ==
"visitInfo":
168 elif component ==
"wcs":
173 """Read the full Exposure object. 177 parameters : `dict`, optional 178 If specified a dictionary of slicing parameters that overrides 179 those in ``self.fileDescriptor`. 183 exposure : `~lsst.afw.image.Exposure` 184 Complete in-memory exposure. 186 from lsst.afw.image
import makeExposure, makeMaskedImage
187 full = makeExposure(makeMaskedImage(self.
readImage()))
192 if variance
is not None:
193 full.setVariance(variance)
194 info = full.getInfo()
201 full.setMetadata(self.metadata)
205 """Write a Python object to a file. 209 inMemoryDataset : `object` 210 The Python object to store. 215 The `URI` where the primary file is stored. 217 raise NotImplementedError(
"Raw data cannot be `put`.")
221 """The `~astro_metadata_translator.ObservationInfo` extracted from 222 this file's metadata (`~astro_metadata_translator.ObservationInfo`,