Skip to content

Commit

Permalink
fixed use of position-attitude data
Browse files Browse the repository at this point in the history
with the new position_attitude data in a single dataset I load the
data directly, only taking lat and lon dimensions as others are
not needed, and use it throughout.  Some minor typos were also
corrected
  • Loading branch information
bjorn-stevens committed Feb 27, 2025
1 parent 76acac9 commit 91fe8b1
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions orcestra_book/halo_flight_segmentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ meta = get_flight_segments()
flight_ids = [flight_id
for flights in meta.values()
for flight_id in flights]
print(f"Totel number of flights: {len(flight_ids)}")
print(f"Total number of flights: {len(flight_ids)}")
flight_ids
```

## Segments

Sometimes it may be useful to have a flat list of segments, irrespective of which flight or platformt they belong to. So we build it here:
Sometimes it may be useful to have a flat list of segments, irrespective of which flight or platform they belong to. So we build it here:

```{code-cell} ipython3
segments = [{**s,
Expand Down Expand Up @@ -69,11 +69,6 @@ import xarray as xr
import matplotlib.pyplot as plt
from orcestra.flightplan import sal, tbpb
def get_halo_position_attitude(flight_id):
root = "ipns://latest.orcestra-campaign.org/products/HALO/position_attitude"
return (xr.open_dataset(f"{root}.zarr", engine="zarr")
.reset_coords().resample(time="1s").mean().load())
def kinds2color(kinds):
if "circle" and "atr_coordination" in kinds:
return "C2"
Expand All @@ -85,11 +80,13 @@ def kinds2color(kinds):
```

```{code-cell} ipython3
flight = "HALO-20240811a"
ds = get_halo_position_attitude(flight)
ds = xr.open_dataset(
"ipns://latest.orcestra-campaign.org/products/HALO/position_attitude.zarr"
, engine="zarr")['lat']['lon'].reset_coords().resample(time="1s").mean().load()
flight_id = "HALO-20240811a"
fig, ax = plt.subplots()
for s in meta["HALO"][flight]["segments"]:
for s in meta["HALO"][flight_id]["segments"]:
t = slice(s["start"], s["end"])
ax.plot(ds.lon.sel(time=t), ds.lat.sel(time=t), c=kinds2color(s["kinds"]))#, label=s["name"])
Expand All @@ -103,7 +100,7 @@ ax.set_xlabel("longitude / °")
ax.set_ylabel("latitude / °")
ax.spines[['right', 'top']].set_visible(False)
ax.legend()
plt.title(flight);
plt.title(flight_id);
```

### Plotting all segments of a specific kind
Expand All @@ -113,7 +110,6 @@ fig, ax = plt.subplots()
kind = "circle"
for f in flight_ids:
ds = get_halo_position_attitude(f)
for s in segments:
if kind in s["kinds"] and f==s["flight_id"]:
t = slice(s["start"], s["end"])
Expand Down

0 comments on commit 91fe8b1

Please sign in to comment.