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 Time-Series Viewer and Create a Figure

Add Indicators

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

examples/demo_omni_data.py
# 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 = '1min'       # '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=0)    # Omni dataset index is 1 in the OMNIDashboard. To check other dashboards, use the method "list_datasets()"
print(B_x_gsm)

dashboard.quicklook()

dashboard.list_assigned_variables()

# save figure
dashboard.save_figure()

Output:

IMF and solar wind from the OMNI database and the geomagnetic indices from WDC and GFZ

EISCAT from Madrigal with Marking Tools

examples/demo_eiscat_quicklook.py
 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:

EISCAT quicklook

DMSP/SSUSI auroral images

examples/demo_dmsp_ssusi_single_panel.py
  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
 11
 12import datetime
 13import matplotlib.pyplot as plt
 14
 15# from geospacelab import preferences as pref
 16# pref.user_config['visualization']['mpl']['style'] = 'dark'
 17import geospacelab.visualization.mpl.geomap.geodashboards as geomap
 18
 19
 20def test_ssusi():
 21    dt_fr = datetime.datetime(2015, 9, 8, 8)
 22    dt_to = datetime.datetime(2015, 9, 8, 23, 59)
 23    time1 = datetime.datetime(2015, 9, 8, 20, 21)
 24    pole = 'N'
 25    sat_id = 'f16'
 26    band = 'LBHS'
 27
 28    # Create a geodashboard object
 29    dashboard = geomap.GeoDashboard(dt_fr=dt_fr, dt_to=dt_to, figure_config={'figsize': (5, 5)})
 30
 31    # If the orbit_id is specified, only one file will be downloaded. This option saves the downloading time.
 32    # dashboard.dock(datasource_contents=['jhuapl', 'dmsp', 'ssusi', 'edraur'], pole='N', sat_id='f17', orbit_id='46863')
 33    # If not specified, the data during the whole day will be downloaded.
 34    dashboard.dock(datasource_contents=['jhuapl', 'dmsp', 'ssusi', 'edraur'], pole=pole, sat_id=sat_id, orbit_id=None)
 35    ds_s1 = dashboard.dock(
 36        datasource_contents=['madrigal', 'satellites', 'dmsp', 's1'],
 37        dt_fr=time1 - datetime.timedelta(minutes=45),
 38        dt_to=time1 + datetime.timedelta(minutes=45),
 39        sat_id=sat_id, replace_orbit=True)
 40
 41    dashboard.set_layout(1, 1)
 42
 43    # Get the variables: LBHS emission intensiy, corresponding times and locations
 44    lbhs = dashboard.assign_variable('GRID_AUR_' + band, dataset_index=0)
 45    dts = dashboard.assign_variable('DATETIME', dataset_index=0).value.flatten()
 46    mlat = dashboard.assign_variable('GRID_MLAT', dataset_index=0).value
 47    mlon = dashboard.assign_variable('GRID_MLON', dataset_index=0).value
 48    mlt = dashboard.assign_variable(('GRID_MLT'), dataset_index=0).value
 49
 50    # Search the index for the time to plot, used as an input to the following polar map
 51    ind_t = dashboard.datasets[0].get_time_ind(ut=time1)
 52    if (dts[ind_t] - time1).total_seconds()/60 > 60:     # in minutes
 53        raise ValueError("The time does not match any SSUSI data!")
 54    lbhs_ = lbhs.value[ind_t]
 55    mlat_ = mlat[ind_t]
 56    mlon_ = mlon[ind_t]
 57    mlt_ = mlt[ind_t]
 58    # Add a polar map panel to the dashboard. Currently the style is the fixed MLT at mlt_c=0. See the keywords below:
 59    panel1 = dashboard.add_polar_map(
 60        row_ind=0, col_ind=0, style='mlt-fixed', cs='AACGM',
 61        mlt_c=0., pole=pole, ut=time1, boundary_lat=55., mirror_south=True
 62    )
 63
 64    # Some settings for plotting.
 65    pcolormesh_config = lbhs.visual.plot_config.pcolormesh
 66    # Overlay the SSUSI image in the map.
 67    ipc = panel1.overlay_pcolormesh(
 68        data=lbhs_, coords={'lat': mlat_, 'lon': mlon_, 'mlt': mlt_}, cs='AACGM', **pcolormesh_config)
 69    # Add a color bar
 70    panel1.add_colorbar(ipc, c_label=band + " (R)", c_scale=pcolormesh_config['c_scale'], left=1.1, bottom=0.1,
 71                        width=0.05, height=0.7)
 72
 73    # Overlay the gridlines
 74    panel1.overlay_gridlines(lat_res=5, lon_label_separator=5)
 75
 76    # Overlay the coastlines in the AACGM coordinate
 77    panel1.overlay_coastlines()
 78
 79    # Overlay cross-track velocity along satellite trajectory
 80    sc_dt = ds_s1['SC_DATETIME'].value.flatten()
 81    sc_lat = ds_s1['SC_GEO_LAT'].value.flatten()
 82    sc_lon = ds_s1['SC_GEO_LON'].value.flatten()
 83    sc_alt = ds_s1['SC_GEO_ALT'].value.flatten()
 84    sc_coords = {'lat': sc_lat, 'lon': sc_lon, 'height': sc_alt}
 85
 86    v_H = ds_s1['v_i_H'].value.flatten()
 87    panel1.overlay_cross_track_vector(
 88        vector=v_H, unit_vector=1000, vector_unit='m/s', alpha=0.3, color='red',
 89        sc_coords=sc_coords, sc_ut=sc_dt, cs='GEO',
 90    )
 91    # Overlay the satellite trajectory with ticks
 92    panel1.overlay_sc_trajectory(sc_ut=sc_dt, sc_coords=sc_coords, cs='GEO')
 93
 94    # Overlay sites
 95    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)
 96
 97    # Add the title and save the figure
 98    polestr = 'North' if pole == 'N' else 'South'
 99    panel1.add_title(title='DMSP/SSUSI, ' + band + ', ' + sat_id.upper() + ', ' + polestr + ', ' + time1.strftime('%Y-%m-%d %H%M UT'))
100    plt.savefig('DMSP_SSUSI_' + time1.strftime('%Y%m%d-%H%M') + '_' + band + '_' + sat_id.upper() + '_' + pole, dpi=300)
101
102    # show the figure
103    plt.show()
104
105
106if __name__ == "__main__":
107    test_ssusi()

Output:

DMSP SSUSI image