Downloading and plotting an HMI magnetogram

This example shows how to download a HMI magnetogram data with Fido and make a plot.

import matplotlib.pyplot as plt

from import Fido
from import attrs as a

To download the required data, we use, a downloader client, to query the Virtual Solar Observatory to acquire HMI data.

result ='2020/01/20 00:00:00', '2020/01/20 00:01:00'),
                     a.Instrument.hmi, a.Physobs.los_magnetic_field)

Now we can see what results we obtained from our search.



Results from 1 Provider:

1 Results from the VSOClient:

       Start Time               End Time        ...   Size          Info
                                                ...  Mibyte
----------------------- ----------------------- ... -------- ------------------
2020-01-20 00:00:22.000 2020-01-20 00:00:23.000 ... -0.00098 45sec. Magnetogram

We can look at the values of specific keywords from this result.

jsoc_result = result[0]
print('T_REC', 'CROTA2'))


Start Time End Time Source Instrument ... Extent Type  Size  Info fileid
                                      ...             Mibyte
---------- -------- ------ ---------- ... ----------- ------ ---- ------

The following shows how to download the results. If we don’t provide a path it will download the file into the sunpy data directory. The output provides the path of the downloaded files.

downloaded_file = Fido.fetch(result)



Now load it into a map and plot it. We see that solar North is pointed down instead of up in this image, which is indicated by the coordinates (that range from positive to negative, rather than negative to positive).

hmi_map =[0])
HMI magnetogram 2020-01-20 00:00:22

Now rotate the image such that solar North is pointed up. We have to do this because the HMI instrument is mounted upside-down relative to the AIA instrument on the SDO satellite, which means most of the images are taken with solar North pointed up. The roll angle of the instrument is reported in the FITS header keyword CROTA2 (see Figure 17 of Couvidat et al. (2016), which states that “the nominal CROTA2 for HMI is ≈179.93”).

The order keyword, below, specifies the type of interpolation; in this case, 3 refers to bi-cubic.

hmi_rotated = hmi_map.rotate(order=3)
HMI magnetogram 2020-01-20 00:00:22

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

Gallery generated by Sphinx-Gallery