Skip to content

Commit 1f3eefc

Browse files
BUG: forecast and reanalysis models - update ECMWF weather model variables dictionary (RocketPy-Team#736)
* forecast_reanalysis - move wind_speed to correct position * forecast_reanalysis - move wind_speed to correct position * DEV: adds RocketPy-Team#735 to CHANGELOG * update ECMWF dictionary values * allow depreciated .nc files * allow .nc files with only one time variable * TST? parameterize acceptance test for NDRT 2020 rocket data with multiple environment files * STY: apply black --------- Co-authored-by: Gui-FernandesBR <[email protected]> Co-authored-by: Gui-FernandesBR <[email protected]>
1 parent ddf71f9 commit 1f3eefc

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Attention: The newest changes should be on top -->
4343

4444
### Fixed
4545

46+
- BUG: forecast and reanalysis models - Update ECMWF dictionary values [#736](https://github.com/RocketPy-Team/RocketPy/pull/736)
4647
- BUG: forecast and reanalysis models - move wind_speed to correct position [#735](https://github.com/RocketPy-Team/RocketPy/pull/735)
4748
- BUG: Sideslip Angle and Damping Coefficient Calculation [#729](https://github.com/RocketPy-Team/RocketPy/pull/729)
4849

2.35 MB
Binary file not shown.

rocketpy/environment/environment.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,8 @@ def process_forecast_reanalysis(
17461746
# Read weather file
17471747
if isinstance(file, str):
17481748
data = netCDF4.Dataset(file)
1749+
if dictionary["time"] not in data.variables.keys():
1750+
dictionary = self.__weather_model_map.get("ECMWF_v0")
17491751
else:
17501752
data = file
17511753

@@ -1910,7 +1912,12 @@ def process_forecast_reanalysis(
19101912
# Compute info data
19111913
self.atmospheric_model_init_date = get_initial_date_from_time_array(time_array)
19121914
self.atmospheric_model_end_date = get_final_date_from_time_array(time_array)
1913-
self.atmospheric_model_interval = get_interval_date_from_time_array(time_array)
1915+
if self.atmospheric_model_init_date != self.atmospheric_model_end_date:
1916+
self.atmospheric_model_interval = get_interval_date_from_time_array(
1917+
time_array
1918+
)
1919+
else:
1920+
self.atmospheric_model_interval = 0
19141921
self.atmospheric_model_init_lat = lat_list[0]
19151922
self.atmospheric_model_end_lat = lat_list[-1]
19161923
self.atmospheric_model_init_lon = lon_list[0]

rocketpy/environment/weather_model_mapping.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class WeatherModelMapping:
2727
"u_wind": "ugrdprs",
2828
"v_wind": "vgrdprs",
2929
}
30-
ECMWF = {
30+
ECMWF_v0 = {
3131
"time": "time",
3232
"latitude": "latitude",
3333
"longitude": "longitude",
@@ -39,6 +39,18 @@ class WeatherModelMapping:
3939
"u_wind": "u",
4040
"v_wind": "v",
4141
}
42+
ECMWF = {
43+
"time": "valid_time",
44+
"latitude": "latitude",
45+
"longitude": "longitude",
46+
"level": "pressure_level",
47+
"temperature": "t",
48+
"surface_geopotential_height": None,
49+
"geopotential_height": None,
50+
"geopotential": "z",
51+
"u_wind": "u",
52+
"v_wind": "v",
53+
}
4254
NOAA = {
4355
"time": "time",
4456
"latitude": "lat",
@@ -108,6 +120,7 @@ def __init__(self):
108120
self.all_dictionaries = {
109121
"GFS": self.GFS,
110122
"NAM": self.NAM,
123+
"ECMWF_v0": self.ECMWF_v0,
111124
"ECMWF": self.ECMWF,
112125
"NOAA": self.NOAA,
113126
"RAP": self.RAP,

tests/acceptance/test_ndrt_2020_rocket.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import numpy as np
22
import pandas as pd
3+
import pytest
34
from scipy.signal import savgol_filter
45

56
from rocketpy import Environment, Flight, Rocket, SolidMotor
67

78

8-
def test_ndrt_2020_rocket_data_asserts_acceptance():
9+
@pytest.mark.parametrize(
10+
"env_file",
11+
[
12+
"data/weather/ndrt_2020_weather_data_ERA5.nc",
13+
"data/weather/ndrt_2020_weather_data_ERA5_new.nc",
14+
],
15+
)
16+
def test_ndrt_2020_rocket_data_asserts_acceptance(env_file):
917
# Notre Dame Rocket Team 2020 Flight
1018
# Launched at 19045-18879 Avery Rd, Three Oaks, MI 49128
1119
# Permission to use flight data given by Brooke Mumma, 2020
@@ -73,7 +81,7 @@ def test_ndrt_2020_rocket_data_asserts_acceptance():
7381
)
7482
env.set_atmospheric_model(
7583
type="Reanalysis",
76-
file="data/weather/ndrt_2020_weather_data_ERA5.nc",
84+
file=env_file,
7785
dictionary="ECMWF",
7886
)
7987
env.max_expected_height = 2000

0 commit comments

Comments
 (0)