Beispiel #1
0
    def test_passing_camera_by_hand(self):
        """
        Test that you can pass a camera from one WCS to another
        """

        with warnings.catch_warnings(record=True) as ww:
            wcs1 = LsstWCS(self.pointing, self.rotation, chip_name='R:0,1 S:1,1',
                           camera=self.wcs.camera)

        self.assertEqual(len(ww), 0)


        # verify that, if the camera does not have the pointing or rotation angle you want,
        # a new camera will be instantiated
        with warnings.catch_warnings(record=True) as ww:
            wcs1 = LsstWCS(galsim.CelestialCoord(0.0*galsim.degrees, 0.0*galsim.degrees),
                           self.rotation, chip_name='R:0,1 S:1,1', camera=self.wcs.camera)

        expected_message = "The camera you passed to LsstWCS does not have the same\n" \
                           "pointing and rotation angle as you asked for for this WCS.\n" \
                           "LsstWCS is creating a new camera with the pointing and\n" \
                           "rotation angle you specified in the constructor for LsstWCS."
        self.assertEqual(str(ww[0].message), expected_message)

        with warnings.catch_warnings(record=True) as ww:
            wcs1 = LsstWCS(self.pointing, 49.0*galsim.degrees,
                           chip_name='R:0,1 S:1,1', camera=self.wcs.camera)

        expected_message = "The camera you passed to LsstWCS does not have the same\n" \
                           "pointing and rotation angle as you asked for for this WCS.\n" \
                           "LsstWCS is creating a new camera with the pointing and\n" \
                           "rotation angle you specified in the constructor for LsstWCS."
        self.assertEqual(str(ww[0].message), expected_message)
Beispiel #2
0
    def test_copy(self):
        """
        Test that copy() works
        """

        pointing = CelestialCoord(64.82*galsim.degrees, -16.73*galsim.degrees)
        rotation = 116.8*galsim.degrees
        chip_name = 'R:1,2 S:2,2'
        wcs0 = LsstWCS(pointing, rotation, chip_name)
        wcs0 = wcs0._newOrigin(galsim.PositionI(112, 4))
        wcs1 = wcs0.copy()
        self.assertEqual(wcs0, wcs1)

        wcs0 = wcs0._newOrigin(galsim.PositionI(66, 77))
        self.assertNotEqual(wcs0, wcs1)
Beispiel #3
0
    def test_constructor(self):
        """
        Just make sure that the constructor for LsstWCS runs, and that it throws an error
        when you specify a nonsense chip.
        """

        pointing = CelestialCoord(112.0*galsim.degrees, -39.0*galsim.degrees)
        rotation = 23.1*galsim.degrees

        wcs1 = LsstWCS(pointing, rotation, 'R:1,1 S:2,2')

        with self.assertRaises(RuntimeError) as context:
            wcs2 = LsstWCS(pointing, rotation, 'R:1,1 S:3,3')
        self.assertEqual(context.exception.args[0],
                         "R:1,1 S:3,3 is not a valid chip_name for an LsstWCS")
Beispiel #4
0
    def test_copy(self):
        """
        Test that copy() works
        """

        pointing = CelestialCoord(64.82*galsim.degrees, -16.73*galsim.degrees)
        rotation = 116.8*galsim.degrees
        chip_name = 'R:1,2 S:2,2'
        wcs0 = LsstWCS(pointing, rotation, chip_name)
        wcs0 = wcs0._newOrigin(galsim.PositionI(112, 4))
        wcs1 = wcs0.copy()
        self.assertEqual(wcs0, wcs1)

        wcs0 = wcs0._newOrigin(galsim.PositionI(66, 77))
        self.assertNotEqual(wcs0, wcs1)
Beispiel #5
0
    def test_copy(self):
        """
        Test that copy() works
        """

        start = time.clock()

        pointing = CelestialCoord(64.82*galsim.degrees, -16.73*galsim.degrees)
        rotation = 116.8*galsim.degrees
        chip_name = 'R:1,2 S:2,2'
        wcs0 = LsstWCS(pointing, rotation, chip_name)
        wcs0 = wcs0._newOrigin(galsim.PositionI(112, 4))
        wcs1 = wcs0.copy()
        self.assertEqual(wcs0, wcs1)

        wcs0 = wcs0._newOrigin(galsim.PositionI(66, 77))
        self.assertNotEqual(wcs0, wcs1)

        print 'time to run %s = %e sec' % (funcname(), time.clock()-start)
Beispiel #6
0
    def test_eq(self):
        """
        Test that __eq__ works for LsstWCS
        """

        start = time.clock()

        wcs1 = LsstWCS(self.pointing, self.rotation, self.chip_name)
        self.assertEqual(self.wcs, wcs1)

        new_origin = galsim.PositionI(9, 9)
        wcs1 = wcs1._newOrigin(new_origin)
        self.assertNotEqual(self.wcs, wcs1)

        other_pointing = CelestialCoord(1.9*galsim.degrees, -34.0*galsim.degrees)
        wcs2 = LsstWCS(other_pointing, self.rotation, self.chip_name)
        self.assertNotEqual(self.wcs, wcs2)

        wcs3 = LsstWCS(self.pointing, 112.0*galsim.degrees, self.chip_name)
        self.assertNotEqual(self.wcs, wcs3)

        wcs4 = LsstWCS(self.pointing, self.rotation, 'R:2,2 S:2,2')
        self.assertNotEqual(self.wcs, wcs4)

        print 'time to run %s = %e sec' % (funcname(), time.clock()-start)
Beispiel #7
0
    def setUpClass(cls):
        if not have_lsst_stack:
            # skip doesn't apply to setUpClass.  cf. https://github.com/nose-devs/nose/issues/946
            return

        # these are taken from the header of the
        # galsim_afwCameraGeom_forced_data.txt file generated by
        # GalSim/devel/external/generate_galsim_lsst_camera_validation.py
        cls.raPointing = 112.064181578541 * galsim.degrees
        cls.decPointing = -33.015167519966 * galsim.degrees
        cls.rotation = 27.0 * galsim.degrees
        cls.chip_name = 'R:0,1 S:1,2'

        cls.pointing = CelestialCoord(cls.raPointing, cls.decPointing)
        cls.wcs = LsstWCS(cls.pointing, cls.rotation, cls.chip_name)