Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: forecast and reanalysis models - update ECMWF weather model variables dictionary #736

Merged
merged 11 commits into from
Nov 23, 2024
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Attention: The newest changes should be on top -->

### Fixed

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

Expand Down
Binary file added data/weather/ndrt_2020_weather_data_ERA5_new.nc
Binary file not shown.
9 changes: 8 additions & 1 deletion rocketpy/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,8 @@ def process_forecast_reanalysis(
# Read weather file
if isinstance(file, str):
data = netCDF4.Dataset(file)
if dictionary["time"] not in data.variables.keys():
dictionary = self.__weather_model_map.get("ECMWF_v0")
else:
data = file

Expand Down Expand Up @@ -1910,7 +1912,12 @@ def process_forecast_reanalysis(
# Compute info data
self.atmospheric_model_init_date = get_initial_date_from_time_array(time_array)
self.atmospheric_model_end_date = get_final_date_from_time_array(time_array)
self.atmospheric_model_interval = get_interval_date_from_time_array(time_array)
if self.atmospheric_model_init_date != self.atmospheric_model_end_date:
self.atmospheric_model_interval = get_interval_date_from_time_array(
time_array
)
else:
self.atmospheric_model_interval = 0
self.atmospheric_model_init_lat = lat_list[0]
self.atmospheric_model_end_lat = lat_list[-1]
self.atmospheric_model_init_lon = lon_list[0]
Expand Down
15 changes: 14 additions & 1 deletion rocketpy/environment/weather_model_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WeatherModelMapping:
"u_wind": "ugrdprs",
"v_wind": "vgrdprs",
}
ECMWF = {
ECMWF_v0 = {
"time": "time",
"latitude": "latitude",
"longitude": "longitude",
Expand All @@ -39,6 +39,18 @@ class WeatherModelMapping:
"u_wind": "u",
"v_wind": "v",
}
ECMWF = {
"time": "valid_time",
"latitude": "latitude",
"longitude": "longitude",
"level": "pressure_level",
"temperature": "t",
"surface_geopotential_height": None,
"geopotential_height": None,
"geopotential": "z",
"u_wind": "u",
"v_wind": "v",
}
NOAA = {
"time": "time",
"latitude": "lat",
Expand Down Expand Up @@ -108,6 +120,7 @@ def __init__(self):
self.all_dictionaries = {
"GFS": self.GFS,
"NAM": self.NAM,
"ECMWF_v0": self.ECMWF_v0,
"ECMWF": self.ECMWF,
"NOAA": self.NOAA,
"RAP": self.RAP,
Expand Down
12 changes: 10 additions & 2 deletions tests/acceptance/test_ndrt_2020_rocket.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import numpy as np
import pandas as pd
import pytest
from scipy.signal import savgol_filter

from rocketpy import Environment, Flight, Rocket, SolidMotor


def test_ndrt_2020_rocket_data_asserts_acceptance():
@pytest.mark.parametrize(
"env_file",
[
"data/weather/ndrt_2020_weather_data_ERA5.nc",
"data/weather/ndrt_2020_weather_data_ERA5_new.nc",
],
)
def test_ndrt_2020_rocket_data_asserts_acceptance(env_file):
# Notre Dame Rocket Team 2020 Flight
# Launched at 19045-18879 Avery Rd, Three Oaks, MI 49128
# Permission to use flight data given by Brooke Mumma, 2020
Expand Down Expand Up @@ -73,7 +81,7 @@ def test_ndrt_2020_rocket_data_asserts_acceptance():
)
env.set_atmospheric_model(
type="Reanalysis",
file="data/weather/ndrt_2020_weather_data_ERA5.nc",
file=env_file,
dictionary="ECMWF",
)
env.max_expected_height = 2000
Expand Down
Loading