"""
Callisto flybys groundtrack
===========================

Example of representation of all the groundtrack
during the Callisto flybys.

"""

import matplotlib.pyplot as plt

from planetary_coverage import CALLISTO, TourConfig


# %%
# Search all the Callisto flybys between 2032 and 2034
# ----------------------------------------------------

# %%
tour = TourConfig(mk='5.1 150lb', spacecraft='JUICE', target='Callisto', version='v400')

flybys = tour['2032-06-01':'2034-06-30':'6 h'].flybys

flybys

# %%
# Represent the flybys on a map
# -----------------------------

# %%
fig = plt.figure(figsize=(12, 9))
ax = fig.add_subplot(projection=CALLISTO)

for flyby in flybys:
    ax.plot(flyby.where(flyby.alt < 20_000), 'inc', lw=3, vmin=0, vmax=90, cbar=False)

    ax.plot(flyby.ca, 'o', color='lightgrey')
    ax.text(*flyby.ca.lonlat, f'{flyby.date_ca}\n',
            color='lightgrey', va='baseline', ha='center')

ax.colorbar(vmin=0, vmax=90, label='inc', extend='max')
ax.set_title('Callisto flybys in 2032 and 2034')

plt.show()

# %%
# .. admonition:: Download
#
#   - :download:`callisto_flybys.ipynb`
#   - :download:`callisto_flybys.py`
