LSSTApplications  17.0+10,17.0+51,17.0+88,18.0.0+10,18.0.0+15,18.0.0+34,18.0.0+4,18.0.0+6,18.0.0-2-ge43143a+6,18.1.0-1-g0001055+2,18.1.0-1-g0896a44+10,18.1.0-1-g1349e88+9,18.1.0-1-g2505f39+7,18.1.0-1-g380d4d4+9,18.1.0-1-g5e4b7ea+2,18.1.0-1-g7e8fceb,18.1.0-1-g85f8cd4+7,18.1.0-1-g9a6769a+3,18.1.0-1-ga1a4c1a+6,18.1.0-1-gc037db8+2,18.1.0-1-gd55f500+3,18.1.0-1-ge10677a+7,18.1.0-10-g73b8679e+12,18.1.0-12-gf30922b,18.1.0-13-g451e75588,18.1.0-13-gbfe7f7f,18.1.0-2-g31c43f9+7,18.1.0-2-g9c63283+9,18.1.0-2-gdf0b915+9,18.1.0-2-gf03bb23+2,18.1.0-3-g52aa583+3,18.1.0-3-g8f4a2b1+1,18.1.0-3-g9cb968e+8,18.1.0-4-g7bbbad0,18.1.0-5-g510c42a+8,18.1.0-5-ga46117f,18.1.0-5-gaeab27e+9,18.1.0-6-gdda7f3e+11,18.1.0-8-g4084bf03+1,w.2019.34
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 1296 of file cameraMapper.py.

1296 def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo=True):
1297  """Generate an Exposure from an image-like object
1298 
1299  If the image is a DecoratedImage then also set its WCS and metadata
1300  (Image and MaskedImage are missing the necessary metadata
1301  and Exposure already has those set)
1302 
1303  Parameters
1304  ----------
1305  image : Image-like object
1306  Can be one of lsst.afw.image.DecoratedImage, Image, MaskedImage or
1307  Exposure.
1308 
1309  Returns
1310  -------
1311  `lsst.afw.image.Exposure`
1312  Exposure containing input image.
1313  """
1314  metadata = None
1315  if isinstance(image, afwImage.MaskedImage):
1316  exposure = afwImage.makeExposure(image)
1317  elif isinstance(image, afwImage.DecoratedImage):
1318  exposure = afwImage.makeExposure(afwImage.makeMaskedImage(image.getImage()))
1319  metadata = image.getMetadata()
1320  exposure.setMetadata(metadata)
1321  elif isinstance(image, afwImage.Exposure):
1322  exposure = image
1323  metadata = exposure.getMetadata()
1324  else: # Image
1326 
1327  # set VisitInfo if we can
1328  if setVisitInfo and exposure.getInfo().getVisitInfo() is None:
1329  if metadata is not None:
1330  if mapper is None:
1331  if not logger:
1332  logger = lsstLog.Log.getLogger("CameraMapper")
1333  logger.warn("I can only set the VisitInfo if you provide a mapper")
1334  else:
1335  exposureId = mapper._computeCcdExposureId(dataId)
1336  visitInfo = mapper.makeRawVisitInfo(md=metadata, exposureId=exposureId)
1337 
1338  exposure.getInfo().setVisitInfo(visitInfo)
1339 
1340  return exposure
1341 
1342 
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:453
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 1343 of file cameraMapper.py.

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