---
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-20240903a
takeoff: "2024-09-03 17:00:00Z"
landing: "2024-09-03 19:30: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: [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 -> ka-west (arrive @FL180 at 18:00 UTC | 17:00 LT)
      - Note: Holding pattern until 18:25 UTC

Leg 2 (Start 18:25 UTC): ka-west -> ka-east (in-cloud at cloud top, ~FL150), 180 kt
      - Note: Communication with HALO (D-ADLR) via 123.45 MHz to coordinate start of common leg

Leg 3: ka_east -> ka_west (in-cloud at cloud top)

Leg 4: ka_west -> RAI



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

flight_time = datetime(2024, 9, 3, 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')

ka_west = LatLon(lat=14.78167, lon= -24.028371, label='ka-west')
ka_east = LatLon(lat=14.809248, lon=-23.056479, label='ka-east')

leg_out = [
     airport,
     ka_west
]

leg_halo = [
      ka_west,
      ka_east,
      ka_west
]

leg_home = [
     ka_west,
     airport
]

path = leg_out + leg_halo + 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)

ax.scatter(-23.31, 14.41, c='red', marker='o', s=200, ec = 'r', alpha = 0.3)
ax.scatter(-22.34, 14.41, c='red', marker='o', s=200, ec = 'r', alpha = 0.3)
ax.scatter(-21.760275, 14.839639, c='red', marker='o', s=200, ec = 'r', alpha = 0.3)

ka_west_alt = LatLon(lat=14.41, lon= -23.31, label='ka-west-alt')
ka_east_alt = LatLon(lat=14.41, lon=-22.34, label='ka-east-alt')
atr_in = LatLon(lat=14.839639, lon=-21.760275, label='atr-in')

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, ka_west, ka_east, airport, ka_west_alt, ka_east_alt, atr_in])).set_index("label")
```

