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

[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()

For gallery#
[5]:
plt.figure(figsize=(9, 3))
plt.subplots_adjust(top=1.3, wspace=0.2, hspace=0.5)
#
ax1 = plt.subplot2grid((1, 2), (0, 0))
ax1.plot(original['x'], original['y'], 'r-')
ax1.plot(reference['x'], reference['y'], 'b-')
#
ax2 = plt.subplot2grid((1, 2), (0, 1))
ax2.plot(reference['x'], reference['y'], 'b-')
ax2.plot(noised['x'], noised['y'], 'g-')
plt.show()
