From f199668a060c4fcba0b7305092c3c7d9bed4ae01 Mon Sep 17 00:00:00 2001 From: danielsf Date: Fri, 25 Oct 2019 15:31:34 -0700 Subject: [PATCH 01/12] do not depend on obs_lsstSim --- ups/sims_GalSimInterface.table | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ups/sims_GalSimInterface.table b/ups/sims_GalSimInterface.table index 2a89d35..01c804b 100644 --- a/ups/sims_GalSimInterface.table +++ b/ups/sims_GalSimInterface.table @@ -8,7 +8,7 @@ setupRequired(sims_coordUtils) setupRequired(sims_catalogs) setupRequired(sims_catUtils) -setupOptional(obs_lsstSim) +setupOptional(obs_lsst) #This is needed by the mssql python module envPrepend(TDSVER, 7.0) From c3fed30200ca098d2f85201ad156cf8135a1c200 Mon Sep 17 00:00:00 2001 From: danielsf Date: Fri, 25 Oct 2019 15:57:25 -0700 Subject: [PATCH 02/12] use new API for observatory location which directly returns an astropy.coordinates.EarthLocation --- .../lsst/sims/GalSimInterface/galSimDetector.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/python/lsst/sims/GalSimInterface/galSimDetector.py b/python/lsst/sims/GalSimInterface/galSimDetector.py index 6d22940..21bc0b6 100644 --- a/python/lsst/sims/GalSimInterface/galSimDetector.py +++ b/python/lsst/sims/GalSimInterface/galSimDetector.py @@ -10,9 +10,9 @@ import galsim import numpy as np import lsst.geom as LsstGeom +import lsst.obs.lsst.translators.lsst from lsst.afw.cameraGeom import FIELD_ANGLE, PIXELS, FOCAL_PLANE from lsst.afw.cameraGeom import WAVEFRONT, GUIDER -from lsst.obs.lsstSim import LsstSimMapper from lsst.sims.utils import arcsecFromRadians from lsst.sims.GalSimInterface.wcsUtils import tanSipWcsFromDetector from lsst.sims.GalSimInterface import GalSimCameraWrapper @@ -116,10 +116,10 @@ def __init__(self, detectorName, cameraWrapper, obs_metadata, epoch, photParams= self.fitsHeader.set('SIMULATE', True) self.fitsHeader.set('ORIGIN', 'IMSIM') observatory = LsstObservatory() - self.fitsHeader.set('OBS-LONG', observatory.getLongitude().asDegrees()) - self.fitsHeader.set('OBS-LAT', observatory.getLongitude().asDegrees()) - self.fitsHeader.set('OBS-ELEV', observatory.getElevation()) - obs_location = observatory.getLocation() + self.fitsHeader.set('OBS-LONG', observatory.lon.degree) + self.fitsHeader.set('OBS-LAT', observatory.lat.degree) + self.fitsHeader.set('OBS-ELEV', observatory.height.value) + obs_location = observatory.to_geocentric() self.fitsHeader.set('OBSGEO-X', obs_location.geocentric[0].value) self.fitsHeader.set('OBSGEO-Y', obs_location.geocentric[1].value) self.fitsHeader.set('OBSGEO-Z', obs_location.geocentric[2].value) @@ -688,7 +688,7 @@ class LsstObservatory: observatory location information. """ def __init__(self): - self.observatory = LsstSimMapper().MakeRawVisitInfoClass().observatory + self.observatory = lsst.obs.lsst.translators.lsst.LSST_LOCATION def getLocation(self): """ @@ -698,10 +698,7 @@ def getLocation(self): ------- astropy.coordinates.earth.EarthLocation """ - return astropy.coordinates.EarthLocation.from_geodetic( - self.observatory.getLongitude().asDegrees(), - self.observatory.getLatitude().asDegrees(), - self.observatory.getElevation()) + return self.observatory def __getattr__(self, attr): if hasattr(self.observatory, attr): From 019ce6b2600a81758ed8eaf398fe0d346ca4c50b Mon Sep 17 00:00:00 2001 From: danielsf Date: Fri, 25 Oct 2019 16:01:40 -0700 Subject: [PATCH 03/12] remove all dependence on clean_up_lsst_camera --- tests/testFitsHeaders.py | 2 -- tests/testGalSimCameraWrapper.py | 5 ----- tests/testGalSimInterface.py | 2 -- 3 files changed, 9 deletions(-) diff --git a/tests/testFitsHeaders.py b/tests/testFitsHeaders.py index c5a7221..8063cab 100644 --- a/tests/testFitsHeaders.py +++ b/tests/testFitsHeaders.py @@ -23,7 +23,6 @@ from testUtils import create_text_catalog -from lsst.sims.coordUtils import clean_up_lsst_camera ROOT = os.path.abspath(os.path.dirname(__file__)) @@ -67,7 +66,6 @@ class FitsHeaderTest(unittest.TestCase): @classmethod def tearDownClass(cls): sims_clean_up() - clean_up_lsst_camera() def testFitsHeader(self): """ diff --git a/tests/testGalSimCameraWrapper.py b/tests/testGalSimCameraWrapper.py index 9ad574a..5785527 100644 --- a/tests/testGalSimCameraWrapper.py +++ b/tests/testGalSimCameraWrapper.py @@ -27,7 +27,6 @@ from lsst.sims.coordUtils import raDecFromPixelCoordsLSST from lsst.sims.coordUtils import lsst_camera -from lsst.sims.coordUtils import clean_up_lsst_camera def setup_module(module): lsst.utils.tests.init() @@ -37,10 +36,6 @@ class Camera_Wrapper_Test_Class(unittest.TestCase): longMessage = True - @classmethod - def tearDownClass(cls): - clean_up_lsst_camera() - def test_generic_camera_wrapper(self): """ Test that GalSimCameraWrapper wraps its methods as expected. diff --git a/tests/testGalSimInterface.py b/tests/testGalSimInterface.py index 3725ce0..05d30ea 100644 --- a/tests/testGalSimInterface.py +++ b/tests/testGalSimInterface.py @@ -34,7 +34,6 @@ from lsst.sims.catUtils.utils import (calcADUwrapper, testGalaxyBulgeDBObj, testGalaxyDiskDBObj, testGalaxyAgnDBObj, testStarsDBObj) import lsst.afw.image as afwImage -from lsst.sims.coordUtils import clean_up_lsst_camera # Tell astropy not to download this file again, even if it's out of date. from astropy.utils import iers @@ -1121,7 +1120,6 @@ def setUp(self): self.db_name = os.path.join(self.scratch_dir, 'galsim_test_db') def tearDown(self): - clean_up_lsst_camera() if os.path.exists(self.db_name): os.remove(self.db_name) if os.path.exists(self.scratch_dir): From a9a9826185e6b987ed92510083fddf4c4b1c314a Mon Sep 17 00:00:00 2001 From: danielsf Date: Fri, 25 Oct 2019 16:10:07 -0700 Subject: [PATCH 04/12] remove all explicit obs_lsstSim from camera wrapper test --- tests/testGalSimCameraWrapper.py | 46 +++++++++++++------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/tests/testGalSimCameraWrapper.py b/tests/testGalSimCameraWrapper.py index 5785527..7f1a257 100644 --- a/tests/testGalSimCameraWrapper.py +++ b/tests/testGalSimCameraWrapper.py @@ -2,6 +2,8 @@ import numpy as np import lsst.utils.tests +import lsst.obs.lsst.phosim as obs_lsst_phosim + from lsst.sims.utils import ObservationMetaData from lsst.sims.utils import raDecFromAltAz from lsst.sims.coordUtils import pixelCoordsFromRaDec @@ -13,20 +15,11 @@ from lsst.sims.GalSimInterface import GalSimCameraWrapper from lsst.sims.GalSimInterface import LSSTCameraWrapper -from lsst.sims.coordUtils import lsst_camera import lsst.afw.cameraGeom.testUtils as camTestUtils from lsst.afw.cameraGeom import FOCAL_PLANE from lsst.afw.cameraGeom import TAN_PIXELS, FIELD_ANGLE, PIXELS -from lsst.sims.coordUtils import chipNameFromPupilCoordsLSST -from lsst.sims.coordUtils import focalPlaneCoordsFromPupilCoordsLSST -from lsst.sims.coordUtils import pupilCoordsFromFocalPlaneCoordsLSST -from lsst.sims.coordUtils import pupilCoordsFromPixelCoordsLSST -from lsst.sims.coordUtils import pixelCoordsFromPupilCoordsLSST -from lsst.sims.coordUtils import raDecFromPixelCoordsLSST -from lsst.sims.coordUtils import lsst_camera - def setup_module(module): lsst.utils.tests.init() @@ -204,7 +197,7 @@ def test_LSST_camera_wrapper(self): Camera +y = DM +x Camera +x = DM -y """ - camera = lsst_camera() + camera = obs_lsst_phosim.PhosimMapper().camera camera_wrapper = LSSTCameraWrapper() obs_mjd = ObservationMetaData(mjd=60000.0) @@ -285,8 +278,8 @@ def test_LSST_camera_wrapper(self): # is as expected x_pup = rng.random_sample(10)*0.005-0.01 y_pup = rng.random_sample(10)*0.005-0.01 - x_pix, y_pix = pixelCoordsFromPupilCoordsLSST(x_pup, y_pup, chipName=name, - band=obs.bandpass) + x_pix, y_pix = pixelCoordsFromPupilCoords(x_pup, y_pup, chipName=name, + camera=camera) (x_pix_wrapper, y_pix_wrapper) = camera_wrapper.pixelCoordsFromPupilCoords(x_pup, y_pup, @@ -319,8 +312,8 @@ def test_LSST_camera_wrapper(self): x_pix = bbox.getMinX() + rng.random_sample(10)*(bbox.getMaxX()-bbox.getMinX()) y_pix = bbox.getMinY() + rng.random_sample(10)*(bbox.getMaxY()-bbox.getMinY()) - ra, dec = raDecFromPixelCoordsLSST(x_pix, y_pix, name, obs_metadata=obs, - band=obs.bandpass) + ra, dec = raDecFromPixelCoords(x_pix, y_pix, name, obs_metadata=obs, + camera=camera) (ra_wrapper, dec_wrapper) = camera_wrapper.raDecFromPixelCoords(2.0*center_pix.getY()-y_pix, @@ -365,14 +358,13 @@ def test_LSST_camera_wrapper(self): del camera del camera_wrapper - del lsst_camera._lsst_camera def test_dmPixFromCameraPix(self): """ Test that the method to return DM pixel coordinates from Camera Team pixel coordinates works. """ - camera = lsst_camera() + camera = obs_lsst_phosim.PhosimMapper().camera camera_wrapper = LSSTCameraWrapper() obs = ObservationMetaData(bandpassName='u') @@ -386,10 +378,10 @@ def test_dmPixFromCameraPix(self): chip_name_list = rng.choice(name_list, size=npts) (xPup_list, - yPup_list) = pupilCoordsFromPixelCoordsLSST(dm_x_pix_list, - dm_y_pix_list, - chipName=chip_name_list, - band=obs.bandpass) + yPup_list) = pupilCoordsFromPixelCoords(dm_x_pix_list, + dm_y_pix_list, + chipName=chip_name_list, + camera=camera) (cam_x_pix_list, cam_y_pix_list) = camera_wrapper.pixelCoordsFromPupilCoords(xPup_list, @@ -420,10 +412,10 @@ def test_dmPixFromCameraPix(self): chip_name = chip_name_list[10] (xPup_list, - yPup_list) = pupilCoordsFromPixelCoordsLSST(dm_x_pix_list, - dm_y_pix_list, - chipName=chip_name, - band=obs.bandpass) + yPup_list) = pupilCoordsFromPixelCoords(dm_x_pix_list, + dm_y_pix_list, + chipName=chip_name, + camera=camera) (cam_x_pix_list, cam_y_pix_list) = camera_wrapper.pixelCoordsFromPupilCoords(xPup_list, @@ -443,7 +435,6 @@ def test_dmPixFromCameraPix(self): del camera del camera_wrapper - del lsst_camera._lsst_camera def test_camPixFromDMpix(self): """ @@ -454,12 +445,11 @@ def test_camPixFromDMpix(self): npts = 200 cam_x_in = rng.random_sample(npts)*4000.0 cam_y_in = rng.random_sample(npts)*4000.0 - dm_x, dm_y = camera_wrapper.dmPixFromCameraPix(cam_x_in, cam_y_in, 'R:1,1 S:2,2') - cam_x, cam_y = camera_wrapper.cameraPixFromDMPix(dm_x, dm_y, 'R:1,1 S:2,2') + dm_x, dm_y = camera_wrapper.dmPixFromCameraPix(cam_x_in, cam_y_in, 'R11_S22') + cam_x, cam_y = camera_wrapper.cameraPixFromDMPix(dm_x, dm_y, 'R11_S22') np.testing.assert_array_almost_equal(cam_x_in, cam_x, decimal=10) np.testing.assert_array_almost_equal(cam_y_in, cam_y, decimal=10) del camera_wrapper - del lsst_camera._lsst_camera class MemoryTestClass(lsst.utils.tests.MemoryTestCase): From 4927be60e58a6930a8a7573a0338c6aaba981a82 Mon Sep 17 00:00:00 2001 From: danielsf Date: Fri, 25 Oct 2019 16:16:49 -0700 Subject: [PATCH 05/12] GalSimCameraWrapper works with obs_lsst --- .../GalSimInterface/galSimCameraWrapper.py | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/python/lsst/sims/GalSimInterface/galSimCameraWrapper.py b/python/lsst/sims/GalSimInterface/galSimCameraWrapper.py index 7e8ec76..15f317c 100644 --- a/python/lsst/sims/GalSimInterface/galSimCameraWrapper.py +++ b/python/lsst/sims/GalSimInterface/galSimCameraWrapper.py @@ -56,6 +56,7 @@ class that inherits from GalSimCameraWrapper. This class will """ import numpy as np +import lsst.obs.lsst.phosim as obs_lsst_phosim from lsst.afw.cameraGeom import FOCAL_PLANE, PIXELS, TAN_PIXELS from lsst.afw.cameraGeom import FIELD_ANGLE import lsst.geom as LsstGeom @@ -483,6 +484,11 @@ def pixelCoordsFromRaDec(self, ra, dec, pm_ra=None, pm_dec=None, parallax=None, class LSSTCameraWrapper(coordUtils.DMtoCameraPixelTransformer, GalSimCameraWrapper): + def __init__(self): + self._camera = obs_lsst_phosim.PhosimMapper().camera + + + def getTanPixelBounds(self, detector_name): """ Return the min and max pixel values of a detector, assuming @@ -544,10 +550,10 @@ def pixelCoordsFromPupilCoords(self, xPupil, yPupil, chipName, obs_metadata, are defined in the Camera team system, rather than the DM system. """ (dm_x_pix, - dm_y_pix) = coordUtils.pixelCoordsFromPupilCoordsLSST(xPupil, yPupil, - chipName=chipName, - band=obs_metadata.bandpass, - includeDistortion=includeDistortion) + dm_y_pix) = coordUtils.pixelCoordsFromPupilCoords(xPupil, yPupil, + chipName=chipName, + camera=self.camera, + includeDistortion=includeDistortion) cam_y_pix = dm_x_pix if isinstance(chipName, list) or isinstance(chipName, np.ndarray): @@ -609,9 +615,9 @@ def pupilCoordsFromPixelCoords(self, xPix, yPix, chipName, obs_metadata, else: cam_center_pix = self.getCenterPixel(chipName) dm_yPix = 2.0*cam_center_pix.getX()-xPix - return coordUtils.pupilCoordsFromPixelCoordsLSST(dm_xPix, dm_yPix, chipName, - band=obs_metadata.bandpass, - includeDistortion=includeDistortion) + return coordUtils.pupilCoordsFromPixelCoords(dm_xPix, dm_yPix, chipName, + camera=self.camera, + includeDistortion=includeDistortion) def _raDecFromPixelCoords(self, xPix, yPix, chipName, obs_metadata, epoch=2000.0, includeDistortion=True): @@ -666,11 +672,11 @@ def _raDecFromPixelCoords(self, xPix, yPix, chipName, obs_metadata, cam_center_pix = self.getCenterPixel(chipName) dm_yPix = 2.0*cam_center_pix.getX() - xPix - return coordUtils._raDecFromPixelCoordsLSST(dm_xPix, dm_yPix, chipName, - obs_metadata=obs_metadata, - band=obs_metadata.bandpass, - epoch=epoch, - includeDistortion=includeDistortion) + return coordUtils._raDecFromPixelCoords(dm_xPix, dm_yPix, chipName, + obs_metadata=obs_metadata, + camera=self.camera, + epoch=epoch, + includeDistortion=includeDistortion) def raDecFromPixelCoords(self, xPix, yPix, chipName, obs_metadata, epoch=2000.0, includeDistortion=True): @@ -775,14 +781,14 @@ def _pixelCoordsFromRaDec(self, ra, dec, pm_ra=None, pm_dec=None, parallax=None, are defined in the Camera team system, rather than the DM system. """ - dm_xPix, dm_yPix = coordUtils._pixelCoordsFromRaDecLSST(ra, dec, - pm_ra=pm_ra, pm_dec=pm_dec, - parallax=parallax, v_rad=v_rad, - obs_metadata=obs_metadata, - chipName=chipName, - band=obs_metadata.bandpass, - epoch=epoch, - includeDistortion=includeDistortion) + dm_xPix, dm_yPix = coordUtils._pixelCoordsFromRaDec(ra, dec, + pm_ra=pm_ra, pm_dec=pm_dec, + parallax=parallax, v_rad=v_rad, + obs_metadata=obs_metadata, + chipName=chipName, + camera=self.camera, + epoch=epoch, + includeDistortion=includeDistortion) return self.cameraPixFromDMPix(dm_xPix, dm_yPix, chipName) From e13605804349695f7dda4b3e1a1f31736c6f6fdd Mon Sep 17 00:00:00 2001 From: danielsf Date: Fri, 25 Oct 2019 16:19:45 -0700 Subject: [PATCH 06/12] change chip naming convention --- tests/testGalSimInterface.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testGalSimInterface.py b/tests/testGalSimInterface.py index 05d30ea..1c7627d 100644 --- a/tests/testGalSimInterface.py +++ b/tests/testGalSimInterface.py @@ -1059,7 +1059,7 @@ def test_checkpointing(self): # Set the image data by hand. key = "R00_S00_r.fits" - detname = "R:0,0 S:0,0" + detname = "R00_S00" detector = make_galsim_detector(camera_wrapper, detname, phot_params, obs_md) image = gs_interpreter.blankImage(detector=detector) @@ -1141,7 +1141,7 @@ def test_getStampBounds(self): obs_md.OpsimMetaData['altitude'] = altitude obs_md.OpsimMetaData['rawSeeing'] = seeing camera_wrapper = LSSTCameraWrapper() - detector = make_galsim_detector(camera_wrapper, 'R:2,2 S:1,1', + detector = make_galsim_detector(camera_wrapper, 'R22_S11', PhotometricParameters(), obs_md) gs_interpreter = make_gs_interpreter(obs_md, [detector], BandpassDict.loadTotalBandpassesFromFiles(), From 05283de63594e4f8b6f048e479a52b29c6aa435f Mon Sep 17 00:00:00 2001 From: danielsf Date: Mon, 28 Oct 2019 10:46:01 -0700 Subject: [PATCH 07/12] fix geocentric API --- python/lsst/sims/GalSimInterface/galSimDetector.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/lsst/sims/GalSimInterface/galSimDetector.py b/python/lsst/sims/GalSimInterface/galSimDetector.py index 21bc0b6..6e20617 100644 --- a/python/lsst/sims/GalSimInterface/galSimDetector.py +++ b/python/lsst/sims/GalSimInterface/galSimDetector.py @@ -119,10 +119,9 @@ def __init__(self, detectorName, cameraWrapper, obs_metadata, epoch, photParams= self.fitsHeader.set('OBS-LONG', observatory.lon.degree) self.fitsHeader.set('OBS-LAT', observatory.lat.degree) self.fitsHeader.set('OBS-ELEV', observatory.height.value) - obs_location = observatory.to_geocentric() - self.fitsHeader.set('OBSGEO-X', obs_location.geocentric[0].value) - self.fitsHeader.set('OBSGEO-Y', obs_location.geocentric[1].value) - self.fitsHeader.set('OBSGEO-Z', obs_location.geocentric[2].value) + self.fitsHeader.set('OBSGEO-X', observatory.geocentric[0].value) + self.fitsHeader.set('OBSGEO-Y', observatory.geocentric[1].value) + self.fitsHeader.set('OBSGEO-Z', observatory.geocentric[2].value) self.crpix1 = self.fitsHeader.getScalar("CRPIX1") self.crpix2 = self.fitsHeader.getScalar("CRPIX2") @@ -689,6 +688,7 @@ class LsstObservatory: """ def __init__(self): self.observatory = lsst.obs.lsst.translators.lsst.LSST_LOCATION + self.geocentric = self.observatory.to_geocentric() def getLocation(self): """ From ade133ce0423f2d743c122382001c1801effdc3a Mon Sep 17 00:00:00 2001 From: danielsf Date: Mon, 28 Oct 2019 10:50:34 -0700 Subject: [PATCH 08/12] fix call to observatory.latitude --- python/lsst/sims/GalSimInterface/galSimInterpreter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/lsst/sims/GalSimInterface/galSimInterpreter.py b/python/lsst/sims/GalSimInterface/galSimInterpreter.py index c0a95c4..c4ce044 100644 --- a/python/lsst/sims/GalSimInterface/galSimInterpreter.py +++ b/python/lsst/sims/GalSimInterface/galSimInterpreter.py @@ -770,7 +770,7 @@ def __init__(self, obs_metadata=None, detectors=None, bandpassDict=None, self.local_hour_angle \ = self.getHourAngle(self.obs_metadata.mjd.TAI, self.obs_metadata.pointingRA)*galsim.degrees - self.obs_latitude = self.observatory.getLatitude().asDegrees()*galsim.degrees + self.obs_latitude = self.observatory.lat.degree*galsim.degrees # Make a trivial SED to use for faint things. blue_limit = np.min([bp.blue_limit for bp in self.gs_bandpass_dict.values()]) From 7436495d5dfbf581338cadb1cb7f2b75a39b390b Mon Sep 17 00:00:00 2001 From: danielsf Date: Mon, 28 Oct 2019 10:58:20 -0700 Subject: [PATCH 09/12] should not have changed test detector name --- tests/testGalSimInterface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testGalSimInterface.py b/tests/testGalSimInterface.py index 1c7627d..807f91c 100644 --- a/tests/testGalSimInterface.py +++ b/tests/testGalSimInterface.py @@ -1059,7 +1059,7 @@ def test_checkpointing(self): # Set the image data by hand. key = "R00_S00_r.fits" - detname = "R00_S00" + detname = "R:0,0 S:0,0" detector = make_galsim_detector(camera_wrapper, detname, phot_params, obs_md) image = gs_interpreter.blankImage(detector=detector) From cdfc873a2053d6193b626b7dd5c369b8a4098288 Mon Sep 17 00:00:00 2001 From: danielsf Date: Mon, 28 Oct 2019 16:33:13 -0700 Subject: [PATCH 10/12] fix chip name --- tests/testWcsUtils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testWcsUtils.py b/tests/testWcsUtils.py index 06c2619..fd40079 100644 --- a/tests/testWcsUtils.py +++ b/tests/testWcsUtils.py @@ -28,7 +28,7 @@ class WcsTest(unittest.TestCase): def setUpClass(cls): cls.camera_wrapper = LSSTCameraWrapper() - cls.detector = cls.camera_wrapper.camera['R:1,1 S:2,2'] + cls.detector = cls.camera_wrapper.camera['R11_S22'] cls.obs = ObservationMetaData(pointingRA=25.0, pointingDec=-10.0, boundType='circle', boundLength=1.0, From ff0a87a90803a076ab6c21558e5e227346280f73 Mon Sep 17 00:00:00 2001 From: danielsf Date: Mon, 28 Oct 2019 16:38:02 -0700 Subject: [PATCH 11/12] testLSSTPlacement.py runs with obs_lsst (but does not pass) --- tests/testLSSTPlacement.py | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/tests/testLSSTPlacement.py b/tests/testLSSTPlacement.py index 3fc005f..7605c17 100644 --- a/tests/testLSSTPlacement.py +++ b/tests/testLSSTPlacement.py @@ -15,6 +15,7 @@ import os from lsst.utils import getPackageDir import lsst.afw.image as afwImage +import lsst.obs.lsst.phosim as obs_lsst_phosim from lsst.sims.utils.CodeUtilities import sims_clean_up from lsst.sims.catUtils.utils import ObservationMetaDataGenerator from lsst.sims.catalogs.db import fileDBObject @@ -24,12 +25,7 @@ from lsst.sims.coordUtils import pixelCoordsFromRaDec from lsst.sims.coordUtils import DMtoCameraPixelTransformer -from lsst.sims.coordUtils import raDecFromPixelCoordsLSST -from lsst.sims.coordUtils import pixelCoordsFromRaDecLSST -from lsst.sims.coordUtils import chipNameFromPupilCoordsLSST -from lsst.sims.coordUtils import pupilCoordsFromFocalPlaneCoordsLSST -from lsst.sims.coordUtils import focalPlaneCoordsFromPupilCoordsLSST -from lsst.sims.coordUtils import lsst_camera +from lsst.sims.coordUtils import raDecFromPixelCoords ROOT = os.path.abspath(os.path.dirname(__file__)) @@ -71,17 +67,10 @@ class GalSimPlacementTest(unittest.TestCase): @classmethod def tearDownClass(cls): sims_clean_up() - if hasattr(chipNameFromPupilCoordsLSST, '_detector_arr'): - del chipNameFromPupilCoordsLSST._detector_arr - if hasattr(focalPlaneCoordsFromPupilCoordsLSST, '_z_fitter'): - del focalPlaneCoordsFromPupilCoordsLSST._z_fitter - if hasattr(pupilCoordsFromFocalPlaneCoordsLSST, '_z_fitter'): - del pupilCoordsFromFocalPlaneCoordsLSST._z_fitter - if hasattr(lsst_camera, '_lsst_camera'): - del lsst_camera._lsst_camera @classmethod def setUpClass(cls): + cls.camera = obs_lsst_phosim.PhosimMapper().camera opsimdb = os.path.join(getPackageDir('sims_data'), 'OpSimData', 'opsimblitz1_1133_sqlite.db') obs_gen = ObservationMetaDataGenerator(opsimdb) @@ -104,7 +93,7 @@ def testObjectPlacement(self): shutil.rmtree(scratchDir) os.mkdir(scratchDir) - detector = lsst_camera()['R:0,3 S:2,2'] + detector = self.camera['R03_S22'] det_name = 'R03_S22' magNorm = 19.0 @@ -121,10 +110,10 @@ def testObjectPlacement(self): imageName = '%s_%s_%s.fits' % (imageRoot, det_name, obs.bandpass) - ra_c, dec_c = raDecFromPixelCoordsLSST(2000.0, 2000.0, - detector.getName(), - band=obs.bandpass, - obs_metadata=obs) + ra_c, dec_c = raDecFromPixelCoords(2000.0, 2000.0, + detector.getName(), + camera=self.camera, + obs_metadata=obs) nSamples = 3 rng = np.random.RandomState(42) @@ -140,12 +129,12 @@ def testObjectPlacement(self): dmx_wrong, dmy_wrong = pixelCoordsFromRaDec(ra_obj, dec_obj, chipName=detector.getName(), obs_metadata=obs, - camera=lsst_camera()) + camera=self.camera) - dmx_pix, dmy_pix = pixelCoordsFromRaDecLSST(ra_obj, dec_obj, - chipName=detector.getName(), - obs_metadata=obs, - band=obs.bandpass) + dmx_pix, dmy_pix = pixelCoordsFromRaDec(ra_obj, dec_obj, + chipName=detector.getName(), + obs_metadata=obs, + camera=self.camera) x_pix, y_pix = pixel_transformer.cameraPixFromDMPix(dmx_pix, dmy_pix, detector.getName()) From eba4ec958c7fa844872e3085f48dad07f3ebccc4 Mon Sep 17 00:00:00 2001 From: danielsf Date: Mon, 28 Oct 2019 16:41:07 -0700 Subject: [PATCH 12/12] remove test that makes no sense anymore since there is no phenomenological modeling of the optical distortions going on in sims_coordUtils at this point --- tests/testLSSTPlacement.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/tests/testLSSTPlacement.py b/tests/testLSSTPlacement.py index 7605c17..52c718a 100644 --- a/tests/testLSSTPlacement.py +++ b/tests/testLSSTPlacement.py @@ -126,10 +126,6 @@ def testObjectPlacement(self): ra_obj = ra_c + rng.random_sample()*0.2 - 0.1 dec_obj = dec_c + rng.random_sample()*0.2 - 0.1 - dmx_wrong, dmy_wrong = pixelCoordsFromRaDec(ra_obj, dec_obj, - chipName=detector.getName(), - obs_metadata=obs, - camera=self.camera) dmx_pix, dmy_pix = pixelCoordsFromRaDec(ra_obj, dec_obj, chipName=detector.getName(), @@ -139,8 +135,6 @@ def testObjectPlacement(self): x_pix, y_pix = pixel_transformer.cameraPixFromDMPix(dmx_pix, dmy_pix, detector.getName()) - x_pix_wrong, y_pix_wrong = pixel_transformer.cameraPixFromDMPix(dmx_wrong, dmy_wrong, - detector.getName()) d_ra = 3600.0*(ra_obj - obs.pointingRA) # in arcseconds d_dec = 3600.0*(dec_obj - obs.pointingDec) @@ -167,11 +161,6 @@ def testObjectPlacement(self): dd = np.sqrt((x_pix-x_centroid)**2 + (y_pix-y_centroid)**2) self.assertLess(dd, 0.5*fwhm) - dd_wrong = np.sqrt((x_pix_wrong-x_centroid)**2 + - (y_pix_wrong-y_centroid)**2) - - self.assertLess(dd, dd_wrong) - if os.path.exists(dbFileName): os.unlink(dbFileName) if os.path.exists(catName):