---
arrival_airport: TBPB
categories: [ec_under, c_mid, c_south]
crew:
- job: PI
  name: Theresa Mieslinger
- job: WALES
  name: "Konstantin Kr\xFCger"
- job: HAMP
  name: "Janina B\xF6hmeke"
- job: Dropsondes
  name: "Helene Gl\xF6ckner"
- job: Smart/VELOX
  name: Patrizia Schoch
- job: SpecMACS
  name: Anja Stallmach
- job: Flight Documentation
  name: Romain Fievet
- job: Ground contact
  name: Sebastian Ortega and Alessandro Savazzi
departure_airport: TBPB
flight_id: HALO-20240923a
jupytext:
  text_representation:
    extension: .md
    format_name: myst
kernelspec:
  display_name: Python 3 (ipykernel)
  language: python
  name: python3
landing: '2024-09-23T20:16:00Z'
orphan: true
platform: HALO
takeoff: '2024-09-23T11:04:00Z'
---

{logo}`PERCUSION`

# Flight plan - {front}`flight_id`

```{badges}
```

## Crew

```{crew}
```

## Flight plan

```{code-cell} ipython3
crew = {'Mission PI': 'Theresa Mieslinger',
        'DropSondes': 'Helene Glöckner',
        'HAMP': 'Janina Böhmeke',
        'SMART/VELOX': 'Patrizia Schoch',
        'SpecMACS': 'Anja Stallmach',
        'WALES' : 'Konstantin Krüger',
        'Flight Documentation': 'Romain Fievet',
        'Ground Support': 'Sebastian Ortega and Alessandro Savazzi'
        }
```

```{code-cell} ipython3
from datetime import datetime
import orcestra.sat
from orcestra.flightplan import tbpb, point_on_track, LatLon, IntoCircle, FlightPlan, aircraft_performance, vertical_preview
import topojson
import json

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, plot_fir
import numpy as np
```

### General definitions

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

bco = LatLon(13.16263889, -59.42875000, "BCO", fl=0)

radius = 72e3*1.852
radius_meteor = 72e3
```

### Load IFS forecast

```{code-cell} ipython3
ifs_fcst_time = datetime(2024, 9, 22, 12, 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")
```

### Load EC track

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

## Meteor coordination after take-off

```{code-cell} ipython3
c_climb = bco.assign(lon=bco.lon+0.61, label="c_climb", fl=150, note="circle to climb up to FL360 and start up all the instruments")
c_meteor = c_climb.course(90, 7e3).assign(label="c_meteor", fl=410)
wp_meteor = LatLon(bco.lat, c_meteor.lon - 0.665)

lon_min, lon_max, lat_min, lat_max = -60, -57.5, 12.4, 14

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)

plan = FlightPlan([
    tbpb.assign(time="2024-09-23T11:04:16Z"),
    wp_meteor.assign(fl=150, label="wp_meteor"),
    IntoCircle(c_climb, radius=65e3, angle=350),
    IntoCircle(c_meteor, radius=radius_meteor, angle=360),
], aircraft="HALO")
plot_path(plan, ax, color="C1")
plt.scatter(wp_meteor.lon, wp_meteor.lat, color="C2", marker="o")
plan.show_details()
```

## Flight path

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

c_climb = bco.assign(lon=bco.lon+0.61, label="c_climb", fl=150)
wp_meteor = LatLon(bco.lat, c_meteor.lon - 0.665)
c_meteor = c_climb.course(90, 7e3).assign(label="c_meteor", fl=410)
c_south  = LatLon(lat=10.5, lon=-46).assign(label = "c_south", fl=450)
ec_north = point_on_track(ec_track, lat=12.9).assign(label="ec_north")
ec_under = point_on_track(ec_track, lat=11.025, with_time=True).assign(label="ec_under", note="meet EarthCARE")
ec_south = point_on_track(ec_track, lat=9.15).assign(label="ec_south")

waypoints = [
    tbpb,
    wp_meteor.assign(fl=150, label="wp_meteor"),
    IntoCircle(c_climb, radius=65e3, angle=360),
    IntoCircle(c_meteor, radius=radius_meteor, angle=360),
    IntoCircle(tbpb.towards(c_south, fraction=.5).assign(fl=430, label="c_mid"), radius, -360),
    IntoCircle(tbpb.towards(c_south, fraction=.75).assign(fl=450, label="c_ec"), radius, -360),
    IntoCircle(c_south.assign(fl=450), radius, -360),
    ec_south.assign(fl=450),
    ec_under.assign(fl=450),
    ec_north.assign(fl=450),
    point_on_track(ec_track, lat=11.1).assign(fl=450, label="wp_home"),
    IntoCircle(tbpb.towards(c_south, fraction=.25).assign(fl=450, label="c_west"), radius, -360),
    wp_meteor.assign(fl=150, label="wp_meteor"),
    tbpb,
    ]

plan = FlightPlan(waypoints, flight_index, crew=crew, aircraft="HALO")
print(f"Take-off: {plan.takeoff_time:%H:%M %Z}\nLanding:  {plan.landing_time:%H:%M %Z}\nDuration:  {plan.duration}\n")
```

## Plotting flight path on CWV

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

lon_min, lon_max, lat_min, lat_max = -65, -40, 5, 17 #-65, -20, 0, 20

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)
plt.title(f"{flight_time}\n(CWV forecast issued on {ifs_fcst_time})")

plot_fir(ax=ax)
plot_cwv(cwv_flight_time, levels = [48.0, 50.0, 52.0, 54.0, 56.0, 58.0, 60.0], ax=ax)
plt.plot(ec_track.lon, ec_track.lat, c='k', ls='dotted')
plot_path(plan, ax, color="C1")
```

## Description
- we start our flight with a small circle to climb up to FL410 (*c_climb*)and ramp up all instruments east of Barbados.
- we continue with a circle of 72km radius *c_meteor* in coordination with Meteor measurements (within the SEA-POL scan range) and with dropping 12 sondes. Meteor plans to sit at the western most point of the circle and we might overpass it twice.
- we continue circling our way east *c_mid*, *c_ec*, *c_south* and with 12 sondes per circle.
- we will next go on the EarthCARE track entering it at *ec_south*,  meet EC at 17:22:37 UTC at *ec_under*, and continue to *ec_north*. A procedure turn will bring us back to on the EC track to the waypoint *wp_home*
- we head home and do one last circle *c_west* on the way, again with 12 sondes.

In total we plan to throw 5*12=60 sondes.

+++

## Waypoint coordinates and times

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

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