LSST Applications  21.0.0+75b29a8a7f,21.0.0+e70536a077,21.0.0-1-ga51b5d4+62c747d40b,21.0.0-10-gbfb87ad6+3307648ee3,21.0.0-15-gedb9d5423+47cba9fc36,21.0.0-2-g103fe59+fdf0863a2a,21.0.0-2-g1367e85+d38a93257c,21.0.0-2-g45278ab+e70536a077,21.0.0-2-g5242d73+d38a93257c,21.0.0-2-g7f82c8f+e682ffb718,21.0.0-2-g8dde007+d179fbfa6a,21.0.0-2-g8f08a60+9402881886,21.0.0-2-ga326454+e682ffb718,21.0.0-2-ga63a54e+08647d4b1b,21.0.0-2-gde069b7+26c92b3210,21.0.0-2-gecfae73+0445ed2f95,21.0.0-2-gfc62afb+d38a93257c,21.0.0-27-gbbd0d29+ae871e0f33,21.0.0-28-g5fc5e037+feb0e9397b,21.0.0-3-g21c7a62+f4b9c0ff5c,21.0.0-3-g357aad2+57b0bddf0b,21.0.0-3-g4be5c26+d38a93257c,21.0.0-3-g65f322c+3f454acf5d,21.0.0-3-g7d9da8d+75b29a8a7f,21.0.0-3-gaa929c8+9e4ef6332c,21.0.0-3-ge02ed75+4b120a55c4,21.0.0-4-g3300ddd+e70536a077,21.0.0-4-g591bb35+4b120a55c4,21.0.0-4-gc004bbf+4911b9cd27,21.0.0-4-gccdca77+f94adcd104,21.0.0-4-ge8fba5a+2b3a696ff9,21.0.0-5-gb155db7+2c5429117a,21.0.0-5-gdf36809+637e4641ee,21.0.0-6-g00874e7+c9fd7f7160,21.0.0-6-g4e60332+4b120a55c4,21.0.0-7-gc8ca178+40eb9cf840,21.0.0-8-gfbe0b4b+9e4ef6332c,21.0.0-9-g2fd488a+d83b7cd606,w.2021.05
LSST Data Management Base Package
Public Member Functions | Static Public Attributes | List of all members
lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase Class Reference
Inheritance diagram for lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase:
lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter lsst.obs.decam.rawFormatter.DarkEnergyCameraCPCalibFormatter

Public Member Functions

def __init__ (self, *args, **kwargs)
 
def fromMetadata (cls, metadata, obsInfo=None, storageClass=None, location=None)
 
def translatorClass (self)
 
def filterDefinitions (self)
 
def readImage (self)
 
def readMask (self)
 
def readVariance (self)
 
def isOnSky (self)
 
def stripMetadata (self)
 
def makeVisitInfo (self)
 
def getDetector (self, id)
 
def makeWcs (self, visitInfo, detector)
 
def makeRawSkyWcsFromBoresight (cls, boresight, orientation, detector)
 
def makeFilter (self)
 
def makeFilterLabel (self)
 
def readComponent (self, component, parameters=None)
 
def readFull (self, parameters=None)
 
def readRawHeaderWcs (self, parameters=None)
 
def write (self, inMemoryDataset)
 
def observationInfo (self)
 
def metadata (self)
 
def readMetadata (self)
 
def read (self, component=None)
 
def getImageCompressionSettings (self, recipeName)
 
def validateWriteRecipes (cls, recipes)
 

Static Public Attributes

bool wcsFlipX = False
 
 supportedExtensions = frozenset({".fits", ".fits.gz", ".fits.fz", ".fz", ".fit"})
 
string extension = ".fits"
 
 supportedWriteParameters = frozenset({"recipe"})
 
dictionary unsupportedParameters = {}
 

Detailed Description

Abstract base class for reading and writing raw data to and from
FITS files.

Definition at line 40 of file _fitsRawFormatterBase.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.__init__ (   self,
args,
**  kwargs 
)

Definition at line 49 of file _fitsRawFormatterBase.py.

49  def __init__(self, *args, **kwargs):
50  self.filterDefinitions.reset()
51  self.filterDefinitions.defineFilters()
52  super().__init__(*args, **kwargs)
53 

