-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: Add tests for FlightDataImporter class
- Loading branch information
1 parent
4b066d3
commit 3e4bb81
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .flight import Flight | ||
from .flight_data_importer import FlightDataImporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
"""Tests the FlightDataImporter class from rocketpy.simulation module. | ||
""" | ||
import numpy as np | ||
|
||
from rocketpy.simulation import FlightDataImporter | ||
|
||
|
||
def test_flight_importer_bella_lui(): | ||
"""Tests the class using the Bella Lui flight data.""" | ||
columns_map = {"time_aprox_(s)": "time", "z_(m)": "altitude", "v_(m/s)": "vz"} | ||
path = "tests/fixtures/acceptance/EPFL_Bella_Lui/bella_lui_flight_data_filtered.csv" | ||
|
||
fd = FlightDataImporter( | ||
name="Bella Lui, EPFL Rocket Team, 2020", | ||
filepath=path, | ||
columns_map=columns_map, | ||
units=None, | ||
interpolation="linear", | ||
extrapolation="zero", | ||
separator=",", | ||
encoding="utf-8", | ||
) | ||
|
||
assert fd.name == "Bella Lui, EPFL Rocket Team, 2020" | ||
assert "time" in fd.columns, "Can't find 'time' column in fd.columns" | ||
assert "altitude" in fd.columns, "Can't find 'altitude' column in fd.columns" | ||
assert "vz" in fd.columns, "Can't find 'vz' column in fd.columns" | ||
assert np.isclose(fd.altitude(0), 0.201, atol=1e-4) | ||
assert np.isclose(fd.vz(0), 5.028, atol=1e-4) | ||
|
||
|
||
def test_flight_importer_ndrt(): | ||
"""Tests the class using the NDRT 2020 flight data.""" | ||
columns_map = { | ||
"Time_(s)": "time", | ||
"Altitude_(Ft-AGL)": "altitude", | ||
} | ||
units = {"Altitude_(Ft-AGL)": "ft"} | ||
path = "tests/fixtures/acceptance/NDRT_2020/ndrt_2020_flight_data.csv" | ||
|
||
fd = FlightDataImporter( | ||
name="NDRT Rocket team, 2020", | ||
filepath=path, | ||
columns_map=columns_map, | ||
units=units, | ||
) | ||
assert fd.name == "name" | ||
assert "time" in fd.columns, "Can't find 'time' column in fd.columns" | ||
assert "altitude" in fd.columns, "Can't find 'altitude' column in fd.columns" | ||
assert np.isclose(fd.altitude(0), 0) |