Note
Click here to download the full example code
HMI data
How to search for HMI data.
This example shows how to search for, download, and load HMI data, using the
sunpy.net.Fido
interface. HMI data is available via. the Joint Stanford
Operations Center (JSOC).
The polar filled radial magnetic field synoptic maps are obtained using the ‘hmi.synoptic_mr_polfil_720s’ series keyword. Note that they are large (1440 x 720), so you will probably want to downsample them to a smaller resolution to use them to calculate PFSS solutions.
For more information on the maps, see the synoptic maps page on the JSOC site.
First import the required modules
import os
import sunpy.map
from sunpy.net import Fido
from sunpy.net import attrs as a
import pfsspy.utils
Set up the search.
Note that for SunPy versions earlier than 2.0, a time attribute is needed to do the search, even if (in this case) it isn’t used, as the synoptic maps are labelled by Carrington rotation number instead of time
time = a.Time('2010/01/01', '2010/01/01')
series = a.jsoc.Series('hmi.synoptic_mr_polfil_720s')
Do the search. This will return all the maps in the ‘hmi_mrsynop_small_720s series.’
result = Fido.search(time, series)
print(result)
Out:
Results from 1 Provider:
152 Results from the JSOCClient:
TELESCOP INSTRUME WAVELNTH CAR_ROT
-------- --------- -------- -------
SDO/HMI HMI_SIDE1 6173.0 2097
SDO/HMI HMI_SIDE1 6173.0 2098
SDO/HMI HMI_SIDE1 6173.0 2099
SDO/HMI HMI_SIDE1 6173.0 2100
SDO/HMI HMI_SIDE1 6173.0 2101
SDO/HMI HMI_SIDE1 6173.0 2102
SDO/HMI HMI_SIDE1 6173.0 2103
SDO/HMI HMI_SIDE1 6173.0 2104
SDO/HMI HMI_SIDE1 6173.0 2105
SDO/HMI HMI_SIDE1 6173.0 2106
... ... ... ...
SDO/HMI HMI_SIDE1 6173.0 2238
SDO/HMI HMI_SIDE1 6173.0 2239
SDO/HMI HMI_SIDE1 6173.0 2240
SDO/HMI HMI_SIDE1 6173.0 2241
SDO/HMI HMI_SIDE1 6173.0 2242
SDO/HMI HMI_SIDE1 6173.0 2243
SDO/HMI HMI_SIDE1 6173.0 2244
SDO/HMI HMI_SIDE1 6173.0 2245
SDO/HMI HMI_SIDE1 6173.0 2246
SDO/HMI HMI_SIDE1 6173.0 2247
SDO/HMI HMI_SIDE1 6173.0 2248
Length = 152 rows
If we just want to download a specific map, we can specify a Carrington rotation number. In addition, downloading files from JSOC requires a notification email. If you use this code, please replace this email address with your own one, registered here: http://jsoc.stanford.edu/ajax/register_email.html
crot = a.jsoc.PrimeKey('CAR_ROT', 2210)
result = Fido.search(time, series, crot,
a.jsoc.Notify(os.environ['JSOC_EMAIL']))
print(result)
Out:
Results from 1 Provider:
1 Results from the JSOCClient:
TELESCOP INSTRUME WAVELNTH CAR_ROT
-------- --------- -------- -------
SDO/HMI HMI_SIDE1 6173.0 2210
Download the files. This downloads files to the default sunpy download directory.
files = Fido.fetch(result)
print(files)
Out:
Export request pending. [id=JSOC_20211018_1007_X_IN, status=2]
Waiting for 0 seconds...
1 URLs found for download. Full request totalling 6MB
Files Downloaded: 0%| | 0/1 [00:00<?, ?file/s]
Files Downloaded: 100%|##########| 1/1 [00:00<00:00, 2.70file/s]
Files Downloaded: 100%|##########| 1/1 [00:00<00:00, 2.70file/s]
['/home/docs/sunpy/data/hmi.synoptic_mr_polfil_720s.2210.Mr_polfil.fits']
Read in a file. This will read in the first file downloaded to a sunpy Map object. Note that HMI maps have several bits of metadata that do not comply to the FITS standard, so we need to fix them first.
hmi_map = sunpy.map.Map(files[0])
pfsspy.utils.fix_hmi_meta(hmi_map)
hmi_map.peek()
Out:
/home/docs/checkouts/readthedocs.org/user_builds/pfsspy/envs/1.0.0/lib/python3.7/site-packages/astropy/wcs/wcs.py:710: FITSFixedWarning: 'datfix' made the change 'Invalid DATE-OBS format '2018.11.09_12:30:52_TAI''.
FITSFixedWarning)
/home/docs/checkouts/readthedocs.org/user_builds/pfsspy/envs/1.0.0/lib/python3.7/site-packages/astropy/wcs/wcs.py:710: FITSFixedWarning: 'unitfix' made the change 'Changed units:
'degree' -> 'deg'.
FITSFixedWarning)
Total running time of the script: ( 0 minutes 14.801 seconds)