Member Function Documentation

◆ filterDefinitions()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.filterDefinitions (   self)
`~lsst.obs.base.FilterDefinitions`, defining the filters for this
instrument.

Definition at line 98 of file _fitsRawFormatterBase.py.

98  def filterDefinitions(self):
99  """`~lsst.obs.base.FilterDefinitions`, defining the filters for this
100  instrument.
101  """
102  return None
103 

◆ fromMetadata()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.fromMetadata (   cls,
  metadata,
  obsInfo = None,
  storageClass = None,
  location = None 
)
Construct a possibly-limited formatter from known metadata.

Parameters
----------
metadata : `lsst.daf.base.PropertyList`
    Raw header metadata, with any fixes (see
    `astro_metadata_translator.fix_header`) applied but nothing
    stripped.
obsInfo : `astro_metadata_translator.ObservationInfo`, optional
    Structured information already extracted from ``metadata``.
    If not provided, will be read from ``metadata`` on first use.
storageClass : `lsst.daf.butler.StorageClass`, optional
    StorageClass for this file.  If not provided, the formatter will
    only support `makeWcs`, `makeVisitInfo`, `makeFilter`, and other
    operations that operate purely on metadata and not the actual file.
location : `lsst.daf.butler.Location`, optional.
    Location of the file.  If not provided, the formatter will only
    support `makeWcs`, `makeVisitInfo`, `makeFilter`, and other
    operations that operate purely on metadata and not the actual file.

Returns
-------
formatter : `FitsRawFormatterBase`
    An instance of ``cls``.

Definition at line 55 of file _fitsRawFormatterBase.py.

55  def fromMetadata(cls, metadata, obsInfo=None, storageClass=None, location=None):
56  """Construct a possibly-limited formatter from known metadata.
57 
58  Parameters
59  ----------
60  metadata : `lsst.daf.base.PropertyList`
61  Raw header metadata, with any fixes (see
62  `astro_metadata_translator.fix_header`) applied but nothing
63  stripped.
64  obsInfo : `astro_metadata_translator.ObservationInfo`, optional
65  Structured information already extracted from ``metadata``.
66  If not provided, will be read from ``metadata`` on first use.
67  storageClass : `lsst.daf.butler.StorageClass`, optional
68  StorageClass for this file. If not provided, the formatter will
69  only support `makeWcs`, `makeVisitInfo`, `makeFilter`, and other
70  operations that operate purely on metadata and not the actual file.
71  location : `lsst.daf.butler.Location`, optional.
72  Location of the file. If not provided, the formatter will only
73  support `makeWcs`, `makeVisitInfo`, `makeFilter`, and other
74  operations that operate purely on metadata and not the actual file.
75 
76  Returns
77  -------
78  formatter : `FitsRawFormatterBase`
79  An instance of ``cls``.
80  """
81  self = cls(FileDescriptor(location, storageClass))
82  self._metadata = metadata
83  self._observationInfo = obsInfo
84  return self
85 

◆ getDetector()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.getDetector (   self,
  id 
)
Return the detector that acquired this raw exposure.

Parameters
----------
id : `int`
    The identifying number of the detector to get.

Returns
-------
detector : `~lsst.afw.cameraGeom.Detector`
    The detector associated with that ``id``.

Reimplemented in lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter.

Definition at line 184 of file _fitsRawFormatterBase.py.

184  def getDetector(self, id):
185  """Return the detector that acquired this raw exposure.
186 
187  Parameters
188  ----------
189  id : `int`
190  The identifying number of the detector to get.
191 
192  Returns
193  -------
194  detector : `~lsst.afw.cameraGeom.Detector`
195  The detector associated with that ``id``.
196  """
197  raise NotImplementedError("Must be implemented by subclasses.")
198 

◆ getImageCompressionSettings()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.getImageCompressionSettings (   self,
  recipeName 
)
inherited
Retrieve the relevant compression settings for this recipe.

Parameters
----------
recipeName : `str`
    Label associated with the collection of compression parameters
    to select.

Returns
-------
settings : `dict`
    The selected settings.

Definition at line 304 of file fitsExposure.py.

