Skip to content

Commit

Permalink
Merge pull request #20 from lsst/tickets/DM-21982
Browse files Browse the repository at this point in the history
DM-21982: Update mag-flux conversions to explicitly use float64
  • Loading branch information
erykoff committed Oct 29, 2019
2 parents 39230f8 + a8c2605 commit 39eacb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions python/lsst/fgcmcal/fgcmOutputProducts.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,11 @@ def _formatCatalog(self, fgcmStarCat, offsets):
# Note that we don't have to set `resolved` because the default is False

for b, band in enumerate(self.bands):
mag = fgcmStarCat['mag_std_noabs'][:, b] + offsets[b]
mag = fgcmStarCat['mag_std_noabs'][:, b].astype(np.float64) + offsets[b]
# We want fluxes in nJy from calibrated AB magnitudes
# (after applying offset). Updated after RFC-549 and RFC-575.
flux = (mag*units.ABmag).to_value(units.nJy)
fluxErr = (np.log(10.) / 2.5) * flux * fgcmStarCat['magErr_std'][:, b]
fluxErr = (np.log(10.) / 2.5) * flux * fgcmStarCat['magErr_std'][:, b].astype(np.float64)

formattedCat['%s_flux' % (band)][:] = flux
formattedCat['%s_fluxErr' % (band)][:] = fluxErr
Expand Down
12 changes: 7 additions & 5 deletions tests/fgcmcalTestBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,13 @@ def _testFgcmOutputProducts(self, visitDataRefName, ccdDataRefName, filterMappin
# And make sure the numbers are consistent
test, = np.where(rawStars['id'][0] == refStruct.refCat['id'])

mag = rawStars['mag_std_noabs'][0, 0] + offsets[0]
flux = (mag*units.ABmag).to_value(units.nJy)
fluxErr = (np.log(10.) / 2.5) * flux * rawStars['magErr_std'][0, 0]
self.assertFloatsAlmostEqual(flux, refStruct.refCat['r_flux'][test[0]], rtol=1e-6)
self.assertFloatsAlmostEqual(fluxErr, refStruct.refCat['r_fluxErr'][test[0]], rtol=1e-6)
# Perform math on numpy arrays to maintain datatypes
mags = rawStars['mag_std_noabs'][:, 0].astype(np.float64) + offsets[0]
fluxes = (mags*units.ABmag).to_value(units.nJy)
fluxErrs = (np.log(10.) / 2.5) * fluxes * rawStars['magErr_std'][:, 0].astype(np.float64)
# Only check the first one
self.assertFloatsAlmostEqual(fluxes[0], refStruct.refCat['r_flux'][test[0]])
self.assertFloatsAlmostEqual(fluxErrs[0], refStruct.refCat['r_fluxErr'][test[0]])

# Test the joincal_photoCalib output

Expand Down

0 comments on commit 39eacb1

Please sign in to comment.