Quick Start¶
This page will show some examples to load a sourced dataset or to make quicklook plots. For more details, please refer to the user manual.
More examples can be found here.
Use the Datahub and Dock a Dataset¶
The example below shows how to dock a sourced dataset (Madrigal/EISCAT data) to a datahub. Please refer to the list of the data sources for loading other geospace data.
Use the Geomap Viewer and Create a Map¶
Use the Express Viewer and Create a Figure¶
The quicklook plots are produced by the method “quicklook” of a viewer,
which is custom-designed for a data source. Those specialized viewer can be imported
from geospacelab.express
. The two examples below show the solar wind and geomagnetic
indices, as well as the EISCAT data, respectively.
Solar Wind and Geomagnetic Indices from OMNI and WDC¶
Solar wind and geomagnetic indices data
# Licensed under the BSD 3-Clause License # Copyright (C) 2021 GeospaceLab (geospacelab) # Author: Lei Cai, Space Physics and Astronomy, University of Oulu __author__ = "Lei Cai" __copyright__ = "Copyright 2021, GeospaceLab" __license__ = "BSD-3-Clause License" __email__ = "lei.cai@oulu.fi" __docformat__ = "reStructureText" import datetime import geospacelab.express.omni_dashboard as omni dt_fr = datetime.datetime.strptime('20160321' + '0600', '%Y%m%d%H%M') dt_to = datetime.datetime.strptime('20160330' + '0600', '%Y%m%d%H%M') omni_type = 'OMNI2' # 'OMNI' or 'OMNI2' omni_res = '5min' # '1min' or '5min' load_mode = 'AUTO' dashboard = omni.OMNIDashboard( dt_fr, dt_to, omni_type=omni_type, omni_res=omni_res, load_mode=load_mode ) # data can be retrieved in the same way as in Example 1: dashboard.list_assigned_variables() B_x_gsm = dashboard.get_variable('B_x_GSM', dataset_index=1) # Omni dataset index is 1 in the OMNIDashboard. To check other dashboards, use the method "list_datasets()" print(B_x_gsm) dashboard.quicklook() # save figure dashboard.save_figure()
Output:
EISCAT from Madrigal with Marking Tools¶
1# Licensed under the BSD 3-Clause License 2# Copyright (C) 2021 GeospaceLab (geospacelab) 3# Author: Lei Cai, Space Physics and Astronomy, University of Oulu 4 5__author__ = "Lei Cai" 6__copyright__ = "Copyright 2021, GeospaceLab" 7__license__ = "BSD-3-Clause License" 8__email__ = "lei.cai@oulu.fi" 9__docformat__ = "reStructureText" 10 11import datetime 12import geospacelab.express.eiscat_dashboard as eiscat 13 14dt_fr = datetime.datetime.strptime('20201209' + '1800', '%Y%m%d%H%M') 15dt_to = datetime.datetime.strptime('20201210' + '0600', '%Y%m%d%H%M') 16 17site = 'UHF' 18antenna = 'UHF' 19modulation = '60' 20load_mode = 'AUTO' 21dashboard = eiscat.EISCATDashboard( 22 dt_fr, dt_to, site=site, antenna=antenna, modulation=modulation, load_mode='AUTO', 23 data_file_type = "madrigal-hdf5" 24) 25dashboard.quicklook() 26 27# dashboard.save_figure() # comment this if you need to run the following codes 28# dashboard.show() # comment this if you need to run the following codes. 29 30""" 31As the dashboard class (EISCATDashboard) is a inheritance of the classes Datahub and TSDashboard. 32The variables can be retrieved in the same ways as shown in Example 1. 33""" 34n_e = dashboard.assign_variable('n_e') 35print(n_e.value) 36print(n_e.error) 37 38""" 39Several marking tools (vertical lines, shadings, and top bars) can be added as the overlays 40on the top of the quicklook plot. 41""" 42# add vertical line 43dt_fr_2 = datetime.datetime.strptime('20201209' + '2030', "%Y%m%d%H%M") 44dt_to_2 = datetime.datetime.strptime('20201210' + '0130', "%Y%m%d%H%M") 45dashboard.add_vertical_line(dt_fr_2, bottom_extend=0, top_extend=0.02, label='Line 1', label_position='top') 46# add shading 47dashboard.add_shading(dt_fr_2, dt_to_2, bottom_extend=0, top_extend=0.02, label='Shading 1', label_position='top') 48# add top bar 49dt_fr_3 = datetime.datetime.strptime('20201210' + '0130', "%Y%m%d%H%M") 50dt_to_3 = datetime.datetime.strptime('20201210' + '0430', "%Y%m%d%H%M") 51dashboard.add_top_bar(dt_fr_3, dt_to_3, bottom=0., top=0.02, label='Top bar 1') 52 53# save figure 54dashboard.save_figure() 55# show on screen 56dashboard.show()
Output:
DMSP/SSUSI auroral images¶
1import datetime 2import matplotlib.pyplot as plt 3 4# from geospacelab import preferences as pref 5# pref.user_config['visualization']['mpl']['style'] = 'dark' 6import geospacelab.visualization.mpl.geomap.geodashboards as geomap 7 8 9def test_ssusi(): 10 dt_fr = datetime.datetime(2015, 9, 8, 8) 11 dt_to = datetime.datetime(2015, 9, 8, 23, 59) 12 time1 = datetime.datetime(2015, 9, 8, 20, 21) 13 pole = 'N' 14 sat_id = 'f16' 15 band = 'LBHS' 16 17 # Create a geodashboard object 18 dashboard = geomap.GeoDashboard(dt_fr=dt_fr, dt_to=dt_to, figure_config={'figsize': (5, 5)}) 19 20 # If the orbit_id is specified, only one file will be downloaded. This option saves the downloading time. 21 # dashboard.dock(datasource_contents=['jhuapl', 'dmsp', 'ssusi', 'edraur'], pole='N', sat_id='f17', orbit_id='46863') 22 # If not specified, the data during the whole day will be downloaded. 23 dashboard.dock(datasource_contents=['jhuapl', 'dmsp', 'ssusi', 'edraur'], pole=pole, sat_id=sat_id, orbit_id=None) 24 ds_s1 = dashboard.dock( 25 datasource_contents=['madrigal', 'satellites', 'dmsp', 's1'], 26 dt_fr=time1 - datetime.timedelta(minutes=45), 27 dt_to=time1 + datetime.timedelta(minutes=45), 28 sat_id=sat_id, replace_orbit=True) 29 30 dashboard.set_layout(1, 1) 31 32 # Get the variables: LBHS emission intensiy, corresponding times and locations 33 lbhs = dashboard.assign_variable('GRID_AUR_' + band, dataset_index=1) 34 dts = dashboard.assign_variable('DATETIME', dataset_index=1).value.flatten() 35 mlat = dashboard.assign_variable('GRID_MLAT', dataset_index=1).value 36 mlon = dashboard.assign_variable('GRID_MLON', dataset_index=1).value 37 mlt = dashboard.assign_variable(('GRID_MLT'), dataset_index=1).value 38 39 # Search the index for the time to plot, used as an input to the following polar map 40 ind_t = dashboard.datasets[1].get_time_ind(ut=time1) 41 if (dts[ind_t] - time1).total_seconds()/60 > 60: # in minutes 42 raise ValueError("The time does not match any SSUSI data!") 43 lbhs_ = lbhs.value[ind_t] 44 mlat_ = mlat[ind_t] 45 mlon_ = mlon[ind_t] 46 mlt_ = mlt[ind_t] 47 # Add a polar map panel to the dashboard. Currently the style is the fixed MLT at mlt_c=0. See the keywords below: 48 panel1 = dashboard.add_polar_map( 49 row_ind=0, col_ind=0, style='mlt-fixed', cs='AACGM', 50 mlt_c=0., pole=pole, ut=time1, boundary_lat=55., mirror_south=True 51 ) 52 53 # Some settings for plotting. 54 pcolormesh_config = lbhs.visual.plot_config.pcolormesh 55 # Overlay the SSUSI image in the map. 56 ipc = panel1.overlay_pcolormesh( 57 data=lbhs_, coords={'lat': mlat_, 'lon': mlon_, 'mlt': mlt_}, cs='AACGM', **pcolormesh_config) 58 # Add a color bar 59 panel1.add_colorbar(ipc, c_label=band + " (R)", c_scale=pcolormesh_config['c_scale'], left=1.1, bottom=0.1, 60 width=0.05, height=0.7) 61 62 # Overlay the gridlines 63 panel1.overlay_gridlines(lat_res=5, lon_label_separator=5) 64 65 # Overlay the coastlines in the AACGM coordinate 66 panel1.overlay_coastlines() 67 68 # Overlay cross-track velocity along satellite trajectory 69 sc_dt = ds_s1['SC_DATETIME'].value.flatten() 70 sc_lat = ds_s1['SC_GEO_LAT'].value.flatten() 71 sc_lon = ds_s1['SC_GEO_LON'].value.flatten() 72 sc_alt = ds_s1['SC_GEO_ALT'].value.flatten() 73 sc_coords = {'lat': sc_lat, 'lon': sc_lon, 'height': sc_alt} 74 75 v_H = ds_s1['v_i_H'].value.flatten() 76 panel1.overlay_cross_track_vector( 77 vector=v_H, unit_vector=1000, vector_unit='m/s', alpha=0.3, color='red', 78 sc_coords=sc_coords, sc_ut=sc_dt, cs='GEO', 79 ) 80 # Overlay the satellite trajectory with ticks 81 panel1.overlay_sc_trajectory(sc_ut=sc_dt, sc_coords=sc_coords, cs='GEO') 82 83 # Overlay sites 84 panel1.overlay_sites(site_ids=['TRO', 'ESR'], coords={'lat': [69.58, 78.15], 'lon': [19.23, 16.02], 'height': 0.}, cs='GEO', marker='^', markersize=2) 85 86 # Add the title and save the figure 87 polestr = 'North' if pole == 'N' else 'South' 88 panel1.add_title(title='DMSP/SSUSI, ' + band + ', ' + sat_id.upper() + ', ' + polestr + ', ' + time1.strftime('%Y-%m-%d %H%M UT')) 89 plt.savefig('DMSP_SSUSI_' + time1.strftime('%Y%m%d-%H%M') + '_' + band + '_' + sat_id.upper() + '_' + pole, dpi=300) 90 91 # show the figure 92 plt.show() 93 94 95if __name__ == "__main__": 96 test_ssusi()
Output: