@@ -104,7 +104,7 @@ class MatchBackgroundsConfig(PipelineTaskConfig, pipelineConnections=MatchBackgr
104104 dtype = float ,
105105 doc = "Image variance weight when calculating the best reference exposure. "
106106 "Higher weights prefers exposures with low image variances. Ignored when ref visit supplied" ,
107- default = 0.4 ,
107+ default = 0.2 ,
108108 min = 0.0 ,
109109 max = 1.0 ,
110110 )
@@ -120,7 +120,7 @@ class MatchBackgroundsConfig(PipelineTaskConfig, pipelineConnections=MatchBackgr
120120 dtype = float ,
121121 doc = "Edge coverage weight (number of valid edge pixels) when calculating the best reference "
122122 "exposure. Higher weights prefer exposures with high coverage. Ignored when a ref visit supplied." ,
123- default = 0.2 ,
123+ default = 0.4 ,
124124 min = 0.0 ,
125125 max = 1.0 ,
126126 )
@@ -159,6 +159,10 @@ class MatchBackgroundsConfig(PipelineTaskConfig, pipelineConnections=MatchBackgr
159159 )
160160 binSize = Field [int ](
161161 doc = "Bin size for gridding the difference image and fitting a spatial model." ,
162+ default = 256 ,
163+ )
164+ chi2BinSize = Field [int ](
165+ doc = "Bin size for gridding images when choosing best reference exposure." ,
162166 default = 1024 ,
163167 )
164168 interpStyle = ChoiceField (
@@ -400,7 +404,7 @@ def _defineWarps(self, warps, refWarpVisit=None):
400404 instFluxToNanojansky = warp .getPhotoCalib ().instFluxToNanojansky (1 )
401405 warp .image *= instFluxToNanojansky # Images in nJy to facilitate difference imaging
402406 warp .variance *= instFluxToNanojansky
403- warpBg , _ = self ._makeBackground (warp .getMaskedImage ())
407+ warpBg , _ = self ._makeBackground (warp .getMaskedImage (), binSize = self . config . chi2BinSize )
404408
405409 # Return an approximation to the background
406410 approxCtrl = ApproximateControl (ApproximateControl .CHEBYSHEV , 1 , 1 , self .config .approxWeighting )
@@ -452,7 +456,7 @@ def _defineWarps(self, warps, refWarpVisit=None):
452456 self .log .info ("Using best reference visit %d" , refWarp .dataId ["visit" ])
453457 return refWarp , ind
454458
455- def _makeBackground (self , warp : MaskedImageF ) -> tuple [BackgroundMI , BackgroundControl ]:
459+ def _makeBackground (self , warp : MaskedImageF , binSize ) -> tuple [BackgroundMI , BackgroundControl ]:
456460 """Generate a simple binned background masked image for warped data.
457461
458462 Parameters
@@ -467,8 +471,8 @@ def _makeBackground(self, warp: MaskedImageF) -> tuple[BackgroundMI, BackgroundC
467471 bgCtrl: `~lsst.afw.math.BackgroundControl`
468472 Background control object.
469473 """
470- nx = warp .getWidth () // self . config . binSize
471- ny = warp .getHeight () // self . config . binSize
474+ nx = warp .getWidth () // binSize
475+ ny = warp .getHeight () // binSize
472476
473477 bgCtrl = BackgroundControl (nx , ny , self .statsCtrl , self .statsFlag )
474478 bgCtrl .setUndersampleStyle (self .config .undersampleStyle )
@@ -557,7 +561,7 @@ def matchBackgrounds(self, refExposure, sciExposure):
557561 diffMI = im .clone ()
558562 diffMI -= sciExposure .getMaskedImage ()
559563
560- bkgd , bctrl = self ._makeBackground (diffMI )
564+ bkgd , bctrl = self ._makeBackground (diffMI , binSize = self . config . binSize )
561565
562566 # Some config and input checks if config.usePolynomial:
563567 # 1) Check that order/bin size make sense:
0 commit comments