Track#

class core.track.Track(list_of_obs=None, user_id=0, track_id=0, base=None)[source]#

Bases: object

Representation of a GPS track.

__init__(list_of_obs=None, user_id=0, track_id=0, base=None)[source]#

Takes a (possibly empty) list of points as input

copy()[source]#

TODO

__str__()[source]#

TODO

Return type:

str

getSRID()[source]#

TODO

Return type:

str

getTimeZone()[source]#

TODO

setTimeZone(zone)[source]#

TODO

convertToTimeZone(zone)[source]#

TODO

duration()[source]#

TODO

nanduration(no_data_value=None)[source]#

ToDo

frequency(mode='temporal')[source]#

Average frequency in Hz (resp. m/pt) for temporal (resp. spatial) mode

Return type:

float

interval(mode='temporal')[source]#

Inverse of average frequency in pt/sec (resp. pt/m) for temporal (resp. spatial) mode

Return type:

float

toECEFCoords(base=None)[source]#

TODO

toENUCoords(base=None)[source]#

TODO

toGeoCoords(base=None)[source]#

TODO

toProjCoords(srid)[source]#

TODO

toImageCoords(P1, P2, p1, p2)[source]#

Function to convert 2D coordinates (GEO or ENU) into image local coordinates Input: two points p1, p2 (image coordinates), P1, P2 (track coordinate system) p1 and p2 are provided as lists. P1 and P2 are GeoCoords or ENUCoords.

toENUCoordsIfNeeded()[source]#

Function to convert track to ENUCoords if it is in GeoCoords. Returns None if no transformation operated, and returns used reference point otherwise

removeNoDataValues(no_data_value=None)[source]#
size()[source]#

TODO

count_missing_geom(no_data_value=None)[source]#
count_missing_temps()[source]#
count_af_value(af_name, val)[source]#
getFirstObs()[source]#

TODO

getLastObs()[source]#

TODO

getObsList()[source]#

TODO

getObs(i)[source]#

TODO

getCoord(i=None)[source]#
getX(i=None)[source]#

TODO

getY(i=None)[source]#

TODO

getZ(i=None)[source]#

TODO

getT(i=None)[source]#

TODO

getTimestamps(i=None)[source]#

TODO

getTimestamps_str(i=None)[source]#

TODO

getCentroid()[source]#

TODO

getFurthestObs(o)[source]#
getNearestObs(o)[source]#
getMedianObs()[source]#
getMedianObsInTime()[source]#
getEnclosedPolygon()[source]#

TODO

getMinX()[source]#

TODO

getMinY()[source]#

TODO

getMinZ()[source]#

TODO

getMaxX()[source]#

TODO

getMaxY()[source]#

TODO

getMaxZ()[source]#

TODO

getLowerLeftPoint()[source]#

TODO

getUpperRightPoint()[source]#

TODO

bbox()[source]#

TODO

shiftTo(idx_point, new_coords=[E=       0.000, N=       0.000, U=       0.000])[source]#
makeOdd()[source]#

TODO

makeEven()[source]#

TODO

loop(add=False)[source]#
__transmitAF(track)#

TODO

hasAnalyticalFeature(af_name)[source]#

TODO

getAnalyticalFeatures(af_names)[source]#

TODO

getAnalyticalFeature(af_name)[source]#
getObsAnalyticalFeatures(af_names, i)[source]#

TODO

getObsAnalyticalFeature(af_name, i)[source]#

TODO

setObsAnalyticalFeature(af_name, i, val)[source]#

TODO

getListAnalyticalFeatures()[source]#

TODO

setXFromAnalyticalFeature(af_name)[source]#

TODO

setYFromAnalyticalFeature(af_name)[source]#

TODO

setZFromAnalyticalFeature(af_name)[source]#

TODO

setTFromAnalyticalFeature(af_name)[source]#

TODO

setXFromFunction(function)[source]#

TODO

setYFromFunction(function)[source]#

TODO

setZFromFunction(function)[source]#

TODO

setOrder(name='order', start=0)[source]#

TODO

sort()[source]#

TODO

isSorted()[source]#

TODO

addObs(obs)[source]#

TODO

insertObs(obs, i=None)[source]#

TODO

insertObsInChronoOrder(obs)[source]#

TODO

setObs(i, obs)[source]#

TODO

setObsList(list_of_obs)[source]#

TODO

removeObs(arg)[source]#

TODO

removeFirstObs()[source]#

