Analyze and plot loaded CDMs

Analyze and plot loaded CDMs#

In this tutorial, we show how to analyze and plot CDM data.

We assume that data has been loaded (see Basics on how to do it) and that events are stored in the events variable.

import kessler
from kessler import EventDataset
path_to_cdms_folder='synthetic_cdms'
events=kessler.EventDataset(cdms_dir=path_to_cdms_folder,cdm_extension='.kvn')
#events=EventDataset(path_to_cdms_folder)
Loading CDMS (with extension .kvn) from directory: synthetic_cdms
Loaded 14 CDMs grouped into 2 events

Then, we can first inspect some descriptive statistics and save it to a file:

import pandas as pd
events_stats=events.to_dataframe().describe()
Converting EventDataset to DataFrame
Time spent  | Time remain.| Progress             | Events | Events/sec
0d:00:00:00 | 0d:00:00:00 | ##########---------- | 1/2 | 102.19       
0d:00:00:00 | 0d:00:00:00 | #################### | 2/2 | 82.96       

Now, we can proceed in plotting events features. First, we start by plotting a single feature of a specific event (e.g. the 31st one):

events[0].plot_feature('OBJECT1_CT_T', file_name='single_feature_single_event.pdf')
Plotting to file: single_feature_single_event.pdf
../_images/badf97690256dc1af50df4ffd523572cf3e6cf6a6d56e8ddcc5fbd87bf6ca526.png

But we can also plot multiple features of multiple events in the same figure:

features=['OBJECT1_CT_T', 'OBJECT2_CT_T']
events.plot_features(features, file_name='multi_features_multi_events.pdf')
Plotting to file: multi_features_multi_events.pdf
../_images/e9779726786ded903561fd976920a74137b87db8b437b8039be11139f4a4007d.png

Furthermore, we can leverage a built-in function to plot the covariance matrix evolution of a specific event (all the covariance matrix elements will be plotted in multiple sub-figures):

events[1].plot_uncertainty(file_name='uncertainties_single_event.pdf')
Plotting to file: uncertainties_single_event.pdf
../_images/e73633fabf3ade5ff61c5d7b9657a7c678269678ce0841bf9622daac5fdacfc0.png

And we can do the same as above, but for all the events:

events.plot_uncertainty(file_name='uncertainties_multi_events.pdf')
Plotting to file: uncertainties_multi_events.pdf
../_images/9694d28ded011b3fe35d955915ae2065282c4b3f8d58009ec4353f5cc6fc8ccb.png

Note that all these plotting methods support an optional apply_func argument that allows to apply a custom lambda function to the data before plotting.