Skip to content

vector_field

The VectorField class is used to calculate the direction of the wavefront in each node of the graph. VectorField(graph) creates a vector_field object based on the graph that was given as a parameter.

There are 3 different implementations on how to calculate the direction of the wavefront:

  • VectorField.weighted_avg_inverse_speed() agrees the most with the interpretation of a wavefront and thus gives the best results.
  • VectorField.weighted_avg_speed() agrees the most with the interpretation of single waves in each node, not really connected wave fronts.
  • VectorField.normalised_avg() lies between the VectorField.weighted_avg_inverse_speed() and VectorField.weighted_avg_speed() and thus gives a general overview of the direction of the wavefront while also taking single node differences into account.

VectorField

delta_lat = graph.edges.weights instance-attribute

distances = graph.edges.distances instance-attribute

edges = graph.edges.indices instance-attribute

normalized = False instance-attribute

points = graph.points instance-attribute

__init__(graph)

Creates VectorField object.

Parameters:

Name Type Description Default
graph Graph object

The graph for which to calculate the vector field.

required

calculate_weighted_vf(delta_lat)

Calculates the vector field in each node by taking a weighted average over all incoming and outgoing vectors for a node.

Parameters:

Name Type Description Default
delta_lat N dimensional array

The delta_lat on each vector. N has to be equal to the amount of vectors in the graph.

required

Returns:

Type Description
ndarray

VectorField in each node of the graph.

normalize(vectors) staticmethod

Normalizes M-dimensional vectors.

Parameters:

Name Type Description Default
vectors [N, M] dimensional array

The vectors to normalize.

required

Returns:

Type Description
ndarray

np.ndarray: The normalized vectors ([N, M] dimensional array).

normalized_avg()

Calculates the vector field in each node by taking the average over all normalized incoming and outgoing vectors of a node.

Returns:

Type Description
ndarray

np.ndarray: Vector field in each node of the graph.

set_normalized(normalized=True)

If set to True, the vector field is normalized.

weighted_avg_inverse_speed()

Calculates the vector field in each node by taking a weighted average over all incoming and outgoing vectors for a node. The weight on the vectors is the lat difference between the start and end point divided by the distance between start and end point (= inverse speed). This is the most stable vector field.

Returns:

Type Description
ndarray

np.ndarray: Vector field in each node of the graph.

weighted_avg_speed()

Calculates the vector field in each node by taking a weighted average over all incoming and outgoing vectors for a node. The weight on the vectors is the distance between start and end point divided by the lat difference between the start and end point (= speed).

Returns:

Type Description
ndarray

np.ndarray: Vector field in each node of the graph.