From d7e8afa3a28dfb722644174c0df69eb11d06ee28 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Wed, 20 Jul 2022 15:08:40 -0700 Subject: [PATCH 1/2] Replace healpy with hpgeom. --- python/lsst/fgcmcal/fgcmLoadReferenceCatalog.py | 12 +++++------- python/lsst/fgcmcal/fgcmOutputProducts.py | 12 +++++++----- tests/test_loadref_hsc.py | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/python/lsst/fgcmcal/fgcmLoadReferenceCatalog.py b/python/lsst/fgcmcal/fgcmLoadReferenceCatalog.py index abddeec..215b567 100644 --- a/python/lsst/fgcmcal/fgcmLoadReferenceCatalog.py +++ b/python/lsst/fgcmcal/fgcmLoadReferenceCatalog.py @@ -29,7 +29,7 @@ """ import numpy as np -import healpy as hp +import hpgeom as hpg from astropy import units import lsst.pex.config as pexConfig @@ -143,11 +143,10 @@ def getFgcmReferenceStarsHealpix(self, nside, pixel, filterList, nest=False): """ # Determine the size of the sky circle to load - theta, phi = hp.pix2ang(nside, pixel, nest=nest) - center = lsst.geom.SpherePoint(phi * lsst.geom.radians, (np.pi/2. - theta) * lsst.geom.radians) + lon, lat = hpg.pixel_to_angle(nside, pixel, nest=nest, degrees=False) + center = lsst.geom.SpherePoint(lon * lsst.geom.degrees, lat * lsst.geom.radians) - corners = hp.boundaries(nside, pixel, step=1, nest=nest) - theta_phi = hp.vec2ang(np.transpose(corners)) + theta_phi = hpg.boundaries(nside, pixel, step=1, nest=nest, lonlat=False) radius = 0.0 * lsst.geom.radians for ctheta, cphi in zip(*theta_phi): @@ -161,8 +160,7 @@ def getFgcmReferenceStarsHealpix(self, nside, pixel, filterList, nest=False): center.getDec().asDegrees(), radius.asDegrees(), filterList) - catPix = hp.ang2pix(nside, np.radians(90.0 - fgcmRefCat['dec']), - np.radians(fgcmRefCat['ra']), nest=nest) + catPix = hpg.angle_to_pixel(nside, fgcmRefCat['ra'], fgcmRefCat['dec'], nest=nest) inPix, = np.where(catPix == pixel) diff --git a/python/lsst/fgcmcal/fgcmOutputProducts.py b/python/lsst/fgcmcal/fgcmOutputProducts.py index 3844db5..3906d43 100644 --- a/python/lsst/fgcmcal/fgcmOutputProducts.py +++ b/python/lsst/fgcmcal/fgcmOutputProducts.py @@ -34,7 +34,7 @@ import copy import numpy as np -import healpy as hp +import hpgeom as hpg import esutil from astropy import units @@ -582,10 +582,12 @@ def _computeReferenceOffsets(self, stdCat, lutCat, physicalFilterMap, bands): # Note that there is an assumption here that the ra/dec coords stored # on-disk are in radians, and therefore that starObs['coord_ra'] / # starObs['coord_dec'] return radians when used as an array of numpy float64s. - theta = np.pi/2. - stdCat['coord_dec'] - phi = stdCat['coord_ra'] - - ipring = hp.ang2pix(self.config.referencePixelizationNside, theta, phi) + ipring = hpg.angle_to_pixel( + self.config.referencePixelizationNside, + stdCat['coord_ra'], + stdCat['coord_dec'], + degrees=False, + ) h, rev = esutil.stat.histogram(ipring, rev=True) gdpix, = np.where(h >= self.config.referencePixelizationMinStars) diff --git a/tests/test_loadref_hsc.py b/tests/test_loadref_hsc.py index 660d4da..011590e 100644 --- a/tests/test_loadref_hsc.py +++ b/tests/test_loadref_hsc.py @@ -27,7 +27,7 @@ import unittest import os import numpy as np -import healpy as hp +import hpgeom as hpg import esutil import tempfile @@ -131,7 +131,7 @@ def test_fgcmLoadReference(self): refCat = loadCat.getFgcmReferenceStarsHealpix(nside, pixel, filterList) - ipring = hp.ang2pix(nside, np.radians(90.0 - refCat['dec']), np.radians(refCat['ra'])) + ipring = hpg.angle_to_pixel(nside, refCat['ra'], refCat['dec'], nest=False) self.assertEqual(pixel, np.max(ipring)) self.assertEqual(pixel, np.min(ipring)) From e27b0f44fadfb52e1ea6ae88bf2bb0fcd830b71d Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Wed, 20 Jul 2022 15:09:05 -0700 Subject: [PATCH 2/2] Replace deprecated setFilterLabel. --- python/lsst/fgcmcal/fgcmOutputProducts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/lsst/fgcmcal/fgcmOutputProducts.py b/python/lsst/fgcmcal/fgcmOutputProducts.py index 3906d43..4bcef11 100644 --- a/python/lsst/fgcmcal/fgcmOutputProducts.py +++ b/python/lsst/fgcmcal/fgcmOutputProducts.py @@ -687,7 +687,7 @@ def _computeOffsetOneBand(self, sourceMapper, badStarKey, rec.set(badStarKey, True) exposure = afwImage.ExposureF() - exposure.setFilterLabel(filterLabel) + exposure.setFilter(filterLabel) if refFluxFields[b_index] is None: # Need to find the flux field in the reference catalog