304  def getImageCompressionSettings(self, recipeName):
305  """Retrieve the relevant compression settings for this recipe.
306 
307  Parameters
308  ----------
309  recipeName : `str`
310  Label associated with the collection of compression parameters
311  to select.
312 
313  Returns
314  -------
315  settings : `dict`
316  The selected settings.
317  """
318  # if no recipe has been provided and there is no default
319  # return immediately
320  if not recipeName:
321  if "default" not in self.writeRecipes:
322  return {}
323  recipeName = "default"
324 
325  if recipeName not in self.writeRecipes:
326  raise RuntimeError(f"Unrecognized recipe option given for compression: {recipeName}")
327 
328  recipe = self.writeRecipes[recipeName]
329 
330  # Set the seed based on dataId
331  seed = hash(tuple(self.dataId.items())) % 2**31
332  for plane in ("image", "mask", "variance"):
333  if plane in recipe and "scaling" in recipe[plane]:
334  scaling = recipe[plane]["scaling"]
335  if "seed" in scaling and scaling["seed"] == 0:
336  scaling["seed"] = seed
337 
338  return recipe
339 
std::vector< SchemaItem< Flag > > * items

◆ isOnSky()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.isOnSky (   self)
Boolean to determine if the exposure is thought to be on the sky.

Returns
-------
onSky : `bool`
    Returns `True` if the observation looks like it was taken on the
    sky.  Returns `False` if this observation looks like a calibration
    observation.

Notes
-----
If there is tracking RA/Dec information associated with the
observation it is assumed that the observation is on sky.
Currently the observation type is not checked.

Definition at line 144 of file _fitsRawFormatterBase.py.

144  def isOnSky(self):
145  """Boolean to determine if the exposure is thought to be on the sky.
146 
147  Returns
148  -------
149  onSky : `bool`
150  Returns `True` if the observation looks like it was taken on the
151  sky. Returns `False` if this observation looks like a calibration
152  observation.
153 
154  Notes
155  -----
156  If there is tracking RA/Dec information associated with the
157  observation it is assumed that the observation is on sky.
158  Currently the observation type is not checked.
159  """
160  if self.observationInfo.tracking_radec is None:
161  return False
162  return True
163 

◆ makeFilter()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.makeFilter (   self)
Construct a Filter from metadata.

Returns
-------
filter : `~lsst.afw.image.Filter`
    Object that identifies the filter for this image.

Raises
------
NotFoundError
    Raised if the physical filter was not registered via
    `~lsst.afw.image.utils.defineFilter`.

Definition at line 286 of file _fitsRawFormatterBase.py.

286  def makeFilter(self):
287  """Construct a Filter from metadata.
288 
289  Returns
290  -------
291  filter : `~lsst.afw.image.Filter`
292  Object that identifies the filter for this image.
293 
294  Raises
295  ------
296  NotFoundError
297  Raised if the physical filter was not registered via
298  `~lsst.afw.image.utils.defineFilter`.
299  """
300  return lsst.afw.image.Filter(self.observationInfo.physical_filter)
301 
Filter makeFilter(FilterLabel const &label)
Convert a FilterLabel back to an old-style Filter.

◆ makeFilterLabel()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.makeFilterLabel (   self)
Construct a FilterLabel from metadata.

Returns
-------
filter : `~lsst.afw.image.FilterLabel`
    Object that identifies the filter for this image.

Definition at line 303 of file _fitsRawFormatterBase.py.

303  def makeFilterLabel(self):
304  """Construct a FilterLabel from metadata.
305 
306  Returns
307  -------
308  filter : `~lsst.afw.image.FilterLabel`
309  Object that identifies the filter for this image.
310  """
311  physical = self.observationInfo.physical_filter
312  band = self.filterDefinitions.physical_to_band[physical]
313  return lsst.afw.image.FilterLabel(physical=physical, band=band)
314 
A group of labels for a filter in an exposure or coadd.
Definition: FilterLabel.h:58
std::shared_ptr< FilterLabel > makeFilterLabel(Filter const &filter)
Convert an old-style Filter to a FilterLabel.

