Process reference: numerical
Generated from the docstrings of vaft.process.numerical:
1 public functions. Each entry is what
vaft.process.describe("numerical.<name>") prints.
All process categories
Overview
One function so far. Anything that is a physics formula belongs in
vaft.formula; anything that knows about a diagnostic belongs in a
diagnostic module. This is for the operations that are neither.
| Symbol | Meaning | Unit |
|---|---|---|
| t | time | s |
| x | the sampled quantity | any |
Functions
time_derivative | Time derivative of a sampled quantity on a non-uniform time axis. Convention |
No function matches.
time_derivative
Machine-independentConvention-sensitive
source
time_derivative(time, data)
Time derivative of a sampled quantity on a non-uniform time axis.
A weighted central difference: at each interior point the forward and backward differences are averaged with weights proportional to the opposite interval, so the closer neighbour counts more. On a uniform grid this reduces to the ordinary central difference; the ends use a one-sided difference.
| Name | Type | Unit | Description |
|---|---|---|---|
time | np.ndarray | s | Sample times; spacing may vary. |
data | np.ndarray | any | The sampled quantity, same shape as |
| Returns | |||
| — | np.ndarray | any/s |
|
Convention
The weighting is the simple interval-weighted average of the two one-sided differences, not the second-order non-uniform stencil; it is what was written and is kept so that results do not move.
Raises
ValueErrorThe arrays differ in shape, or hold fewer than two samples.
Processing steps · Applicability · Limitations
Processing steps
- First sample: forward difference. Last sample: backward difference.
- Interior sample
i: withh_b = t[i] - t[i-1]andh_f = t[i+1] - t[i], the derivative is(h_f * backward + h_b * forward) / (h_b + h_f). - A zero interval on either side falls back to the difference across the
other; zero on both sides yields
0.
Applicability
Machine-independent.
Limitations
A zero time interval produces a 0 derivative silently rather than an
error, so a duplicated timestamp hides as a flat spot. The scheme is
first-order accurate on a non-uniform grid and amplifies sample noise as
any finite difference does; smooth or filter first if the derivative is
to be read quantitatively. The loop over interior points is pure Python
and slow on long records.