def test_against_catalog(self):
        """
        Compare deprecession results to a catalog that was validated
        with PhoSim.
        """
        obs = ObservationMetaData(pointingRA=53.00913847303155535,
                                  pointingDec=-27.43894880881512321,
                                  rotSkyPos=256.75075318193080420,
                                  mjd=59580.13955500000156462,
                                  site=Site(name="LSST",
                                            pressure=0.0,
                                            humidity=0.0))

        dtype = np.dtype([('id', int), ('ra', float), ('dec', float),
                          ('ra_deprecessed', float),
                          ('dec_deprecessed', float), ('x_dm', float),
                          ('y_dm', float), ('x_focal', float),
                          ('y_focal', float), ('x_cam', float),
                          ('y_cam', float)])

        data = np.genfromtxt(os.path.join(getPackageDir('sims_catUtils'),
                                          'tests', 'testData',
                                          'pixel_prediction_catalog.txt'),
                             dtype=dtype)

        ra_obs, dec_obs = observedFromICRS(data['ra'],
                                           data['dec'],
                                           obs_metadata=obs,
                                           includeRefraction=False,
                                           epoch=2000.0)

        phosim_mixin = PhoSimAstrometryBase()
        ra_dep, dec_dep = phosim_mixin._dePrecess(np.radians(ra_obs),
                                                  np.radians(dec_obs), obs)

        dd = 3600.0 * angularSeparation(
            data['ra_deprecessed'], data['dec_deprecessed'],
            np.degrees(ra_dep), np.degrees(dec_dep))
        self.assertLess(dd.max(), 1.0e-5)
Esempio n. 2
0
    def test_against_catalog(self):
        """
        Compare deprecession results to a catalog that was validated
        with PhoSim.
        """
        obs = ObservationMetaData(pointingRA=53.00913847303155535,
                                  pointingDec=-27.43894880881512321,
                                  rotSkyPos=256.75075318193080420,
                                  mjd=59580.13955500000156462,
                                  site=Site(name="LSST", pressure=0.0,
                                            humidity=0.0))

        dtype = np.dtype([('id', int), ('ra', float), ('dec', float),
                          ('ra_deprecessed', float), ('dec_deprecessed', float),
                          ('x_dm', float), ('y_dm', float),
                          ('x_focal', float), ('y_focal', float),
                          ('x_cam', float), ('y_cam', float)])

        data = np.genfromtxt(os.path.join(getPackageDir('sims_catUtils'),
                                          'tests', 'testData',
                                          'pixel_prediction_catalog.txt'),
                             dtype=dtype)

        ra_obs, dec_obs = observedFromICRS(data['ra'], data['dec'],
                                           obs_metadata=obs,
                                           includeRefraction=False,
                                           epoch=2000.0)

        phosim_mixin = PhoSimAstrometryBase()
        ra_dep, dec_dep = phosim_mixin._dePrecess(np.radians(ra_obs),
                                                  np.radians(dec_obs),
                                                  obs)

        dd = 3600.0*angularSeparation(data['ra_deprecessed'], data['dec_deprecessed'],
                                      np.degrees(ra_dep), np.degrees(dec_dep))
        self.assertLess(dd.max(), 1.0e-5)
