コード例 #1
0
    def test_AltitudeProfile_interpolate(self):
        profile = AltitudeProfile(DISTANCES, ALTITUDES)

        distances_0 = np.array([0., 20.0 * NM, 50.0 * NM, DISTANCES[2]])
        alts_0 = profile.interpolate(distances_0)
        self.assertEqual(len(alts_0), len(distances_0))
        self.assertEqual(alts_0[0], ALTITUDES[0])
        self.assertEqual(alts_0[-1], ALTITUDES[2])
コード例 #2
0
    def test_AltitudeProfile_json(self):
        profile_0 = AltitudeProfile(DISTANCES, ALTITUDES)
        s = profile_0.dumps()

        # print(s)

        json_1 = json.loads(s)
        profile_1 = AltitudeProfile.loads(json_1)

        assert_array_almost_equal(profile_1.distances, profile_0.distances)
        assert_array_almost_equal(profile_1.altitudes, profile_0.altitudes)
コード例 #3
0
    def test_AltitudeProfile_altitude_range(self):
        profile = AltitudeProfile(DISTANCES, ALTITUDES)

        min_alt_0, max_alt_0 = profile.altitude_range(0.0, 22.5 * NM)
        self.assertEqual(min_alt_0, 0.0)
        assert_almost_equal(max_alt_0, 4800.0)

        min_alt_1, max_alt_1 = profile.altitude_range(22.5 * NM, 52.5 * NM)
        assert_almost_equal(min_alt_1, 4800.0)
        assert_almost_equal(max_alt_1, 6000.0)

        min_alt_2, max_alt_2 = profile.altitude_range(52.5 * NM, 56.0 * NM)
        assert_almost_equal(min_alt_2, 4200.0)
        assert_almost_equal(max_alt_2, 4800.0)
コード例 #4
0
    def test_AltitudeProfile_intersection_distances(self):
        profile = AltitudeProfile(DISTANCES, ALTITUDES)

        # There should be no intersection at max latitude
        distances_0 = profile.intersection_distances(6000.0, 0.0, 56.0 * NM)
        self.assertEqual(len(distances_0), 0)

        distances_1 = profile.intersection_distances(4800.0, 17.5 * NM, 25.5 * NM)
        self.assertEqual(len(distances_1), 1)
        assert_almost_equal(distances_1[0], 22.5 * NM)

        distances_2 = profile.intersection_distances(4800.0, 25.0 * NM, 53.0 * NM)
        self.assertEqual(len(distances_2), 1)
        assert_almost_equal(distances_2[0], 52.5 * NM)

        distances_3 = profile.intersection_distances(4800.0, 0.0, 56.0 * NM)
        self.assertEqual(len(distances_3), 2)
        assert_almost_equal(distances_3[0], 22.5 * NM)
        assert_almost_equal(distances_3[-1], 52.5 * NM)
コード例 #5
0
    def test_AltitudeProfile_top_of_descent_distancex(self):
        profile = AltitudeProfile(DISTANCES, ALTITUDES)

        self.assertEqual(profile.top_of_descent_distance(), DISTANCES[7])
コード例 #6
0
    def test_AltitudeProfile_top_of_climb_distance(self):
        profile = AltitudeProfile(DISTANCES, ALTITUDES)

        self.assertEqual(profile.top_of_climb_distance(), DISTANCES[6])
コード例 #7
0
    def test_AltitudeProfile_top_of_descent_index(self):
        profile = AltitudeProfile(DISTANCES, ALTITUDES)

        self.assertEqual(profile.top_of_descent_index(), 7)
コード例 #8
0
    def test_AltitudeProfile_profile_type(self):
        CRUISE_ALTITUDES = np.array([35000, 35000,  35000,
                                     35000, 35000,  35000])
        profile_1 = AltitudeProfile(DISTANCES[:6], CRUISE_ALTITUDES)
        self.assertEqual(profile_1.type(), AltitudeProfileType.CRUISING)

        CLIMB_ALTITUDES = np.array([34000, 34500,  35000,
                                    35000, 35500,  36000])
        profile_2 = AltitudeProfile(DISTANCES[:6], CLIMB_ALTITUDES)
        self.assertEqual(profile_2.type(), AltitudeProfileType.CLIMBING)

        DESCENT_ALTITUDES = np.array([36000, 35500,  35000,
                                      35000, 34500,  34000])
        profile_3 = AltitudeProfile(DISTANCES[:6], DESCENT_ALTITUDES)
        self.assertEqual(profile_3.type(), AltitudeProfileType.DESCENDING)

        profile = AltitudeProfile(DISTANCES, ALTITUDES)
        self.assertEqual(profile.type(), AltitudeProfileType.CLIMBING_AND_DESCENDING)