LSSTApplications  17.0+124,17.0+14,17.0+73,18.0.0+37,18.0.0+80,18.0.0-4-g68ffd23+4,18.1.0-1-g0001055+12,18.1.0-1-g03d53ef+5,18.1.0-1-g1349e88+55,18.1.0-1-g2505f39+44,18.1.0-1-g5315e5e+4,18.1.0-1-g5e4b7ea+14,18.1.0-1-g7e8fceb+4,18.1.0-1-g85f8cd4+48,18.1.0-1-g8ff0b9f+4,18.1.0-1-ga2c679d+1,18.1.0-1-gd55f500+35,18.1.0-10-gb58edde+2,18.1.0-11-g0997b02+4,18.1.0-13-gfe4edf0b+12,18.1.0-14-g259bd21+21,18.1.0-19-gdb69f3f+2,18.1.0-2-g5f9922c+24,18.1.0-2-gd3b74e5+11,18.1.0-2-gfbf3545+32,18.1.0-26-g728bddb4+5,18.1.0-27-g6ff7ca9+2,18.1.0-3-g52aa583+25,18.1.0-3-g8ea57af+9,18.1.0-3-gb69f684+42,18.1.0-3-gfcaddf3+6,18.1.0-32-gd8786685a,18.1.0-4-gf3f9b77+6,18.1.0-5-g1dd662b+2,18.1.0-5-g6dbcb01+41,18.1.0-6-gae77429+3,18.1.0-7-g9d75d83+9,18.1.0-7-gae09a6d+30,18.1.0-9-gc381ef5+4,w.2019.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 1312 of file cameraMapper.py.

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

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