From 0eed2e8047422e13e43d7101512b5a3aacf69aef Mon Sep 17 00:00:00 2001 From: James Chiang Date: Tue, 17 Sep 2019 14:19:44 -0700 Subject: [PATCH] silence afw.geom deprecation warnings --- .../lsst/sims/GalSimInterface/galSimCameraWrapper.py | 6 +++--- python/lsst/sims/GalSimInterface/galSimCatalogs.py | 2 +- python/lsst/sims/GalSimInterface/galSimDetector.py | 10 +++++----- .../sims/GalSimInterface/wcsUtils/ApproximateWCS.py | 9 ++++----- python/lsst/sims/GalSimInterface/wcsUtils/WcsUtils.py | 3 ++- tests/testOutputWcs.py | 3 +-- tests/testWcsUtils.py | 3 +-- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/python/lsst/sims/GalSimInterface/galSimCameraWrapper.py b/python/lsst/sims/GalSimInterface/galSimCameraWrapper.py index d3e8ea0..7e8ec76 100644 --- a/python/lsst/sims/GalSimInterface/galSimCameraWrapper.py +++ b/python/lsst/sims/GalSimInterface/galSimCameraWrapper.py @@ -58,7 +58,7 @@ class that inherits from GalSimCameraWrapper. This class will import numpy as np from lsst.afw.cameraGeom import FOCAL_PLANE, PIXELS, TAN_PIXELS from lsst.afw.cameraGeom import FIELD_ANGLE -import lsst.afw.geom as afwGeom +import lsst.geom as LsstGeom import lsst.sims.coordUtils as coordUtils import lsst.sims.utils as simsUtils @@ -113,7 +113,7 @@ def getCenterPixel(self, detector_name): def getCenterPupil(self, detector_name): """ Return the pupil coordinates of the center of the named detector - as an afwGeom.Point2D + as an LsstGeom.Point2D """ if not hasattr(self, '_center_pupil_cache'): self._center_pupil_cache = {} @@ -129,7 +129,7 @@ def getCenterPupil(self, detector_name): def getCornerPupilList(self, detector_name): """ Return a list of the pupil coordinates of the corners of the named - detector as a list of afwGeom.Point2D objects + detector as a list of LsstGeom.Point2D objects """ if not hasattr(self, '_corner_pupil_cache'): self._corner_pupil_cache = {} diff --git a/python/lsst/sims/GalSimInterface/galSimCatalogs.py b/python/lsst/sims/GalSimInterface/galSimCatalogs.py index eda62c2..2bc9dbe 100644 --- a/python/lsst/sims/GalSimInterface/galSimCatalogs.py +++ b/python/lsst/sims/GalSimInterface/galSimCatalogs.py @@ -28,7 +28,7 @@ from lsst.sims.photUtils import (Sed, Bandpass, BandpassDict, PhotometricParameters) import lsst.afw.cameraGeom.testUtils as camTestUtils -import lsst.afw.geom as afwGeom +import lsst.geom as LsstGeom from lsst.afw.cameraGeom import FIELD_ANGLE, PIXELS, FOCAL_PLANE from lsst.afw.cameraGeom import WAVEFRONT, GUIDER diff --git a/python/lsst/sims/GalSimInterface/galSimDetector.py b/python/lsst/sims/GalSimInterface/galSimDetector.py index 9237b64..6d22940 100644 --- a/python/lsst/sims/GalSimInterface/galSimDetector.py +++ b/python/lsst/sims/GalSimInterface/galSimDetector.py @@ -9,7 +9,7 @@ from astropy._erfa import ErfaWarning import galsim import numpy as np -import lsst.afw.geom as afwGeom +import lsst.geom as LsstGeom from lsst.afw.cameraGeom import FIELD_ANGLE, PIXELS, FOCAL_PLANE from lsst.afw.cameraGeom import WAVEFRONT, GUIDER from lsst.obs.lsstSim import LsstSimMapper @@ -23,7 +23,7 @@ class GalSim_afw_TanSipWCS(galsim.wcs.CelestialWCS): """ - This class uses methods from afw.geom and meas_astrom to + This class uses methods from lsst.geom and meas_astrom to fit a TAN-SIP WCS to an afw.cameraGeom.Detector and then wrap that WCS into something that GalSim can parse. @@ -264,7 +264,7 @@ def __init__(self, detectorName, cameraWrapper, obs_metadata, epoch, photParams= self._yMinPix = bbox.getMinY() self._yMaxPix = bbox.getMaxY() - self._bbox = afwGeom.Box2D(bbox) + self._bbox = LsstGeom.Box2D(bbox) centerPupil = self._cameraWrapper.getCenterPupil(self._name) self._xCenterArcsec = arcsecFromRadians(centerPupil.getX()) @@ -374,7 +374,7 @@ def containsRaDec(self, ra, dec): """ xPix, yPix = self.pixelCoordinatesFromRaDec(ra, dec) - points = [afwGeom.Point2D(xx, yy) for xx, yy in zip(xPix, yPix)] + points = [LsstGeom.Point2D(xx, yy) for xx, yy in zip(xPix, yPix)] answer = [self._bbox.contains(pp) for pp in points] return answer @@ -392,7 +392,7 @@ def containsPupilCoordinates(self, xPupil, yPupil): the corresponding RA, Dec pair falls on this detector """ xPix, yPix = self.pixelCoordinatesFromPupilCoordinates(xPupil, yPupil) - points = [afwGeom.Point2D(xx, yy) for xx, yy in zip(xPix, yPix)] + points = [LsstGeom.Point2D(xx, yy) for xx, yy in zip(xPix, yPix)] answer = [self._bbox.contains(pp) for pp in points] return answer diff --git a/python/lsst/sims/GalSimInterface/wcsUtils/ApproximateWCS.py b/python/lsst/sims/GalSimInterface/wcsUtils/ApproximateWCS.py index 7f769b2..9ba3134 100644 --- a/python/lsst/sims/GalSimInterface/wcsUtils/ApproximateWCS.py +++ b/python/lsst/sims/GalSimInterface/wcsUtils/ApproximateWCS.py @@ -30,7 +30,6 @@ import numpy as np import lsst.afw.image as afwImage import lsst.afw.table as afwTable -import lsst.afw.geom as afwGeom import lsst.geom as LsstGeom from lsst.meas.base import SingleFrameMeasurementTask from lsst.meas.astrom.sip import makeCreateWcsWithSip @@ -40,7 +39,7 @@ def approximateWcs(wcs, camera_wrapper=None, detector_name=None, obs_metadata=None, order=3, nx=20, ny=20, iterations=3, - skyTolerance=0.001*afwGeom.arcseconds, pixelTolerance=0.02): + skyTolerance=0.001*LsstGeom.arcseconds, pixelTolerance=0.02): """Approximate an existing WCS as a TAN-SIP WCS The fit is performed by evaluating the WCS at a uniform grid of points within a bounding box. @@ -81,11 +80,11 @@ def approximateWcs(wcs, camera_wrapper=None, detector_name=None, obs_metadata=No matchList = [] bbox = camera_wrapper.getBBox(detector_name) - bboxd = afwGeom.Box2D(bbox) + bboxd = LsstGeom.Box2D(bbox) for x in np.linspace(bboxd.getMinX(), bboxd.getMaxX(), nx): for y in np.linspace(bboxd.getMinY(), bboxd.getMaxY(), ny): - pixelPos = afwGeom.Point2D(x, y) + pixelPos = LsstGeom.Point2D(x, y) ra, dec = camera_wrapper.raDecFromPixelCoords(np.array([x]), np.array([y]), detector_name, @@ -93,7 +92,7 @@ def approximateWcs(wcs, camera_wrapper=None, detector_name=None, obs_metadata=No epoch=2000.0, includeDistortion=True) - skyCoord = afwGeom.SpherePoint(ra[0], dec[0], LsstGeom.degrees) + skyCoord = LsstGeom.SpherePoint(ra[0], dec[0], LsstGeom.degrees) refObj = refCat.addNew() refObj.set(refCoordKey, skyCoord) diff --git a/python/lsst/sims/GalSimInterface/wcsUtils/WcsUtils.py b/python/lsst/sims/GalSimInterface/wcsUtils/WcsUtils.py index 47d46f4..d318d63 100644 --- a/python/lsst/sims/GalSimInterface/wcsUtils/WcsUtils.py +++ b/python/lsst/sims/GalSimInterface/wcsUtils/WcsUtils.py @@ -1,6 +1,7 @@ import numpy as np from lsst.afw.cameraGeom import TAN_PIXELS, FOCAL_PLANE import lsst.afw.geom as afwGeom +import lsst.geom as LsstGeom import lsst.afw.image as afwImage import lsst.afw.image.utils as afwImageUtils import lsst.daf.base as dafBase @@ -169,7 +170,7 @@ def tanSipWcsFromDetector(detector_name, camera_wrapper, obs_metadata, epoch, tanSipWcs = approximateWcs(tanWcs, order=order, - skyTolerance=skyToleranceArcSec*afwGeom.arcseconds, + skyTolerance=skyToleranceArcSec*LsstGeom.arcseconds, pixelTolerance=pixelTolerance, detector_name=detector_name, camera_wrapper=camera_wrapper, diff --git a/tests/testOutputWcs.py b/tests/testOutputWcs.py index 1b80c70..d91115d 100644 --- a/tests/testOutputWcs.py +++ b/tests/testOutputWcs.py @@ -7,7 +7,6 @@ import lsst.utils.tests from lsst.utils import getPackageDir import lsst.afw.image as afwImage -import lsst.afw.geom as afwGeom import lsst.geom as LsstGeom from lsst.sims.utils.CodeUtilities import sims_clean_up from lsst.sims.utils import ObservationMetaData, arcsecFromRadians @@ -132,7 +131,7 @@ def testOutputWcsOfImage(self): xxTestList.append(xx) yyTestList.append(yy) - pt = afwGeom.Point2D(xx, yy) + pt = LsstGeom.Point2D(xx, yy) skyPt = wcs.pixelToSky(pt).getPosition(LsstGeom.degrees) raImage.append(skyPt.getX()) decImage.append(skyPt.getY()) diff --git a/tests/testWcsUtils.py b/tests/testWcsUtils.py index 269c933..06c2619 100644 --- a/tests/testWcsUtils.py +++ b/tests/testWcsUtils.py @@ -2,7 +2,6 @@ import os import numpy as np import lsst.utils.tests -import lsst.afw.geom as afwGeom import lsst.geom as LsstGeom from lsst.utils import getPackageDir from lsst.sims.utils.CodeUtilities import sims_clean_up @@ -76,7 +75,7 @@ def testTanSipWcs(self): xPixList.append(xx) yPixList.append(yy) - pt = afwGeom.Point2D(xx, yy) + pt = LsstGeom.Point2D(xx, yy) skyPt = tanWcs.pixelToSky(pt).getPosition(LsstGeom.degrees) tanWcsRa.append(skyPt.getX()) tanWcsDec.append(skyPt.getY())