Note
Go to the end to download the full example code.
Plots fits files for a selected imager¶
This example shows how to download data for a selected imager, process the fits files, and plot an image.
Import Required Modules
from datetime import datetime, timedelta
import matplotlib.pyplot as plt
from sunpy.net import attrs as a
from PyThea.config import selected_imagers
from PyThea.utils import (download_fits, load_fits, make_figure,
single_imager_maps_process)
Select the imager and specify the time range of the query.
imager = 'LC2'
date_process = datetime.strptime('2021-10-28T16:30:00', '%Y-%m-%dT%H:%M:%S')
time_range = [-1, 1]
timerange = a.Time(date_process + timedelta(hours=time_range[0]),
date_process + timedelta(hours=time_range[1]))
Download the fits files from VSO using the download_fits
utility.
Results from 1 Provider:
10 Results from the VSOClient:
Source: http://vso.stanford.edu/cgi-bin/search
Total estimated size: 21.084 Mbyte
Start Time End Time Source ... Extent Type Size
... Mibyte
----------------------- ----------------------- ------ ... ----------- -------
2021-10-28 15:36:06.000 2021-10-28 15:36:31.000 SOHO ... CORONA 2.01074
2021-10-28 15:48:05.000 2021-10-28 15:48:31.000 SOHO ... CORONA 2.01074
2021-10-28 16:00:05.000 2021-10-28 16:00:30.000 SOHO ... CORONA 2.01074
2021-10-28 16:12:05.000 2021-10-28 16:12:30.000 SOHO ... CORONA 2.01074
2021-10-28 16:24:06.000 2021-10-28 16:24:31.000 SOHO ... CORONA 2.01074
2021-10-28 16:36:05.000 2021-10-28 16:36:30.000 SOHO ... CORONA 2.01074
2021-10-28 16:48:05.000 2021-10-28 16:48:30.000 SOHO ... CORONA 2.01074
2021-10-28 17:00:05.000 2021-10-28 17:00:30.000 SOHO ... CORONA 2.01074
2021-10-28 17:12:06.000 2021-10-28 17:12:31.000 SOHO ... CORONA 2.01074
2021-10-28 17:24:05.000 2021-10-28 17:24:30.000 SOHO ... CORONA 2.01074
Files Downloaded: 0%| | 0/10 [00:00<?, ?file/s]
Files Downloaded: 60%|██████ | 6/10 [00:00<00:00, 43.28file/s]
Files Downloaded: 100%|██████████| 10/10 [00:00<00:00, 67.42file/s]
Process the downloaded fits files using the single_imager_maps_process
utility. We select to process the maps into running differences images.
processed_images = single_imager_maps_process(maps,
**selected_imagers.imager_dict[imager]['process'],
image_mode='Running Diff.',
diff_num=1)
Preparing image sequence for C2. This could take a while...
INFO: Obtained JPL HORIZONS location for SOHO (spacecraft) (-21) [sunpy.coordinates.ephemeris]
Plot the first image using the make_figure
utility.
fig, ax = make_figure(processed_images[0], cmap='Greys_r', clim=[-20, 20], clip_model=True)
plt.show()
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]
INFO: Missing metadata for solar radius: assuming the standard radius of the photosphere. [sunpy.map.mapbase]
Total running time of the script: (0 minutes 6.209 seconds)