22__all__ = [
"MakeDiscreteSkyMapConfig",
"MakeDiscreteSkyMapTask"]
30from lsst.utils.timer
import timeMethod
34 """Config for MakeDiscreteSkyMapTask.
37 coaddName = pexConfig.Field(
38 doc="coadd name, e.g. deep, goodSeeing, chiSquared",
42 skyMap = pexConfig.ConfigField(
43 dtype=BaseSkyMap.ConfigClass,
44 doc=
"SkyMap configuration parameters, excluding position and radius"
46 borderSize = pexConfig.Field(
47 doc=
"additional border added to the bounding box of the calexps, in degrees",
51 doAppend = pexConfig.Field(
52 doc=
"append another tract to an existing DiscreteSkyMap on disk, if present?",
56 doWrite = pexConfig.Field(
57 doc=
"persist the skyMap?",
63 self.
skyMap.tractOverlap = 0.0
67 """Make a DiscreteSkyMap in a repository, using the bounding box of a set of calexps.
69 The command-line and run signatures
and config are sufficiently different
from MakeSkyMapTask
70 that we don
't inherit from it, but it is a replacement, so we use the same config/metadata names.
73 ConfigClass = MakeDiscreteSkyMapConfig
74 _DefaultName = "makeDiscreteSkyMap"
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(
def run(self, wcs_bbox_tuple_list, oldSkyMap=None)
static ConvexPolygon convexHull(std::vector< UnitVector3d > const &points)