Note
Go to the end 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.
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)
Results from 1 Provider:
177 Results from the JSOCClient:
Source: http://jsoc.stanford.edu
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 2263
SDO/HMI HMI_SIDE1 6173.0 2264
SDO/HMI HMI_SIDE1 6173.0 2265
SDO/HMI HMI_SIDE1 6173.0 2266
SDO/HMI HMI_SIDE1 6173.0 2267
SDO/HMI HMI_SIDE1 6173.0 2268
SDO/HMI HMI_SIDE1 6173.0 2269
SDO/HMI HMI_SIDE1 6173.0 2270
SDO/HMI HMI_SIDE1 6173.0 2271
SDO/HMI HMI_SIDE1 6173.0 2272
SDO/HMI HMI_SIDE1 6173.0 2273
Length = 177 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)
Results from 1 Provider:
1 Results from the JSOCClient:
Source: http://jsoc.stanford.edu
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)
Export request pending. [id=JSOC_20230824_1951_X_IN, status=2]
Waiting for 0 seconds...
1 URLs found for download. Full request totalling 4MB
Files Downloaded: 0%| | 0/1 [00:00<?, ?file/s]
Files Downloaded: 100%|██████████| 1/1 [00:00<00:00, 2.80file/s]
Files Downloaded: 100%|██████████| 1/1 [00:00<00:00, 2.80file/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()
INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]
INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]
Total running time of the script: (0 minutes 14.027 seconds)