예제 #1
0
    def test_scan_geometry(self):
        """Test the ScanGeometry object.
        """
        scans_nb = 1

        xy = np.vstack((np.deg2rad(np.array([10, 0, -10])), np.array([0, 0,
                                                                      0])))
        xy = np.tile(xy[:, np.newaxis, :], [1, np.int(scans_nb), 1])

        times = np.tile([-0.1, 0, 0.1], [np.int(scans_nb), 1])

        instrument = ScanGeometry(xy, times)

        self.assertTrue(
            np.allclose(np.rad2deg(instrument.fovs[0]), np.array([[10, 0,
                                                                   -10]])))

        # Test vectors

        pos = np.rollaxis(np.tile(np.array([0, 0, 7000]), [3, 1, 1]), 2)
        vel = np.rollaxis(np.tile(np.array([1, 0, 0]), [3, 1, 1]), 2)
        pos = np.stack([np.array([0, 0, 7000])] * 3, 1)[:, np.newaxis, :]
        vel = np.stack([np.array([1, 0, 0])] * 3, 1)[:, np.newaxis, :]

        vec = instrument.vectors(pos, vel)

        self.assertTrue(np.allclose(np.array([[0, 0, -1]]), vec[:, 0, 1]))

        # minus sin because we use trigonometrical direction of angles

        self.assertTrue(
            np.allclose(
                np.array(
                    [[0, -np.sin(np.deg2rad(10)), -np.cos(np.deg2rad(10))]]),
                vec[:, 0, 0]))
        self.assertTrue(
            np.allclose(
                np.array(
                    [[0, -np.sin(np.deg2rad(-10)), -np.cos(np.deg2rad(-10))]]),
                vec[:, 0, 2]))

        # Test times

        start_of_scan = np.datetime64(datetime(2014, 1, 8, 11, 30))
        times = instrument.times(start_of_scan)

        self.assertEqual(times[0, 1], start_of_scan)
        self.assertEqual(times[0, 0],
                         start_of_scan - np.timedelta64(100, 'ms'))
        self.assertEqual(times[0, 2],
                         start_of_scan + np.timedelta64(100, 'ms'))
예제 #2
0
    def test_scan_geometry(self):
        """Test the ScanGeometry object.
        """
        scans_nb = 1

        xy = np.vstack((np.deg2rad(np.array([10, 0, -10])),
                        np.array([0, 0, 0])))
        xy = np.tile(xy[:, np.newaxis, :], [1, np.int(scans_nb), 1])

        times = np.tile([-0.1, 0, 0.1], [np.int(scans_nb), 1])

        instrument = ScanGeometry(xy, times)

        self.assertTrue(np.allclose(np.rad2deg(instrument.fovs[0]),
                                    np.array([[10, 0, -10]])))

        # Test vectors

        pos = np.rollaxis(np.tile(np.array([0, 0, 7000]), [3, 1, 1]), 2)
        vel = np.rollaxis(np.tile(np.array([1, 0, 0]), [3, 1, 1]), 2)
        pos = np.stack([np.array([0, 0, 7000])] * 3, 1)[:, np.newaxis, :]
        vel = np.stack([np.array([1, 0, 0])] * 3, 1)[:, np.newaxis, :]

        vec = instrument.vectors(pos, vel)

        self.assertTrue(np.allclose(np.array([[0, 0, -1]]),
                                    vec[:, 0, 1]))

        # minus sin because we use trigonometrical direction of angles

        self.assertTrue(np.allclose(np.array([[0,
                                               -np.sin(np.deg2rad(10)),
                                               -np.cos(np.deg2rad(10))]]),
                                    vec[:, 0, 0]))
        self.assertTrue(np.allclose(np.array([[0,
                                               -np.sin(np.deg2rad(-10)),
                                               -np.cos(np.deg2rad(-10))]]),
                                    vec[:, 0, 2]))

        # Test times

        start_of_scan = np.datetime64(datetime(2014, 1, 8, 11, 30))
        times = instrument.times(start_of_scan)

        self.assertEquals(times[0, 1], start_of_scan)
        self.assertEquals(times[0, 0], start_of_scan -
                          np.timedelta64(100, 'ms'))
        self.assertEquals(times[0, 2], start_of_scan +
                          np.timedelta64(100, 'ms'))
예제 #3
0
    def test_scan_geometry(self):
        """Test the ScanGeometry object.
        """
        instrument = ScanGeometry(
            np.deg2rad(np.array([[10, 0], [0, 0], [-10, 0]])),
            np.array([-0.1, 0, 0.1]))
        self.assertTrue(
            np.allclose(np.rad2deg(instrument.fovs[:, 0]),
                        np.array([10, 0, -10])))

        # Test vectors

        pos = np.array([[0, 0, 7000]]).T
        vel = np.array([[1, 0, 0]]).T
        vec = instrument.vectors(pos, vel)
        self.assertTrue(np.allclose(np.array([[0, 0, -1]]), vec[:, 1]))

        # minus sin because we use trigonometrical direction of angles

        self.assertTrue(
            np.allclose(
                np.array(
                    [[0, -np.sin(np.deg2rad(10)), -np.cos(np.deg2rad(10))]]),
                vec[:, 0]))
        self.assertTrue(
            np.allclose(
                np.array(
                    [[0, -np.sin(np.deg2rad(-10)), -np.cos(np.deg2rad(-10))]]),
                vec[:, 2]))

        # Test times

        start_of_scan = datetime(2014, 1, 8, 11, 30)
        times = instrument.times(start_of_scan)
        self.assertEqual(times[1], start_of_scan)
        self.assertEqual(times[0], start_of_scan - timedelta(seconds=0.1))
        self.assertEqual(times[2], start_of_scan + timedelta(seconds=0.1))
예제 #4
0
    def test_scan_geometry(self):
        """Test the ScanGeometry object.
        """
        instrument = ScanGeometry(np.deg2rad(np.array([[10, 0],
                                                       [0, 0],
                                                       [-10, 0]])),
                                  np.array([-0.1, 0, 0.1]))
        self.assertTrue(np.allclose(np.rad2deg(instrument.fovs[:, 0]),
                                    np.array([10, 0, -10])))

        # Test vectors
        
        pos = np.array([[0, 0, 7000]]).T
        vel = np.array([[1, 0, 0]]).T
        vec = instrument.vectors(pos, vel)
        self.assertTrue(np.allclose(np.array([[0, 0, -1]]),
                                    vec[:, 1]))

        # minus sin because we use trigonometrical direction of angles
        
        self.assertTrue(np.allclose(np.array([[0,
                                               -np.sin(np.deg2rad(10)),
                                               -np.cos(np.deg2rad(10))]]),
                                    vec[:, 0]))
        self.assertTrue(np.allclose(np.array([[0,
                                               -np.sin(np.deg2rad(-10)),
                                               -np.cos(np.deg2rad(-10))]]),
                                    vec[:, 2]))

        # Test times

        start_of_scan = datetime(2014, 1, 8, 11, 30)
        times = instrument.times(start_of_scan)
        self.assertEquals(times[1], start_of_scan)
        self.assertEquals(times[0], start_of_scan - timedelta(seconds=0.1))
        self.assertEquals(times[2], start_of_scan + timedelta(seconds=0.1))