コード例 #1
0
ファイル: test_windows.py プロジェクト: JaiWillems/Celest
    def test_windows(self):

        location = GroundPosition(43.6532, -79.3832)

        altitude = self.sat._altitude(location)
        off_nadir = self.sat.off_nadir(location, stroke=True)

        # Test the window generator for day imaging case.

        enc, ang, lighting, tol = "image", 30, 1, 1e-5
        windows = generate(self.sat, location, enc, ang, lighting, tol)

        for window in windows:
            start, end = window.start, window.end
            window_times = np.linspace(start, end, 10)

            tha = Time(window_times).true_hour_angle(location.lon)

            self.assertTrue(np.all(altitude(window_times) > 0))
            self.assertTrue(np.all(off_nadir(window_times) < ang))
            self.assertTrue(np.all((-90 < tha) & (tha < 90)))

        # Test the window generator for all day data link case.

        enc, ang, lighting, tol = "data_link", 10, 0, 1e-5
        windows = generate(self.sat, location, enc, ang, lighting, tol)

        for window in windows:
            start, end = window.start, window.end
            window_times = np.linspace(start, end, 10)

            tha = Time(window_times).true_hour_angle(location.lon)

            self.assertTrue(np.all(altitude(window_times) > 10))
コード例 #2
0
ファイル: test_coordinate.py プロジェクト: JaiWillems/Celest
    def test_off_nadir(self):
        """Test `Coordinate.off_nadir`.

        Notes
        -----
        Test cases generated using a geometric model designed by Mingde Yin.

        The tolerance required to pass all test cases is artificially inflated
        due to the low precision in the model's output and parameters used to
        generate the test cases.
        """

        off_nadir = np.array([
            66.88, 65.09, 63.90, 63.22, 62.46, 61.67, 58.42, 38.27, 23.73,
            56.29
        ])

        location = GroundPosition(52.1579, -106.6702)

        julian = self.times[210:220]
        coor = Coordinate(self.ITRS[210:220], "itrs", julian, self.offset)
        calc_off_nadir = coor.off_nadir(location)

        for i in range(10):
            with self.subTest(i=i):
                self.assertAlmostEqual(off_nadir[i],
                                       calc_off_nadir[i],
                                       delta=0.3)
コード例 #3
0
ファイル: test_coordinate.py プロジェクト: JaiWillems/Celest
    def test_distance(self):
        """Test `Coordinate.distance`."""

        julian = [
            30462.5, 30462.50069444, 30462.50171802, 30462.50278711,
            30462.50386162
        ]
        position = [[6343.81620221, -2640.87223125, -11.25541802],
                    [6295.64583763, -2718.09271472, 443.08232543],
                    [6173.04658005, -2808.91831102, 1108.5854422],
                    [5980.91111229, -2872.96257946, 1792.17964249],
                    [5724.3020284, -2904.09809986, 2460.25799377]]
        dist = [
            9070.49268746, 8776.7179543, 8330.99543153, 7851.70082642,
            7359.09189844
        ]

        location = GroundPosition(52.1579, -106.6702)

        coor = Coordinate(position, "itrs", julian, self.offset)
        calc_dist = coor.distance(location)

        for i in range(5):
            with self.subTest(i=i):
                self.assertAlmostEqual(calc_dist[i], dist[i], delta=0.1)
コード例 #4
0
ファイル: _window_handling.py プロジェクト: JaiWillems/Celest
    def copy(self) -> Any:
        """Return `Window` copy.

        Returns
        -------
        Window

        Examples
        --------
        Let `window_old` be a `Window` object.

        >>> window_new = window_old.copy()
        """

        sat = self.satellite
        gnd = GroundPosition(self.coor[0], self.coor[1])
        start = self.start
        end = self.end
        enc = self.type
        ang = self.ang
        lighting = self.lighting

        return_window = Window(sat, gnd, start, end, enc, ang, lighting)

        return return_window
コード例 #5
0
ファイル: test_coordinate.py プロジェクト: JaiWillems/Celest
    def test_horizontal(self):
        """Test `Coordinate.horizontal`.

        Notes
        -----
        Test cases generated using the `Astropy` Python package.
        """

        from astropy.coordinates import SkyCoord, ITRS, GCRS, EarthLocation, AltAz
        from astropy import units as u
        from astropy import time

        # Set up observer location.
        lat, lon = 52.1579, -106.6702
        loc = EarthLocation.from_geodetic(lon * u.deg, lat * u.deg)

        # Prepare time and position information.
        times = time.Time(self.times + self.offset, format="jd")
        x, y, z = self.GCRS.T

        # Define coordinate frames.
        gcrs = GCRS(obstime=times)
        itrs = ITRS(obstime=times)
        altaz = AltAz(obstime=times, location=loc)

        # Convert between frames.
        gcrsCoor = SkyCoord(x=x,
                            y=y,
                            z=z,
                            unit='km',
                            frame=gcrs,
                            representation_type='cartesian')
        itrsCoor = gcrsCoor.transform_to(itrs)
        altazCoor = itrsCoor.transform_to(altaz)

        # Get validation data.
        itrsData = np.transpose(np.array([itrsCoor.x, itrsCoor.y, itrsCoor.z]))
        alt = altazCoor.alt.degree
        az = altazCoor.az.degree

        # Get Celest results.
        coor = Coordinate(itrsData, "itrs", self.times, self.offset)
        groundPos = GroundPosition(lat, lon)
        calc_alt, calc_az = coor.horizontal(groundPos)

        for i in range(calc_alt.size):
            with self.subTest(i=i):
                self.assertAlmostEqual(alt[i], calc_alt[i], delta=0.25)
                self.assertAlmostEqual(az[i], calc_az[i], delta=7.5)
コード例 #6
0
    def setUp(self):

        location = GroundPosition(43.6532, 79.3832)
        self.windows = Windows()

        self.wind_one = Window("", location, 1319, 1319.2, "image", 30, 1)
        self.wind_two = Window("", location, 1322.3, 1322.31, "data link", 10,
                               -1)
        self.wind_three = Window("", location, 1324, 1324.2, "image", 30, 1)
        self.wind_four = Window("", location, 1324.3, 1325.3, "image", 30, 1)
        self.wind_five = Window("", location, 1325, 1326.1, "image", 30, 1)

        self.windows._add_window(self.wind_one)
        self.windows._add_window(self.wind_two)
        self.windows._add_window(self.wind_three)
        self.windows._add_window(self.wind_four)
        self.windows._add_window(self.wind_five)
コード例 #7
0
    def test_radius(self):
        """Test `GroundPosition._WGS84_radius`.

        Notes
        -----
        Validation against online calculator methodology.[1]_

        References
        ----------
        .. [1] Timur. Earth Radius by Latitude (WGS 84). 2018. url:
           https://planetcalc.com/7721/.
        """

        ground_pos = GroundPosition(self.lat, self.lon)

        a = 6378.1370
        b = 6356.7523142
        lat = np.radians(ground_pos.lat)
        clat, slat = np.cos(lat), np.sin(lat)
        num = (a**2 * clat)**2 + (b**2 * slat)**2
        denom = (a * clat)**2 + (b * slat)**2
        radius = np.sqrt(num / denom)

        self.assertAlmostEqual(radius, ground_pos.radius, delta=0.001)
コード例 #8
0
    def setUp(self):

        location = GroundPosition(43.6532, 79.3832)
        self.window = Window("", location, 21282.4, 21282.5, "image", 30, 1)