---
arrival_airport: GVAC
categories: [ec_under, ec_track, c_north, c_mid, c_south, c_atr]
crew:
- job: PI
  name: Bjorn Stevens
- job: WALES
  name: Tanya Bodenbach
- job: HAMP
  name: Clara Bayley
- job: Dropsondes
  name: Nina Robbins
- job: Smart/VELOX
  name: Sophie Rosenburg
- job: SpecMACS
  name: Zekican Demiralay
- job: Flight Documentation
  name: Marius Rixen
- job: Ground contact
  name: Karsten Peters
departure_airport: GVAC
flight_id: HALO-20240903a
jupytext:
  text_representation:
    extension: .md
    format_name: myst
kernelspec:
  display_name: Python 3 (ipykernel)
  language: python
  name: python3
landing: '2024-09-03 19:44:03Z'
orphan: true
platform: HALO
takeoff: '2024-09-03 11:04:13Z'
---

{logo}`PERCUSION`

# Flight plan - {front}`flight_id`

```{badges}
```

## Crew

The flight is planned to take off at {front}`takeoff`.

```{crew}
```

## Flight plan

```{code-cell} ipython3
:tags: [hide-input]

from datetime import datetime
import orcestra.sat
from orcestra.flightplan import bco, sal, point_on_track, LatLon, IntoCircle, FlightPlan

# Some fixed coordinates

lon_min, lon_max, lat_min, lat_max = -65, -5, -5, 25

band    = "east"
airport = sal if band == "east" else bco

radius = 72e3*1.852

atr_radius = 38e3*1.852
c_atr_nw = LatLon(17.433,-23.500, label = "c_atr")
c_atr_se = LatLon(16.080,-21.715, label = "c_atr")

# Define dates for flight

flight_time   = datetime(2024, 9, 3, 12, 0, 0)
flight_index = f"HALO-{flight_time.strftime('%Y%m%d')}a"

# Load satellite tracks 

ec_fcst_time  = "2024-09-02"
ec_track = orcestra.sat.SattrackLoader("EARTHCARE", ec_fcst_time, kind="PRE") \
    .get_track_for_day(f"{flight_time:%Y-%m-%d}")\
    .sel(time=slice(f"{flight_time:%Y-%m-%d} 14:00", None))

# Create elements of track

ec_north = point_on_track(ec_track,lat= 14.75).assign(label = "ec_north") 
ec_south = point_on_track(ec_track,lat=  2.00).assign(label = "ec_south")
c_north  = point_on_track(ec_track,lat= 13.00).assign(label = "c_north")
c_south  = point_on_track(ec_track,lat=  4.00).assign(label = "c_south")
c_mid    = point_on_track(ec_track,lat=c_south.towards(c_north).lat).assign(label = "c_mid")
c_atr    = LatLon(ec_north.lat+atr_radius/1852./60.,-22.1, label = "c_atr")
j_beg    = LatLon(lat=ec_north.lat,lon=-25.).assign(label = "junction")
ec_under = point_on_track(ec_track, lat=c_mid.towards(c_north,fraction=2./5.).lat, with_time=True).assign(label = "ec_under", note = "meet EarthCARE, drop sonde")

# Additional Waypoints

x_cnn = point_on_track(ec_track,lat= 13.67).assign(label="x_cnn", note="Northern alternative center for c_north")
x_cns = point_on_track(ec_track,lat= 11.50).assign(label="x_cns", note="Southern alternative center for c_north")
x_cms = point_on_track(ec_track,lat=  7.75).assign(label="x_cms", note="Southern alternative center for c_mid")
x_xsd = c_south.towards(c_mid).assign(label="x_sonde", note="Position for an extra sonde heading south")
j_atr = c_atr.towards(sal,distance=-atr_radius).assign(label="j_atr", note = "ATR circle start and end")
extra_waypoints = [LatLon(17.5,-24.00).assign(label="x_atr", note="alternative ATR circle")]

# Define Flight Paths

waypoints = [
     airport.assign(fl=0),
     j_beg.assign(fl=390),
     ec_north.assign(fl=410),
     c_mid.assign(fl=410),
     x_xsd.assign(fl=410),
     IntoCircle(c_south.assign(fl=410), radius, -360),
     x_cms.assign(fl=450).assign(note='might be to soon to rise to FL450, if so rise to FL430 and higher later'),
     IntoCircle(c_mid.assign(fl=450), radius, -360),
     ec_under.assign(fl=450),
     x_cns.assign(fl=450),
     IntoCircle(c_north.assign(fl=450), radius, -360,enter=90),
     x_cnn.assign(fl=450),
     ec_north.assign(fl=450),
     j_beg.assign(fl=450),
     j_atr.assign(fl=350),
     IntoCircle(c_atr.assign(fl=350), atr_radius,-360),
     airport.assign(fl=0),
     ]

# Crew

crew = {'Mission PI': 'Bjorn Stevens',
        'DropSondes': 'Nina Robbins',
        'HAMP': 'Clara Bayley',
        'SMART/VELOX': 'Sophie Rosenburg',
        'SpecMACS': 'Zekican Demiralay',
        'WALES' : 'Tanja Bodenbach',
        'Flight Documentation': 'Marius Rixen',
        'Ground Support': 'Karsten Peters',
        }

# Plan

plan = FlightPlan(waypoints, flight_index, extra_waypoints=extra_waypoints, crew=crew)
print(f"Flight index: {plan.flight_id}")
print(f"Take-off: {plan.takeoff_time:%H:%M %Z}\nLanding:  {plan.landing_time:%H:%M %Z}\n")
```

```{code-cell} ipython3
:tags: [hide-input]

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import easygems.healpix as egh
import intake
from orcestra.flightplan import plot_cwv, plot_path

plt.figure(figsize = (14, 8))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.set_extent([lon_min, lon_max, lat_min, lat_max], crs=ccrs.PlateCarree())
ax.coastlines(alpha=1.0)
ax.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False, alpha = 0.25)

ifs_fcst_time = datetime(2024, 9, 1, 0, 0, 0)
ds = intake.open_catalog("https://tcodata.mpimet.mpg.de/internal.yaml").HIFS(datetime = ifs_fcst_time).to_dask().pipe(egh.attach_coords)
cwv_flight_time = ds["tcwv"].sel(time=flight_time, method = "nearest")
plot_cwv(cwv_flight_time, levels = [50.0, 60.0], ax=ax)
plt.title(f"{flight_time}\n(CWV forecast issued on {ifs_fcst_time})")

plt.plot(ec_track.lon, ec_track.lat, c='k', ls='dotted')
plot_path(plan, ax, color="C1")
```

```{code-cell} ipython3
:tags: [hide-input]

from orcestra.flightplan import vertical_preview

vertical_preview(waypoints)
```

```{code-cell} ipython3
:tags: [hide-input]

plan.show_details()
plan.export()
```
