77 def run(self, wcs_bbox_tuple_list, oldSkyMap=None):
78 """Make a SkyMap from the bounds of the given set of calexp metadata.
82 wcs_bbox_tuple_list : `iterable`
83 A list of tuples with each element expected to be a (Wcs, Box2I) pair.
84 oldSkyMap : `lsst.skymap.DiscreteSkyMap`, optional
85 The SkyMap to extend if appending.
89 skyMap : `lsst.pipe.base.Struct`
90 Sky map returned as a struct with attributes:
93 The returned SkyMap (`lsst.skyMap.SkyMap`).
95 self.log.info(
"Extracting bounding boxes of %d images", len(wcs_bbox_tuple_list))
97 for wcs, boxI
in wcs_bbox_tuple_list:
99 points.extend(wcs.pixelToSky(corner).getVector()
for corner
in boxD.getCorners())
101 raise RuntimeError(
"No data found from which to compute convex hull")
102 self.log.info(
"Computing spherical convex hull")
106 "Failed to compute convex hull of the vertices of all calexp bounding boxes; "
107 "they may not be hemispherical."
109 circle = polygon.getBoundingCircle()
111 skyMapConfig = DiscreteSkyMap.ConfigClass()
113 skyMapConfig.raList.extend(oldSkyMap.config.raList)
114 skyMapConfig.decList.extend(oldSkyMap.config.decList)
115 skyMapConfig.radiusList.extend(oldSkyMap.config.radiusList)
116 configIntersection = {k: getattr(self.config.skyMap, k)
117 for k
in self.config.skyMap.toDict()
118 if k
in skyMapConfig}
119 skyMapConfig.update(**configIntersection)
121 skyMapConfig.raList.append(circleCenter[0].asDegrees())
122 skyMapConfig.decList.append(circleCenter[1].asDegrees())
123 circleRadiusDeg = circle.getOpeningAngle().asDegrees()
124 skyMapConfig.radiusList.append(circleRadiusDeg + self.config.borderSize)
125 skyMap = DiscreteSkyMap(skyMapConfig)
127 for tractInfo
in skyMap:
128 wcs = tractInfo.getWcs()
136 skyPosList = [wcs.pixelToSky(pos).getPosition(geom.degrees)
for pos
in pixelPosList]
137 posStrList = [
"(%0.3f, %0.3f)" % tuple(skyPos)
for skyPos
in skyPosList]
138 self.log.info(
"tract %s has corners %s (RA, Dec deg) and %s x %s patches",
139 tractInfo.getId(),
", ".join(posStrList),
140 tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1])
141 return pipeBase.Struct(