.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/planet_locations.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_generated_gallery_planet_locations.py: ==================================== Planet Positions in the Solar System ==================================== The purpose of this demo is to demonstrate the ability of sunpy to get the position of planetary bodies im the solar system. .. GENERATED FROM PYTHON SOURCE LINES 12-13 First the imports .. GENERATED FROM PYTHON SOURCE LINES 13-19 .. code-block:: default from astropy.coordinates import SkyCoord from sunpy.coordinates import get_body_heliographic_stonyhurst from astropy.time import Time import matplotlib.pyplot as plt import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 20-21 Lets grab the positions of each of the planets in stonyhurt coordinates. .. GENERATED FROM PYTHON SOURCE LINES 21-25 .. code-block:: default obstime = Time('2014-05-15T07:54:00.005') planet_list = ['earth', 'venus', 'mars', 'mercury', 'jupiter', 'neptune', 'uranus'] planet_coord = [get_body_heliographic_stonyhurst(this_planet, time=obstime) for this_planet in planet_list] .. GENERATED FROM PYTHON SOURCE LINES 26-27 Now lets make a plot. .. GENERATED FROM PYTHON SOURCE LINES 27-33 .. code-block:: default fig = plt.figure() ax1 = plt.subplot(1, 1, 1, projection='polar') for this_planet, this_coord in zip(planet_list, planet_coord): plt.plot(np.deg2rad(this_coord.lon), this_coord.radius, 'o', label=this_planet) plt.legend(loc='lower left') plt.show() .. image-sg:: /generated/gallery/images/sphx_glr_planet_locations_001.png :alt: planet locations :srcset: /generated/gallery/images/sphx_glr_planet_locations_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.636 seconds) .. _sphx_glr_download_generated_gallery_planet_locations.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/HeliophysicsPy/gallery/gh-pages?urlpath=lab/tree/notebooks/generated/gallery/planet_locations.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: planet_locations.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: planet_locations.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_