diff --git a/CHANGELOG.md b/CHANGELOG.md index 47b37198a..8df36b8df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/data/weather/ndrt_2020_weather_data_ERA5_new.nc b/data/weather/ndrt_2020_weather_data_ERA5_new.nc new file mode 100644 index 000000000..7fea7c5e2 Binary files /dev/null and b/data/weather/ndrt_2020_weather_data_ERA5_new.nc differ diff --git a/rocketpy/environment/environment.py b/rocketpy/environment/environment.py index c7a85c002..394275763 100644 --- a/rocketpy/environment/environment.py +++ b/rocketpy/environment/environment.py @@ -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 @@ -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] diff --git a/rocketpy/environment/weather_model_mapping.py b/rocketpy/environment/weather_model_mapping.py index 7aed6d5e1..59c6e2fd9 100644 --- a/rocketpy/environment/weather_model_mapping.py +++ b/rocketpy/environment/weather_model_mapping.py @@ -27,7 +27,7 @@ class WeatherModelMapping: "u_wind": "ugrdprs", "v_wind": "vgrdprs", } - ECMWF = { + ECMWF_v0 = { "time": "time", "latitude": "latitude", "longitude": "longitude", @@ -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", @@ -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, diff --git a/tests/acceptance/test_ndrt_2020_rocket.py b/tests/acceptance/test_ndrt_2020_rocket.py index f189bdac2..7874ee164 100644 --- a/tests/acceptance/test_ndrt_2020_rocket.py +++ b/tests/acceptance/test_ndrt_2020_rocket.py @@ -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 @@ -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