◆ makeRawSkyWcsFromBoresight()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.makeRawSkyWcsFromBoresight (   cls,
  boresight,
  orientation,
  detector 
)
Class method to make a raw sky WCS from boresight and detector.

Parameters
----------
boresight : `lsst.geom.SpherePoint`
    The ICRS boresight RA/Dec
orientation : `lsst.geom.Angle`
    The rotation angle of the focal plane on the sky.
detector : `lsst.afw.cameraGeom.Detector`
    Where to get the camera geomtry from.

Returns
-------
skyWcs : `~lsst.afw.geom.SkyWcs`
    Reversible mapping from pixel coordinates to sky coordinates.

Definition at line 245 of file _fitsRawFormatterBase.py.

245  def makeRawSkyWcsFromBoresight(cls, boresight, orientation, detector):
246  """Class method to make a raw sky WCS from boresight and detector.
247 
248  Parameters
249  ----------
250  boresight : `lsst.geom.SpherePoint`
251  The ICRS boresight RA/Dec
252  orientation : `lsst.geom.Angle`
253  The rotation angle of the focal plane on the sky.
254  detector : `lsst.afw.cameraGeom.Detector`
255  Where to get the camera geomtry from.
256 
257  Returns
258  -------
259  skyWcs : `~lsst.afw.geom.SkyWcs`
260  Reversible mapping from pixel coordinates to sky coordinates.
261  """
262  return createInitialSkyWcsFromBoresight(boresight, orientation, detector, flipX=cls.wcsFlipX)
263 
def createInitialSkyWcsFromBoresight(boresight, orientation, detector, flipX=False)
Definition: utils.py:80

◆ makeVisitInfo()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.makeVisitInfo (   self)
Construct a VisitInfo from metadata.

Returns
-------
visitInfo : `~lsst.afw.image.VisitInfo`
    Structured metadata about the observation.

Definition at line 173 of file _fitsRawFormatterBase.py.

173  def makeVisitInfo(self):
174  """Construct a VisitInfo from metadata.
175 
176  Returns
177  -------
178  visitInfo : `~lsst.afw.image.VisitInfo`
179  Structured metadata about the observation.
180  """
181  return MakeRawVisitInfoViaObsInfo.observationInfo2visitInfo(self.observationInfo)
182 

◆ makeWcs()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.makeWcs (   self,
  visitInfo,
  detector 
)
Create a SkyWcs from information about the exposure.

If VisitInfo is not None, use it and the detector to create a SkyWcs,
otherwise return the metadata-based SkyWcs (always created, so that
the relevant metadata keywords are stripped).

Parameters
----------
visitInfo : `~lsst.afw.image.VisitInfo`
    The information about the telescope boresight and camera
    orientation angle for this exposure.
detector : `~lsst.afw.cameraGeom.Detector`
    The detector used to acquire this exposure.

Returns
-------
skyWcs : `~lsst.afw.geom.SkyWcs`
    Reversible mapping from pixel coordinates to sky coordinates.

Raises
------
InitialSkyWcsError
    Raised if there is an error generating the SkyWcs, chained from the
    lower-level exception if available.

Definition at line 199 of file _fitsRawFormatterBase.py.

199  def makeWcs(self, visitInfo, detector):
200  """Create a SkyWcs from information about the exposure.
201 
202  If VisitInfo is not None, use it and the detector to create a SkyWcs,
203  otherwise return the metadata-based SkyWcs (always created, so that
204  the relevant metadata keywords are stripped).
205 
206  Parameters
207  ----------
208  visitInfo : `~lsst.afw.image.VisitInfo`
209  The information about the telescope boresight and camera
210  orientation angle for this exposure.
211  detector : `~lsst.afw.cameraGeom.Detector`
212  The detector used to acquire this exposure.
213 
214  Returns
215  -------
216  skyWcs : `~lsst.afw.geom.SkyWcs`
217  Reversible mapping from pixel coordinates to sky coordinates.
218 
219  Raises
220  ------
221  InitialSkyWcsError
222  Raised if there is an error generating the SkyWcs, chained from the
223  lower-level exception if available.
224  """
225  if not self.isOnSky():
226  # This is not an on-sky observation
227  return None
228 
229  skyWcs = self._createSkyWcsFromMetadata()
230 
231  log = lsst.log.Log.getLogger("fitsRawFormatter")
232  if visitInfo is None:
233  msg = "No VisitInfo; cannot access boresight information. Defaulting to metadata-based SkyWcs."
234  log.warn(msg)
235  if skyWcs is None:
236  raise InitialSkyWcsError("Failed to create both metadata and boresight-based SkyWcs."
237  "See warnings in log messages for details.")
238  return skyWcs
239 
240  return self.makeRawSkyWcsFromBoresight(visitInfo.getBoresightRaDec(),
241  visitInfo.getBoresightRotAngle(),
242  detector)
243 
static Log getLogger(Log const &logger)
Definition: Log.h:760
std::shared_ptr< afw::geom::SkyWcs > makeWcs(SipForwardTransform const &sipForward, SipReverseTransform const &sipReverse, geom::SpherePoint const &skyOrigin)
Create a new TAN SIP Wcs from a pair of SIP transforms and the sky origin.

