Plotting the solar limb

This example demonstrates how you can draw the limb as seen by an arbitrary observer.

import matplotlib.pyplot as plt

import sunpy.map
from sunpy.coordinates import get_body_heliographic_stonyhurst
from sunpy.visualization.limb import draw_limb

Let’s download a magnetic field synoptic map and read it into a Map.

syn_map = sunpy.map.Map('http://jsoc.stanford.edu/data/hmi/synoptic/hmi.Synoptic_Mr.2191.fits')
syn_map.plot_settings['cmap'] = 'hmimag'
syn_map.plot_settings['norm'] = plt.Normalize(-1500, 1500)
Files Downloaded:   0%|          | 0/1 [00:00<?, ?file/s]

hmi.Synoptic_Mr.2191.fits:   0%|          | 0.00/20.7M [00:00<?, ?B/s]

hmi.Synoptic_Mr.2191.fits:   0%|          | 1.02k/20.7M [00:00<40:44, 8.49kB/s]

hmi.Synoptic_Mr.2191.fits:   0%|          | 60.2k/20.7M [00:00<01:09, 298kB/s]

hmi.Synoptic_Mr.2191.fits:   1%|          | 204k/20.7M [00:00<00:28, 720kB/s]

hmi.Synoptic_Mr.2191.fits:   3%|2         | 532k/20.7M [00:00<00:13, 1.54MB/s]

hmi.Synoptic_Mr.2191.fits:   5%|5         | 1.14M/20.7M [00:00<00:06, 2.85MB/s]

hmi.Synoptic_Mr.2191.fits:  11%|#         | 2.21M/20.7M [00:00<00:03, 4.97MB/s]

hmi.Synoptic_Mr.2191.fits:  22%|##1       | 4.46M/20.7M [00:00<00:01, 9.64MB/s]

hmi.Synoptic_Mr.2191.fits:  39%|###9      | 8.11M/20.7M [00:00<00:00, 16.5MB/s]

hmi.Synoptic_Mr.2191.fits:  62%|######1   | 12.9M/20.7M [00:01<00:00, 24.0MB/s]

hmi.Synoptic_Mr.2191.fits:  86%|########5 | 17.8M/20.7M [00:01<00:00, 29.5MB/s]


Files Downloaded: 100%|##########| 1/1 [00:01<00:00,  1.39s/file]
Files Downloaded: 100%|##########| 1/1 [00:01<00:00,  1.39s/file]

Get coordinates for Earth and Mars at the date of the synoptic map

coords = {body: get_body_heliographic_stonyhurst(body, syn_map.date)
          for body in ['Earth', 'Mars']}

Now we can plot the map the the solar limb seen from these two coordinates. To create a legend for these limbs, we need to keep the patches returned by draw_limb() and provide them to legend().

fig = plt.figure(figsize=(12, 5))
ax = fig.add_subplot(projection=syn_map)
im = syn_map.plot(axes=ax)

visible_limbs = []
for (body, coord), color in zip(coords.items(), ['tab:blue', 'tab:red']):
    v, _ = draw_limb(ax, coord, color=color, label=f'Limb seen from {body}', linewidth=2)
    visible_limbs.append(v)

ax.legend(handles=visible_limbs)
plt.show()
HMI carrington 2017-06-09 10:56:34
INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]

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

Gallery generated by Sphinx-Gallery