This page was generated by nbsphinx from docs/examples/CDAWeb.ipynb.
Interactive online version: Binder badge Google Colab badge

CDAWeb first steps

Only for Google Colab users:

[ ]:
%pip install --upgrade ipympl speasy
[ ]:
try:
    from google.colab import output
    output.enable_custom_widget_manager()
except:
    print("Not running inside Google Collab")

For all users:

[1]:
import speasy as spz
%matplotlib widget
cda_tree = spz.inventories.tree.cda
# Use this instead if you are not using jupyterlab yet
#%matplotlib notebook
import matplotlib.pyplot as plt
from datetime import datetime

A simple example with MMS FGM data

[5]:
fig = plt.figure()
mms3_fgm_b_gse_srvy = spz.get_data(cda_tree.MMS.MMS3.FGM.MMS3_FGM_SRVY_L2.mms3_fgm_b_gse_srvy_l2_clean, "2015-09-09T08:40",
                                   "2015-09-09T08:55")
mms3_fgm_b_gse_srvy.plot()
plt.tight_layout()
plt.show()

Replacing fill values by NaN and filtering components

Let’s look at the data as we get it on an interval where there are some fill values

[6]:
fig = plt.figure()
mms1_fgm_b_gse_srvy = spz.get_data(cda_tree.MMS.MMS1.FGM.MMS1_FGM_SRVY_L2.mms1_fgm_b_gse_srvy_l2_clean, "2019-01-01",
                                   "2019-01-03")
mms1_fgm_b_gse_srvy.plot()
plt.tight_layout()
plt.show()

Now let’s replace fill values by NaNs

[7]:
fig = plt.figure()
gs = fig.add_gridspec(2, hspace=0)
ax = gs.subplots(sharex=True, sharey=True)
mms1_fgm_b_gse_srvy = spz.get_data(cda_tree.MMS.MMS1.FGM.MMS1_FGM_SRVY_L2.mms1_fgm_b_gse_srvy_l2_clean, "2019-01-01",
                                   "2019-01-03")
mms1_fgm_b_gse_srvy["Bx GSE", "By GSE", "Bz GSE"].replace_fillval_by_nan().plot(ax=ax[0])
mms1_fgm_b_gse_srvy["Bt"].replace_fillval_by_nan().plot(ax=ax[1])
plt.tight_layout()
plt.show()

Another example with an MMS FPI spectrogram

[9]:
mms1_dis_energyspectr_omni_fast = spz.get_data(
    cda_tree.MMS.MMS1.DIS.MMS1_FPI_FAST_L2_DIS_MOMS.mms1_dis_energyspectr_omni_fast, "2019-01-02T15:30",
    "2019-01-02T20")

plt.figure()
mms1_dis_energyspectr_omni_fast.plot["matplotlib"].colormap(cmap='viridis')
plt.tight_layout()
plt.show()