◆ metadata()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.metadata (   self)
inherited
The metadata read from this file. It will be stripped as
components are extracted from it
(`lsst.daf.base.PropertyList`).

Definition at line 95 of file fitsExposure.py.

95  def metadata(self):
96  """The metadata read from this file. It will be stripped as
97  components are extracted from it
98  (`lsst.daf.base.PropertyList`).
99  """
100  if self._metadata is None:
101  self._metadata = self.readMetadata()
102  return self._metadata
103 

◆ observationInfo()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.observationInfo (   self)
The `~astro_metadata_translator.ObservationInfo` extracted from
this file's metadata (`~astro_metadata_translator.ObservationInfo`,
read-only).

Definition at line 407 of file _fitsRawFormatterBase.py.

407  def observationInfo(self):
408  """The `~astro_metadata_translator.ObservationInfo` extracted from
409  this file's metadata (`~astro_metadata_translator.ObservationInfo`,
410  read-only).
411  """
412  if self._observationInfo is None:
413  location = self.fileDescriptor.location
414  path = location.path if location is not None else None
415  self._observationInfo = ObservationInfo(self.metadata, translator_class=self.translatorClass,
416  filename=path)
417  return self._observationInfo

◆ read()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.read (   self,
  component = None 
)
inherited
Read data from a file.

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

Definition at line 242 of file fitsExposure.py.

242  def read(self, component=None):
243  """Read data from a file.
244 
245  Parameters
246  ----------
247  component : `str`, optional
248  Component to read from the file. Only used if the `StorageClass`
249  for reading differed from the `StorageClass` used to write the
250  file.
251 
252  Returns
253  -------
254  inMemoryDataset : `object`
255  The requested data as a Python object. The type of object
256  is controlled by the specific formatter.
257 
258  Raises
259  ------
260  ValueError
261  Component requested but this file does not seem to be a concrete
262  composite.
263  KeyError
264  Raised when parameters passed with fileDescriptor are not
265  supported.
266  """
267  fileDescriptor = self.fileDescriptor
268  if fileDescriptor.readStorageClass != fileDescriptor.storageClass:
269  if component == "metadata":
270  self.stripMetadata()
271  return self.metadata
272  elif component is not None:
273  return self.readComponent(component)
274  else:
275  raise ValueError("Storage class inconsistency ({} vs {}) but no"
276  " component requested".format(fileDescriptor.readStorageClass.name,
277  fileDescriptor.storageClass.name))
278  return self.readFull()
279 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174

◆ readComponent()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.readComponent (   self,
  component,
  parameters = None 
)
Read a component held by the Exposure.

Parameters
----------
component : `str`, optional
    Component to read from the file.
parameters : `dict`, optional
    If specified, a dictionary of slicing parameters that
    overrides those in ``fileDescriptor``.

Returns
-------
obj : component-dependent
    In-memory component object.

Raises
------
KeyError
    Raised if the requested component cannot be handled.

Reimplemented from lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.

Definition at line 315 of file _fitsRawFormatterBase.py.

