Note
Click here to download the full example code
Overplotting the position of the Venus transit¶
How to accurately plot the position of Venus as it transitted in front of the Sun as observed by SDO/AIA.
import matplotlib.pyplot as plt
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.coordinates import solar_system_ephemeris
from sunpy.net import Fido, attrs as a
import sunpy.map
from sunpy.coordinates import get_body_heliographic_stonyhurst
Let’s download an image of the Venus transit.
result = Fido.search(a.Time('2012/06/06 04:07:25', '2012/06/06 04:07:35'),
a.Instrument('aia'),
a.Wavelength(1600*u.angstrom))
files = Fido.fetch(result)
aiamap = sunpy.map.Map(files[0])
Out:
Files Downloaded: 0%| | 0/1 [00:00<?, ?file/s]
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 0%| | 0.00/7.54M [00:00<?, ?B/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 1%| | 47.1k/7.54M [00:00<00:22, 336kB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 2%|1 | 120k/7.54M [00:00<00:19, 375kB/s] [A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 3%|2 | 214k/7.54M [00:00<00:16, 432kB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 5%|4 | 349k/7.54M [00:00<00:13, 517kB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 7%|6 | 520k/7.54M [00:00<00:11, 624kB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 10%|9 | 718k/7.54M [00:00<00:09, 748kB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 12%|#2 | 941k/7.54M [00:00<00:07, 888kB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 16%|#5 | 1.19M/7.54M [00:01<00:06, 1.04MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 20%|#9 | 1.48M/7.54M [00:01<00:04, 1.22MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 23%|##2 | 1.70M/7.54M [00:01<00:04, 1.28MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 27%|##7 | 2.06M/7.54M [00:01<00:03, 1.53MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 33%|###2 | 2.48M/7.54M [00:01<00:02, 1.88MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 38%|###7 | 2.83M/7.54M [00:01<00:02, 2.06MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 43%|####2 | 3.21M/7.54M [00:01<00:01, 2.32MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 48%|####8 | 3.64M/7.54M [00:02<00:01, 2.70MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 54%|#####4 | 4.10M/7.54M [00:02<00:01, 3.08MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 61%|###### | 4.58M/7.54M [00:02<00:00, 3.31MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 68%|######7 | 5.09M/7.54M [00:02<00:00, 3.62MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 76%|#######5 | 5.70M/7.54M [00:02<00:00, 4.12MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 84%|########3 | 6.30M/7.54M [00:02<00:00, 4.42MB/s][A
aia_lev1_1600a_2012_06_06t04_07_29_12z_image_lev1.fits: 92%|#########2| 6.96M/7.54M [00:02<00:00, 4.92MB/s][A
[A
Files Downloaded: 100%|##########| 1/1 [00:03<00:00, 3.65s/file]
Files Downloaded: 100%|##########| 1/1 [00:03<00:00, 3.65s/file]
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.7/asyncio/base_events.py:623: ResourceWarning: unclosed event loop <_UnixSelectorEventLoop running=False closed=False debug=False>
source=self)
For this example, we require high-precision ephemeris information. The built-in
ephemeris provided by astropy is not accurate enough. This call requires jplephem
to be installed. This will also trigger a download of about ~10 MB.
solar_system_ephemeris.set('de432s')
Out:
<ScienceState solar_system_ephemeris: 'de432s'>
Now we get the position of Venus and convert it into the SDO/AIA coordinates. The apparent position of Venus accounts for the time it takes for light to travel from Venus to SDO.
venus = get_body_heliographic_stonyhurst('venus', aiamap.date, observer=aiamap.observer_coordinate)
venus_hpc = venus.transform_to(aiamap.coordinate_frame)
Out:
INFO: Apparent body location accounts for 144.14 seconds of light travel time [sunpy.coordinates.ephemeris]
Let’s crop the image with Venus at its center.
fov = 100 * u.arcsec
top_right = SkyCoord(venus_hpc.Tx + fov, venus_hpc.Ty + fov, frame=aiamap.coordinate_frame)
bottom_left = SkyCoord(venus_hpc.Tx - fov, venus_hpc.Ty - fov, frame=aiamap.coordinate_frame)
smap = aiamap.submap(top_right, bottom_left)
Let’s plot the results.
ax = plt.subplot(projection=smap)
smap.plot()
smap.draw_limb()
ax.grid(False)
ax.plot_coord(venus_hpc, 'x', color='deepskyblue', label='Venus')
plt.legend()
plt.show()

Total running time of the script: ( 0 minutes 10.640 seconds)