LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
Classes | Functions
lsst.obs.base.cameraMapper Namespace Reference

Classes

class  CameraMapper
 

Functions

def exposureFromImage (image, dataId=None, mapper=None, logger=None, setVisitInfo=True)
 
def validateRecipeFitsStorage (recipes)
 

Function Documentation

◆ exposureFromImage()

def lsst.obs.base.cameraMapper.exposureFromImage (   image,
  dataId = None,
  mapper = None,
  logger = None,
  setVisitInfo = True 
)
Generate an Exposure from an image-like object

If the image is a DecoratedImage then also set its WCS and metadata
(Image and MaskedImage are missing the necessary metadata
and Exposure already has those set)

Parameters
----------
image : Image-like object
    Can be one of lsst.afw.image.DecoratedImage, Image, MaskedImage or
    Exposure.

Returns
-------
`lsst.afw.image.Exposure`
    Exposure containing input image.

Definition at line 1319 of file cameraMapper.py.

1319 def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo=True):
1320  """Generate an Exposure from an image-like object
1321 
1322  If the image is a DecoratedImage then also set its WCS and metadata
1323  (Image and MaskedImage are missing the necessary metadata
1324  and Exposure already has those set)
1325 
1326  Parameters
1327  ----------
1328  image : Image-like object
1329  Can be one of lsst.afw.image.DecoratedImage, Image, MaskedImage or
1330  Exposure.
1331 
1332  Returns
1333  -------
1334  `lsst.afw.image.Exposure`
1335  Exposure containing input image.
1336  """
1337  translatorClass = None
1338  if mapper is not None:
1339  translatorClass = mapper.translatorClass
1340 
1341  metadata = None
1342  if isinstance(image, afwImage.MaskedImage):
1343  exposure = afwImage.makeExposure(image)
1344  elif isinstance(image, afwImage.DecoratedImage):
1345  exposure = afwImage.makeExposure(afwImage.makeMaskedImage(image.getImage()))
1346  metadata = image.getMetadata()
1347  fix_header(metadata, translator_class=translatorClass)
1348  exposure.setMetadata(metadata)
1349  elif isinstance(image, afwImage.Exposure):
1350  exposure = image
1351  metadata = exposure.getMetadata()
1352  fix_header(metadata, translator_class=translatorClass)
1353  else: # Image
1355 
1356  # set VisitInfo if we can
1357  if setVisitInfo and exposure.getInfo().getVisitInfo() is None:
1358  if metadata is not None:
1359  if mapper is None:
1360  if not logger:
1361  logger = lsstLog.Log.getLogger("CameraMapper")
1362  logger.warn("I can only set the VisitInfo if you provide a mapper")
1363  else:
1364  exposureId = mapper._computeCcdExposureId(dataId)
1365  visitInfo = mapper.makeRawVisitInfo(md=metadata, exposureId=exposureId)
1366 
1367  exposure.getInfo().setVisitInfo(visitInfo)
1368 
1369  return exposure
1370 
1371 

◆ validateRecipeFitsStorage()

def lsst.obs.base.cameraMapper.validateRecipeFitsStorage (   recipes)
Validate recipes for FitsStorage

The recipes are supplemented with default values where appropriate.

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

Parameters
----------
recipes : `lsst.daf.persistence.Policy`
    FitsStorage recipes to validate.

Returns
-------
validated : `lsst.daf.base.PropertySet`
    Validated FitsStorage recipe.

Raises
------
`RuntimeError`
    If validation fails.

Definition at line 1372 of file cameraMapper.py.

1372 def validateRecipeFitsStorage(recipes):
1373  """Validate recipes for FitsStorage
1374 
1375  The recipes are supplemented with default values where appropriate.
1376 
1377  TODO: replace this custom validation code with Cerberus (DM-11846)
1378 
1379  Parameters
1380  ----------
1381  recipes : `lsst.daf.persistence.Policy`
1382  FitsStorage recipes to validate.
1383 
1384  Returns
1385  -------
1386  validated : `lsst.daf.base.PropertySet`
1387  Validated FitsStorage recipe.
1388 
1389  Raises
1390  ------
1391  `RuntimeError`
1392  If validation fails.
1393  """
1394  # Schemas define what should be there, and the default values (and by the
1395  # default value, the expected type).
1396  compressionSchema = {
1397  "algorithm": "NONE",
1398  "rows": 1,
1399  "columns": 0,
1400  "quantizeLevel": 0.0,
1401  }
1402  scalingSchema = {
1403  "algorithm": "NONE",
1404  "bitpix": 0,
1405  "maskPlanes": ["NO_DATA"],
1406  "seed": 0,
1407  "quantizeLevel": 4.0,
1408  "quantizePad": 5.0,
1409  "fuzz": True,
1410  "bscale": 1.0,
1411  "bzero": 0.0,
1412  }
1413 
1414  def checkUnrecognized(entry, allowed, description):
1415  """Check to see if the entry contains unrecognised keywords"""
1416  unrecognized = set(entry.keys()) - set(allowed)
1417  if unrecognized:
1418  raise RuntimeError(
1419  "Unrecognized entries when parsing image compression recipe %s: %s" %
1420  (description, unrecognized))
1421 
1422  validated = {}
1423  for name in recipes.names(True):
1424  checkUnrecognized(recipes[name], ["image", "mask", "variance"], name)
1425  rr = dafBase.PropertySet()
1426  validated[name] = rr
1427  for plane in ("image", "mask", "variance"):
1428  checkUnrecognized(recipes[name][plane], ["compression", "scaling"],
1429  name + "->" + plane)
1430 
1431  for settings, schema in (("compression", compressionSchema),
1432  ("scaling", scalingSchema)):
1433  prefix = plane + "." + settings
1434  if settings not in recipes[name][plane]:
1435  for key in schema:
1436  rr.set(prefix + "." + key, schema[key])
1437  continue
1438  entry = recipes[name][plane][settings]
1439  checkUnrecognized(entry, schema.keys(), name + "->" + plane + "->" + settings)
1440  for key in schema:
1441  value = type(schema[key])(entry[key]) if key in entry else schema[key]
1442  rr.set(prefix + "." + key, value)
1443  return validated
lsst::afw::image::DecoratedImage
A container for an Image and its associated metadata.
Definition: Image.h:404
lsst::afw::image::Exposure
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition: Exposure.h:72
lsst::afw::image::makeExposure
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:442
lsst::afw::image::MaskedImage
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
lsst.obs.base.cameraMapper.exposureFromImage
def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo=True)
Definition: cameraMapper.py:1319
lsst.obs.base.cameraMapper.validateRecipeFitsStorage
def validateRecipeFitsStorage(recipes)
Definition: cameraMapper.py:1372
type
table::Key< int > type
Definition: Detector.cc:163
lsst::daf::base::PropertySet
Class for storing generic metadata.
Definition: PropertySet.h:67
lsst::afw::image::makeMaskedImage
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
set
daf::base::PropertySet * set
Definition: fits.cc:912