Querying and loading SHARP data#

In this example we will demonstrate how to acquire Spaceweather HMI Active Region Patch (SHARP) data and load it into a sunpy.map.Map.

import os

import matplotlib.pyplot as plt

import astropy.units as u

import sunpy.map
from sunpy.net import Fido
from sunpy.net import attrs as a

To search for SHARP data, we will need to query the JSOC. We will use Fido and make use of the search attributes in sunpy.net.jsoc that allow us to query the JSOC.

Exporting data from the JSOC requires registering your email first. Please replace this with your email address once you have registered like so: jsoc_email = “your_email@example.com” See this page for more details.

jsoc_email = os.environ["JSOC_EMAIL"]

result = Fido.search(a.Time("2011-03-09 23:20:00", "2011-03-09 23:30:00"),
                     a.Sample(1*u.hour),
                     a.jsoc.Series("hmi.sharp_cea_720s"),
                     a.jsoc.PrimeKey("HARPNUM", 401),
                     a.jsoc.Notify(jsoc_email),
                     a.jsoc.Segment("Bp"))
print(result)
Results from 1 Provider:

1 Results from the JSOCClient:
Source: http://jsoc.stanford.edu

         T_REC          TELESCOP  INSTRUME WAVELNTH CAR_ROT
----------------------- -------- --------- -------- -------
2011.03.09_23:24:00_TAI  SDO/HMI HMI_SIDE1   6173.0    2107

Next, we can download the file.

file = Fido.fetch(result)
INFO: 1 URLs found for download. Full request totaling 1MB [sunpy.net.jsoc.jsoc]

Now that we have the file, we can construct a Map and plot it.

sharp_map = sunpy.map.Map(file)
fig = plt.figure()
ax = fig.add_subplot(projection=sharp_map)
sharp_map.plot(axes=ax, vmin=-1500, vmax=1500)

plt.show()
HMI hmi 2011-03-09 23:22:14
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/latest/lib/python3.10/site-packages/sunpy/map/mapbase.py:737: SunpyMetadataWarning: Could not parse unit string "Mx/cm^2" as a valid FITS unit.
See https://docs.sunpy.org/en/stable/how_to/fix_map_metadata.html for how to fix metadata before loading it with sunpy.map.Map.
See https://fits.gsfc.nasa.gov/fits_standard.html for the FITS unit standards.
  warn_metadata(f'Could not parse unit string "{unit_str}" as a valid FITS unit.\n'

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

Gallery generated by Sphinx-Gallery