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)