Using weather database#

AirTrafficSim can use ECMWF ERA5 as a weather data source. The WeatherDemo class in airtrafficsim_data/environment/WeatherDemo.py demonstrates how to set up ERA5 weather mode in AirTrafficSim.

airtrafficsim_data/environment/WeatherDemo.py#
11# Initialize environment super class
12super().__init__(file_name = Path(__file__).name.removesuffix('.py'), #File name (do not change)
13                start_time = datetime.fromisoformat('2018-05-01T00:00:00+00:00'),
14                end_time = 1000,
15                weather_mode = "ERA5",
16                performance_mode = "BADA" 
17                )

To use the historical weather database, set weather_mode to “ERA5”. This will download the weather data in netCDF format to airtrafficsim_data/weather/erea5/<environment name>/. By default, it is an empty string "" which will use the International Standard Atmosphere (ISA) for computation and assume 0 winds.

Attention

Please ensure that the API key for the weather database from ECMWF Climate Data Store has been set up following this guide.

Usage of ERA5 weather data#

The downloaded ERA5 data will be loaded and for each timestep, AirTrafficSim will find the related temperature and wind data at the location and altitude of each aircraft. Then, the temperature difference with ISA will be computed for further atmosphere condition calculation in the performance model.

weather.py#
65if self.mode == "ERA5":
66    ds = self.weather_data.sel(longitude=xr.DataArray(long, dims="points"), latitude=xr.DataArray(lat, dims="points"), time=np.datetime64((self.start_time+timedelta(seconds=global_time)).replace(second=0, minute=0),'ns'), method="ffill") # 
67    index = np.array([np.searchsorted(-x, -Unit.ft2m(alt) * 9.80665, side='right') for x, alt in zip(ds['z'].values.T, alt)]) - 1
68    temp = np.array([x[i] for x, i in zip(ds['t'].values.T, index)])
69    self.d_T = temp - perf.cal_temperature(Unit.ft2m(alt), 0.0)
70    self.wind_east = Unit.mps2kts(np.array([x[i] for x, i in zip(ds['u'].values.T, index)]))
71    self.wind_north = Unit.mps2kts(np.array([x[i] for x, i in zip(ds['v'].values.T, index)]))