Covariance calculation

This is a brief document describing where we learn how to access how we can calculate and use the covariance and weight properties of the quadtree. More, detailed information how kite calculates the covariance matrix can be found at the module docmentation kite.Covariance.

Accessing the Covariance

In this example we will access the covariance attributes of a pre-configured scene.

from kite import Scene
import matplotlib.pyplot as plt

# Assume we have a existing kite.Scene with defined quadtree parametrized
scene = Scene.load('acquila_2016.yml')

ax = plt.gca()
# Inspect the noise data which is used to calculate the covariance
ax.imshow(scene.covariance.noise_data)
plt.show()

# Inspect the focal-point (quick mode) covariance matrix
ax.imshow(scene.covariance.covariance_matrix_focal)

# Inspect the full covariance matrix
ax.imshow(scene.covariance.covariance_matrix)

# Get the full weight matrix
ax.imshow(scene.covariance.weight_matrix)

# Get the covariance and weight between two leafes
leaf_1 = scene.quadtree.leaves[0]
leaf_2 = scene.quadtree.leaves[0]

scene.covariance.getLeafCovariance(leaf_1, leaf_2)
scene.covariance.getLeafWeight(leaf_1, leaf_2)

Graphical Inspection and Tuning of the Covariance

The covariance can be manipulated through spool. More information here Covariance parametrisation.

Manual Covariance Tuning

The covariance can be manipulated by editing the .yml file. Or by changing the covariance parameters during runtime:

scene.covariance.a = 1.412e-4
scene.covariance.b = 1.2521

# Will show the updated covariance
plt.imshow(scene.covariance.covariance_focal)

# Will calculate the covariance matrix
scene.covariance
scene.save('filename')