315  def readComponent(self, component, parameters=None):
316  """Read a component held by the Exposure.
317 
318  Parameters
319  ----------
320  component : `str`, optional
321  Component to read from the file.
322  parameters : `dict`, optional
323  If specified, a dictionary of slicing parameters that
324  overrides those in ``fileDescriptor``.
325 
326  Returns
327  -------
328  obj : component-dependent
329  In-memory component object.
330 
331  Raises
332  ------
333  KeyError
334  Raised if the requested component cannot be handled.
335  """
336  if component == "image":
337  return self.readImage()
338  elif component == "mask":
339  return self.readMask()
340  elif component == "variance":
341  return self.readVariance()
342  elif component == "filter":
343  return self.makeFilter()
344  elif component == "filterLabel":
345  return self.makeFilterLabel()
346  elif component == "visitInfo":
347  return self.makeVisitInfo()
348  elif component == "wcs":
349  detector = self.getDetector(self.observationInfo.detector_num)
350  visitInfo = self.makeVisitInfo()
351  return self.makeWcs(visitInfo, detector)
352  return None
353 

◆ readFull()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.readFull (   self,
  parameters = None 
)
Read the full Exposure object.

Parameters
----------
parameters : `dict`, optional
    If specified, a dictionary of slicing parameters that overrides
    those in the `fileDescriptor` attribute.

Returns
-------
exposure : `~lsst.afw.image.Exposure`
    Complete in-memory exposure.

Reimplemented from lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.

Definition at line 354 of file _fitsRawFormatterBase.py.

354  def readFull(self, parameters=None):
355  """Read the full Exposure object.
356 
357  Parameters
358  ----------
359  parameters : `dict`, optional
360  If specified, a dictionary of slicing parameters that overrides
361  those in the `fileDescriptor` attribute.
362 
363  Returns
364  -------
365  exposure : `~lsst.afw.image.Exposure`
366  Complete in-memory exposure.
367  """
368  from lsst.afw.image import makeExposure, makeMaskedImage
369  full = makeExposure(makeMaskedImage(self.readImage()))
370  mask = self.readMask()
371  if mask is not None:
372  full.setMask(mask)
373  variance = self.readVariance()
374  if variance is not None:
375  full.setVariance(variance)
376  full.setDetector(self.getDetector(self.observationInfo.detector_num))
377  info = full.getInfo()
378  info.setFilterLabel(self.makeFilterLabel())
379  info.setVisitInfo(self.makeVisitInfo())
380  info.setWcs(self.makeWcs(info.getVisitInfo(), info.getDetector()))
381  # We don't need to call stripMetadata() here because it has already
382  # been stripped during creation of the ObservationInfo, WCS, etc.
383  full.setMetadata(self.metadata)
384  return full
385 
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
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.
Definition: Exposure.h:462
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.
Definition: MaskedImage.h:1268

◆ readImage()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.readImage (   self)
Read just the image component of the Exposure.

Returns
-------
image : `~lsst.afw.image.Image`
    In-memory image component.

Reimplemented in lsst.obs.decam.rawFormatter.DarkEnergyCameraCPCalibFormatter, and lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter.

Definition at line 104 of file _fitsRawFormatterBase.py.

104  def readImage(self):
105  """Read just the image component of the Exposure.
106 
107  Returns
108  -------
109  image : `~lsst.afw.image.Image`
110  In-memory image component.
111  """
112  return lsst.afw.image.ImageU(self.fileDescriptor.location.path)
113 

◆ readMask()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.readMask (   self)
Read just the mask component of the Exposure.

May return None (as the default implementation does) to indicate that
there is no mask information to be extracted (at least not trivially)
from the raw data.  This will prohibit direct reading of just the mask,
and set the mask of the full Exposure to zeros.

Returns
-------
mask : `~lsst.afw.image.Mask`
    In-memory mask component.

Definition at line 114 of file _fitsRawFormatterBase.py.

114  def readMask(self):
115  """Read just the mask component of the Exposure.
116 
117  May return None (as the default implementation does) to indicate that
118  there is no mask information to be extracted (at least not trivially)
119  from the raw data. This will prohibit direct reading of just the mask,
120  and set the mask of the full Exposure to zeros.
121 
122  Returns
123  -------
124  mask : `~lsst.afw.image.Mask`
125  In-memory mask component.
126  """
127  return None
128 

