contrailcirrus/pycontrails

Geodesic interpolation with missing altitude data

Closed this issue · 0 comments

Description

Flight.resample_and_fill uses geodesic interpolation when the distance between waypoints, as measured by Flight.segment_length, exceeds a threshold. However, Flight.segment_length returns NaN for segments bounded by waypoints with NaN altitudes. As a result, the presence of NaN altitudes can prevent geodesic interpolation from being used to fill gaps between waypoints separated by large horizontal distances.

Details

  • Version: 0.50.2
  • Module: core.flight
  • OS: ubuntu

Steps to Reproduce

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import numpy as np

from pycontrails.core import Flight

longitude = [-120, -70, 1]
latitude = [45, 45, 45]
time = ["2024-01-01 00:00", "2024-01-01 05:00", "2024-01-01 12:00"]

flight = Flight(
    longitude = longitude,
    latitude = latitude,
    altitude_ft = [35_000, 35_000, 35_000],
    time=time
).resample_and_fill("10min")

plt.subplot(111, projection=ccrs.PlateCarree())
plt.plot(flight["longitude"], flight["latitude"], 
    "k-", transform=ccrs.PlateCarree(), label="expected")

flight = Flight(
    longitude = longitude,
    latitude = latitude,
    altitude_ft = [35_000, np.nan, 35_000],
    time=time
).resample_and_fill("10min")

plt.plot(flight["longitude"], flight["latitude"], 
    "r-", transform=ccrs.PlateCarree(), label="missing altitude")

plt.legend()
plt.gca().set_extent([-140, 20, 0, 90])
plt.gca().coastlines()
plt.show()

image