aquaduct.geom.traces module

diff(trace)[source]

This function calculates the distance between 2 given points.

Parameters:trace – coordinates in numpy array object
Returns:distance between points
tracepoints(start, stop, nr)[source]
Parameters:
  • start – coordinates of the first point as a numpy array object
  • stop – coordinates of the second point as a numpy array object
  • nr – number of elements between the first and second point
Returns:

two-dimentional numpy array; number of dimentions depends on nr parameter

midpoints(paths)[source]
The function returns a tuple of numpy arrays extended with mid point spanning last and first element(column)
of these arrays.
Parameters:paths – a tuple of 2-dimentional np.arrays that hold 3D coordinates; each element holds one trace, all elements are supposed to make one path divided in to sections
Returns:paths elements with additional mid points as a generator object
length_step_std(trace)[source]

This function calculates sum, mean and standard deviation from all segments of a trace.

Parameters:trace – coordinates of points as numpy array
Returns:a tuple with basics statistics of a trace
derrivative(values)[source]
vector_norm(V)[source]
Parameters:V – a vector in a form of array-like object, tuple or a list
Returns:normalized length of a vector
triangle_angles(A, B, C)[source]

Parameters are coordinates of points which are tops of triangle. The function calculates angles in a triangle formed by given coordinates.

Parameters:
  • A – coordinates of the first point
  • B – coordinates of the second point
  • C – coordinates of the third point
Returns:

list of arguments where angle is given in radians , the output is as follow: [BAC,CAB,ABC]

triangle_angles_last(A, B, C)[source]

Parameters are coordinates of points which are tops of triangle. The function calculates the [ABC] angle.

Parameters:
  • A – coordinates of the first point [A top]
  • B – coordinates of the second point [B top]
  • C – coordinates of the third point [C top]
Returns:

list with one value of ABC angle in radians

triangle_height(A, B, C)[source]

Parameters are coordinates of points which are tops of triangle. The function calculates the ABC triangle height.

Parameters:
  • A – coordinates of the first point [A top]
  • B – coordinates of the second point [B top]
  • C – coordinates of the third point [C top]
Returns:

one value of ABC triangle height

vectors_angle(A, B)[source]

This function calculates the angle between two given vectors (starting from the [0,0,0] to the given coordinates.

Parameters:
  • A – coordinates of the first point which is the end of the vector
  • B – coordinates of the second point which is the end of the vector
Returns:

the angle between vectors in question (in radians)

vectors_angle_alt(A, B)[source]

This function calculates the angle between two given vectors (starting from the [0,0,0] to the given coordinates

  • alternative method.
Parameters:
  • A – coordinates of the first point which is the end of the vector
  • B – coordinates of the second point which is the end of the vector
Returns:

the angle between vectors in question (in radians)

vectors_angle_alt_anorm(A, B, A_norm)[source]
This function calculates the angle between two given vectors (starting from the [0,0,0] to the given coordinates
  • alternative method with additional A_norm holding norm of A.
Parameters:
  • A – coordinates of the first point which is the end of the vector
  • B – coordinates of the second point which is the end of the vector
  • A_norm – additional parameter holding normalized of vector A
Returns:

the angle between vectors in question (in radians)

vectors_angle_anorm(A, B, A_norm)[source]
This function calculates the angle between two given vectors (starting from the [0,0,0] to the given coordinates
using additional A_norm holding norm of A.
Parameters:
  • A – coordinates of the first point which is the end of the vector
  • B – coordinates of the second point which is the end of the vector
  • A_norm – additional parameter holding normalized of vector A
Returns:

the angle between vectors in question (in radians)

class LinearizeOneWay[source]

Bases: object

here(coords)[source]

This function simplifies the trace by removing the redundant, linear points :param coords: 3D coordinates of a trace as an array-like object :return: indices of coordinates which are a staring and ending points of linear fragments and other non-linear points of the trace

class LinearizeHobbit[source]

Bases: aquaduct.geom.traces.LinearizeOneWay

and_back_again(coords)[source]
__call__(coords)[source]
class LinearizeRecursive[source]

Bases: object

Base class for linearization methods classes.

It implements recursive algorithm.

here(coords, depth=0)[source]

Core of recursive linearization argorithm.

It checks if the first, the last and the middle point are linear according to the criterion. The middle point is a selected point that is in the middle of length of the paths made by input coordinates.

If these points are linear their indices are returned. Otherwise, coordinates are split into two parts. First part spans points from the first point to the middle point (inclusive) and the second part spans points from the middle (inclusive) to the last point. Next, these two parts are submitted recursively to here().

Results of these recursive calls are joined, redundant indices are removed and sorted result is returned.

Parameters:
  • coords (numpy.ndarray) – Input coordinates.
  • depth (int) – Depth of recurence.
Returns:

Indices of coords points that can be used instead of all points in visulatization.

Return type:

list of int

__call__(coords)[source]
class TriangleLinearize(threshold=0.01)[source]

Bases: object

__init__(threshold=0.01)[source]
is_linear(coords, **kwargs)[source]
class VectorLinearize(treshold=0.05236)[source]

Bases: object

Base class for linearization methods classes.

It implements vector linearization criterion.

__init__(treshold=0.05236)[source]
is_linear_core(coords, depth=None)[source]

Method checks if input coordinates are linear according to the threshold and depth.

It begins with calculation of the threshold. If depth is None it is set to 1. Current threshold is calculated with following simple equation:

\[threshold_{current} = threshold_{initial} * (2 - 0.9^{depth})\]

Next, in a loop over all points but the first and the last the angle is calculated between two vectors. The first one made by the point and the first point, and the second vector made by the last and the first point. If any of the calculated angles is bigger the the treshold methods returns False; otherwise method returns True.

Parameters:
  • coords (numpy.ndarray) – Coordinates for which linearization criterion is checked.
  • depth (int) – Depth of recurence.
Returns:

True if input coordinates are linear and False otherwise.

Return type:

bool

is_linear(coords, depth=None, **kwargs)[source]

For more detail see is_linear_core() which is used as the criterion of linearity in this method.

Parameters:
  • coords (numpy.ndarray) – Coordinates for which linearization criterion is checked.
  • depth (int) – Depth of recurence.
Returns:

True if input coordinates are linear and False otherwise. Criterion is checked for coordinates in normal and reverse order.

Return type:

bool

class LinearizeRecursiveVector(treshold=0.05236)[source]

Bases: aquaduct.geom.traces.LinearizeRecursive, aquaduct.geom.traces.VectorLinearize

Class provides recursive linearization of coordinates with LinearizeRecursive algorithm and the criterion of linearity implemented by VectorLinearize. This is default method.

class LinearizeRecursiveTriangle(threshold=0.01)[source]

Bases: aquaduct.geom.traces.LinearizeRecursive, aquaduct.geom.traces.TriangleLinearize

Class provides recursive linearization of coordinates with LinearizeRecursive algorithm and the criterion of linearity implemented by TriangleLinearize.

class LinearizeHobbitVector(treshold=0.05236)[source]

Bases: aquaduct.geom.traces.LinearizeHobbit, aquaduct.geom.traces.VectorLinearize

Class provides recursive linearization of coordinates with LinearizeHobbit algorithm and the criterion of linearity implemented by VectorLinearize.

class LinearizeHobbitTriangle(threshold=0.01)[source]

Bases: aquaduct.geom.traces.LinearizeHobbit, aquaduct.geom.traces.TriangleLinearize

Class provides recursive linearization of coordinates with LinearizeHobbit algorithm and the criterion of linearity implemented by TriangleLinearize.

class LinearizeOneWayVector(treshold=0.05236)[source]

Bases: aquaduct.geom.traces.LinearizeOneWay, aquaduct.geom.traces.VectorLinearize

Class provides recursive linearization of coordinates with LinearizeOneWay algorithm and the criterion of linearity implemented by VectorLinearize.

class LinearizeOneWayTriangle(threshold=0.01)[source]

Bases: aquaduct.geom.traces.LinearizeOneWay, aquaduct.geom.traces.TriangleLinearize

Class provides recursive linearization of coordinates with LinearizeOneWay algorithm and the criterion of linearity implemented by TriangleLinearize.