TODO

removeLastObs()[source]#

TODO

popObs(idx)[source]#

TODO

removeObsList(tab)[source]#

TODO

setUid(used_id)[source]#

TODO

setTid(trace_id)[source]#

TODO

sortRadix()[source]#

TODO

removeTpsDup(et=0.001)[source]#
removePosDup(ep=0.01)[source]#
removeObsDup(et=0.001, ep=0.01)[source]#
__removeObsById(i)#

TODO

__removeObsByTimestamp(tps)#

TODO

__removeObsListById(tab_idx)#

TODO

__removeObsListByTimestamp(tab_tps)#

TODO

__getInsertionIndex(timestamp)#

TODO

print(n=-1, af_names='#all_features')[source]#

TODO

Console print of track with analytical features

summary()[source]#

Print summary (complete wkt below).

length()[source]#

Total length of track

Return type:

int

Returns:

Length of track

toWKT()[source]#

Transforms track into WKT string

Return type:

str

extract(id_ini, id_fin)[source]#

Extract between two indices from a track

Parameters:
  • id_ini (int) – Initial index of extraction

  • id_fin (int) – final index of extraction

Retun:

TODO

Return type:

Track

extractSpanTime(tini, tfin=None)[source]#

Extract span time from a track

tini: Initial time of extraction tfin: final time of extraction

addSeconds(sec_number)[source]#

Adds seconds to timestamps in track sec_number: number of seconds to add (may be < 0)

roundTimestamps(unit=1)[source]#

Rounds timestamps in a track unit: round timestamps up to unit seconds (default = 1)

__controlName()#

TODO

addAnalyticalFeature(algorithm, name=None)[source]#

Execute l’algo de l’AF. L’AF est déjà dans le dico, dans les features de Obs et initialisé.

createAnalyticalFeature(name, val_init=0.0)[source]#

Ajout de l’AF dans le dico et dans le features de Obs. Initialise tous les obs.

updateAnalyticalFeature(name, new_val)[source]#

Update values of an AF.

removeAnalyticalFeature(name)[source]#

TODO

fillAnalyticalFeature(af_name, X, T, tol=1, agg=<function Track.<lambda>>)[source]#
__compare(k1, k2, code)#

TODO

cleanDuplicates(code='XYZ')[source]#

TODO

op(operator, arg1=None, arg2=None, arg3=None)[source]#

Shortcut for operate() function

Parameters:
  • operator – TODO

  • arg1 – TODO

  • arg2 – TODO

  • arg3 – TODO

Returns:

TODO

operate(operator, arg1=None, arg2=None, arg3=None)[source]#

General function to perform computations on analytical features.

  • Case 1 : operator and operand listed separately

    • operator : to be selected in Operator class

      • Unary void operator : arg2 = F(arg1), arg1, arg2 must be provided

      • Binary void operator : arg3 = F(arg1, arg2)

      • Unary operator : F(arg1), arg1 must be provided

      • Binary operator : F(arg1, arg2), arg1, arg2 must be provided

Note that arg2 may be an AF name or a scalar value. When output AF name is not provided, it is automatically set as the first AF input in the formula. AF “x”, “y”, “z”, “t”, “timestamp” and “idx” are right away availables as “virtual” analytical features.

  • Case 2 : operator and operand listed in an algebraic expression

arg1 defines the algebraic expression. If this expression contains ‘=’ sign, then output is registered as an AF in track, with name defined by the left-hand side of arg1. For example :

>>> track.operate("P=X+Y")

performs the sum of AFs X and Y, and returns the result as an AF named P in track.

  • Available operators : +, -, /, *, ^ in scalar and AF versions.

  • Available functions : almost all those listed in Operator class

  • Functions are expressed with '{}'. E.g:

    >>> track.operate("P=LOG{X}")
    
  • Special shorthand functions: D for differentiation, I for integration D2 for second-order differentiation and >> (resp. <<) for advance (resp. delay) scalar operators. E.g:

    >>> track.operate("v=3.6*D{s}/D{t}")
    

    performs speed computation (in km/h), provided that curvilinear abscissa s is already definedinside track. It is equivalent to the somehow more sophisticated following version with delay operator:

    >>> track.operate("v=3.6*(s-(s>>1))/(t-(t>>1))")
    
  • It is possible to add external identificator to the computations by using passing a dictionnary of variables in arg2. For example, to divide an AF A in a track by a (beforehand unknown) variable var:

    >>> track.operate("A=A/factor", {'factor' : var}])
    