◆ readMetadata()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.readMetadata (   self)
inherited
Read all header metadata directly into a PropertyList.

Returns
-------
metadata : `~lsst.daf.base.PropertyList`
    Header metadata.

Reimplemented in lsst.obs.decam.rawFormatter.DarkEnergyCameraRawFormatter.

Definition at line 104 of file fitsExposure.py.

104  def readMetadata(self):
105  """Read all header metadata directly into a PropertyList.
106 
107  Returns
108  -------
109  metadata : `~lsst.daf.base.PropertyList`
110  Header metadata.
111  """
112  md = readMetadata(self.fileDescriptor.location.path)
113  fix_header(md)
114  return md
115 
std::shared_ptr< daf::base::PropertyList > readMetadata(std::string const &fileName, int hdu=DEFAULT_HDU, bool strip=false)
Read FITS header.
Definition: fits.cc:1657

◆ readRawHeaderWcs()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.readRawHeaderWcs (   self,
  parameters = None 
)
Read the SkyWcs stored in the un-modified raw FITS WCS header keys.

Definition at line 386 of file _fitsRawFormatterBase.py.

386  def readRawHeaderWcs(self, parameters=None):
387  """Read the SkyWcs stored in the un-modified raw FITS WCS header keys.
388  """
389  return lsst.afw.geom.makeSkyWcs(lsst.afw.fits.readMetadata(self.fileDescriptor.location.path))
390 
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition: SkyWcs.cc:526

◆ readVariance()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.readVariance (   self)
Read just the variance component of the Exposure.

May return None (as the default implementation does) to indicate that
there is no variance information to be extracted (at least not
trivially) from the raw data.  This will prohibit direct reading of
just the variance, and set the variance of the full Exposure to zeros.

Returns
-------
image : `~lsst.afw.image.Image`
    In-memory variance component.

Definition at line 129 of file _fitsRawFormatterBase.py.

129  def readVariance(self):
130  """Read just the variance component of the Exposure.
131 
132  May return None (as the default implementation does) to indicate that
133  there is no variance information to be extracted (at least not
134  trivially) from the raw data. This will prohibit direct reading of
135  just the variance, and set the variance of the full Exposure to zeros.
136 
137  Returns
138  -------
139  image : `~lsst.afw.image.Image`
140  In-memory variance component.
141  """
142  return None
143 

◆ stripMetadata()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.stripMetadata (   self)
Remove metadata entries that are parsed into components.

Reimplemented from lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.

Definition at line 164 of file _fitsRawFormatterBase.py.

164  def stripMetadata(self):
165  """Remove metadata entries that are parsed into components.
166  """
167  # NOTE: makeVisitInfo() may not strip any metadata itself, but calling
168  # it ensures that ObservationInfo is created from the metadata, which
169  # will strip the VisitInfo keys and more.
170  self.makeVisitInfo()
171  self._createSkyWcsFromMetadata()
172 

◆ translatorClass()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.translatorClass (   self)
`~astro_metadata_translator.MetadataTranslator` to translate
metadata header to `~astro_metadata_translator.ObservationInfo`.

Definition at line 88 of file _fitsRawFormatterBase.py.

88  def translatorClass(self):
89  """`~astro_metadata_translator.MetadataTranslator` to translate
90  metadata header to `~astro_metadata_translator.ObservationInfo`.
91  """
92  return None
93 

◆ validateWriteRecipes()

def lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.validateWriteRecipes (   cls,
  recipes 
)
inherited
Validate supplied recipes for this formatter.

The recipes are supplemented with default values where appropriate.

TODO: replace this custom validation code with Cerberus (DM-11846)

Parameters
----------
recipes : `dict`
    Recipes to validate. Can be empty dict or `None`.

Returns
-------
validated : `dict`
    Validated recipes. Returns what was given if there are no
    recipes listed.

Raises
------
RuntimeError
    Raised if validation fails.

Definition at line 341 of file fitsExposure.py.

