Querying the GOES flare event list through the HEK

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

from sunpy.net import hek

We first set up the HEK client and define our event type that we will search for, which is flare (‘FL’). We also set up the start and end times over which we will search for flare events.

client = hek.HEKClient()
event_type = 'FL'

tstart = '2013/10/28'
tend = '2013/10/29'

We then use the client to query the HEK for a list of events that were detected by the GOES X-ray Sensor (XRS) instrument between tstart and tend.

result = client.search(hek.attrs.Time(tstart, tend),
                       hek.attrs.EventType(event_type),
                       hek.attrs.OBS.Observatory == 'GOES')

The result is returned as a HEKTable. We can print the number of flares and inspect the result information. We can also print the key-values that correspond to the HEK parameters returned in result.

print(len(result))
print(result)
print(result.keys())

Out:

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

We can also specify what GOES class flares we want to query. For example, let’s search only for large solar flares with a GOES class > M1.0. This can be achieved by using the FL.GOESCls attribute of the HEK client:

result_m1 = client.search(hek.attrs.Time(tstart, tend),
                          hek.attrs.EventType(event_type),
                          hek.attrs.FL.GOESCls > 'M1.0',
                          hek.attrs.OBS.Observatory == 'GOES')

print(result_m1)

Out:

         SOL_standard          active ... skel_startc2 sum_overlap_scores
------------------------------ ------ ... ------------ ------------------
SOL2013-10-28T01:41:00L031C086   true ...         None                  0
SOL2013-10-28T04:32:00L034C082   true ...         None                  0
SOL2013-10-28T11:32:00L003C106   true ...         None                  0
SOL2013-10-28T14:00:00L319C090   true ...         None                  0
SOL2013-10-28T14:46:00L318C090   true ...         None                  0
SOL2013-10-28T15:07:00L318C090   true ...         None                  0
SOL2013-10-28T20:48:00L315C090   true ...         None                  0

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 = result_m1[['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 1.899 seconds)

Gallery generated by Sphinx-Gallery