Align two tracks#

Align two tracks with different coordinate systems with a geometric affine transformation.

The function to map a track on a track is: mapOn.

Let’s start by importing tracklib library#

The first task is only useful for the online notebook and import the local tracklib code source. It’s not necessary if tracklib is installed from PyPI.

[1]:
import matplotlib.pyplot as plt
import os
import sys

#-------------------------------------------------------
# 1. [if tracklib is not installed using pip] add tracklib's local path in the python path
module_path = os.path.abspath(os.path.join('../../..'))
if module_path not in sys.path:
    sys.path.append(module_path)

# 2. Import
import tracklib as tkl

The following two imports are necessary for the tutorial:

[2]:
import matplotlib.pyplot as plt
[3]:
tkl.seed(123)

reference = tkl.generate(0.2, dt=10)

noised = tkl.noise(reference, 3, tkl.ExponentialKernel(100))
noised = tkl.noise(noised, 20, tkl.GaussianKernel(1000))
original = noised.copy()

print (reference.size(), noised.size())

plt.plot(noised['x'], noised['y'], 'r-')
plt.plot(reference['x'], reference['y'], 'b-')
plt.show()
Generated track from 05/02/2042 00:44:56 to 05/02/2042 01:44:56 [360 pts, 159.24m]
360 360
../_images/userguide_UG_MapOn_5_1.png
[4]:
tkl.mapping.mapOn(noised, reference, TP1=range(len(noised)), verbose=False)

plt.plot(reference['x'], reference['y'], 'b-')
plt.plot(noised['x'], noised['y'], 'g-')
plt.show()
../_images/userguide_UG_MapOn_6_0.png