Parameters:
  • operator – TODO

  • arg1 – TODO

  • arg2 – TODO

  • arg3 – TODO

Returns:

TODO

biop(track, expression)[source]#

Shortcut for bioperate() function

bioperate(track, expression)[source]#

Algebraic operation on 2 tracks.

If expression contains a left hand side AF, it is added to self track. Self track and second track may have same name AF. Any AF referring to to the second track must be terminated with single ° character.

For example :

>>> t1.bioperate(t2, "a=b°+c")

adds 1st track’s AF c with 2nd track’s AF b and the result a is stored in 1st track AF a.

reverse()[source]#

Return a reversed track (based on index)

Important: track may not be valid for some other functions Used mostly to simplify backward kalman filter formulation

resample(delta=None, algo=1, mode=1, npts=None, factor=1)[source]#

Resampling a track with linear interpolation.

Parameters#

delta: interpolation interval

(time in sec if temporal mode is selected, space in meters if spatial).

npts = number of points

If none of delta and npts are specified, the track is resampled regularly with the same number of points * factor. If both are specified, priority is given to delta.

Available modes are:

  • MODE_SPATIAL (mode=1)

  • MODE_TEMPORAL (mode=2)

Algorithm:

  • ALGO_LINEAR (algo=1)

  • ALGO_THIN_SPLINE (algo=2)

  • ALGO_B_SPLINES (algo=3)

  • ALGO_GAUSSIAN_PROCESS (algo=4)

In temporal mode, argument may be:

  • an integer or float: interval in seconds

  • a list of timestamps where interpolation should be computed

  • a reference track

smooth(width=1)[source]#

TODO

incrementTime(dt=1, offset=0)[source]#

Add 1 sec to each subsequent record. Use incrementTime to get valid timestamps sequence when timestamps are set as default date on 1970/01/01 00:00:00 for example

mapOn(reference, TP1, TP2=[], init=[], N_ITER_MAX=20, mode='2D', verbose=True)[source]#

Geometric affine transformation to align two tracks with different coordinate systems.

Deprecated since version 1.0.0: TODO: Check if is really deprecated

For “2D” mode, coordinates must be core.Coords.ENUCoords or core.Coords.GeoCoords. For “3D” mode, any type of coordinates is valid. In general, it is recommended to avoid usage of non-metric core.Coords.GeoCoords coordinates for mapping operation, since it is relying on an isotropic error model.

Inputs:

  • reference: another track we want to align on or a list of points

  • TP1: list of tie points indices (relative to track self)

  • TP2: list of tie points indices (relative to track)

  • mode: could be “2D” (default) or “3D” if TP2 is not specified, it is assumed equal to TP1.

TP1 and TP2 must have same size. Adjustment is performed with least squares. The general transformation from point X to point X’ is provided below:

