lsst.meas.astrom  13.0-14-g9415442+22
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
createMatchMetadata.py
Go to the documentation of this file.
1 from __future__ import absolute_import, division, print_function
2 
3 __all__ = ["MatchMetadata", "createMatchMetadata"]
4 
5 from lsst.daf.base import PropertyList
6 from lsst.afw.geom import Box2D
7 from lsst.afw.image.utils import getDistortedWcs
8 
9 
10 class MatchMetadata(PropertyList):
11  """Metadata required for unpersisting a match list"""
12 
13  def __init__(self, ctrCoord, radius, filterName):
14  """!Ctor
15 
16  @param[in] ctrCoord: Coordinates of center (lsst.afw.coord.IcrsCoord)
17  @param[in] radius: Minimum radius for selecting sources (lsst.afw.geom.Angle)
18  @param[in] filterName: Name of filter (str) or None
19  """
20  PropertyList.__init__(self)
21  ctrCoord = ctrCoord.toIcrs()
22  self.add('RA', ctrCoord.getRa().asDegrees(), 'field center in degrees')
23  self.add('DEC', ctrCoord.getDec().asDegrees(), 'field center in degrees')
24  self.add('RADIUS', radius.asDegrees(), 'field radius in degrees, minimum')
25  self.add('SMATCHV', 1, 'SourceMatchVector version number')
26  filterName = "UNKNOWN" if filterName is None else str(filterName)
27  self.add('FILTER', filterName, 'filter name for photometric data')
28 
29 
30 def createMatchMetadata(exposure, border=0):
31  """Create metadata required for unpersisting a match list
32 
33  @param[in] exposure exposure for which to create metadata
34  @param[in] border number of pixels by which to grow the bbox in all directions
35 
36  @return metadata about the field (a daf_base PropertyList)
37  """
38  bboxd = Box2D(exposure.getBBox())
39  bboxd.grow(border)
40  wcs = getDistortedWcs(exposure.getInfo())
41  ctrCoord = wcs.pixelToSky(bboxd.getCenter()).toIcrs()
42  approxRadius = max(ctrCoord.angularSeparation(wcs.pixelToSky(pp).toIcrs()) for pp in bboxd.getCorners())
43  return MatchMetadata(ctrCoord, approxRadius, exposure.getFilter().getName())