.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/Utilites/download_process_fits_files.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_Utilites_download_process_fits_files.py: Download and process fits files ------------------------------- In this example, using the utility `download_fits` we download data for a selected imager and then process the fits files. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Import Required Modules .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: Python from datetime import datetime, timedelta from sunpy.net import attrs as a from PyThea.config import selected_imagers from PyThea.utils import download_fits, load_fits, single_imager_maps_process .. GENERATED FROM PYTHON SOURCE LINES 18-19 Retrieve the list of available imagers and their corresponding keys using the following, .. GENERATED FROM PYTHON SOURCE LINES 19-25 .. code-block:: Python for key in selected_imagers.imager_dict.keys(): imager = selected_imagers.imager_dict[key] detector_or_wavelenght = imager['detector'] if 'detector' in imager else imager['wavelength'] print(f'{imager["source"]}/{imager["instrument"]}-{detector_or_wavelenght}: {key}') .. rst-class:: sphx-glr-script-out .. code-block:: none SOHO/LASCO-C2: LC2 SOHO/LASCO-C3: LC3 SDO/AIA-193: AIA-193 SDO/AIA-211: AIA-211 STEREO_A/SECCHI-COR2: COR2A STEREO_B/SECCHI-COR2: COR2B STEREO_A/SECCHI-EUVI: EUVIA STEREO_B/SECCHI-EUVI: EUVIB STEREO_A/SECCHI-COR1: COR1A STEREO_B/SECCHI-COR1: COR1B STEREO_A/SECCHI-HI1: HI1A STEREO_B/SECCHI-HI1: HI1B STEREO_A/SECCHI-HI2: HI2A STEREO_B/SECCHI-HI2: HI2B PSP/WISPR-Inner: WISPR1 PSP/WISPR-Outer: WISPR2 SOLO/EUI-FSI-174: EUI-FSI SOLO/METIS-VLD: METIS SOLO/SOLOHI-T1: SOLOHI-T1 SOLO/SOLOHI-T2: SOLOHI-T2 SOLO/SOLOHI-T3: SOLOHI-T3 SOLO/SOLOHI-T4: SOLOHI-T4 .. GENERATED FROM PYTHON SOURCE LINES 26-27 First, select the imager and specify the time range of the query. For this example we will download data from SOHO LASCO coronagraph. .. GENERATED FROM PYTHON SOURCE LINES 27-37 .. code-block:: Python # Set the SOHO LASCO imager key. imager = 'LC2' # Query data for one hour before and one hour after a selected time. 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])) .. GENERATED FROM PYTHON SOURCE LINES 38-39 Download the fits files from VSO using the ``download_fits`` utility. .. GENERATED FROM PYTHON SOURCE LINES 39-44 .. code-block:: Python files = download_fits(timerange, imager) print(f'Files downloaded from VSO: {len(files)}') .. rst-class:: sphx-glr-script-out .. code-block:: none Results from 1 Provider: 10 Results from the VSOClient: Source: https://sdac.virtualsolar.org/cgi/search Data retrieval status: https://docs.virtualsolar.org/wiki/VSOHealthReport Total estimated size: 21.084 Mbyte Start Time End Time Source Instrument Provider Physobs Extent Type Size Mibyte ----------------------- ----------------------- ------ ---------- -------- --------- ----------- ------- 2021-10-28 15:36:06.000 2021-10-28 15:36:31.000 SOHO LASCO SDAC intensity CORONA 2.01074 2021-10-28 15:48:05.000 2021-10-28 15:48:31.000 SOHO LASCO SDAC intensity CORONA 2.01074 2021-10-28 16:00:05.000 2021-10-28 16:00:30.000 SOHO LASCO SDAC intensity CORONA 2.01074 2021-10-28 16:12:05.000 2021-10-28 16:12:30.000 SOHO LASCO SDAC intensity CORONA 2.01074 2021-10-28 16:24:06.000 2021-10-28 16:24:31.000 SOHO LASCO SDAC intensity CORONA 2.01074 2021-10-28 16:36:05.000 2021-10-28 16:36:30.000 SOHO LASCO SDAC intensity CORONA 2.01074 2021-10-28 16:48:05.000 2021-10-28 16:48:30.000 SOHO LASCO SDAC intensity CORONA 2.01074 2021-10-28 17:00:05.000 2021-10-28 17:00:30.000 SOHO LASCO SDAC intensity CORONA 2.01074 2021-10-28 17:12:06.000 2021-10-28 17:12:31.000 SOHO LASCO SDAC intensity CORONA 2.01074 2021-10-28 17:24:05.000 2021-10-28 17:24:30.000 SOHO LASCO SDAC intensity CORONA 2.01074 Files Downloaded: 0%| | 0/10 [00:00, ), 'polar': 'Clear', 'superpixel': 2} .. GENERATED FROM PYTHON SOURCE LINES 61-62 At the last step, the images are callibrated and resampled using SynPy's ``superpixel`` method and the final maps are processed into running/base difference or plain image sequence maps. .. GENERATED FROM PYTHON SOURCE LINES 62-69 .. code-block:: Python processed_images = single_imager_maps_process(maps, **selected_imagers.imager_dict[imager]['process'], image_mode='Running Diff.', diff_num=1) # These images can now be used in the fitting process or just plot them (see example). .. rst-class:: sphx-glr-script-out .. code-block:: none Preparing image sequence for C2. This could take a while... INFO: Obtained JPL HORIZONS location for SOHO (spacecraft) (-21) [sunpy.coordinates.ephemeris] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 7.425 seconds) .. _sphx_glr_download__examples_Utilites_download_process_fits_files.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: download_process_fits_files.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: download_process_fits_files.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: download_process_fits_files.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_