341  def validateWriteRecipes(cls, recipes):
342  """Validate supplied recipes for this formatter.
343 
344  The recipes are supplemented with default values where appropriate.
345 
346  TODO: replace this custom validation code with Cerberus (DM-11846)
347 
348  Parameters
349  ----------
350  recipes : `dict`
351  Recipes to validate. Can be empty dict or `None`.
352 
353  Returns
354  -------
355  validated : `dict`
356  Validated recipes. Returns what was given if there are no
357  recipes listed.
358 
359  Raises
360  ------
361  RuntimeError
362  Raised if validation fails.
363  """
364  # Schemas define what should be there, and the default values (and by
365  # the default value, the expected type).
366  compressionSchema = {
367  "algorithm": "NONE",
368  "rows": 1,
369  "columns": 0,
370  "quantizeLevel": 0.0,
371  }
372  scalingSchema = {
373  "algorithm": "NONE",
374  "bitpix": 0,
375  "maskPlanes": ["NO_DATA"],
376  "seed": 0,
377  "quantizeLevel": 4.0,
378  "quantizePad": 5.0,
379  "fuzz": True,
380  "bscale": 1.0,
381  "bzero": 0.0,
382  }
383 
384  if not recipes:
385  # We can not insist on recipes being specified
386  return recipes
387 
388  def checkUnrecognized(entry, allowed, description):
389  """Check to see if the entry contains unrecognised keywords"""
390  unrecognized = set(entry) - set(allowed)
391  if unrecognized:
392  raise RuntimeError(
393  f"Unrecognized entries when parsing image compression recipe {description}: "
394  f"{unrecognized}")
395 
396  validated = {}
397  for name in recipes:
398  checkUnrecognized(recipes[name], ["image", "mask", "variance"], name)
399  validated[name] = {}
400  for plane in ("image", "mask", "variance"):
401  checkUnrecognized(recipes[name][plane], ["compression", "scaling"],
402  f"{name}->{plane}")
403 
404  np = {}
405  validated[name][plane] = np
406  for settings, schema in (("compression", compressionSchema),
407  ("scaling", scalingSchema)):
408  np[settings] = {}
409  if settings not in recipes[name][plane]:
410  for key in schema:
411  np[settings][key] = schema[key]
412  continue
413  entry = recipes[name][plane][settings]
414  checkUnrecognized(entry, schema.keys(), f"{name}->{plane}->{settings}")
415  for key in schema:
416  value = type(schema[key])(entry[key]) if key in entry else schema[key]
417  np[settings][key] = value
418  return validated
419 
420 
table::Key< int > type
Definition: Detector.cc:163
daf::base::PropertySet * set
Definition: fits.cc:912

◆ write()

def lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.write (   self,
  inMemoryDataset 
)
Write a Python object to a file.

Parameters
----------
inMemoryDataset : `object`
    The Python object to store.

Returns
-------
path : `str`
    The `URI` where the primary file is stored.

Reimplemented from lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.

Definition at line 391 of file _fitsRawFormatterBase.py.

391  def write(self, inMemoryDataset):
392  """Write a Python object to a file.
393 
394  Parameters
395  ----------
396  inMemoryDataset : `object`
397  The Python object to store.
398 
399  Returns
400  -------
401  path : `str`
402  The `URI` where the primary file is stored.
403  """
404  raise NotImplementedError("Raw data cannot be `put`.")
405 
void write(OutputArchiveHandle &handle) const override

Member Data Documentation

◆ extension

string lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.extension = ".fits"
staticinherited

Definition at line 86 of file fitsExposure.py.

◆ supportedExtensions

lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.supportedExtensions = frozenset({".fits", ".fits.gz", ".fits.fz", ".fz", ".fit"})
staticinherited

Definition at line 85 of file fitsExposure.py.

◆ supportedWriteParameters

lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.supportedWriteParameters = frozenset({"recipe"})
staticinherited

Definition at line 88 of file fitsExposure.py.

◆ unsupportedParameters

dictionary lsst.obs.base.formatters.fitsExposure.FitsExposureFormatter.unsupportedParameters = {}
staticinherited

Definition at line 91 of file fitsExposure.py.

◆ wcsFlipX

bool lsst.obs.base._fitsRawFormatterBase.FitsRawFormatterBase.wcsFlipX = False
static

Definition at line 46 of file _fitsRawFormatterBase.py.


The documentation for this class was generated from the following file: