Utils#

This module contains an algorithm of Analytical Features calculation and some utility functions.

tracklib.core.Utils.isnan(number)[source]#

Check if two numbers are different

Return type

bool

tracklib.core.Utils.removeNan(T)[source]#
Return type

list

tracklib.core.Utils.isfloat(value)[source]#

Check is a value is a float

Return type

bool

tracklib.core.Utils.islist(value)[source]#

Check is a value is a list

Return type

bool

tracklib.core.Utils.listify(input)[source]#

Make to list if needed

Return type

list[Any]

tracklib.core.Utils.unlistify(input)[source]#

Remove list if needed

Parameters

input – TODO

Returns

TODO

tracklib.core.Utils.compLike(s1, s2)[source]#

TODO

Parameters
  • s1 – TODO

  • s2 – TODO

Return type

bool

Returns

TODO

tracklib.core.Utils.makeCoords(x, y, z, srid)[source]#

Function to form coords object from (x,y,z) data

Parameters
  • x (float) – 1st coordinate (X, lon or E)

  • y (float) – 2nd coordinate (Y, lat or N)

  • z (float) – 3rd coordinate (Z, hgt or U)

  • srid (str) – Id of coord system (ECEF, GEO or ENU)

Return type

Union[ENUCoords, ECEFCoords, GeoCoords]

Returns

Coords object in the proper srid

tracklib.core.Utils.makeDistanceMatrixOld(T1, T2)[source]#
tracklib.core.Utils.makeDistanceMatrix(track, mode='linear')[source]#

Function to form distance matrix

Parameters

track – a track :mode: computation mode (‘linear’, ‘circular’ or ‘euclidian’)

Returns

numpy distance matrix with a track

tracklib.core.Utils.makeCovarianceMatrixFromKernelOld(kernel, T1, T2, factor=1.0, force=False, cycle=False)[source]#

Function to form covariance matrix from kernel :param kernel: A function describing statistical similarity between points :type T1: list[tuple[float, float]] :param T1: A list of points :type T2: list[tuple[float, float]] :param T2: A list of points :type factor: float :param factor: Unit factor of std dev (default 1.0)

tracklib.core.Utils.makeCovarianceMatrixFromKernel(kernel, track, factor=1.0, mode='linear', force=False)[source]#

Function to form covariance matrix from kernel

Parameters
  • kernel – A function describing statistical similarity between points

  • track – A track :mode: computation mode (‘linear’, ‘circular’ or ‘euclidian’)

  • factor – Unit factor of std dev (default 1.0)

tracklib.core.Utils.rgbToHex(color)[source]#

Function to convert RGBA color to hexadecimal

Parameters

color (list[float, float, float, Optional[float]]) – A 3 or 4-element array R, G, B [,alpha]. Each color and transparency channel is in [0,1]

Return type

str

Returns

A string containing color in hexadecimal

tracklib.core.Utils.interpColors(v, vmin, vmax, cmin, cmax)[source]#

Function to interpolate RGBA (or RGB) color between two values

Parameters
  • v (float) – a float value

  • vmin (float) – minimal value of v (color cmin)

  • vmax (float) – maximal value of v (color cmin)

  • cmin (list[float, float, float, Optional[float]]) – a 3 or 4-element array R, G, B [,alpha]

  • cmax (list[float, float, float, Optional[float]]) – a 3 or 4-element array R, G, B [,alpha]

Return type

list[float, float, float, float]

Returns

A 4-element array

tracklib.core.Utils.getColorMap(cmin, cmax)[source]#

TODO

Parameters
  • cmin – TODO

  • cmax – TODO

Returns

TODO

tracklib.core.Utils.getOffsetColorMap(cmin, cmax, part)[source]#

TODO

Parameters
  • cmin – TODO

  • cmax – TODO

  • part – TODO

Returns

TODO

class tracklib.core.Utils.priority_dict(*args, **kwargs)[source]#

Dictionary that can be used as a priority queue.

Keys of the dictionary are items to be put into the queue, and values are their respective priorities. All dictionary methods work as expected. The advantage over a standard heapq-based priority queue is that priorities of items can be efficiently updated (amortized O(1)) using code as ‘thedict[item] = new_priority.’

The ‘smallest’ method can be used to return the object with lowest priority, and ‘pop_smallest’ also removes it.

The ‘sorted_iter’ method provides a destructive sorted iterator.

__init__(*args, **kwargs)[source]#
_rebuild_heap()[source]#
smallest()[source]#

Return the item with the lowest priority.

Raises IndexError if the object is empty.

pop_smallest()[source]#

Return the item with the lowest priority and remove it.

Raises IndexError if the object is empty.

setdefault(key, val)[source]#

TODO

update(*args, **kwargs)[source]#

TODO

sorted_iter()[source]#

Sorted iterator of the priority dictionary items.

Beware: this will destroy elements as they are returned.