---
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: King Air
flight_id: KA-20240907a
takeoff: "2024-09-07 14:30:00Z"
landing: "2024-09-07 16:15:00Z"
departure_airport: GVNP
arrival_airport: GVNP
crew:
  - name: Tim Carlsen
    job: PI
  - name: Sorin Ghemulet
    job: Instrument operator
  - name: Alex Vlad
    job: Instrument operator
categories: [ec_under, ec_track, in_cloud, insitu_aerosol]
orphan: true
---

{logo}`CELLO`

# Flight plan - {front}`flight_id`

```{badges}
```

## Crew

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

```{crew}
```

## Flight plan

Leg 1: RAI -> WP1 (arrive @FL060 at 15:05 UTC | 14:05 LT)

Leg 2: Holding pattern at WP1 until 15:25 UTC (assessing cloud situation)

Leg 3 (Start 15:25 UTC): WP1 -> WP3 (via WP2) - around FL020-FL060 - 140 kt (~40min) - in-cloud if possible
      Note: Be at WP2 at 15:45 UTC | 14:45 LT for satellite overpass

Leg 6: WP3 -> RAI (~25min).


```{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, 9, 5, 0, 0, 0)
issued_time_str = issued_time.strftime('%Y-%m-%d')

flight_time = datetime(2024, 9, 7, 12, 0, 0)
flight_time_str = flight_time.strftime('%Y-%m-%d')
flight_index = f"KA-{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)

airport = LatLon(lat=14.945, lon=-23.4863889, label='RAI')

wp1 = LatLon(lat=15.750969, lon= -23.810386, label='wp1')
wp2 = LatLon(lat=14.973537, lon=-23.962397, label='wp2 (ec-meet)')
wp3 = LatLon(lat=14.131217, lon=-24.126245, label='wp3')

leg_out = [
     airport,
     wp1
]

leg_calval = [
      wp1,
      wp2,
      wp3
]

leg_home = [
     wp3,
     airport
]

path = leg_out + leg_calval + 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, [airport, wp1, wp2, wp3, airport])).set_index("label")
```

