Querying the GOES flare event list

How to retrieve the GOES flare event list through use of sunpy’s Heliophysics Event Knowledgebase (HEK) client.

from sunpy.net import Fido
from sunpy.net import attrs as a

We use Fido to to query the HEK catalogue. We define our event type as a flare (“FL”). We also set up the start and end times over which we will search for flare events. We want the list of events that were detected by the GOES X-ray Sensor (XRS) instrument between tstart and tend and GOES class > M1.0.

event_type = "FL"
tstart = "2013/10/28"
tend = "2013/10/29"
result = Fido.search(a.Time(tstart, tend),
                     a.hek.FL.GOESCls > "M1.0",
                     a.hek.OBS.Observatory == "GOES")

The result is returned as a UnifiedResponse, from which we can see a table from one provider is found and returned.

# Here we only show two columns due there being over 100 columns returned normally.
print(result.show("hpc_bbox", "refs"))

# It"s also possible to access the HEK results from the
# `~sunpy.net.fido_factory.UnifiedResponse` by name.

hek_results = result["hek"]
Results from 1 Provider:

7 Results from the HEKClient:

                                              hpc_bbox                                               ...
---------------------------------------------------------------------------------------------------- ...
POLYGON((16.92036 -63.6504,16.92036 -63.6504,16.92036 -63.6504,16.92036 -63.6504,16.92036 -63.6504)) ...
     POLYGON((16.9209 -63.4614,16.9209 -63.4614,16.9209 -63.4614,16.9209 -63.4614,16.9209 -63.4614)) ...
POLYGON((16.92216 -62.9952,16.92216 -62.9952,16.92216 -62.9952,16.92216 -62.9952,16.92216 -62.9952)) ...
                  POLYGON((0.000084 -961.62,-0.000084 -961.62,0 962.358,0 962.358,0.000084 -961.62)) ...
                 POLYGON((0.000084 -961.632,-0.000084 -961.632,0 962.37,0 962.37,0.000084 -961.632)) ...
               POLYGON((0.000084 -961.638,-0.000084 -961.638,0 962.376,0 962.376,0.000084 -961.638)) ...
               POLYGON((0.000084 -961.734,-0.000084 -961.734,0 962.466,0 962.466,0.000084 -961.734)) ...

We can also print the key-values that correspond to the HEK parameters returned in result[0]. The .table attribute returns an Table.

['gs_thumburl', 'comment_count', 'hpc_bbox', 'frm_humanflag', 'hgc_coord', 'event_coordsys', 'obs_levelnum', 'hpc_coord', 'event_npixels', 'gs_imageurl', 'ar_polarity', 'frm_paramset', 'hrc_coord', 'event_starttime', 'ar_mtwilsoncls', 'event_type', 'intensmin', 'fl_fluence', 'obs_meanwavel', 'frm_url', 'skel_chaincode', 'bound_chaincode', 'noposition', 'fl_fluenceunit', 'active', 'intensmax', 'frm_versionnumber', 'fl_peaktempunit', 'fl_halphaclass', 'area_uncert', 'obs_dataprepurl', 'hpc_geom', 'hgc_bbox', 'intensmedian', 'chaincodetype', 'obs_channelid', 'event_clippedspatial', 'ar_noaaclass', 'SOL_standard', 'event_avg_rating', 'eventtype', 'intensunit', 'hpc_boundcc', 'event_mapurl', 'frm_contact', 'ar_penumbracls', 'intensmean', 'bound_ccstartc1', 'frm_name', 'area_atdiskcenter', 'frm_identifier', 'obs_observatory', 'event_description', 'boundbox_c2ur', 'obs_firstprocessingdate', 'boundbox_c2ll', 'frm_institute', 'hrc_bbox', 'refs_orig', 'ar_mcintoshcls', 'event_maskurl', 'bound_ccstartc2', 'gs_movieurl', 'event_score', 'skel_startc2', 'skel_startc1', 'fl_efoldtime', 'event_expires', 'fl_efoldtimeunit', 'hrc_boundcc', 'event_probability', 'intensvar', 'frm_daterun', 'event_coordunit', 'hpc_y', 'hpc_x', 'search_instrument', 'ar_numspots', 'kb_archivdate', 'kb_archivist', 'intenstotal', 'sum_overlap_scores', 'hgs_boundcc', 'intensskew', 'obs_includesnrt', 'rasterscan', 'obs_wavelunit', 'kb_archivid', 'search_frm_name', 'boundbox_c1ur', 'ar_noaanum', 'area_atdiskcenteruncert', 'boundbox_c1ll', 'event_importance_num_ratings', 'ar_compactnesscls', 'skel_curvature', 'event_testflag', 'event_c2error', 'hrc_r', 'skel_nsteps', 'hgs_y', 'obs_title', 'fl_peakemunit', 'hgs_x', 'hcr_checked', 'frm_specificid', 'event_title', 'obs_instrument', 'event_c1error', 'revision', 'hpc_radius', 'event_endtime', 'event_importance', 'event_coord2', 'event_coord3', 'event_coord1', 'search_observatory', 'area_raw', 'concept', 'event_pixelunit', 'hgc_boundcc', 'fl_peakflux', 'hgc_x', 'hrc_a', 'event_peaktime', 'hgc_y', 'gs_galleryid', 'fl_goescls', 'hgs_coord', 'ar_zurichcls', 'bound_ccnsteps', 'intenskurt', 'event_clippedtemporal', 'fl_peakfluxunit', 'fl_peakem', 'rasterscantype', 'search_channelid', 'fl_peaktemp', 'hgs_bbox', 'area_unit', 'obs_lastprocessingdate', 'refs']

The results returned to the HEKTable contain a lot of information and we may only want to keep some main results such as start time, end time, peak time, GOES-class, and active region number. This can be done as so:

new_table = hek_results["event_starttime", "event_peaktime",
                        "event_endtime", "fl_goescls", "ar_noaanum"]

These results can then be saved to a CSV file, or any other file format that Table supports.

new_table.write("october_M1_flares.csv", format="csv")

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

Gallery generated by Sphinx-Gallery