\[X' = kRX + T\]

with: \(k\) a positive real value, \(R\) a 2D or 3D rotation matrix and \(T\) a 2D or 3D translation vector.

Transformation parameters are returned in standard output in the following format: [theta, k, tx, ty] (theta in radians) Track argument may also be replaced ny a list of points. Note that mapOn does not handle negative determinant (symetries not allowed)

noise(sigma=5, kernel=None, force=False, cycle=False, control=[], n=1)[source]#

TODO

plotAsMarkers(size=8, frg='k', bkg='w', sym_frg='+', sym_bkg='o', type=None, label='', append=True, v=None)[source]#

TODO

plotEllipses(sym='r-', factor=3, af=None, append=True, v=None)[source]#

Plot track uncertainty (as error ellipses) Input track must contain an AF with (at least) a 2 x 2 covariance matrix. If this matrix has dim > 2, first two dimensions are arbitrarily considered

plot(sym='k-', type='LINE', af_name='', cmap=-1, append=True, pointsize=5, style=None, color=None, w=6.4, h=4.8, title='', xlabel=None, ylabel=None, xlim=None, ylim=None, v=None)[source]#

Method to plot a track (short cut from Plot)

style and color has priority over sym.

af_name: test si isAFTransition

Append#

  • True: append to the current plot

  • False: create a new plot

  • Ax: append to the given Axes object

Output#

Ax object (may be input into append parameter)

plotProfil(template='SPATIAL_SPEED_PROFIL', afs=[], append=False, linestyle='-', linewidth=1, color='g', v=None)[source]#

Représentation du profil de la trace.

plotAnalyticalFeature(af_name, template='BOXPLOT', append=False, v=None)[source]#

Plot AF values by abcisse curvilign.

plotFirstObs(color='r', text='S', dx=0, dy=0, markersize=4, append=False, v=None)[source]#
plotLastObs(color='r', text='E', dx=0, dy=0, markersize=4, append=False, v=None)[source]#
isAFTransition(af_name)[source]#

Return True if the AF is a transition marker.

A transition marker is defined as an AF whose values are binary (0 or 1), where 1 indicates a regime change.

For example, returns True if AF values look like:

000000000000010000100000000000000000001000000100000

estimate_speed(kernel=None)[source]#

Compute and return speed for each points 2nd order time centered time finite difference if raw speeds are required. If kernel is specified smoothed speed estimation is computed.

getSpeed()[source]#

TODO

getAbsCurv()[source]#

TODO

__condition(operator, val2)#

TODO

query(cmd)[source]#

Query observations in a track with SQL-like commands.

Output depends on the SELECT clause:

  • If SELECT * then output is a copied track of the original track (with all its AF hopefully)

  • If SELECT f1, f2... fp, then output is a (p x n)-dimensional array, with p = number of fields queried and n = number of observations selected by the WHERE conditions.

  • If SELECT AGG1(f1), AGG2(f2)... AGGp(fp), with AGG1, AGG2,.. AGGp, a set of p aggregators, then output is a p-dimensional array, with on value for each aggregator

  • If SELECT AGG(f), then output is the floating point value returned by the operator.

Note that operators take as input only analytical feature names. Therefore, SELECT COUNT(*) syntax is not allowed and must be replaced equivalently by SELECT COUNT(f) with any AF name f.

General rules:

  • Only SELECT and WHERE keywords (SET and DELETE available soon)

  • All analytical features + x, y, z, t, and timestamp are available as fields

  • Fields are written without quotes. They must not contain blank spaces

  • “t” is time as integer in seconds since 1970/01/01 00:00:00, and “timestamp” is core.GPSTime.GPSTime object

  • Blank space must be used between every other words, symbols and operators

  • WHERE clause may contain as many conditions as needed, separated by OR / AND key words

  • Parenthesis are not allowed within WHERE clause. Use boolean algebra rules to reformulate query without parenthesis: e.g. A AND (B OR C) = A AND B OR A AND C. Or use successive queries.

  • Each condition must contain exactly 3 parts (separated by blank spaces) in this exact order:

    1. the name of an analytical feature to test

    2. a comparison operator among >, <, >=, <=, ==, != and LIKE (with % in str and timestamps)

    3. a threshold value which is automatically casted to the type of the AF given in (1). Intended types accepted are: int, float, str, bool and core.ObsTime.ObsTime. When core.ObsTime.ObsTime is used as a threshold value, eventhough it may contain 2 parts (date and time), it must not be enclosed within quotes. For boolean, “1”, “T” and “TRUE” are considered as logical True, all other values are considered as False.

  • Important: no computation allowed in WHERE conditions. E.g. “… WHERE z-2 > 10” not allowed

  • Available aggregators: all unary operators as described in * core.Operator.Operator, except core.Operator.Mse

  • Capital letters must be used for SQL keywords SELECT, WHERE, AND, OR and aggregator

Parameters:

cmd (str) – TODO

Return type:

list[Any]

Returns:

TODO

__applyOperation(op1, op2, operator, temp_af_counter)#

Applying operators through algebraic expressions

__evaluateRPN(expression, external=[])#

TODO

__convertReflexOperator()#

TODO

__unaryOp()#

TODO

__specialOpChar()#

TODO

__prime()#

TODO

__double_prime()#

TODO

__evaluate(expression, external=[])#

TODO

rotate(theta, center=None)[source]#

TODO

rotate3D(R)[source]#

TODO

scale(h)[source]#

TODO

scale3D(h, center=None)[source]#

TODO

translate(tx, ty, tz=0)[source]#

TODO

symmetrize(dim, val=0)[source]#

TODO

removeIdleEnds(parameter, mode='begin')[source]#

Removal of idle points at the begining or end of track

Parameters:
  • parameter – TODO

  • mode (str) –

    Mode of cleaning. Choose between:

    1. ’begin’

    2. ’end’

Return type:

Track

Returns:

Cleared track

digitize(r, clean=True)[source]#
dual()[source]#