.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated_examples/mercury-schematic.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_examples_mercury-schematic.py: Creating a schematic of spacecraft orbits in Mercury's magnetosphere ==================================================================== In this example, we talk through how create a to-scale schematic of Mercury's magnetosphere, inlcuding average boundary locations, and sample orbits from both MESSENGER and predictions from BepiColombo's MPO and Mio. .. GENERATED FROM PYTHON SOURCE LINES 8-22 .. code-block:: Python import matplotlib as mpl import matplotlib.pyplot as plt import spiceypy as spice from matplotlib.patches import Circle from sunpy.time import TimeRange from hermpy.net import ClientSPICE from hermpy.plotting import plot_magnetospheric_boundaries from hermpy.utils import Constants as c # Controls the plot border width mpl.rcParams["axes.linewidth"] = 2 .. GENERATED FROM PYTHON SOURCE LINES 23-26 We start by outlining some times from which to fetch orbits. Here we use ``TimeRange`` from `sunpy`_. .. _sunpy: https://www.sunpy.org/ .. GENERATED FROM PYTHON SOURCE LINES 26-29 .. code-block:: Python bepi_time_range = TimeRange("2026-08-15", "2026-08-16") messenger_time_range = TimeRange("2012-08-05", "2012-08-06") .. GENERATED FROM PYTHON SOURCE LINES 30-36 We use ``hermpy.net.ClientSPICE`` to aid in the downloading a querying of SPICE kernels. We designate specific SPICE kernels to download which we require to get positions for BepiColombo's MPO and Mio, along with MESSENGER. See `here`_ for more details. .. _here: spice.html .. GENERATED FROM PYTHON SOURCE LINES 36-64 .. code-block:: Python spice_client = ClientSPICE() spice_client.KERNEL_LOCATIONS.update( { "MESSENGER": { "BASE": "https://naif.jpl.nasa.gov/pub/naif/", "DIRECTORY": "pds/data/mess-e_v_h-spice-6-v1.0/messsp_1000/data/spk/", "PATTERNS": ["msgr_??????_??????_??????_od431sc_2.bsp"], }, "BepiColombo": { "BASE": "http://spiftp.esac.esa.int/data/SPICE/BEPICOLOMBO/", "DIRECTORY": "kernels/spk/", "PATTERNS": [ "de432s.bsp", "bc_sci_v02.bsp", "bc_mpo_mlt_50037_20260314_20280529_v05.bsp", "bc_mmo_mlt_50038_20251220_20280305_v05.bsp", ], }, "BepiColombo Frames": { "BASE": "http://spiftp.esac.esa.int/data/SPICE/BEPICOLOMBO/", "DIRECTORY": "kernels/fk/", "PATTERNS": [ "bc_sci_v12.tf", ], }, } ) .. GENERATED FROM PYTHON SOURCE LINES 65-69 The time ranges defined earlier are used to query the positions for those times in the Mercury-Solar-Magnetospheric (MSM) frame. Those postions are divided by Mercury's radius (``hermpy.utils.Constants``) so our plot will be in units of Mercury radii. .. GENERATED FROM PYTHON SOURCE LINES 69-90 .. code-block:: Python with spice_client.KernelPool(): bepi_times = [t.center.to_datetime() for t in bepi_time_range.split(1000)] bepi_ets = spice.datetime2et(bepi_times) mpo_positions, _ = spice.spkpos("MPO", bepi_ets, "BC_MSO", "NONE", "MERCURY") mpo_positions /= c.MERCURY_RADIUS.to("km").value mpo_positions -= c.DIPOLE_OFFSET_RADII.value mmo_positions, _ = spice.spkpos("MMO", bepi_ets, "BC_MSO", "NONE", "MERCURY") mmo_positions /= c.MERCURY_RADIUS.to("km").value mmo_positions -= c.DIPOLE_OFFSET_RADII.value messenger_times = [t.center.to_datetime() for t in messenger_time_range.split(1000)] messenger_ets = spice.datetime2et(messenger_times) messenger_positions, _ = spice.spkpos( "MESSENGER", messenger_ets, "BC_MSO", "NONE", "MERCURY" ) messenger_positions /= c.MERCURY_RADIUS.to("km").value messenger_positions -= c.DIPOLE_OFFSET_RADII.value .. rst-class:: sphx-glr-script-out .. code-block:: none Files Downloaded: 0%| | 0/12 [00:00` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: mercury-schematic.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: mercury-schematic.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_