---
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-20240818a
takeoff: "2024-08-18 10:00:00Z"
landing: "2024-08-18 19:10:00Z"
departure_airport: GVAC
arrival_airport: GVAC
crew:
  - name: Bernhard Mayer
    job: PI
  - name: Tanja Bodenbach
    job: WALES
  - name: Christian Heske
    job: HAMP
  - name: Therese Mieslinger
    job: Dropsondes
  - name: Anna Luebke
    job: Smart/VELOX
  - name: Veronica Portge
    job: SpecMACS
  - name: Henning Franke
    job: Scientist
  - name: Florian Ewald
    job: Ground contact
categories: [ec_under, ec_track, c_north, c_mid, c_south, c_atr, c_cloud]
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, 16, 12, 0, 0)
issued_time_str = issued_time.strftime('%Y-%m-%d')

flight_time = datetime(2024, 8, 18, 12, 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 = 130e3
atr_radius = 70e3

airport = sal
north_ec = LatLon(lat=13.1, lon=-28.5167, label='north_ec')

circle_north = LatLon(lat=13.1, lon=-28.5167, label='circle_north')

circle_cloud = LatLon(lat=10.00, lon=-29.0667, label='circle_cloud')

circle_center = LatLon(lat=8.05, lon=-29.4667, label='circle_center')

circle_south = LatLon(lat=3.0, lon=-30.41667, label='circle_south')

south_ec = LatLon(lat=3.0, lon=-30.41667, label='south_ec')

earthcare = LatLon(lat=8.05, lon=-29.4667, label='earthcare')

atr = LatLon(lat=16.4212, lon=-21.8315, label='atr')

leg_south = [
     airport,
     north_ec,
     south_ec
]

leg_circles = [
     IntoCircle(circle_south, radius, 360),
     IntoCircle(circle_center, radius, 360),
     earthcare,
     IntoCircle(circle_cloud, radius*1.5, 360),
     IntoCircle(circle_north, radius, 360),
]
    
leg_home = [
     north_ec,
     IntoCircle(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(refdate=issued_time_str, reftime=issued_time.hour).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, [north_ec, circle_north, circle_center, circle_south, south_ec, earthcare, atr, circle_cloud])).set_index("label")
```

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

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