{
  "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 BepiColombo\n===============\n\nExample of analysis of Earth flyby during BepiColombo cruise mission.\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "On its journey to Mercury, the BepiColombo spacecraft made a close flyby\nof the Earth in April 2020. In this example we will represent its ground\ntrack above the Earth surface.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nfrom planetary_coverage import EARTH, ESA_MK, TourConfig\nfrom planetary_coverage.ticks import date_ticks, km_ticks"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Get Bepi Colombo metakernel\n===========================\n\nThe BepiColombo mission is in operation since 2018 and its kernel set is\nalready quite large and contains more than 400 versions:\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "BEPI_MK = ESA_MK['BEPICOLOMBO']\n\nlen(BEPI_MK.versions)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "For the purpose of this example, we will use an old metakernel generated\nin 2018 (`v200_20181212_002`) that contains less kernels than the\ncurrent version. Feel, free to change this value by [latest]{.title-ref}\nto use the latest version. Here is the list of the available metakernels\nfor this version:\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "BEPI_MK.version('v200_20181212_002')"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Download the kernels and load the trajectory\n============================================\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "tour = TourConfig(\n    mk='plan',\n    version='v200_20181212_002',\n    kernels_dir='./data/BEPICOLOMBO/kernels',\n    download_kernels=True,\n    spacecraft='BEPICOLOMBO MPO',\n    target='Earth',\n)\n\ntraj = tour['2020-04-10T00':'2020-04-10T06']\n\ntraj"
      ]
    },
    {
      "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(traj.utc, traj.alt)\n\nax.set_ylabel('Altitude')\nax.xaxis.set_major_formatter(date_ticks)\nax.yaxis.set_major_formatter(km_ticks)\n\nax.set_title('Earth flyby by Bepi Colombo')\n\nplt.show()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "fig = plt.figure(figsize=(14, 9))\nax = fig.add_subplot(projection=EARTH)\n\nax.plot(traj, 'inc', vmin=0, vmax=90, lw=3)\n\nax.set_title('Earth flyby by Bepi Colombo (April 2020)')\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "::: {.admonition}\nDownload\n\n-   `bepicolombo.ipynb`{.interpreted-text role=\"download\"}\n-   `bepicolombo.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
}