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.
Importing Tracklib#
[1]:
import matplotlib.pyplot as plt
import os
import sys
# Import the Tracklib library
import tracklib as tkl
Code running in a no shapely environment
[2]:
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
[3]:
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#
[4]:
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()