Esempio n. 3
0
                dm_xpix_in, dm_ypix_in = camera_wrapper.dmPixFromCameraPix(
                    cam_xpix_in, cam_ypix_in, det_name)

                ra_icrs, dec_icrs = raDecFromPixelCoords(dm_xpix_in,
                                                         dm_ypix_in,
                                                         det_name,
                                                         camera=lsst_camera(),
                                                         obs_metadata=obs)

                ra_obs, dec_obs = observedFromICRS(ra_icrs,
                                                   dec_icrs,
                                                   obs_metadata=obs,
                                                   epoch=2000.0,
                                                   includeRefraction=False)

                (ra_deprecessed, dec_deprecessed) = de_precessor._dePrecess(
                    np.radians(ra_obs), np.radians(dec_obs), obs)

                x_f, y_f = focalPlaneCoordsFromRaDec(ra_icrs,
                                                     dec_icrs,
                                                     obs_metadata=obs,
                                                     camera=lsst_camera())

                for ra, dec, camxx, camyy, r_icrs, d_icrs, dmxx, dmyy, xxf, yyf in \
                zip(ra_deprecessed, dec_deprecessed, cam_xpix_in, cam_ypix_in, ra_icrs, dec_icrs,
                    dm_xpix_in, dm_ypix_in, x_f, y_f):

                    i_obj += 1
                    cat_file.write('object %d ' % (i_obj))
                    cat_file.write('%.17f %.17f ' %
                                   (np.degrees(ra), np.degrees(dec)))
                    cat_file.write(
Esempio n. 4
0
    def test_naive_focal_plane_position(self):
        """
        Test deprecession of PhoSim coordinates by comparing
        the focal plane position predicted by CatSim from ICRS
        with the focal plane position predicted by CatSim from deprecessed
        coordinates.
        """

        phosim_mixin = PhoSimAstrometryBase()

        mjd = 59587.2

        # create site with no atmosphere so that we can avoid
        # refraction
        site = Site(name="LSST", pressure=0.0, humidity=0.0)

        obs = ObservationMetaData(mjd=mjd, site=site)
        ra, dec = raDecFromAltAz(31.0, 112.0, obs)

        d_sun = distanceToSun(ra, dec, obs.mjd)
        self.assertGreater(d_sun, 45.0)

        obs = ObservationMetaData(pointingRA=ra, pointingDec=dec,
                                  rotSkyPos=27.3, mjd=mjd,
                                  site=site)
        ra_icrs = np.arange(obs.pointingRA-2.0, obs.pointingRA+2.0, 0.05)
        dec_icrs = np.arange(obs.pointingDec-2.0, obs.pointingDec+2.0, 0.05)

        coord_grid = np.meshgrid(ra_icrs, dec_icrs)
        ra_icrs = coord_grid[0].flatten()
        dec_icrs = coord_grid[1].flatten()

        (xpup_icrs,
         ypup_icrs) = pupilCoordsFromRaDec(ra_icrs, dec_icrs,
                                           obs_metadata=obs,
                                           epoch=2000.0,
                                           includeRefraction=False)

        (x_focal_icrs,
         y_focal_icrs) = focalPlaneCoordsFromPupilCoords(xpup_icrs,
                                                         ypup_icrs,
                                                         camera=lsst_camera())

        ra_obs, dec_obs = observedFromICRS(ra_icrs, dec_icrs, obs_metadata=obs,
                                           epoch=2000.0,
                                           includeRefraction=False)

        ra_obs_rad = np.radians(ra_obs)
        dec_obs_rad = np.radians(dec_obs)

        (ra_deprecessed_rad,
         dec_deprecessed_rad) = phosim_mixin._dePrecess(ra_obs_rad,
                                                        dec_obs_rad, obs)

        (xpup_deprecessed,
         ypup_deprecessed) = _naivePupilCoordsFromObserved(ra_deprecessed_rad,
                                                           dec_deprecessed_rad,
                                                           obs._pointingRA,
                                                           obs._pointingDec,
                                                           obs._rotSkyPos)

        (x_focal_deprecessed,
         y_focal_deprecessed) = focalPlaneCoordsFromPupilCoords(xpup_deprecessed,
                                                                ypup_deprecessed,
                                                                camera=lsst_camera())

        dd = np.sqrt((x_focal_icrs-x_focal_deprecessed)**2
                     +(y_focal_icrs-y_focal_deprecessed)**2)

        self.assertLess(dd.max(), 5.0e-8)
    def test_naive_focal_plane_position(self):
        """
        Test deprecession of PhoSim coordinates by comparing
        the focal plane position predicted by CatSim from ICRS
        with the focal plane position predicted by CatSim from deprecessed
        coordinates.
        """

        phosim_mixin = PhoSimAstrometryBase()

        mjd = 59587.2

        # create site with no atmosphere so that we can avoid
        # refraction
        site = Site(name="LSST", pressure=0.0, humidity=0.0)

        obs = ObservationMetaData(mjd=mjd, site=site)
        ra, dec = raDecFromAltAz(31.0, 112.0, obs)

        d_sun = distanceToSun(ra, dec, obs.mjd)
        self.assertGreater(d_sun, 45.0)

        obs = ObservationMetaData(pointingRA=ra,
                                  pointingDec=dec,
                                  rotSkyPos=27.3,
                                  mjd=mjd,
                                  site=site)
        ra_icrs = np.arange(obs.pointingRA - 2.0, obs.pointingRA + 2.0, 0.05)
        dec_icrs = np.arange(obs.pointingDec - 2.0, obs.pointingDec + 2.0,
                             0.05)

        coord_grid = np.meshgrid(ra_icrs, dec_icrs)
        ra_icrs = coord_grid[0].flatten()
        dec_icrs = coord_grid[1].flatten()

        (xpup_icrs, ypup_icrs) = pupilCoordsFromRaDec(ra_icrs,
                                                      dec_icrs,
                                                      obs_metadata=obs,
                                                      epoch=2000.0,
                                                      includeRefraction=False)

        (x_focal_icrs,
         y_focal_icrs) = focalPlaneCoordsFromPupilCoords(xpup_icrs,
                                                         ypup_icrs,
                                                         camera=lsst_camera())

        ra_obs, dec_obs = observedFromICRS(ra_icrs,
                                           dec_icrs,
                                           obs_metadata=obs,
                                           epoch=2000.0,
                                           includeRefraction=False)

        ra_obs_rad = np.radians(ra_obs)
        dec_obs_rad = np.radians(dec_obs)

        (ra_deprecessed_rad, dec_deprecessed_rad) = phosim_mixin._dePrecess(
            ra_obs_rad, dec_obs_rad, obs)

        (xpup_deprecessed, ypup_deprecessed) = _naivePupilCoordsFromObserved(
            ra_deprecessed_rad, dec_deprecessed_rad, obs._pointingRA,
            obs._pointingDec, obs._rotSkyPos)

        (x_focal_deprecessed,
         y_focal_deprecessed) = focalPlaneCoordsFromPupilCoords(
             xpup_deprecessed, ypup_deprecessed, camera=lsst_camera())

        dd = np.sqrt((x_focal_icrs - x_focal_deprecessed)**2 +
                     (y_focal_icrs - y_focal_deprecessed)**2)

        self.assertLess(dd.max(), 1.0e-8)