{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# This example is part of the planetary-coverage examples gallery.\n# More examples can be found here: https://docs.planetary-coverage.org"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "JANUS FOV during Ganymede flyby\n===============================\n\nExample of representation of JANUS field of view during 2G2 Ganymede\nflyby.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nfrom planetary_coverage import GANYMEDE, TourConfig, read_events\nfrom planetary_coverage.misc import wget"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Download JUICE timeline from the SOC\n====================================\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "URL = 'https://juicesoc.esac.esa.int/data/DATA/crema_5_0'\nTIMELINE = 'mission_timeline_event_file_5_0.csv'\n\nwget(f'{URL}/{TIMELINE}', TIMELINE, skip=True)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Get the 2G2 flyby date from the timeline\n========================================\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "timeline = read_events(TIMELINE)\n\nflyby_2G2 = timeline['FLYBY_GANYMEDE']['2G2']\n\nflyby_2G2"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Load JUICE trajectory during 2G2\n================================\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "tour = TourConfig(mk='5.1 150lb', spacecraft='JUICE', instrument='JANUS',\n                  target='Ganymede', version='v400')\n\njanus_flyby = tour.flyby(flyby_2G2)\n\njanus_flyby"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Keep only the part of the trajectory below 100,000 km\n=====================================================\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mask_janus_flyby = janus_flyby.where(janus_flyby.alt < 100_000)\n\nmask_janus_flyby"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Represent JANUS FOV on the map\n==============================\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig = plt.figure(figsize=(12, 9))\nax = fig.add_subplot(projection=GANYMEDE)\n\nax.add_collection(mask_janus_flyby.fovs(facecolors='inc',\n                                        vmin=0, vmax=90, sort='inc'))\n\nax.colorbar(vmin=0, vmax=90, label='inc', extend='max')\n\nax.set_title('JANUS footprints during 2G2 flyby (Feb. 13th 2032)')\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "::: {.admonition}\nDownload\n\n-   `janus_fov.ipynb`{.interpreted-text role=\"download\"}\n-   `janus_fov.py`{.interpreted-text role=\"download\"}\n:::\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.8.15"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}