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:

135 Results from the JSOCClient:
     T_REC      TELESCOP  INSTRUME WAVELNTH CAR_ROT
--------------- -------- --------- -------- -------
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    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
Invalid KeyLink  SDO/HMI HMI_SIDE1   6173.0    2230
Invalid KeyLink  SDO/HMI HMI_SIDE1   6173.0    2231
Length = 135 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("jsoc@cadair.com"))
print(result)

Out:

Results from 1 Provider:

1 Results from the JSOCClient:
     T_REC      TELESCOP  INSTRUME WAVELNTH CAR_ROT
--------------- -------- --------- -------- -------
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_20200703_533_X_IN", status=2]
Waiting for 0 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]


hmi.mrsynop_small_720s.2210.epts.fits:   0%|          | 0.00/1.05M [00:00<?, ?B/s]

hmi.mrsynop_small_720s.2210.synopMr.fits:   0%|          | 100/1.05M [00:00<24:26, 713B/s]


hmi.mrsynop_small_720s.2210.epts.fits:   0%|          | 100/1.05M [00:00<24:17, 717B/s]


hmi.mrsynop_small_720s.2210.epts.fits:   2%|2         | 22.3k/1.05M [00:00<16:40, 1.02kB/s]

hmi.mrsynop_small_720s.2210.synopMr.fits:   2%|1         | 20.9k/1.05M [00:00<16:48, 1.02kB/s]


hmi.mrsynop_small_720s.2210.epts.fits:   7%|6         | 69.4k/1.05M [00:00<11:08, 1.46kB/s]

hmi.mrsynop_small_720s.2210.synopMr.fits:   6%|5         | 59.4k/1.05M [00:00<11:20, 1.45kB/s]


hmi.mrsynop_small_720s.2210.epts.fits:  14%|#4        | 151k/1.05M [00:00<07:09, 2.08kB/s] 

hmi.mrsynop_small_720s.2210.synopMr.fits:  11%|#1        | 118k/1.05M [00:00<07:28, 2.07kB/s] 


hmi.mrsynop_small_720s.2210.epts.fits:  26%|##6       | 275k/1.05M [00:00<04:19, 2.97kB/s]

hmi.mrsynop_small_720s.2210.synopMr.fits:  22%|##1       | 227k/1.05M [00:00<04:37, 2.95kB/s]


hmi.mrsynop_small_720s.2210.epts.fits:  46%|####6     | 484k/1.05M [00:00<02:12, 4.24kB/s]

hmi.mrsynop_small_720s.2210.synopMr.fits:  38%|###8      | 402k/1.05M [00:00<02:32, 4.21kB/s]


hmi.mrsynop_small_720s.2210.epts.fits:  76%|#######6  | 795k/1.05M [00:00<00:41, 6.06kB/s]

hmi.mrsynop_small_720s.2210.synopMr.fits:  56%|#####5    | 585k/1.05M [00:00<01:16, 6.01kB/s]


hmi.mrsynop_small_720s.2210.epts.fits:  89%|########9 | 931k/1.05M [00:01<00:13, 8.63kB/s]

hmi.mrsynop_small_720s.2210.synopMr.fits:  71%|#######   | 738k/1.05M [00:01<00:35, 8.56kB/s]


                                                                                          
Files Downloaded:  50%|#####     | 1/2 [00:01<00:01,  1.23s/file]

hmi.mrsynop_small_720s.2210.synopMr.fits:  80%|#######9  | 835k/1.05M [00:01<00:17, 12.2kB/s]

hmi.mrsynop_small_720s.2210.synopMr.fits:  88%|########8 | 924k/1.05M [00:01<00:07, 17.2kB/s]

hmi.mrsynop_small_720s.2210.synopMr.fits:  96%|#########6| 1.01M/1.05M [00:01<00:01, 24.3kB/s]

                                                                                              
Files Downloaded: 100%|##########| 2/2 [00:01<00:00,  1.02file/s]
Files Downloaded: 100%|##########| 2/2 [00:01<00:00,  1.22file/s]
['/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 13.902 seconds)

Gallery generated by Sphinx-Gallery