From 26cfecb7283104dac4a12684e7acace27a36d526 Mon Sep 17 00:00:00 2001 From: Theresa Mieslinger Date: Wed, 4 Dec 2024 16:15:51 +0100 Subject: [PATCH] add func to load flight segmentation info --- orcestra/__init__.py | 12 ++++++++++-- orcestra/utils.py | 11 +++++++++++ pyproject.toml | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/orcestra/__init__.py b/orcestra/__init__.py index 91317f7..caa9a34 100644 --- a/orcestra/__init__.py +++ b/orcestra/__init__.py @@ -1,5 +1,5 @@ from .flightplan import LatLon, bco, sal -from .utils import parse_datestr +from .utils import parse_datestr, get_flight_segments from .io import read_igi, read_bahamas_100hz import warnings @@ -14,4 +14,12 @@ module="intake_xarray", ) -__all__ = ["LatLon", "bco", "sal", "parse_datestr", "read_igi", "read_bahamas_100hz"] +__all__ = [ + "LatLon", + "bco", + "sal", + "parse_datestr", + "get_flight_segments", + "read_igi", + "read_bahamas_100hz", +] diff --git a/orcestra/utils.py b/orcestra/utils.py index f0fd1f1..f73d91e 100644 --- a/orcestra/utils.py +++ b/orcestra/utils.py @@ -9,6 +9,7 @@ import xarray as xr import matplotlib.pyplot as plt import yaml +import fsspec def parse_datestr(datestr): @@ -100,3 +101,13 @@ def export_planet(fname, fig=None, dpi=144, stem_ext="_planet", **kwargs): }, **kwargs, ) + + +@lru_cache +def get_flight_segments(): + flight_segment_file = ( + "https://orcestra-campaign.github.io/flight_segmentation/all_flights.yaml" + ) + with fsspec.open(flight_segment_file) as f: + meta = yaml.safe_load(f) + return meta diff --git a/pyproject.toml b/pyproject.toml index ae3f9b0..a352e2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ cartopy = "*" cmocean = "*" easygems = ">=0.0.8" flox = "*" # part of xarray[accel] +fsspec = "*" geopandas = "*" gpxpy = "*" healpix = "*"