---
jupytext:
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.12
    jupytext_version: 1.7.1
kernelspec:
  display_name: Python 3
  language: python
  name: python3
platform: HALO
flight_id: HALO-20240816a
takeoff: "2024-08-16 10:30:00Z"
landing: "2024-08-16 20:00:00Z"
departure_airport: GVAC
arrival_airport: GVAC
crew:
  - name: Bjorn Stevens
    job: PI
  - name: Georgios Dekoutsidis
    job: WALES
  - name: Jakob Deutloff
    job: HAMP
  - name: Helene Glöckner
    job: Dropsondes
  - name: Anna Luebke
    job: Smart/VELOX
  - name: Lea Volkmer
    job: SpecMACS
  - name: Martin Singh
    job: Scientist
  - name: Cathy Hohenegger
    job: Ground contact
categories: [ec_under, ec_track, c_north, c_mid, c_south, ec_south, c_atr]
orphan: true
---

{logo}`PERCUSION`

# Flight plan - {front}`flight_id`

```{badges}
```

## Crew

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

```{crew}
```

## Flight plan

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

from orcestra.flightplan import sal, bco, LatLon, IntoCircle, path_preview, plot_cwv
from datetime import datetime
import intake
import easygems.healpix as egh

cat = intake.open_catalog("https://tcodata.mpimet.mpg.de/internal.yaml")

# Define dates for forecast initialization and flight

issued_time = datetime(2024, 8, 15, 0, 0, 0)
issued_time_str = issued_time.strftime('%Y-%m-%d')

flight_time = datetime(2024, 8, 16, 16, 0, 0)
flight_time_str = flight_time.strftime('%Y-%m-%d')
flight_index = f"HALO-{flight_time.strftime('%Y%m%d')}a"

print("Initalization date of IFS forecast: " + issued_time_str + "\nFlight date: " + flight_time_str + "\nFlight index: " + flight_index)

radius = 1.852 * 72e3 # factor of 1.852 is km/nm (definition)
atr_radius = 1.852 * 38e3 

airport = sal
c_atr = LatLon(lat=17.43333, lon=-23.500000, label='c_atr')
c_north = LatLon(lat=11.0045, lon=-31.4247, label='c_north')
c_mid = LatLon(lat=7.119, lon=-32.1586, label='c_mid')
c_south = LatLon(lat=3.2327, lon=-32.8863, label='c_south')
ec_north = LatLon(lat=12.2994, lon=-31.1748, label='ec_north')
ec_south = LatLon(lat=1.5, lon=-33.2358, label='ec_south')
ec_under = LatLon(lat=8.4143, lon=-31.9163, label='ec_under')

leg_south = [
     airport,
     ec_north,
     ec_south
]

leg_circles = [
     IntoCircle(c_south, radius, 360),
     IntoCircle(c_mid, radius, 360),
     ec_under,
     IntoCircle(c_north, radius, 360, enter=90),
]
    
leg_home = [
     ec_north,
     IntoCircle(c_atr, atr_radius, -360, enter = 180),
     airport
]

path = leg_south + leg_circles + leg_home 

cat = intake.open_catalog("https://tcodata.mpimet.mpg.de/internal.yaml")
ds = cat.HIFS(datetime=issued_time).to_dask().pipe(egh.attach_coords)
cwv_flight_time = ds["tcwv"].sel(time=flight_time, method = "nearest")

ax = path_preview(path)
plot_cwv(cwv_flight_time)



```

```{code-cell} python3
:tags: [hide-input]
import pandas as pd
from dataclasses import asdict

pd.DataFrame.from_records(map(asdict, [ec_north, c_north, c_mid, c_south, ec_south, ec_under, c_atr])).set_index("label")
```

```{code-cell} python3
:tags: [hide-input]
from orcestra.flightplan import export_flightplan

export_flightplan("HALO-20240816a", path)
```
