Coverage for python/lsst/meas/algorithms/makeCoaddApCorrMap.py : 94%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#
2# LSST Data Management System
3#
4# Copyright 2008-2017 AURA/LSST.
5#
6# This product includes software developed by the
7# LSST Project (http://www.lsst.org/).
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the LSST License Statement and
20# the GNU General Public License along with this program. If not,
21# see <https://www.lsstcorp.org/LegalNotices/>.
22#
23__all__ = ["makeCoaddApCorrMap", ]
25from lsst.afw.image import ApCorrMap
26from .coaddBoundedField import CoaddBoundedField, CoaddBoundedFieldElement
29def makeCoaddApCorrMap(catalog, coaddBox, coaddWcs, weightFieldName="weight"):
30 """Construct an ApCorrMap for a coadd
32 @param catalog: Table of coadd inputs (lsst.afw.table.ExposureCatalog)
33 @param coaddBox: Bounding box for coadd (lsst.geom.Box2I)
34 @param coaddWcs: Wcs for coadd
35 @param weightFieldName: name of weight field in catalog
36 @return aperture corrections
37 """
39 # Assemble the BoundedFields for each type
40 everything = {} # name --> list of CoaddBoundedFieldElement
41 weightKey = catalog.schema[weightFieldName].asKey()
42 for row in catalog:
43 apCorrMap = row.getApCorrMap()
44 if not apCorrMap: 44 ↛ 45line 44 didn't jump to line 45, because the condition on line 44 was never true
45 continue
46 weight = row.get(weightKey)
47 wcs = row.getWcs()
48 validPolygon = row.getValidPolygon()
49 for name, bf in apCorrMap.items():
50 if name not in everything:
51 everything[name] = []
52 everything[name].append(CoaddBoundedFieldElement(bf, wcs, validPolygon, weight))
54 # Construct a CoaddBoundedField for each type
55 apCorrMap = ApCorrMap()
56 for name, elements in everything.items():
57 apCorrMap.set(name, CoaddBoundedField(coaddBox, coaddWcs, elements))
59 return apCorrMap