Thanks for the review, Jim. I made the changes you requested (removed above noted obs_subaru config, so there's a new PR here, and added a comment to the test override in ap_association). I also did a bit more testing with other datasets just to make sure things look ok (thanks to Meredith Rawls for getting my going with DECam processing in gen3!)
The following plots show:
- full reference catalog (i.e. all of the shards associated with the visit/detector) as blue circles
- new "pre-filtered" catalog added in this ticket as orange crosses
- sources actually used in the SFM astrometry fit (astrom_used) as purple stars
- several WCS/bboxes: black = raw WCS, dotted pink = black + original 300 padding, dash-dot lime = dotted pink + 100 pixel "extra" outerRegion padding, dashed teal = calexp WCS.
In the following series of plots for the three datasets, the first plot shows the above for the original padding of 300 and the second is for the new 250 pixel padding (the pink and lime bboxes still reflect the 300, so you can see the pre-filtered cat doesn't extend all the way out to them).
HSC:
300 pixel padding
250 pixel padding

DECam:
300 pixel padding
250 pixel padding

DC2:
300 pixel padding
250 pixel padding

They all look like the ended up with identical astrometry fits...except for DC2 example, where there seems to be a dearth of astrom_used points in the upper right corner of the original 300 pixel padding, but a bunch do show up in the 250 pixel padding. I actually looked at ~twenty different detectors for this DC2 visit and this was the only one showing any difference. Given that the calexp WCSs look identical and that the 250 padding seems to be "better", I'm not concerned about this difference.
I had to do some rebasing and there's the new obs_subaru PR, so I kicked off another Jenkins (but seeing the recent traffic on #dm-build-problems, I won't be surprised if the MacOS build fails...)
Ok, I have confirmed that setting the pixelMargin to match computeVisitRegions["single-raw-wcs"].padding does indeed resolve the issue for the first CCD I've tested. Here is the before (with pixelMargin = 300):
and here is the after (with pixelMargin = 250):
I still have to battle-test this against a larger selection of the cases this showed up in RC2 and have a think about whether we can guard against "bad/internally inconsistent" settings of these parameters in code...but an override in obs_subaru will be a minimal "solution" for now.