contrailopt.EdgeMetLookup¶
- class contrailopt.EdgeMetLookup(*, ds: Dataset, edge_ptr: NDArray[int64], edge_idx: NDArray[int64], sample_lon: NDArray[floating], sample_lat: NDArray[floating], cum_dist: NDArray[floating], delta_dist: NDArray[floating], sample_azimuth: NDArray[floating])[source]¶
Pre-interpolated met data on edge sample points.
- __init__(*, ds: Dataset, edge_ptr: NDArray[int64], edge_idx: NDArray[int64], sample_lon: NDArray[floating], sample_lat: NDArray[floating], cum_dist: NDArray[floating], delta_dist: NDArray[floating], sample_azimuth: NDArray[floating]) None¶
Methods
__init__(*, ds, edge_ptr, edge_idx, ...)from_met(met, dag, altitude_ft, ...[, eef])Interpolate met data onto
dagedge sample points.Attributes
xr.Datasetwith dims(sample, altitude_ft, time)containing weather variables interpolated onto edge sample coordinates.CSR-style pointer array
(n_edges + 1,).Edge index for each sample point
(n_samples,).Longitude of each sample point
(n_samples,).Latitude of each sample point
(n_samples,).Cumulative distance from edge source to each sample point in meters
(n_samples,).Distance in meters from this sample to the next
(n_samples,).Azimuth in radians from each sample to the next
(n_samples,).- ds: Dataset¶
xr.Datasetwith dims(sample, altitude_ft, time)containing weather variables interpolated onto edge sample coordinates.
- edge_ptr: NDArray[int64]¶
CSR-style pointer array
(n_edges + 1,). Samples for edgeiare at indicesedge_ptr[i]:edge_ptr[i+1].
- edge_idx: NDArray[int64]¶
Edge index for each sample point
(n_samples,).
- cum_dist: NDArray[floating]¶
Cumulative distance from edge source to each sample point in meters
(n_samples,).
- delta_dist: NDArray[floating]¶
Distance in meters from this sample to the next
(n_samples,). The last sample of each edge hasdelta_dist = 0. Equal todiff(cum_dist)within each edge.
- sample_azimuth: NDArray[floating]¶
Azimuth in radians from each sample to the next
(n_samples,). The last sample of each edge copies the previous sample’s azimuth.
- classmethod from_met(met: MetDataset | Dataset, dag: HorizontalDAG, altitude_ft: NDArray[floating], takeoff_time: Timestamp, flight_hours: int, spacing_m: float, eef: DataArray | MetDataArray | None = None) Self[source]¶
Interpolate met data onto
dagedge sample points.- Parameters:
met (
MetDatasetorxarray.Dataset) – Gridded met dataset with “air_temperature”, “eastward_wind”, and “northward_wind”. If “eef_per_m” is present, it will also be included in the output with NaN values filled to 0.0 (no EEF forecast is treated as zero forcing). NaN values in weather variables are not allowed and will raise an error; usecontrailopt.fill_nan_spatial()to patch them beforehand. Either a pycontrailsMetDatasetor a rawxr.Datasetwith similar structure can be passed.dag (
HorizontalDAG) – Horizontal DAG whose edges will be sampled.altitude_ft (
numpy.ndarray) – An array of altitudes in feet to interpolate onto.takeoff_time (
pandas.Timestamp) – Departure time for the flight, used to select met time steps.flight_hours (
int) – Number of hourly time steps to retain starting from takeoff_time.spacing_m (
float) – Spacing in meters between sample points along edges. Passed todag.sample_edges.eef (
xarray.DataArrayorMetDataArrayorNone, defaultNone) – Optional “eef_per_m” DataArray on its own lon/lat grid. If provided, EEF is interpolated onto sample points independently from the weather grid, avoiding the need to pre-merge onto a common grid. Takes precedence over “eef_per_m” inmetif both are present. Assumed to adhere to pycontrailsMetDataArrayconventions.
- Returns:
EdgeMetLookup with weather interpolated onto
(sample, altitude_ft, time)dims.- Return type: