In DM-13054, I refactored PhotoCalTask to make
Colorterms more useable by other code. This necessitated pulling the code that extracted the flux and fluxErr from the cross-matched reference catalog and computed the colorterm corrections out of
PhotoCalTask.extractMagArrays() and moving it to
In doing so, I changed the flux->ABmag calculations to use
astropy.units wherever possible, and unrolled a loop over the “primary/secondary” fluxes that go into the colorterm calculation. Surprisingly, this resulted in changes to the results of an
fgcmcal test. Some investigation by @erykoff found two relevant differences: 1)
astropy.units does a more correct Jy->ABmag calculation, and 2) the old code was using the wrong reference flux/fluxErr to compute the reference magnitude error.
Calib.abMagErrFromFluxErr hard coded
3631.0 as the jansky ABmag reference flux, when the correct value is
1e23 * 10^(48.6 / -2.5) (as used by astropy.units). This is a change on the order of 1e-5, so unlikely to matter to most calculations.
2: A loop over flux fields in
extractMagArrays() overwrote the reference flux error array extracted from the matched catalog, so that the fluxErr that went into the magErr calculation was the “secondary” flux, instead of the “primary” flux. Thus, the
refMagErr in the result of that method (and thus the output of
PhotoCalTask.run().array) was fundamentally incorrect.
@erykoff and I think that the only code affected by this change is fgcmcal, since we couldn’t find anywhere else that used the
refMagErr produced by
PhotoCalTask itself ignores reference magnitude errors as part of the single frame calibration calculation. There are no tests that properly exercised this code; I didn’t write any new tests for it because I’m skeptical of the existing colorterm error propagation code. If anyone does use that output from
PhotoCalTask, you will now get different, and less incorrect, results from it.
I’m sure there’s even more fallout related to the long-untouched DM-2308, due to the fact that we haven’t been using the reference catalog flux errors in our calibrations so far (RFC-535). I’ve filed DM-17692 to dig into the flux error propagation in
Colorterms, as it all seems rather suspect to me. Tackling the colorterm error math should probably wait for some decisions on how to deal with that system overall (a la this post: Reference catalogs, camFluxes, and colorterms), but I fear we further delay DM-2308 at our calibration-y peril.