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), and the radial magnetic field synoptic maps come
in two sizes:
‘hmi.Synoptic_Mr_720s’: 3600 x 1440 in (lon, lat)
‘hmi.mrsynop_small_720s’: 720 x 360 in (lon, lat)
For more information on the maps, see the synoptic maps page on the JSOC site.
First import the required modules
import pfsspy
from sunpy.net import Fido, attrs as a
import sunpy.map
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.mrsynop_small_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:
133 Results from the JSOCClient:
T_REC TELESCOP INSTRUME WAVELNTH CAR_ROT
str15 str7 str9 float64 int64
--------------- -------- --------- -------- -------
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2097
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2098
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2099
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2100
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2101
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2102
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2103
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2104
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2105
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2106
... ... ... ... ...
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2220
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2221
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2222
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2223
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2224
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2225
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2226
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2227
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2228
Invalid KeyLink SDO/HMI HMI_SIDE1 6173.0 2229
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("jsoc@cadair.com"))
print(result)
Out:
Results from 1 Provider:
1 Results from the JSOCClient:
T_REC TELESCOP INSTRUME WAVELNTH CAR_ROT
str15 str7 str9 float64 int64
--------------- -------- --------- -------- -------
Invalid KeyLink 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_20200501_1169_X_IN", status=2]
Waiting for 0 seconds...
Export request pending. [id="JSOC_20200501_1169_X_IN", status=1]
Waiting for 5 seconds...
2 URLs found for download. Full request totalling 2MB
Files Downloaded: 0%| | 0/2 [00:00<?, ?file/s]
hmi.mrsynop_small_720s.2210.synopMr.fits: 0%| | 0.00/1.05M [00:00<?, ?B/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 0%| | 0.00/1.05M [00:00<?, ?B/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 1%| | 10.0k/1.05M [00:00<00:13, 75.5kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 1%| | 10.0k/1.05M [00:00<00:13, 75.7kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 2%|2 | 25.8k/1.05M [00:00<00:12, 84.7kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 2%|2 | 25.8k/1.05M [00:00<00:12, 85.0kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 5%|4 | 47.3k/1.05M [00:00<00:10, 98.8kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 5%|4 | 48.8k/1.05M [00:00<00:09, 100kB/s] [A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 7%|7 | 74.5k/1.05M [00:00<00:08, 117kB/s] [A
hmi.mrsynop_small_720s.2210.epts.fits: 9%|8 | 90.3k/1.05M [00:00<00:07, 126kB/s][A[A
hmi.mrsynop_small_720s.2210.epts.fits: 14%|#3 | 143k/1.05M [00:00<00:05, 162kB/s] [A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 11%|# | 110k/1.05M [00:00<00:06, 141kB/s] [A
hmi.mrsynop_small_720s.2210.epts.fits: 20%|## | 210k/1.05M [00:00<00:04, 203kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 15%|#4 | 153k/1.05M [00:00<00:05, 169kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 29%|##8 | 302k/1.05M [00:00<00:02, 258kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 20%|#9 | 206k/1.05M [00:00<00:04, 204kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 38%|###8 | 401k/1.05M [00:01<00:02, 321kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 27%|##6 | 279k/1.05M [00:01<00:03, 252kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 43%|####3 | 454k/1.05M [00:01<00:01, 325kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 35%|###5 | 366k/1.05M [00:01<00:02, 308kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 48%|####7 | 501k/1.05M [00:01<00:01, 333kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 44%|####4 | 464k/1.05M [00:01<00:01, 372kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 53%|#####3 | 555k/1.05M [00:01<00:01, 352kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 55%|#####4 | 574k/1.05M [00:01<00:01, 444kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 60%|###### | 631k/1.05M [00:01<00:01, 398kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 68%|######8 | 711k/1.05M [00:01<00:00, 534kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 69%|######9 | 726k/1.05M [00:01<00:00, 458kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 80%|######## | 840k/1.05M [00:01<00:00, 616kB/s][A
hmi.mrsynop_small_720s.2210.epts.fits: 80%|#######9 | 834k/1.05M [00:01<00:00, 526kB/s][A[A
hmi.mrsynop_small_720s.2210.synopMr.fits: 93%|#########2| 968k/1.05M [00:01<00:00, 691kB/s][A
[A
Files Downloaded: 50%|##### | 1/2 [00:02<00:02, 2.03s/file]
hmi.mrsynop_small_720s.2210.epts.fits: 92%|#########1| 959k/1.05M [00:01<00:00, 605kB/s][A[A
[A[A
Files Downloaded: 100%|##########| 2/2 [00:02<00:00, 1.46s/file]
Files Downloaded: 100%|##########| 2/2 [00:02<00:00, 1.08s/file]
['/home/docs/sunpy/data/hmi.mrsynop_small_720s.2210.synopMr.fits', '/home/docs/sunpy/data/hmi.mrsynop_small_720s.2210.epts.fits']
Read in a file. This will read in the first file downloaded to a sunpy Map object.
hmi_map = sunpy.map.Map(files[0])
print(hmi_map)
Out:
[[ nan nan nan ... nan
nan nan]
[ 6.8606806e+00 6.9322715e+00 1.7138639e+01 ... nan
nan nan]
[ 2.2991274e+01 2.3272142e+01 2.5686041e+01 ... -6.5474920e+00
-1.1747680e+01 -5.7880988e+00]
...
[ 2.4496571e+01 2.4475569e+01 2.3493109e+01 ... 9.1998796e+00
4.6518126e+00 -5.1214037e+00]
[ 2.7395411e+01 2.6415035e+01 2.8137531e+01 ... 2.9862759e-01
-2.2819099e-01 -3.0025697e+00]
[ 2.7601993e+00 -2.1510720e-02 -3.4529107e+00 ... 3.0673847e+01
3.4140205e+01 3.5398293e+01]]
Total running time of the script: ( 0 minutes 19.841 seconds)