Skip to content

← tensor_math package

FiniteDifferences

Calculate the discrete n'th derivative of the given data along a chosen axis using finite differences.

This node will calculate the difference between each value and the next (if order=1). For higher orders it will apply the procedure multiple times, which yields the discrete derivative of order n. This node can be used to compute, for instance, the velocity and acceleration from a time series of positions. The data tensor in the packet, will be replaced with a tensor containing the differences. This node can alternatively take a list of values into its data port, in which case it will output a list of the differences to the same port instead of a packet. More Info... Version 1.1.1

Ports/Properties

data

Data to process.

verbose name
Data
default value
None
port type
DataPort
value type
AnyNumeric (can be None)
data direction
INOUT

axis

Axis along which to compute the finite difference. The resulting axis will have order elements less than the original (i.e., 3 less if order is set to 3), unless keep_shape (keep output shape) property is set to True.

verbose name
Compute Differences Along Axis
default value
axis
port type
ComboPort
value type
str (can be None)

order

Differencing order. If this is 3, the 3rd discrete derivative will be computed.

verbose name
Differencing Order
default value
1
port type
IntPort
value type
int (can be None)

keep_shape

If True then the output shape will be the same as the input shape. For arrays and non-streaming packet data, this is accomplished by prepending zeros along the target axis, which creates artifacts in the first order samples that should typically be ignored. For streaming packet data with axes having a times array (time, instance), past data are held in a buffer and the buffer will be overwritten with new data, avoiding artifacts.

verbose name
Keep Output Shape (Streaming)
default value
False
port type
BoolPort
value type
bool (can be None)

scale_by_timestep

If True then differences along an axis with a times array will be scaled by the difference in times. This is important for calculating velocity and acceleration in units of x/sec and /sec^2, or when samples are irregular. Set this to false if using this node to calculate differences in timestamps (i.e., if preceded by the ExtractMarkerTimestamps node).

verbose name
Scale By Timestep
default value
True
port type
BoolPort
value type
bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

verbose name
Set Breakpoint (Debug Only)
default value
False
port type
BoolPort
value type
bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

verbose name
Metadata
default value
{}
port type
DictPort
value type
dict (can be None)