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 dag edge sample points.

Attributes

ds

xr.Dataset with dims (sample, altitude_ft, time) containing weather variables interpolated onto edge sample coordinates.

edge_ptr

CSR-style pointer array (n_edges + 1,).

edge_idx

Edge index for each sample point (n_samples,).

sample_lon

Longitude of each sample point (n_samples,).

sample_lat

Latitude of each sample point (n_samples,).

cum_dist

Cumulative distance from edge source to each sample point in meters (n_samples,).

delta_dist

Distance in meters from this sample to the next (n_samples,).

sample_azimuth

Azimuth in radians from each sample to the next (n_samples,).

ds: Dataset

xr.Dataset with 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 edge i are at indices edge_ptr[i]:edge_ptr[i+1].

edge_idx: NDArray[int64]

Edge index for each sample point (n_samples,).

sample_lon: NDArray[floating]

Longitude of each sample point (n_samples,).

sample_lat: NDArray[floating]

Latitude of 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 has delta_dist = 0. Equal to diff(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 dag edge sample points.

Parameters:
  • met (MetDataset or xarray.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; use contrailopt.fill_nan_spatial() to patch them beforehand. Either a pycontrails MetDataset or a raw xr.Dataset with 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 to dag.sample_edges.

  • eef (xarray.DataArray or MetDataArray or None, default None) – 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” in met if both are present. Assumed to adhere to pycontrails MetDataArray conventions.

Returns:

EdgeMetLookup with weather interpolated onto (sample, altitude_ft, time) dims.

Return type:

EdgeMetLookup