{
  "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": [
        "ESA EnVision\n============\n\nExample of mission planning for EnVision Venus orbital insertion.\n\nIn June 2021, ESA selected a new M-class mission,\n[Envision](https://www.esa.int/Science_Exploration/Space_Science/ESA_selects_revolutionary_Venus_mission_EnVision),\nto study Venus planet from its inner core to upper atmosphere. This\nmission is still in development but its proposed orbital trajectory is\nalready available on the ESA-SPICE archive.\n\n![EnVision spacecraft (Credits ESA)](https://www.esa.int/var/esa/storage/images/esa_multimedia/images/2021/06/envision_understanding_why_earth_s_closest_neighbour_is_so_different/23341064-1-eng-GB/EnVision_Understanding_why_Earth_s_closest_neighbour_is_so_different_pillars.jpg)\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nfrom planetary_coverage import VENUS, TourConfig\nfrom planetary_coverage.ticks import date_ticks, km_ticks"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Download EnVision kernels and load the orbital insertion trajectory\n===================================================================\n\n*Note*: the location of the EnVision kernels are not explicitly listed\nin the metakernel header, we need to provide this information manually\nin `remote_kernels`.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "tour = TourConfig(\n    mk='study_esc_t2_south_voi_v040',\n    kernels_dir='./data/EnVision/kernels',\n    remote_kernels='https://spiftp.esac.esa.int/data/SPICE/EnVision/kernels',\n    download_kernels=True,\n    spacecraft='EnVision',\n    target='Venus',\n)\n\nvoi_traj = tour['2033-05-01':'2033-06-01':'6 h']\n\nvoi_traj"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig = plt.figure(figsize=(10, 7))\nax = fig.add_subplot()\n\n\nax.plot(voi_traj.utc, voi_traj.alt, color='tab:green')\n\nax.set_ylabel('Altitude')\nax.xaxis.set_major_formatter(date_ticks)\nax.yaxis.set_major_formatter(km_ticks)\n\nplt.title('EnVision Venus orbital insertion')\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "First orbits after insertion\n============================\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "orbits = tour['2033-05-21':'2033-05-25':'1 min']\n\norbits"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig = plt.figure(figsize=(14, 9))\nax = fig.add_subplot(projection=VENUS)\n\nax.plot(orbits, 'alt', vmax=20_000, cmap='Greens_r', lw=3)\n\nax.set_title('EnVision orbits after Venus insertion')\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "::: {.admonition}\nDownload\n\n-   `envision.ipynb`{.interpreted-text role=\"download\"}\n-   `envision.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
}