Weather
The AEIC.weather module loads ERA5-style NetCDF files and provides
wind-aware ground speeds along a mission’s ground track.
The dataset is read from disk (no pre-processing required) and must contain:
variables: temperature
t[K], eastward windu[m/s], northward windv[m/s];coordinates:
pressure_level[hPa],latitude,longitude;valid_timecoordinate: required when the configureddata_resolutionis finer than the configuredfile_resolution(i.e., a single file holds multiple time steps). In that casevalid_timeis sliced viaxarray.Dataset.sel(method='nearest', tolerance=1h)for the requested timestamp. Ifdata_resolutionequalsfile_resolution,valid_timeis absent or length-1 and no slicing is performed.
During a ground-speed query, altitude is converted to a pressure level using a
standard-atmosphere approximation, winds are interpolated at the requested
longitude/latitude, and those winds are combined with the aircraft heading
derived from the ground track (or an override supplied via azimuth).
Example:
import pandas as pd
from AEIC.config import Config
from AEIC.config.weather import TemporalResolution
from AEIC.trajectories.ground_track import GroundTrack
from AEIC.types.spatial import Location
from AEIC.weather import Weather
Config.load()
# Construct a Weather instance pointing at a directory of daily ERA5
# NetCDF files (one file per UTC day, named YYYY-MM-DD.nc by default).
weather = Weather('data/weather', file_resolution=TemporalResolution.DAILY)
# Build a great-circle track between two locations.
track = GroundTrack.great_circle(
Location(longitude=-71.0, latitude=42.4), # origin
Location(longitude=-0.5, latitude=51.5), # destination
)
ground_speed = weather.get_ground_speed(
time=pd.Timestamp('2024-09-01 12:00:00', tz='UTC'),
gt_point=track.location(5000.0), # 5 km along the track
altitude=10000.0, # meters above sea level
true_airspeed=230.0, # m/s
)
Class members
- class AEIC.weather.Weather(data_dir, file_resolution, data_resolution=None, file_format=None)
A class to query weather data variables and ground speed along ground track points.
- Parameters:
data_dir (str | Path) – Path to directory containing ERA5 weather data NetCDF files. The filename for a given timestamp is resolved via
file_format. Files should contain variablest,u,vwith coordinatespressure_level,latitude,longitude. Avalid_timecoord is required whendata_resolutionis finer thanfile_resolutionand is otherwise either absent or length-1.file_resolution (TemporalResolution) – Temporal layout of files on disk: one file per
file_resolutionperiod. Must beannual,monthly, ordaily.data_resolution (TemporalResolution, optional) – Temporal resolution of the data within each file. Defaults to
file_resolution(one period-mean per file). Must satisfydata_resolution <= file_resolution.file_format (str, optional) –
strftime-style pattern (relative todata_dir) for mapping a timestamp to a filename. Defaults are derived fromfile_resolution:%Y.nc(annual),%Y-%m.nc(monthly),%Y-%m-%d.nc(daily).
- get_ground_speed(time, gt_point, altitude, true_airspeed, azimuth=None)
Compute ground speed at a point along the mission.
- Parameters:
time (pd.Timestamp) – Time at the ground track point. Interpreted as UTC; tz-aware timestamps are converted to UTC, tz-naive timestamps are assumed UTC.
gt_point (GroundTrack.Point) – Spatial point along the ground track from the origin.
altitude (float) – Altitude above sea level [meters].
true_airspeed (float) – True airspeed [m/s].
azimuth (float, optional) – Azimuth [degrees]. If omitted, use the precomputed ground-track azimuth.
- Returns:
ground_speed – Ground speed [m/s]
- Return type:
float