Downloading and plotting LASCO C3 data

How to download SOHO/LASCO C3 data with Fido and make a plot.

import matplotlib.pyplot as plt

import sunpy.map
from sunpy.io.file_tools import read_file
from sunpy.net import Fido
from sunpy.net import attrs as a

In order to download the required data, we use sunpy.net.Fido, a downloader client. We define two search variables: a timerange and the instrument.

timerange = a.Time('2002/05/24 11:06', '2002/05/24 11:07')
instrument = a.Instrument.lasco
detector = a.Detector.c3
result = Fido.search(timerange, instrument)

Let’s inspect the result

print(result)

Out:

Results from 1 Provider:

2 Results from the VSOClient:
   Start Time [1]       End Time [1]    Source Instrument  Type
------------------- ------------------- ------ ---------- ------
2002-05-24 11:05:48 2002-05-24 11:06:14   SOHO      LASCO CORONA
2002-05-24 11:06:05 2002-05-24 11:06:31   SOHO      LASCO CORONA

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_files = Fido.fetch(result)
print(downloaded_files)

Out:

Files Downloaded:   0%|          | 0/2 [00:00<?, ?file/s]


22119649.fts:   0%|          | 0.00/2.11M [00:00<?, ?B/s]

25119649.fts:   0%|          | 0.00/4.20M [00:00<?, ?B/s]

25119649.fts:   5%|4         | 206k/4.20M [00:00<00:01, 2.06MB/s]


22119649.fts:   6%|6         | 128k/2.11M [00:00<00:01, 1.22MB/s]

25119649.fts:  14%|#3        | 570k/4.20M [00:00<00:01, 2.28MB/s]


22119649.fts:  32%|###2      | 683k/2.11M [00:00<00:00, 1.52MB/s]

25119649.fts:  22%|##2       | 943k/4.20M [00:00<00:01, 2.57MB/s]


22119649.fts:  50%|#####     | 1.06M/2.11M [00:00<00:00, 1.84MB/s]

25119649.fts:  36%|###6      | 1.52M/4.20M [00:00<00:00, 3.05MB/s]


22119649.fts:  82%|########2 | 1.73M/2.11M [00:00<00:00, 2.33MB/s]

25119649.fts:  53%|#####2    | 2.21M/4.20M [00:00<00:00, 3.66MB/s]


22119649.fts:  98%|#########7| 2.06M/2.11M [00:00<00:00, 2.53MB/s]
Files Downloaded:  50%|#####     | 1/2 [00:00<00:00,  1.34file/s]

25119649.fts:  80%|#######9  | 3.35M/4.20M [00:00<00:00, 4.46MB/s]
Files Downloaded: 100%|##########| 2/2 [00:00<00:00,  2.49file/s]
['/home/docs/sunpy/data/22119649.fts', '/home/docs/sunpy/data/25119649.fts']

The downloaded file lacks the correct meta. We want to open the file and access both the data and the header information.

data, header = read_file(downloaded_files[0])[0]

# Add the missing meta information to the header
header['CUNIT1'] = 'arcsec'
header['CUNIT2'] = 'arcsec'

Out:

/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/astropy/io/fits/verify.py:117: VerifyWarning: Verification reported errors:
  warnings.warn(line, VerifyWarning)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/astropy/io/fits/verify.py:117: VerifyWarning: Card 78:
  warnings.warn(line, VerifyWarning)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/astropy/io/fits/verify.py:117: VerifyWarning:     Unfixable error: Unprintable string 'offset_bias.pro\t1.24 12/13/01, 591.583'; commentary cards may only contain printable ASCII characters
  warnings.warn(line, VerifyWarning)
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/astropy/io/fits/verify.py:117: VerifyWarning: Note: astropy.io.fits uses zero-based indexing.

  warnings.warn(line, VerifyWarning)

With this fix we can load it into a map and plot the results. Please note that there is no plot displayed below as this example is skipped due to timeouts that can occur when you try to download LASCO C3 data.

lascomap = sunpy.map.Map(data, header)
fig = plt.figure()
lascomap.plot()
plt.show()
LASCO-C2 white-light 2002-05-24 11:06:05

Out:

/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/astropy/wcs/wcs.py:684: FITSFixedWarning: 'datfix' made the change 'Set MJD-OBS to 52418.462567 from DATE-OBS.
Changed DATE-OBS from '2002/05/24T11:06:05.762' to '2002-05-24T11:06:05.762''.
  warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/sunpy/conda/stable/lib/python3.8/site-packages/sunpy/map/mapbase.py:838: SunpyUserWarning: Missing metadata for observer: assuming Earth-based observer.

  warnings.warn(warning_message, SunpyUserWarning)

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

Gallery generated by Sphinx-Gallery