pysdic.numeric.apply_forward_finite_difference#
- apply_forward_finite_difference(data, order, *, axis=-1, spacing=1.0, accuracy=1, mode='one_sided', value=0.0)[source]#
Apply the forward finite difference approximation of a derivative to an array sampled uniformly along an axis.
The available modes for the ends of the sampling are:
Mode
Description
"one_sided"Stencils shifted inside the sampling, of the same accuracy: the result is a derivative everywhere (default).
"reflect"\((d c b a | a b c d | d c b a)\)
"constant"\((k k k k | a b c d | k k k k)\)
"nearest"\((a a a a | a b c d | d d d d)\)
"mirror"\((d c b | a b c d | c b a)\)
"wrap"\((a b c d | a b c d | a b c d)\)
With the modes of
scipy.ndimage.correlate1d(), the values near the ends use the extended signal: they are not approximations of the derivative (except for periodic signals with"wrap").- Parameters:
data (ArrayLike) – The sampled signal (converted to
numpy.float64).order (Integral) – The order \(n \geq 1\) of the derivative.
axis (Integral, optional (default:
-1)) – The axis of the sampling.spacing (Real, optional (default:
1.0)) – The sampling step \(h > 0\).accuracy (Integral, optional) – The order \(p\) of the error (see
compute_forward_finite_difference_coefficients()).mode (str, optional (default:
"one_sided")) – The treatment of the ends of the sampling (see above).value (Real, optional (default:
0.0)) – The padding value of the mode"constant".
- Returns:
The derivative, with the shape of
data.- Return type: