@@ -80,6 +80,9 @@ def run(self, exposure, sensorRef, templateIdList=None):
8080 self .log .info ("Using skyMap tract %s" % (tractInfo .getId (),))
8181 skyCorners = [expWcs .pixelToSky (pixPos ) for pixPos in expBoxD .getCorners ()]
8282 patchList = tractInfo .findPatchList (skyCorners )
83+ expFilterName = sensorRef .getButler ().queryMetadata ("calexp" ,
84+ format = "filter" ,
85+ dataId = sensorRef .dataId )[0 ]
8386
8487 if not patchList :
8588 raise RuntimeError ("No suitable tract found" )
@@ -99,7 +102,8 @@ def run(self, exposure, sensorRef, templateIdList=None):
99102 coaddExposure .getMaskedImage ().set (np .nan , afwImage .Mask \
100103 .getPlaneBitMask ("NO_DATA" ), np .nan )
101104 nPatchesFound = 0
102- coaddFilter = None
105+
106+ coaddFilterName = expFilterName
103107 coaddPsf = None
104108 for patchInfo in patchList :
105109 patchSubBBox = patchInfo .getOuterBBox ()
@@ -108,6 +112,7 @@ def run(self, exposure, sensorRef, templateIdList=None):
108112 datasetType = self .getCoaddDatasetName () + "_sub" ,
109113 bbox = patchSubBBox ,
110114 tract = tractInfo .getId (),
115+ filter = coaddFilterName ,
111116 patch = "%s,%s" % (patchInfo .getIndex ()[0 ], patchInfo .getIndex ()[1 ]),
112117 )
113118 if patchSubBBox .isEmpty ():
@@ -122,8 +127,6 @@ def run(self, exposure, sensorRef, templateIdList=None):
122127 self .log .info ("Reading patch %s" % patchArgDict )
123128 coaddPatch = sensorRef .get (** patchArgDict )
124129 coaddExposure .getMaskedImage ().assign (coaddPatch .getMaskedImage (), coaddPatch .getBBox ())
125- if coaddFilter is None :
126- coaddFilter = coaddPatch .getFilter ()
127130
128131 # Retrieve the PSF for this coadd tract, if not already retrieved
129132 if coaddPsf is None and coaddPatch .hasPsf ():
@@ -136,7 +139,7 @@ def run(self, exposure, sensorRef, templateIdList=None):
136139 raise RuntimeError ("No coadd Psf found!" )
137140
138141 coaddExposure .setPsf (coaddPsf )
139- coaddExposure .setFilter (coaddFilter )
142+ coaddExposure .setFilter (exposure . getFilter () )
140143 return pipeBase .Struct (exposure = coaddExposure ,
141144 sources = None )
142145
0 commit comments