open-space-toolkit-physics 11.3.0__py311-none-manylinux2014_x86_64.whl
Sign up to get free protection for your applications and to get access to all the features.
- open_space_toolkit_physics-11.3.0.dist-info/METADATA +29 -0
- open_space_toolkit_physics-11.3.0.dist-info/RECORD +104 -0
- open_space_toolkit_physics-11.3.0.dist-info/WHEEL +5 -0
- open_space_toolkit_physics-11.3.0.dist-info/top_level.txt +1 -0
- open_space_toolkit_physics-11.3.0.dist-info/zip-safe +1 -0
- ostk/__init__.py +1 -0
- ostk/physics/OpenSpaceToolkitPhysicsPy.cpython-311-x86_64-linux-gnu.so +0 -0
- ostk/physics/__init__.py +6 -0
- ostk/physics/__init__.pyi +488 -0
- ostk/physics/coordinate/__init__.pyi +1002 -0
- ostk/physics/coordinate/frame/__init__.pyi +30 -0
- ostk/physics/coordinate/frame/provider/__init__.pyi +77 -0
- ostk/physics/coordinate/frame/provider/iau.pyi +64 -0
- ostk/physics/coordinate/frame/provider/iers.pyi +584 -0
- ostk/physics/coordinate/spherical.pyi +421 -0
- ostk/physics/data/__init__.pyi +459 -0
- ostk/physics/data/provider.pyi +21 -0
- ostk/physics/environment/__init__.pyi +108 -0
- ostk/physics/environment/atmospheric/__init__.pyi +181 -0
- ostk/physics/environment/atmospheric/earth.pyi +552 -0
- ostk/physics/environment/gravitational/__init__.pyi +559 -0
- ostk/physics/environment/gravitational/earth.pyi +56 -0
- ostk/physics/environment/magnetic/__init__.pyi +171 -0
- ostk/physics/environment/magnetic/earth.pyi +56 -0
- ostk/physics/environment/object/__init__.pyi +430 -0
- ostk/physics/environment/object/celestial/__init__.pyi +248 -0
- ostk/physics/environment/object/celestial/moon.pyi +2 -0
- ostk/physics/environment/object/celestial/sun.pyi +2 -0
- ostk/physics/libopen-space-toolkit-physics.so.11 +0 -0
- ostk/physics/py.typed +0 -0
- ostk/physics/test/__init__.py +1 -0
- ostk/physics/test/coordinate/__init__.py +1 -0
- ostk/physics/test/coordinate/frame/__init__.py +1 -0
- ostk/physics/test/coordinate/frame/provider/__init__.py +1 -0
- ostk/physics/test/coordinate/frame/provider/iers/__init__.py +1 -0
- ostk/physics/test/coordinate/frame/provider/iers/conftest.py +38 -0
- ostk/physics/test/coordinate/frame/provider/iers/data/finals2000A.data +10953 -0
- ostk/physics/test/coordinate/frame/provider/iers/data/ser7.dat +524 -0
- ostk/physics/test/coordinate/frame/provider/iers/test_bulletin_a.py +108 -0
- ostk/physics/test/coordinate/frame/provider/iers/test_finals_2000a.py +93 -0
- ostk/physics/test/coordinate/frame/provider/iers/test_manager.py +205 -0
- ostk/physics/test/coordinate/spherical/__init__.py +1 -0
- ostk/physics/test/coordinate/spherical/test_aer.py +143 -0
- ostk/physics/test/coordinate/spherical/test_lla.py +514 -0
- ostk/physics/test/coordinate/test_axes.py +116 -0
- ostk/physics/test/coordinate/test_frame.py +107 -0
- ostk/physics/test/coordinate/test_position.py +201 -0
- ostk/physics/test/coordinate/test_transform.py +294 -0
- ostk/physics/test/coordinate/test_velocity.py +180 -0
- ostk/physics/test/data/conftest.py +34 -0
- ostk/physics/test/data/data/manifest.json +22 -0
- ostk/physics/test/data/provider/test_provider.py +34 -0
- ostk/physics/test/data/test_direction.py +40 -0
- ostk/physics/test/data/test_manifest.py +43 -0
- ostk/physics/test/data/test_manifest_manager.py +62 -0
- ostk/physics/test/data/test_scalar.py +54 -0
- ostk/physics/test/data/test_vector.py +70 -0
- ostk/physics/test/environment/__init__.py +1 -0
- ostk/physics/test/environment/atmospheric/__init__.py +1 -0
- ostk/physics/test/environment/atmospheric/earth/__init__.py +1 -0
- ostk/physics/test/environment/atmospheric/earth/conftest.py +67 -0
- ostk/physics/test/environment/atmospheric/earth/data/SW-Last5Years.test.csv +22 -0
- ostk/physics/test/environment/atmospheric/earth/data/SpaceWeather-All-v1.2.test.txt +811 -0
- ostk/physics/test/environment/atmospheric/earth/test_cssi_space_weather.py +126 -0
- ostk/physics/test/environment/atmospheric/earth/test_exponential.py +34 -0
- ostk/physics/test/environment/atmospheric/earth/test_manager.py +173 -0
- ostk/physics/test/environment/atmospheric/earth/test_nrlmsise00.py +34 -0
- ostk/physics/test/environment/atmospheric/test_earth.py +141 -0
- ostk/physics/test/environment/gravitational/__init__.py +1 -0
- ostk/physics/test/environment/gravitational/earth/__init__.py +1 -0
- ostk/physics/test/environment/gravitational/earth/test_manager.py +76 -0
- ostk/physics/test/environment/gravitational/test_earth.py +103 -0
- ostk/physics/test/environment/gravitational/test_moon.py +55 -0
- ostk/physics/test/environment/gravitational/test_spherical.py +36 -0
- ostk/physics/test/environment/gravitational/test_sun.py +53 -0
- ostk/physics/test/environment/magnetic/__init__.py +1 -0
- ostk/physics/test/environment/magnetic/earth/test_manager.py +64 -0
- ostk/physics/test/environment/magnetic/test_earth.py +38 -0
- ostk/physics/test/environment/object/__init__.py +1 -0
- ostk/physics/test/environment/object/celestial/__init__ .py +1 -0
- ostk/physics/test/environment/object/celestial/test_earth.py +174 -0
- ostk/physics/test/environment/object/celestial/test_moon.py +17 -0
- ostk/physics/test/environment/object/celestial/test_sun.py +17 -0
- ostk/physics/test/environment/object/test_celestial.py +12 -0
- ostk/physics/test/test_environment.py +97 -0
- ostk/physics/test/test_import.py +25 -0
- ostk/physics/test/time/__init__.py +1 -0
- ostk/physics/test/time/test_date.py +136 -0
- ostk/physics/test/time/test_date_time.py +230 -0
- ostk/physics/test/time/test_duration.py +215 -0
- ostk/physics/test/time/test_instant.py +103 -0
- ostk/physics/test/time/test_interval.py +432 -0
- ostk/physics/test/time/test_scale.py +11 -0
- ostk/physics/test/time/test_time.py +114 -0
- ostk/physics/test/unit/__init__.py +1 -0
- ostk/physics/test/unit/derived/__init__.py +1 -0
- ostk/physics/test/unit/derived/test_angle.py +368 -0
- ostk/physics/test/unit/test_derived.py +152 -0
- ostk/physics/test/unit/test_electric_current.py +5 -0
- ostk/physics/test/unit/test_length.py +297 -0
- ostk/physics/test/unit/test_mass.py +141 -0
- ostk/physics/test/unit/test_time.py +101 -0
- ostk/physics/time.pyi +1744 -0
- ostk/physics/unit.pyi +1590 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
from datetime import datetime
|
6
|
+
|
7
|
+
from ostk.core.filesystem import File
|
8
|
+
|
9
|
+
from ostk.physics.time import Scale
|
10
|
+
from ostk.physics.time import Instant
|
11
|
+
|
12
|
+
from ostk.physics.environment.atmospheric.earth import CSSISpaceWeather
|
13
|
+
|
14
|
+
|
15
|
+
class TestCSSISpaceWeather:
|
16
|
+
def test_str_success(self, cssi_space_weather: CSSISpaceWeather):
|
17
|
+
assert str(cssi_space_weather).startswith("-- CSSI Space Weather --")
|
18
|
+
|
19
|
+
def test_repr_success(self, cssi_space_weather: CSSISpaceWeather):
|
20
|
+
assert repr(cssi_space_weather).startswith("-- CSSI Space Weather --")
|
21
|
+
|
22
|
+
def test_is_defined_success(self, cssi_space_weather: CSSISpaceWeather):
|
23
|
+
assert cssi_space_weather.is_defined() is True
|
24
|
+
|
25
|
+
def test_access_last_observation_date_success(
|
26
|
+
self, cssi_space_weather: CSSISpaceWeather
|
27
|
+
):
|
28
|
+
assert (
|
29
|
+
cssi_space_weather.access_last_observation_date().to_string() == "2023-06-19"
|
30
|
+
)
|
31
|
+
|
32
|
+
def test_access_observation_interval_success(
|
33
|
+
self, cssi_space_weather: CSSISpaceWeather
|
34
|
+
):
|
35
|
+
assert (
|
36
|
+
cssi_space_weather.access_observation_interval().to_string()
|
37
|
+
== "[2018-01-01 00:00:00 - 2023-06-20 00:00:00[ [UTC]"
|
38
|
+
)
|
39
|
+
|
40
|
+
def test_access_observation_at_success(self, cssi_space_weather: CSSISpaceWeather):
|
41
|
+
observation: Observation = cssi_space_weather.access_observation_at(
|
42
|
+
Instant.date_time(datetime(2023, 6, 19, 0, 0, 0), Scale.UTC)
|
43
|
+
)
|
44
|
+
|
45
|
+
assert observation.date.to_string() == "2023-06-19"
|
46
|
+
assert observation.kp_sum == 177
|
47
|
+
assert observation.f107_obs == pytest.approx(168.8)
|
48
|
+
assert observation.f107_obs_center_81 == pytest.approx(160.1)
|
49
|
+
|
50
|
+
def test_access_daily_prediction_interval_success(
|
51
|
+
self, cssi_space_weather: CSSISpaceWeather
|
52
|
+
):
|
53
|
+
assert (
|
54
|
+
cssi_space_weather.access_daily_prediction_interval().to_string()
|
55
|
+
== "[2023-06-20 00:00:00 - 2023-08-04 00:00:00[ [UTC]"
|
56
|
+
)
|
57
|
+
|
58
|
+
def test_access_daily_prediction_at_success(
|
59
|
+
self, cssi_space_weather: CSSISpaceWeather
|
60
|
+
):
|
61
|
+
prediction: Reading = cssi_space_weather.access_daily_prediction_at(
|
62
|
+
Instant.date_time(datetime(2023, 8, 3, 0, 0, 0), Scale.UTC)
|
63
|
+
)
|
64
|
+
|
65
|
+
assert prediction.date.to_string() == "2023-08-03"
|
66
|
+
assert prediction.kp_sum == 104
|
67
|
+
assert prediction.f107_obs == pytest.approx(165.1)
|
68
|
+
assert prediction.f107_obs_center_81 == pytest.approx(157.4)
|
69
|
+
|
70
|
+
def test_access_monthly_prediction_interval_success(
|
71
|
+
self, cssi_space_weather: CSSISpaceWeather
|
72
|
+
):
|
73
|
+
assert (
|
74
|
+
cssi_space_weather.access_monthly_prediction_interval().to_string()
|
75
|
+
== "[2023-08-01 00:00:00 - 2029-01-01 00:00:00] [UTC]"
|
76
|
+
)
|
77
|
+
|
78
|
+
def test_access_monthly_prediction_at_success(
|
79
|
+
self, cssi_space_weather: CSSISpaceWeather
|
80
|
+
):
|
81
|
+
prediction: Reading = cssi_space_weather.access_monthly_prediction_at(
|
82
|
+
Instant.date_time(datetime(2029, 1, 1, 0, 0, 0), Scale.UTC)
|
83
|
+
)
|
84
|
+
|
85
|
+
assert prediction.date.to_string() == "2029-01-01"
|
86
|
+
assert prediction.f107_obs == pytest.approx(83.5)
|
87
|
+
assert prediction.f107_obs_center_81 == pytest.approx(83.6)
|
88
|
+
|
89
|
+
def test_access_reading_at_success(self, cssi_space_weather: CSSISpaceWeather):
|
90
|
+
reading: Reading = cssi_space_weather.access_reading_at(
|
91
|
+
Instant.date_time(datetime(2029, 1, 1, 0, 0, 0), Scale.UTC)
|
92
|
+
)
|
93
|
+
|
94
|
+
assert reading.date.to_string() == "2029-01-01"
|
95
|
+
assert reading.f107_obs == pytest.approx(83.5)
|
96
|
+
assert reading.f107_obs_center_81 == pytest.approx(83.6)
|
97
|
+
assert reading.f107_data_type == "PRM"
|
98
|
+
|
99
|
+
def test_access_last_reading_where_success(
|
100
|
+
self, cssi_space_weather: CSSISpaceWeather
|
101
|
+
):
|
102
|
+
reading: Reading = cssi_space_weather.access_last_reading_where(
|
103
|
+
lambda reading: reading.f107_data_type == "PRD",
|
104
|
+
Instant.date_time(datetime(2023, 12, 1, 0, 0, 0), Scale.UTC),
|
105
|
+
)
|
106
|
+
|
107
|
+
assert reading.date.to_string() == "2023-08-03"
|
108
|
+
assert reading.f107_data_type == "PRD"
|
109
|
+
|
110
|
+
def test_access_last_reading_where_failure(
|
111
|
+
self, cssi_space_weather: CSSISpaceWeather
|
112
|
+
):
|
113
|
+
with pytest.raises(RuntimeError):
|
114
|
+
cssi_space_weather.access_last_reading_where(
|
115
|
+
lambda reading: reading.f107_data_type == "FAKE",
|
116
|
+
Instant.date_time(datetime(2029, 1, 1, 0, 0, 0), Scale.UTC),
|
117
|
+
)
|
118
|
+
|
119
|
+
def test_undefined_success(self):
|
120
|
+
assert CSSISpaceWeather.undefined() is not None
|
121
|
+
|
122
|
+
def test_load_success(self, cssi_space_weather_file: File):
|
123
|
+
assert CSSISpaceWeather.load(cssi_space_weather_file) is not None
|
124
|
+
|
125
|
+
def test_load_legacy_success(self, cssi_space_weather_legacy_file: File):
|
126
|
+
assert CSSISpaceWeather.load_legacy(cssi_space_weather_legacy_file) is not None
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
import numpy as np
|
5
|
+
|
6
|
+
from ostk.physics.time import Instant
|
7
|
+
from ostk.physics.time import DateTime
|
8
|
+
from ostk.physics.time import Scale
|
9
|
+
from ostk.physics.unit import Length
|
10
|
+
from ostk.physics.unit import Angle
|
11
|
+
from ostk.physics.coordinate import Position
|
12
|
+
from ostk.physics.coordinate import Frame
|
13
|
+
from ostk.physics.coordinate.spherical import LLA
|
14
|
+
|
15
|
+
from ostk.physics.environment.atmospheric import Earth as EarthAtmosphericModel
|
16
|
+
from ostk.physics.environment.atmospheric.earth import Exponential
|
17
|
+
|
18
|
+
|
19
|
+
class TestExponential:
|
20
|
+
def test_constructor_success(self, exponential_model):
|
21
|
+
assert isinstance(exponential_model, Exponential)
|
22
|
+
|
23
|
+
def test_is_defined_success(self, exponential_model):
|
24
|
+
assert exponential_model.is_defined() is True
|
25
|
+
|
26
|
+
def test_get_density_at_lla_success(self, exponential_model):
|
27
|
+
lla = LLA(Angle.degrees(0.0), Angle.degrees(0.0), Length.meters(500e3))
|
28
|
+
|
29
|
+
density = exponential_model.get_density_at(
|
30
|
+
lla, Instant.date_time(DateTime.parse("2021-01-01 00:00:00"), Scale.UTC)
|
31
|
+
)
|
32
|
+
|
33
|
+
# assert sensible number for density
|
34
|
+
assert 1.0e-15 < density < 1.0e-12
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
from datetime import datetime
|
6
|
+
import pathlib
|
7
|
+
|
8
|
+
from ostk.core.filesystem import Path
|
9
|
+
from ostk.core.filesystem import File
|
10
|
+
from ostk.core.filesystem import Directory
|
11
|
+
|
12
|
+
from ostk.physics.time import Scale
|
13
|
+
from ostk.physics.time import Instant
|
14
|
+
from ostk.physics.time import Duration
|
15
|
+
|
16
|
+
from ostk.physics.environment.atmospheric.earth import Manager
|
17
|
+
from ostk.physics.environment.atmospheric.earth import CSSISpaceWeather
|
18
|
+
|
19
|
+
|
20
|
+
class TestManager:
|
21
|
+
def test_get_mode_success(self, manager: Manager):
|
22
|
+
assert manager.get_mode() == Manager.Mode.Automatic
|
23
|
+
|
24
|
+
def test_get_local_repository_success(self, manager: Manager):
|
25
|
+
assert isinstance(manager.get_local_repository(), Directory)
|
26
|
+
assert len(str(manager.get_local_repository().to_string())) > 0
|
27
|
+
|
28
|
+
def test_get_cssi_space_weather_directory_success(self, manager: Manager):
|
29
|
+
assert isinstance(manager.get_cssi_space_weather_directory(), Directory)
|
30
|
+
assert len(str(manager.get_cssi_space_weather_directory().to_string())) > 0
|
31
|
+
|
32
|
+
def test_get_loaded_cssi_space_weather_success(self, manager: Manager):
|
33
|
+
assert isinstance(manager.get_loaded_cssi_space_weather(), CSSISpaceWeather)
|
34
|
+
assert not manager.get_loaded_cssi_space_weather().is_defined()
|
35
|
+
|
36
|
+
def test_get_cssi_space_weather_at_success(self, manager: Manager):
|
37
|
+
try:
|
38
|
+
cssi_space_weather: CSSISpaceWeather = manager.get_cssi_space_weather_at(
|
39
|
+
Instant.now() - Duration.days(8.0)
|
40
|
+
)
|
41
|
+
except RuntimeError:
|
42
|
+
manager.reset()
|
43
|
+
manager.clear_local_repository()
|
44
|
+
cssi_space_weather: CSSISpaceWeather = manager.get_cssi_space_weather_at(
|
45
|
+
Instant.now() - Duration.days(5.0)
|
46
|
+
)
|
47
|
+
|
48
|
+
assert isinstance(cssi_space_weather, CSSISpaceWeather)
|
49
|
+
|
50
|
+
def test_get_kp_3_hour_solar_indices_at_success(
|
51
|
+
self, manager: Manager, cssi_space_weather: CSSISpaceWeather
|
52
|
+
):
|
53
|
+
# load test file data for comparison
|
54
|
+
manager.load_cssi_space_weather(cssi_space_weather)
|
55
|
+
|
56
|
+
kp_indices = manager.get_kp_3_hour_solar_indices_at(
|
57
|
+
Instant.date_time(datetime(2023, 6, 18, 12, 34, 56), Scale.UTC)
|
58
|
+
)
|
59
|
+
|
60
|
+
assert kp_indices == [27, 20, 13, 20, 17, 17, 27, 20]
|
61
|
+
|
62
|
+
def test_get_ap_3_hour_solar_indices_at_success(
|
63
|
+
self, manager: Manager, cssi_space_weather: CSSISpaceWeather
|
64
|
+
):
|
65
|
+
# load test file data for comparison
|
66
|
+
manager.load_cssi_space_weather(cssi_space_weather)
|
67
|
+
|
68
|
+
ap_indices = manager.get_ap_3_hour_solar_indices_at(
|
69
|
+
Instant.date_time(datetime(2023, 6, 18, 12, 34, 56), Scale.UTC)
|
70
|
+
)
|
71
|
+
|
72
|
+
assert ap_indices == [12, 7, 5, 7, 6, 6, 12, 7]
|
73
|
+
|
74
|
+
def test_get_ap_daily_index_at_success(
|
75
|
+
self, manager: Manager, cssi_space_weather: CSSISpaceWeather
|
76
|
+
):
|
77
|
+
# load test file data for comparison
|
78
|
+
manager.load_cssi_space_weather(cssi_space_weather)
|
79
|
+
|
80
|
+
ap_index = manager.get_ap_daily_index_at(
|
81
|
+
Instant.date_time(datetime(2023, 6, 18, 12, 34, 56), Scale.UTC)
|
82
|
+
)
|
83
|
+
|
84
|
+
assert ap_index == 8
|
85
|
+
|
86
|
+
def test_get_f107_solar_flux_at_success(
|
87
|
+
self, manager: Manager, cssi_space_weather: CSSISpaceWeather
|
88
|
+
):
|
89
|
+
# load test file data for comparison
|
90
|
+
manager.load_cssi_space_weather(cssi_space_weather)
|
91
|
+
|
92
|
+
flux = manager.get_f107_solar_flux_at(
|
93
|
+
Instant.date_time(datetime(2023, 6, 18, 12, 34, 56), Scale.UTC)
|
94
|
+
)
|
95
|
+
|
96
|
+
assert flux == pytest.approx(164.1)
|
97
|
+
|
98
|
+
def test_get_f107_solar_flux_81_day_avg_at_success(
|
99
|
+
self, manager: Manager, cssi_space_weather: CSSISpaceWeather
|
100
|
+
):
|
101
|
+
# load test file data for comparison
|
102
|
+
manager.load_cssi_space_weather(cssi_space_weather)
|
103
|
+
|
104
|
+
flux_avg = manager.get_f107_solar_flux_81_day_avg_at(
|
105
|
+
Instant.date_time(datetime(2018, 1, 1, 12, 34, 56), Scale.UTC)
|
106
|
+
)
|
107
|
+
|
108
|
+
assert flux_avg == pytest.approx(71.4)
|
109
|
+
|
110
|
+
def test_set_mode_success(self, manager: Manager):
|
111
|
+
assert manager.get_mode() == Manager.Mode.Automatic
|
112
|
+
|
113
|
+
manager.set_mode(Manager.Mode.Manual)
|
114
|
+
|
115
|
+
assert manager.get_mode() == Manager.Mode.Manual
|
116
|
+
|
117
|
+
def test_set_local_repository_success(self, manager: Manager):
|
118
|
+
assert isinstance(manager.get_local_repository(), Directory)
|
119
|
+
|
120
|
+
manager.set_local_repository(
|
121
|
+
Directory.path(
|
122
|
+
Path.parse("./.open-space-toolkit/physics/environment/atmospheric/earth")
|
123
|
+
)
|
124
|
+
)
|
125
|
+
|
126
|
+
assert isinstance(manager.get_local_repository(), Directory)
|
127
|
+
assert (
|
128
|
+
manager.get_local_repository().to_string()
|
129
|
+
== "./.open-space-toolkit/physics/environment/atmospheric/earth"
|
130
|
+
)
|
131
|
+
|
132
|
+
def test_load_cssi_space_weather_success(
|
133
|
+
self, manager: Manager, cssi_space_weather: CSSISpaceWeather
|
134
|
+
):
|
135
|
+
assert not manager.get_loaded_cssi_space_weather().is_defined()
|
136
|
+
|
137
|
+
manager.load_cssi_space_weather(cssi_space_weather)
|
138
|
+
|
139
|
+
assert manager.get_loaded_cssi_space_weather().is_defined()
|
140
|
+
|
141
|
+
def test_fetch_latest_cssi_space_weather_success(self, manager: Manager):
|
142
|
+
file: File = manager.fetch_latest_cssi_space_weather()
|
143
|
+
|
144
|
+
assert isinstance(file, File)
|
145
|
+
assert file.exists()
|
146
|
+
|
147
|
+
file.remove()
|
148
|
+
|
149
|
+
def test_reset_success(self, manager: Manager, cssi_space_weather: CSSISpaceWeather):
|
150
|
+
manager.load_cssi_space_weather(cssi_space_weather)
|
151
|
+
|
152
|
+
assert manager.get_loaded_cssi_space_weather().is_defined()
|
153
|
+
|
154
|
+
manager.reset()
|
155
|
+
|
156
|
+
assert not manager.get_loaded_cssi_space_weather().is_defined()
|
157
|
+
|
158
|
+
def test_clear_local_repository_success(self, manager: Manager):
|
159
|
+
assert manager.get_local_repository().exists()
|
160
|
+
assert manager.get_cssi_space_weather_directory().exists()
|
161
|
+
pathlib.Path(
|
162
|
+
str(manager.get_cssi_space_weather_directory().get_path().to_string())
|
163
|
+
+ "/toto"
|
164
|
+
).touch()
|
165
|
+
assert not manager.get_local_repository().is_empty()
|
166
|
+
|
167
|
+
manager.clear_local_repository()
|
168
|
+
|
169
|
+
assert manager.get_local_repository().exists()
|
170
|
+
assert manager.get_cssi_space_weather_directory().is_empty()
|
171
|
+
|
172
|
+
def test_get_success(self):
|
173
|
+
assert isinstance(Manager.get(), Manager)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
import numpy as np
|
5
|
+
|
6
|
+
from ostk.physics.time import Instant
|
7
|
+
from ostk.physics.time import DateTime
|
8
|
+
from ostk.physics.time import Scale
|
9
|
+
from ostk.physics.unit import Length
|
10
|
+
from ostk.physics.unit import Angle
|
11
|
+
from ostk.physics.coordinate import Position
|
12
|
+
from ostk.physics.coordinate import Frame
|
13
|
+
from ostk.physics.coordinate.spherical import LLA
|
14
|
+
|
15
|
+
from ostk.physics.environment.atmospheric import Earth as EarthAtmosphericModel
|
16
|
+
from ostk.physics.environment.atmospheric.earth import NRLMSISE00
|
17
|
+
|
18
|
+
|
19
|
+
class TestNRLMSISE00:
|
20
|
+
def test_constructor_success(self, nrlmsise00_model):
|
21
|
+
assert isinstance(nrlmsise00_model, NRLMSISE00)
|
22
|
+
|
23
|
+
def test_is_defined_success(self, nrlmsise00_model):
|
24
|
+
assert nrlmsise00_model.is_defined() is True
|
25
|
+
|
26
|
+
def test_get_density_at_lla_no_sun_success(self, nrlmsise00_model):
|
27
|
+
lla = LLA(Angle.degrees(0.0), Angle.degrees(0.0), Length.meters(500e3))
|
28
|
+
|
29
|
+
density = nrlmsise00_model.get_density_at(
|
30
|
+
lla, Instant.date_time(DateTime.parse("2021-01-01 00:00:00"), Scale.UTC)
|
31
|
+
)
|
32
|
+
|
33
|
+
# assert sensible number for density
|
34
|
+
assert 1.0e-15 < density < 1.0e-12
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
import numpy as np
|
6
|
+
|
7
|
+
from ostk.core.filesystem import Directory
|
8
|
+
|
9
|
+
from ostk.physics.time import Instant
|
10
|
+
from ostk.physics.time import DateTime
|
11
|
+
from ostk.physics.time import Scale
|
12
|
+
from ostk.physics.unit import Length
|
13
|
+
from ostk.physics.unit import Angle
|
14
|
+
from ostk.physics.coordinate import Position
|
15
|
+
from ostk.physics.coordinate import Frame
|
16
|
+
from ostk.physics.coordinate.spherical import LLA
|
17
|
+
from ostk.physics.environment.atmospheric import Earth as EarthAtmosphericModel
|
18
|
+
from ostk.physics.environment.gravitational import Earth as EarthGravitationalModel
|
19
|
+
from ostk.physics.environment.object.celestial import Sun
|
20
|
+
|
21
|
+
|
22
|
+
@pytest.fixture
|
23
|
+
def earth_atmospheric_model_exponential() -> EarthAtmosphericModel:
|
24
|
+
return EarthAtmosphericModel(EarthAtmosphericModel.Type.Exponential)
|
25
|
+
|
26
|
+
|
27
|
+
@pytest.fixture
|
28
|
+
def earth_atmospheric_model_nrlmsise() -> EarthAtmosphericModel:
|
29
|
+
return EarthAtmosphericModel(EarthAtmosphericModel.Type.NRLMSISE00)
|
30
|
+
|
31
|
+
|
32
|
+
class TestEarth:
|
33
|
+
def test_constructor_success_with_type(self):
|
34
|
+
earth_atmospheric_model = EarthAtmosphericModel(
|
35
|
+
type=EarthAtmosphericModel.Type.Exponential,
|
36
|
+
input_data_type=EarthAtmosphericModel.InputDataType.Undefined,
|
37
|
+
)
|
38
|
+
|
39
|
+
assert isinstance(earth_atmospheric_model, EarthAtmosphericModel)
|
40
|
+
|
41
|
+
def test_constructor_success_exponential_with_params(self):
|
42
|
+
earth_atmospheric_model = EarthAtmosphericModel(
|
43
|
+
type=EarthAtmosphericModel.Type.Exponential,
|
44
|
+
input_data_type=EarthAtmosphericModel.InputDataType.Undefined,
|
45
|
+
f107_constant_value=160.0,
|
46
|
+
f107_average_constant_value=160.0,
|
47
|
+
kp_constant_value=4.0,
|
48
|
+
earth_frame=Frame.ITRF(),
|
49
|
+
earth_radius=EarthGravitationalModel.WGS84.equatorial_radius,
|
50
|
+
earth_flattening=EarthGravitationalModel.WGS84.flattening,
|
51
|
+
sun_celestial=Sun.default(),
|
52
|
+
)
|
53
|
+
|
54
|
+
assert isinstance(earth_atmospheric_model, EarthAtmosphericModel)
|
55
|
+
|
56
|
+
def test_constructor_success_nrlmsise_file_with_params(self):
|
57
|
+
earth_atmospheric_model = EarthAtmosphericModel(
|
58
|
+
type=EarthAtmosphericModel.Type.NRLMSISE00,
|
59
|
+
input_data_type=EarthAtmosphericModel.InputDataType.CSSISpaceWeatherFile,
|
60
|
+
earth_frame=Frame.ITRF(),
|
61
|
+
earth_radius=EarthGravitationalModel.WGS84.equatorial_radius,
|
62
|
+
earth_flattening=EarthGravitationalModel.WGS84.flattening,
|
63
|
+
)
|
64
|
+
|
65
|
+
assert isinstance(earth_atmospheric_model, EarthAtmosphericModel)
|
66
|
+
|
67
|
+
def test_constructor_success_nrlmsise_constant_with_params(self):
|
68
|
+
earth_atmospheric_model = EarthAtmosphericModel(
|
69
|
+
type=EarthAtmosphericModel.Type.NRLMSISE00,
|
70
|
+
input_data_type=EarthAtmosphericModel.InputDataType.ConstantFluxAndGeoMag,
|
71
|
+
f107_constant_value=160.0,
|
72
|
+
f107_average_constant_value=160.0,
|
73
|
+
kp_constant_value=4.0,
|
74
|
+
earth_frame=Frame.ITRF(),
|
75
|
+
earth_radius=EarthGravitationalModel.WGS84.equatorial_radius,
|
76
|
+
earth_flattening=EarthGravitationalModel.WGS84.flattening,
|
77
|
+
sun_celestial=Sun.default(),
|
78
|
+
)
|
79
|
+
|
80
|
+
assert isinstance(earth_atmospheric_model, EarthAtmosphericModel)
|
81
|
+
|
82
|
+
def test_get_type_success(
|
83
|
+
self, earth_atmospheric_model_exponential: EarthAtmosphericModel
|
84
|
+
):
|
85
|
+
assert (
|
86
|
+
earth_atmospheric_model_exponential.get_type()
|
87
|
+
== EarthAtmosphericModel.Type.Exponential
|
88
|
+
)
|
89
|
+
|
90
|
+
def test_get_input_data_type_success(
|
91
|
+
self, earth_atmospheric_model_exponential: EarthAtmosphericModel
|
92
|
+
):
|
93
|
+
assert (
|
94
|
+
earth_atmospheric_model_exponential.get_input_data_type()
|
95
|
+
== EarthAtmosphericModel.InputDataType.Undefined
|
96
|
+
)
|
97
|
+
|
98
|
+
def test_is_defined_success(
|
99
|
+
self, earth_atmospheric_model_exponential: EarthAtmosphericModel
|
100
|
+
):
|
101
|
+
assert earth_atmospheric_model_exponential.is_defined() == True
|
102
|
+
|
103
|
+
def test_get_density_at_exponential_success(
|
104
|
+
self, earth_atmospheric_model_exponential: EarthAtmosphericModel
|
105
|
+
):
|
106
|
+
latitude = Angle.degrees(30.0)
|
107
|
+
longitude = Angle.degrees(40.0)
|
108
|
+
altitude = Length.kilometers(500.0)
|
109
|
+
|
110
|
+
density = earth_atmospheric_model_exponential.get_density_at(
|
111
|
+
position=Position.meters(
|
112
|
+
coordinates=LLA(latitude, longitude, altitude).to_cartesian(
|
113
|
+
ellipsoid_equatorial_radius=EarthGravitationalModel.EGM2008.equatorial_radius,
|
114
|
+
ellipsoid_flattening=EarthGravitationalModel.EGM2008.flattening,
|
115
|
+
),
|
116
|
+
frame=Frame.ITRF(),
|
117
|
+
),
|
118
|
+
instant=Instant.J2000(),
|
119
|
+
)
|
120
|
+
|
121
|
+
assert density is not None
|
122
|
+
|
123
|
+
def test_get_density_at_nrlmsise_success(
|
124
|
+
self, earth_atmospheric_model_nrlmsise: EarthAtmosphericModel
|
125
|
+
):
|
126
|
+
latitude = Angle.degrees(30.0)
|
127
|
+
longitude = Angle.degrees(40.0)
|
128
|
+
altitude = Length.kilometers(500.0)
|
129
|
+
|
130
|
+
density = earth_atmospheric_model_nrlmsise.get_density_at(
|
131
|
+
position=Position.meters(
|
132
|
+
coordinates=LLA(latitude, longitude, altitude).to_cartesian(
|
133
|
+
ellipsoid_equatorial_radius=EarthGravitationalModel.EGM2008.equatorial_radius,
|
134
|
+
ellipsoid_flattening=EarthGravitationalModel.EGM2008.flattening,
|
135
|
+
),
|
136
|
+
frame=Frame.ITRF(),
|
137
|
+
),
|
138
|
+
instant=Instant.date_time(DateTime.parse("2021-01-01 00:00:00"), Scale.UTC),
|
139
|
+
)
|
140
|
+
|
141
|
+
assert density is not None
|
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|
@@ -0,0 +1 @@
|
|
1
|
+
# Apache License 2.0
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
from ostk.core.filesystem import Path, Directory, PermissionSet
|
6
|
+
|
7
|
+
from ostk.physics.time import Duration
|
8
|
+
from ostk.physics.environment.gravitational import Earth as EarthGravitationalModel
|
9
|
+
from ostk.physics.environment.gravitational.earth import (
|
10
|
+
Manager as EarthGravitationalModelManager,
|
11
|
+
)
|
12
|
+
|
13
|
+
|
14
|
+
@pytest.fixture
|
15
|
+
def manager() -> EarthGravitationalModelManager:
|
16
|
+
manager = EarthGravitationalModelManager.get()
|
17
|
+
|
18
|
+
yield manager
|
19
|
+
|
20
|
+
# This reset is important so that other test modules are not affected
|
21
|
+
manager.reset()
|
22
|
+
|
23
|
+
|
24
|
+
class TestManager:
|
25
|
+
def test_get_mode_success(self, manager: EarthGravitationalModelManager):
|
26
|
+
assert manager.get_mode() == EarthGravitationalModelManager.Mode.Automatic
|
27
|
+
|
28
|
+
def test_has_data_files_for_type_success(
|
29
|
+
self, manager: EarthGravitationalModelManager
|
30
|
+
):
|
31
|
+
assert manager.has_data_files_for_type(EarthGravitationalModel.Type.WGS84) == True
|
32
|
+
assert manager.has_data_files_for_type(EarthGravitationalModel.Type.EGM84) == True
|
33
|
+
assert manager.has_data_files_for_type(EarthGravitationalModel.Type.EGM96) == True
|
34
|
+
assert (
|
35
|
+
manager.has_data_files_for_type(EarthGravitationalModel.Type.EGM2008) == True
|
36
|
+
)
|
37
|
+
|
38
|
+
def test_get_local_repository_success(self, manager: EarthGravitationalModelManager):
|
39
|
+
assert isinstance(manager.get_local_repository(), Directory)
|
40
|
+
assert len(str(manager.get_local_repository().to_string())) > 0
|
41
|
+
|
42
|
+
def test_fetch_data_files_for_type_success(
|
43
|
+
self, manager: EarthGravitationalModelManager
|
44
|
+
):
|
45
|
+
test_directory = Directory.path(
|
46
|
+
manager.get_local_repository().get_path() + Path.parse("/test")
|
47
|
+
)
|
48
|
+
if test_directory.exists():
|
49
|
+
test_directory.remove()
|
50
|
+
|
51
|
+
test_directory.create(PermissionSet.rw(), PermissionSet.r(), PermissionSet.r())
|
52
|
+
manager.set_local_repository(test_directory)
|
53
|
+
|
54
|
+
manager.fetch_data_files_for_type(EarthGravitationalModel.Type.WGS84)
|
55
|
+
|
56
|
+
def test_set_mode_success(self, manager: EarthGravitationalModelManager):
|
57
|
+
assert manager.get_mode() == EarthGravitationalModelManager.Mode.Automatic
|
58
|
+
|
59
|
+
manager.set_mode(EarthGravitationalModelManager.Mode.Manual)
|
60
|
+
|
61
|
+
assert manager.get_mode() == EarthGravitationalModelManager.Mode.Manual
|
62
|
+
|
63
|
+
def test_set_local_repository_success(self, manager: EarthGravitationalModelManager):
|
64
|
+
manager.set_local_repository(
|
65
|
+
Directory.path(
|
66
|
+
Path.parse(
|
67
|
+
"./.open-space-toolkit/physics/environment/gravitational/earth2"
|
68
|
+
)
|
69
|
+
)
|
70
|
+
)
|
71
|
+
|
72
|
+
assert isinstance(manager.get_local_repository(), Directory)
|
73
|
+
assert (
|
74
|
+
manager.get_local_repository().to_string()
|
75
|
+
== "./.open-space-toolkit/physics/environment/gravitational/earth2"
|
76
|
+
)
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# Apache License 2.0
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
import numpy as np
|
6
|
+
|
7
|
+
from ostk.core.filesystem import Directory
|
8
|
+
|
9
|
+
from ostk.physics.time import Instant
|
10
|
+
from ostk.physics.environment.gravitational import Model as GravitationalModel
|
11
|
+
from ostk.physics.environment.gravitational import Earth as EarthGravitationalModel
|
12
|
+
|
13
|
+
|
14
|
+
@pytest.fixture
|
15
|
+
def earth_gravitational_model() -> EarthGravitationalModel:
|
16
|
+
return EarthGravitationalModel(EarthGravitationalModel.Type.EGM2008)
|
17
|
+
|
18
|
+
|
19
|
+
class TestEarth:
|
20
|
+
def test_constructor_success_with_type(self):
|
21
|
+
assert isinstance(
|
22
|
+
EarthGravitationalModel(EarthGravitationalModel.Type.Spherical),
|
23
|
+
EarthGravitationalModel,
|
24
|
+
)
|
25
|
+
assert isinstance(
|
26
|
+
EarthGravitationalModel(EarthGravitationalModel.Type.WGS84),
|
27
|
+
EarthGravitationalModel,
|
28
|
+
)
|
29
|
+
assert isinstance(
|
30
|
+
EarthGravitationalModel(EarthGravitationalModel.Type.EGM96),
|
31
|
+
EarthGravitationalModel,
|
32
|
+
)
|
33
|
+
assert isinstance(
|
34
|
+
EarthGravitationalModel(EarthGravitationalModel.Type.EGM84),
|
35
|
+
EarthGravitationalModel,
|
36
|
+
)
|
37
|
+
assert isinstance(
|
38
|
+
EarthGravitationalModel(EarthGravitationalModel.Type.EGM2008),
|
39
|
+
EarthGravitationalModel,
|
40
|
+
)
|
41
|
+
|
42
|
+
def test_constructor_success_with_directory(self):
|
43
|
+
earth_gravitational_model = EarthGravitationalModel(
|
44
|
+
EarthGravitationalModel.Type.EGM2008, Directory.undefined()
|
45
|
+
)
|
46
|
+
|
47
|
+
assert isinstance(earth_gravitational_model, EarthGravitationalModel)
|
48
|
+
assert isinstance(earth_gravitational_model, GravitationalModel)
|
49
|
+
|
50
|
+
def test_constructor_success_with_degree_and_order(self):
|
51
|
+
earth_gravitational_model = EarthGravitationalModel(
|
52
|
+
EarthGravitationalModel.Type.EGM2008, Directory.undefined(), 2, 2
|
53
|
+
)
|
54
|
+
|
55
|
+
assert isinstance(earth_gravitational_model, EarthGravitationalModel)
|
56
|
+
assert isinstance(earth_gravitational_model, GravitationalModel)
|
57
|
+
|
58
|
+
def test_constructor_success_without_directory_with_degree_and_order(self):
|
59
|
+
earth_gravitational_model = EarthGravitationalModel(
|
60
|
+
EarthGravitationalModel.Type.EGM2008, 2, 2
|
61
|
+
)
|
62
|
+
|
63
|
+
assert isinstance(earth_gravitational_model, EarthGravitationalModel)
|
64
|
+
assert isinstance(earth_gravitational_model, GravitationalModel)
|
65
|
+
|
66
|
+
def test_get_type_success(self, earth_gravitational_model: EarthGravitationalModel):
|
67
|
+
assert (
|
68
|
+
earth_gravitational_model.get_type() == EarthGravitationalModel.Type.EGM2008
|
69
|
+
)
|
70
|
+
|
71
|
+
def test_get_degree_order_success(self):
|
72
|
+
egm_earth_gravitational_model = EarthGravitationalModel(
|
73
|
+
EarthGravitationalModel.Type.EGM2008, Directory.undefined(), 51, 50
|
74
|
+
)
|
75
|
+
|
76
|
+
assert egm_earth_gravitational_model.get_degree() == 51
|
77
|
+
assert egm_earth_gravitational_model.get_order() == 50
|
78
|
+
|
79
|
+
spherical_earth_gravitational_model = EarthGravitationalModel(
|
80
|
+
EarthGravitationalModel.Type.Spherical
|
81
|
+
)
|
82
|
+
|
83
|
+
assert spherical_earth_gravitational_model.get_degree().is_defined() is False
|
84
|
+
assert spherical_earth_gravitational_model.get_order().is_defined() is False
|
85
|
+
|
86
|
+
def test_get_field_value_at_success(
|
87
|
+
self, earth_gravitational_model: EarthGravitationalModel
|
88
|
+
):
|
89
|
+
grav_acceleration = earth_gravitational_model.get_field_value_at(
|
90
|
+
np.array([6400e3, 0.0, 0.0]), Instant.J2000()
|
91
|
+
)
|
92
|
+
grav_acceleration_ref = np.array(
|
93
|
+
[-9.74722832e00, -1.29220148e-05, -1.34173896e-05]
|
94
|
+
)
|
95
|
+
assert all(
|
96
|
+
[
|
97
|
+
round(grav_acceleration[i], -7) == round(grav_acceleration_ref[i], -7)
|
98
|
+
for i in range(0, len(grav_acceleration_ref))
|
99
|
+
]
|
100
|
+
)
|
101
|
+
|
102
|
+
def test_gravity_constant(self):
|
103
|
+
assert EarthGravitationalModel.gravity_constant is not None
|