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

1437 def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo=True):
1438  """Generate an Exposure from an image-like object
1439 
1440  If the image is a DecoratedImage then also set its WCS and metadata
1441  (Image and MaskedImage are missing the necessary metadata
1442  and Exposure already has those set)
1443 
1444  Parameters
1445  ----------
1446  image : Image-like object
1447  Can be one of lsst.afw.image.DecoratedImage, Image, MaskedImage or
1448  Exposure.
1449 
1450  Returns
1451  -------
1452  `lsst.afw.image.Exposure`
1453  Exposure containing input image.
1454  """
1455  translatorClass = None
1456  if mapper is not None:
1457  translatorClass = mapper.translatorClass
1458 
1459  metadata = None
1460  if isinstance(image, afwImage.MaskedImage):
1461  exposure = afwImage.makeExposure(image)
1462  elif isinstance(image, afwImage.DecoratedImage):
1463  exposure = afwImage.makeExposure(afwImage.makeMaskedImage(image.getImage()))
1464  metadata = image.getMetadata()
1465  fix_header(metadata, translator_class=translatorClass)
1466  exposure.setMetadata(metadata)
1467  elif isinstance(image, afwImage.Exposure):
1468  exposure = image
1469  metadata = exposure.getMetadata()
1470  fix_header(metadata, translator_class=translatorClass)
1471  else: # Image
1473 
1474  # set VisitInfo if we can
1475  if setVisitInfo and exposure.getInfo().getVisitInfo() is None:
1476  if metadata is not None:
1477  if mapper is None:
1478  if not logger:
1479  logger = lsstLog.Log.getLogger("CameraMapper")
1480  logger.warn("I can only set the VisitInfo if you provide a mapper")
1481  else:
1482  exposureId = mapper._computeCcdExposureId(dataId)
1483  visitInfo = mapper.makeRawVisitInfo(md=metadata, exposureId=exposureId)
1484 
1485  exposure.getInfo().setVisitInfo(visitInfo)
1486 
1487  return exposure
1488 
1489 
A container for an Image and its associated metadata.
Definition: Image.h:404
A class to contain the data, WCS, and other information needed to describe an image of the sky.
Definition: Exposure.h:72
A class to manipulate images, masks, and variance as a single object.
Definition: MaskedImage.h:73
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
def exposureFromImage(image, dataId=None, mapper=None, logger=None, setVisitInfo=True)

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

1490 def validateRecipeFitsStorage(recipes):
1491  """Validate recipes for FitsStorage
1492 
1493  The recipes are supplemented with default values where appropriate.
1494 
1495  TODO: replace this custom validation code with Cerberus (DM-11846)
1496 
1497  Parameters
1498  ----------
1499  recipes : `lsst.daf.persistence.Policy`
1500  FitsStorage recipes to validate.
1501 
1502  Returns
1503  -------
1504  validated : `lsst.daf.base.PropertySet`
1505  Validated FitsStorage recipe.
1506 
1507  Raises
1508  ------
1509  `RuntimeError`
1510  If validation fails.
1511  """
1512  # Schemas define what should be there, and the default values (and by the
1513  # default value, the expected type).
1514  compressionSchema = {
1515  "algorithm": "NONE",
1516  "rows": 1,
1517  "columns": 0,
1518  "quantizeLevel": 0.0,
1519  }
1520  scalingSchema = {
1521  "algorithm": "NONE",
1522  "bitpix": 0,
1523  "maskPlanes": ["NO_DATA"],
1524  "seed": 0,
1525  "quantizeLevel": 4.0,
1526  "quantizePad": 5.0,
1527  "fuzz": True,
1528  "bscale": 1.0,
1529  "bzero": 0.0,
1530  }
1531 
1532  def checkUnrecognized(entry, allowed, description):
1533  """Check to see if the entry contains unrecognised keywords"""
1534  unrecognized = set(entry.keys()) - set(allowed)
1535  if unrecognized:
1536  raise RuntimeError(
1537  "Unrecognized entries when parsing image compression recipe %s: %s" %
1538  (description, unrecognized))
1539 
1540  validated = {}
1541  for name in recipes.names(True):
1542  checkUnrecognized(recipes[name], ["image", "mask", "variance"], name)
1543  rr = dafBase.PropertySet()
1544  validated[name] = rr
1545  for plane in ("image", "mask", "variance"):
1546  checkUnrecognized(recipes[name][plane], ["compression", "scaling"],
1547  name + "->" + plane)
1548 
1549  for settings, schema in (("compression", compressionSchema),
1550  ("scaling", scalingSchema)):
1551  prefix = plane + "." + settings
1552  if settings not in recipes[name][plane]:
1553  for key in schema:
1554  rr.set(prefix + "." + key, schema[key])
1555  continue
1556  entry = recipes[name][plane][settings]
1557  checkUnrecognized(entry, schema.keys(), name + "->" + plane + "->" + settings)
1558  for key in schema:
1559  value = type(schema[key])(entry[key]) if key in entry else schema[key]
1560  rr.set(prefix + "." + key, value)
1561  return validated
Class for storing generic metadata.
Definition: PropertySet.h:67
def validateRecipeFitsStorage(recipes)
table::Key< int > type
Definition: Detector.cc:163
daf::base::PropertySet * set
Definition: fits.cc:912