Plotting Functionalities#

In this tutorial, we shed some light on all the plotting functionalities of Kessler, and how to use them..

We tackle the following:

  • TLEs loading and plotting of their distributions

  • plot distributions from synthetically generated CDMs (these are generated using the probabilistic programming module, see the related tutorial probabilistic_programming_module.ipynb for a guide on how to use it)

  • plot orbits from trace of synthetic CDMs

**Note**: A probabilistic program 'trace' is a record of all the random variables sampled in the program execution.

Let’s dive into these functionalities..

Imports#

import kessler
import dsgp4
import pickle

First, let’s load the population#

This is here a file of TLEs (e.g. from Space-Track or Celestrack).. we use dsgp4 to handle TLEs

tles=dsgp4.tle.load('tles_sample_population.txt')

Let’s plot the distribution of the TLE elements from the loaded file

kessler.plot.plot_tles(tles)
../_images/df996ae0e463739924a1db5e4705694dbc38a20c48fb5ec8208444d22b15328d.png

Plotting priors from TLEs#

We can fit mixtures to the prior distribution and for instance use them as priors in the probabilistic programming module.

Here, we show how to display the prior :

priors=kessler.util.create_priors_from_tles(tles, mixture_components = {'mean_motion': 5, 'eccentricity': 5, 'inclination': 13, 'b_star': 4})
#we also extract the mean motion alues from the TLEs, to then have the minimum and maximum values for the mean motion priors (else the priors will be wide and you cannot see anything)
mean_motions=[el.mean_motion for el in tles]
kessler.plot.plot_mix(mix=priors['mean_motion_prior'],              
                      min_val=min(mean_motions),
                      max_val=max(mean_motions),
                      xlabel='Mean Motion',
                      figsize=(10,8),
                      linewidth=4.,
                      color='dodgerblue',
                      resolution=1000)
../_images/10b021ceba9fe7526359a52fad77984841cae81dd53dd7f8ff34810db667c55b.png
<Axes: xlabel='Mean Motion', ylabel='Probability'>

Or in log-scale

kessler.plot.plot_mix(mix = priors['mean_motion_prior'], 
                      min_val=min(mean_motions), 
                      max_val=max(mean_motions), 
                      log_yscale=True,
                      xlabel='Mean Motion',
                      figsize=(10,8),
                      linewidth=4.,
                      color='dodgerblue',
                      resolution=1000)
../_images/f811b8c465d4e4773d69aa0881fedd87548e348471e050d9588284b17b5f7f5b.png
<Axes: xlabel='Mean Motion', ylabel='Probability'>

Plotting Orbit from Trace#

Let’s load the generated trace:

with open('trace.pickle', 'rb') as f:
    trace = pickle.load(f)
kessler.plot.plot_trace_orbit(trace=trace[0])
<Axes: xlabel='y', ylabel='z'>
../_images/0c0666f520a8811b6f7085a2dcdfc966aabbc8d4506ce652ec7bdf62e57a28e0.png