LSSTApplications
20.0.0
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
22 __all__ = (
"FitsRawFormatterBase",)
24 from abc
import ABCMeta, abstractmethod
26 from astro_metadata_translator
import ObservationInfo
31 from lsst.daf.butler
import FileDescriptor
34 from .fitsExposureFormatter
import FitsExposureFormatter
35 from .makeRawVisitInfoViaObsInfo
import MakeRawVisitInfoViaObsInfo
36 from .utils
import createInitialSkyWcs, InitialSkyWcsError
40 """Abstract base class for reading and writing raw data to and from
50 def fromMetadata(cls, metadata, obsInfo=None, storageClass=None, location=None):
51 """Construct a possibly-limited formatter from known metadata.
55 metadata : `lsst.daf.base.PropertyList`
56 Raw header metadata, with any fixes (see
57 `astro_metadata_translator.fix_header`) applied but nothing
59 obsInfo : `astro_metadata_translator.ObservationInfo`, optional
60 Structured information already extracted from ``metadata``.
61 If not provided, will be read from ``metadata`` on first use.
62 storageClass : `lsst.daf.butler.StorageClass`, optional
63 StorageClass for this file. If not provided, the formatter will
64 only support `makeWcs`, `makeVisitInfo`, `makeFilter`, and other
65 operations that operate purely on metadata and not the actual file.
66 location : `lsst.daf.butler.Location`, optional.
67 Location of the file. If not provided, the formatter will only
68 support `makeWcs`, `makeVisitInfo`, `makeFilter`, and other
69 operations that operate purely on metadata and not the actual file.
73 formatter : `FitsRawFormatterBase`
74 An instance of ``cls``.
76 self =
cls(FileDescriptor(location, storageClass))
84 """`~astro_metadata_translator.MetadataTranslator` to translate
85 metadata header to `~astro_metadata_translator.ObservationInfo`.
89 _observationInfo =
None
94 """`~lsst.obs.base.FilterDefinitions`, defining the filters for this
100 """Read just the image component of the Exposure.
104 image : `~lsst.afw.image.Image`
105 In-memory image component.
107 return lsst.afw.image.ImageU(self.fileDescriptor.location.path)
110 """Read just the mask component of the Exposure.
112 May return None (as the default implementation does) to indicate that
113 there is no mask information to be extracted (at least not trivially)
114 from the raw data. This will prohibit direct reading of just the mask,
115 and set the mask of the full Exposure to zeros.
119 mask : `~lsst.afw.image.Mask`
120 In-memory mask component.
125 """Read just the variance component of the Exposure.
127 May return None (as the default implementation does) to indicate that
128 there is no variance information to be extracted (at least not
129 trivially) from the raw data. This will prohibit direct reading of
130 just the variance, and set the variance of the full Exposure to zeros.
134 image : `~lsst.afw.image.Image`
135 In-memory variance component.
140 """Boolean to determine if the exposure is thought to be on the sky.
145 Returns `True` if the observation looks like it was taken on the
146 sky. Returns `False` if this observation looks like a calibration
151 If there is tracking RA/Dec information associated with the
152 observation it is assumed that the observation is on sky.
153 Currently the observation type is not checked.
160 """Remove metadata entries that are parsed into components.
169 """Construct a VisitInfo from metadata.
173 visitInfo : `~lsst.afw.image.VisitInfo`
174 Structured metadata about the observation.
176 return MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(self.
observationInfo)
180 """Return the detector that acquired this raw exposure.
185 The identifying number of the detector to get.
189 detector : `~lsst.afw.cameraGeom.Detector`
190 The detector associated with that ``id``.
192 raise NotImplementedError(
"Must be implemented by subclasses.")
195 """Create a SkyWcs from information about the exposure.
197 If VisitInfo is not None, use it and the detector to create a SkyWcs,
198 otherwise return the metadata-based SkyWcs (always created, so that
199 the relevant metadata keywords are stripped).
203 visitInfo : `~lsst.afw.image.VisitInfo`
204 The information about the telescope boresight and camera
205 orientation angle for this exposure.
206 detector : `~lsst.afw.cameraGeom.Detector`
207 The detector used to acquire this exposure.
211 skyWcs : `~lsst.afw.geom.SkyWcs`
212 Reversible mapping from pixel coordinates to sky coordinates.
217 Raised if there is an error generating the SkyWcs, chained from the
218 lower-level exception if available.
227 if visitInfo
is None:
228 msg =
"No VisitInfo; cannot access boresight information. Defaulting to metadata-based SkyWcs."
232 "See warnings in log messages for details.")
238 def _createSkyWcsFromMetadata(self):
239 """Create a SkyWcs from the FITS header metadata in an Exposure.
243 skyWcs: `lsst.afw.geom.SkyWcs`, or None
244 The WCS that was created from ``self.metadata``, or None if that
245 creation fails due to invalid metadata.
253 except TypeError
as e:
255 log.warn(
"Cannot create a valid WCS from metadata: %s", e.args[0])
259 """Construct a Filter from metadata.
263 filter : `~lsst.afw.image.Filter`
264 Object that identifies the filter for this image.
269 Raised if the physical filter was not registered via
270 `~lsst.afw.image.utils.defineFilter`.
275 """Read a component held by the Exposure.
279 component : `str`, optional
280 Component to read from the file.
281 parameters : `dict`, optional
282 If specified, a dictionary of slicing parameters that
283 overrides those in ``fileDescriptor``.
287 obj : component-dependent
288 In-memory component object.
293 Raised if the requested component cannot be handled.
295 if component ==
"image":
297 elif component ==
"mask":
299 elif component ==
"variance":
301 elif component ==
"filter":
303 elif component ==
"visitInfo":
305 elif component ==
"wcs":
308 return self.
makeWcs(visitInfo, detector)
312 """Read the full Exposure object.
316 parameters : `dict`, optional
317 If specified, a dictionary of slicing parameters that overrides
318 those in the `fileDescriptor` attribute.
322 exposure : `~lsst.afw.image.Exposure`
323 Complete in-memory exposure.
331 if variance
is not None:
332 full.setVariance(variance)
334 info = full.getInfo()
337 info.setWcs(self.
makeWcs(info.getVisitInfo(), info.getDetector()))
344 """Read the SkyWcs stored in the un-modified raw FITS WCS header keys.
349 """Write a Python object to a file.
353 inMemoryDataset : `object`
354 The Python object to store.
359 The `URI` where the primary file is stored.
361 raise NotImplementedError(
"Raw data cannot be `put`.")
365 """The `~astro_metadata_translator.ObservationInfo` extracted from
366 this file's metadata (`~astro_metadata_translator.ObservationInfo`,
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
Holds an integer identifier for an LSST filter.
std::shared_ptr< Exposure< ImagePixelT, MaskPixelT, VariancePixelT > > makeExposure(MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > &mimage, std::shared_ptr< geom::SkyWcs const > wcs=std::shared_ptr< geom::SkyWcs const >())
A function to return an Exposure of the correct type (cf.
static Log getLogger(Log const &logger)
std::shared_ptr< SkyWcs > makeSkyWcs(TransformPoint2ToPoint2 const &pixelsToFieldAngle, lsst::geom::Angle const &orientation, bool flipX, lsst::geom::SpherePoint const &boresight, std::string const &projection="TAN")
Construct a FITS SkyWcs from camera geometry.
std::shared_ptr< daf::base::PropertyList > readMetadata(fits::Fits &fitsfile, bool strip=false)
Read FITS header.
def createInitialSkyWcs(visitInfo, detector, flipX=False)
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename std::shared_ptr< Image< ImagePixelT >> image, typename std::shared_ptr< Mask< MaskPixelT >> mask=Mask< MaskPixelT >(), typename std::shared_ptr< Image< VariancePixelT >> variance=Image< VariancePixelT >())
A function to return a MaskedImage of the correct type (cf.