28from lsst.utils.timer
import timeMethod
32 """Config for MakeDiscreteSkyMapTask
34 coaddName = pexConfig.Field(
35 doc="coadd name, e.g. deep, goodSeeing, chiSquared",
39 skyMap = pexConfig.ConfigField(
40 dtype=BaseSkyMap.ConfigClass,
41 doc=
"SkyMap configuration parameters, excluding position and radius"
43 borderSize = pexConfig.Field(
44 doc=
"additional border added to the bounding box of the calexps, in degrees",
48 doAppend = pexConfig.Field(
49 doc=
"append another tract to an existing DiscreteSkyMap on disk, if present?",
53 doWrite = pexConfig.Field(
54 doc=
"persist the skyMap?",
60 self.
skyMap.tractOverlap = 0.0
64 """!Make a DiscreteSkyMap in a repository, using the bounding box of a set of calexps.
66 The command-line and run signatures
and config are sufficiently different
from MakeSkyMapTask
67 that we don
't inherit from it, but it is a replacement, so we use the same config/metadata names.
69 ConfigClass = MakeDiscreteSkyMapConfig
70 _DefaultName = "makeDiscreteSkyMap"
73 def run(self, wcs_bbox_tuple_list, oldSkyMap=None):
74 """Make a SkyMap from the bounds of the given set of calexp metadata.
78 wcs_bbox_tuple_list : iterable
79 A list of tuples with each element expected to be a (Wcs, Box2I) pair
80 oldSkyMap : `lsst.skymap.DiscreteSkyMap`, option
81 The SkyMap to extend
if appending
84 struct : `lsst.pipe.base.Struct
85 The returned struct has one attribute, ``skyMap``, which holds the returned SkyMap
87 self.log.info("Extracting bounding boxes of %d images", len(wcs_bbox_tuple_list))
89 for wcs, boxI
in wcs_bbox_tuple_list:
91 points.extend(wcs.pixelToSky(corner).getVector()
for corner
in boxD.getCorners())
93 raise RuntimeError(
"No data found from which to compute convex hull")
94 self.log.info(
"Computing spherical convex hull")
98 "Failed to compute convex hull of the vertices of all calexp bounding boxes; "
99 "they may not be hemispherical."
101 circle = polygon.getBoundingCircle()
103 skyMapConfig = DiscreteSkyMap.ConfigClass()
105 skyMapConfig.raList.extend(oldSkyMap.config.raList)
106 skyMapConfig.decList.extend(oldSkyMap.config.decList)
107 skyMapConfig.radiusList.extend(oldSkyMap.config.radiusList)
108 configIntersection = {k: getattr(self.config.skyMap, k)
109 for k
in self.config.skyMap.toDict()
110 if k
in skyMapConfig}
111 skyMapConfig.update(**configIntersection)
113 skyMapConfig.raList.append(circleCenter[0].asDegrees())
114 skyMapConfig.decList.append(circleCenter[1].asDegrees())
115 circleRadiusDeg = circle.getOpeningAngle().asDegrees()
116 skyMapConfig.radiusList.append(circleRadiusDeg + self.config.borderSize)
117 skyMap = DiscreteSkyMap(skyMapConfig)
119 for tractInfo
in skyMap:
120 wcs = tractInfo.getWcs()
128 skyPosList = [wcs.pixelToSky(pos).getPosition(geom.degrees)
for pos
in pixelPosList]
129 posStrList = [
"(%0.3f, %0.3f)" % tuple(skyPos)
for skyPos
in skyPosList]
130 self.log.info(
"tract %s has corners %s (RA, Dec deg) and %s x %s patches",
131 tractInfo.getId(),
", ".join(posStrList),
132 tractInfo.getNumPatches()[0], tractInfo.getNumPatches()[1])
133 return pipeBase.Struct(
Make a DiscreteSkyMap in a repository, using the bounding box of a set of calexps.
static ConvexPolygon convexHull(std::vector< UnitVector3d > const &points)