LSSTApplications  18.0.0+54,19.0.0,19.0.0+1,19.0.0+16,19.0.0+17,19.0.0+19,19.0.0+24,19.0.0+3,19.0.0-1-g20d9b18+10,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+10,19.0.0-1-g6fe20d0+2,19.0.0-1-g8c57eb9+10,19.0.0-1-gbfe0924+1,19.0.0-1-gdc0e4a7+15,19.0.0-1-ge272bc4+10,19.0.0-1-ge3aa853+1,19.0.0-14-gbb28fe44+1,19.0.0-16-g8258e2a+1,19.0.0-2-g0d9f9cd+17,19.0.0-2-g260436e+1,19.0.0-2-g9b11441+4,19.0.0-2-gd955cfd+23,19.0.0-3-g6513920+1,19.0.0-3-gc4f6e04,19.0.0-4-g41ffa1d+3,19.0.0-4-g725f80e+19,19.0.0-4-ga8eba22,19.0.0-5-g0745e3f+1,19.0.0-5-gd943061d,19.0.0-6-gb6b8b0a+1,19.0.0-7-ge358e0fc4,19.0.0-7-gea0a0fe+6,w.2020.03
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 1311 of file cameraMapper.py.

1311 def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo=True):
1312  """Generate an Exposure from an image-like object
1313 
1314  If the image is a DecoratedImage then also set its WCS and metadata
1315  (Image and MaskedImage are missing the necessary metadata
1316  and Exposure already has those set)
1317 
1318  Parameters
1319  ----------
1320  image : Image-like object
1321  Can be one of lsst.afw.image.DecoratedImage, Image, MaskedImage or
1322  Exposure.
1323 
1324  Returns
1325  -------
1326  `lsst.afw.image.Exposure`
1327  Exposure containing input image.
1328  """
1329  metadata = None
1330  if isinstance(image, afwImage.MaskedImage):
1331  exposure = afwImage.makeExposure(image)
1332  elif isinstance(image, afwImage.DecoratedImage):
1333  exposure = afwImage.makeExposure(afwImage.makeMaskedImage(image.getImage()))
1334  metadata = image.getMetadata()
1335  exposure.setMetadata(metadata)
1336  elif isinstance(image, afwImage.Exposure):
1337  exposure = image
1338  metadata = exposure.getMetadata()
1339  else: # Image
1341 
1342  # set VisitInfo if we can
1343  if setVisitInfo and exposure.getInfo().getVisitInfo() is None:
1344  if metadata is not None:
1345  if mapper is None:
1346  if not logger:
1347  logger = lsstLog.Log.getLogger("CameraMapper")
1348  logger.warn("I can only set the VisitInfo if you provide a mapper")
1349  else:
1350  exposureId = mapper._computeCcdExposureId(dataId)
1351  visitInfo = mapper.makeRawVisitInfo(md=metadata, exposureId=exposureId)
1352 
1353  exposure.getInfo().setVisitInfo(visitInfo)
1354 
1355  return exposure
1356 
1357 
A class to contain the data, WCS, and other information needed to describe an image of the sky...
Definition: Exposure.h:72
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:1279
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
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo=True)
A container for an Image and its associated metadata.
Definition: Image.h:404

◆ 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 1358 of file cameraMapper.py.

1358 def validateRecipeFitsStorage(recipes):
1359  """Validate recipes for FitsStorage
1360 
1361  The recipes are supplemented with default values where appropriate.
1362 
1363  TODO: replace this custom validation code with Cerberus (DM-11846)
1364 
1365  Parameters
1366  ----------
1367  recipes : `lsst.daf.persistence.Policy`
1368  FitsStorage recipes to validate.
1369 
1370  Returns
1371  -------
1372  validated : `lsst.daf.base.PropertySet`
1373  Validated FitsStorage recipe.
1374 
1375  Raises
1376  ------
1377  `RuntimeError`
1378  If validation fails.
1379  """
1380  # Schemas define what should be there, and the default values (and by the default
1381  # value, the expected type).
1382  compressionSchema = {
1383  "algorithm": "NONE",
1384  "rows": 1,
1385  "columns": 0,
1386  "quantizeLevel": 0.0,
1387  }
1388  scalingSchema = {
1389  "algorithm": "NONE",
1390  "bitpix": 0,
1391  "maskPlanes": ["NO_DATA"],
1392  "seed": 0,
1393  "quantizeLevel": 4.0,
1394  "quantizePad": 5.0,
1395  "fuzz": True,
1396  "bscale": 1.0,
1397  "bzero": 0.0,
1398  }
1399 
1400  def checkUnrecognized(entry, allowed, description):
1401  """Check to see if the entry contains unrecognised keywords"""
1402  unrecognized = set(entry.keys()) - set(allowed)
1403  if unrecognized:
1404  raise RuntimeError(
1405  "Unrecognized entries when parsing image compression recipe %s: %s" %
1406  (description, unrecognized))
1407 
1408  validated = {}
1409  for name in recipes.names(True):
1410  checkUnrecognized(recipes[name], ["image", "mask", "variance"], name)
1411  rr = dafBase.PropertySet()
1412  validated[name] = rr
1413  for plane in ("image", "mask", "variance"):
1414  checkUnrecognized(recipes[name][plane], ["compression", "scaling"],
1415  name + "->" + plane)
1416 
1417  for settings, schema in (("compression", compressionSchema),
1418  ("scaling", scalingSchema)):
1419  prefix = plane + "." + settings
1420  if settings not in recipes[name][plane]:
1421  for key in schema:
1422  rr.set(prefix + "." + key, schema[key])
1423  continue
1424  entry = recipes[name][plane][settings]
1425  checkUnrecognized(entry, schema.keys(), name + "->" + plane + "->" + settings)
1426  for key in schema:
1427  value = type(schema[key])(entry[key]) if key in entry else schema[key]
1428  rr.set(prefix + "." + key, value)
1429  return validated
1430 
def validateRecipeFitsStorage(recipes)
daf::base::PropertySet * set
Definition: fits.cc:902
table::Key< int > type
Definition: Detector.cc:163
Class for storing generic metadata.
Definition: PropertySet.h:67