Note
Click here to download the full example code
Loading an HMI synoptic map¶
In this example we load a synoptic map produced by the HMI team. This data is an interesting demonstration of sunpy’s Map class as it is not in the more common Helioprojective coordinate system, but in heliographic Carrington coordinates and a cylindrical equal area (CEA) projection.
import matplotlib.pyplot as plt
from astropy.utils.data import download_file
import sunpy.map
Download the file and read it into a Map.
filename = download_file(
'http://jsoc.stanford.edu/data/hmi/synoptic/hmi.Synoptic_Mr.2191.fits', cache=True)
syn_map = sunpy.map.Map(filename)
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/checkouts/stable/examples/plotting/hmi_synoptic_maps.py", line 20, in <module>
filename = download_file(
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.10/site-packages/astropy/utils/data.py", line 1393, in download_file
raise errors[sources[0]]
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.10/site-packages/astropy/utils/data.py", line 1363, in download_file
f_name = _download_file_from_source(
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.10/site-packages/astropy/utils/data.py", line 1167, in _download_file_from_source
with _try_url_open(source_url, timeout=timeout, http_headers=http_headers,
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.10/site-packages/astropy/utils/data.py", line 1104, in _try_url_open
return urlopener.open(req, timeout=timeout)
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.10/urllib/request.py", line 519, in open
response = self._open(req, data)
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.10/urllib/request.py", line 536, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.10/urllib/request.py", line 496, in _call_chain
result = func(*args)
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.10/urllib/request.py", line 1377, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.10/urllib/request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error timed out>
Plot the results.
fig = plt.figure(figsize=(12, 5))
ax = plt.subplot(projection=syn_map)
im = syn_map.plot(axes=ax)
ax.coords[0].set_axislabel("Carrington Longitude [deg]")
ax.coords[1].set_axislabel("Latitude [deg]")
ax.coords.grid(color='black', alpha=0.6, linestyle='dotted', linewidth=0.5)
cb = plt.colorbar(im, fraction=0.019, pad=0.1)
cb.set_label(f"Radial magnetic field [{syn_map.unit}]")
# In order to make the x-axis ticks show, the bottom y-limit has to be adjusted slightly
ax.set_ylim(bottom=0)
ax.set_title(f"{syn_map.meta['content']},\n"
f"Carrington rotation {syn_map.meta['CAR_ROT']}")
plt.show()
Total running time of the script: ( 0 minutes 10.037 seconds)