pyrfu.pyrf.sliding_derivative module#
- pyrfu.pyrf.sliding_derivative.sliding_derivative(time_series, t_units: str = 'ns', window_size=3, method: str = 'window')[source]#
Compute the sliding time derivative of a time series using central differences.
This function calculates the rate of change of a time series at each point by computing the derivative within a sliding window of a specified size. The derivative at each point is estimated using the first and last points in the window (central difference).
Parameters:#
- time_seriesxarray.DataArray
The time series data for which the derivative is to be calculated.
- t_units: str, optional, default: “ns”
The units of the time coordinate in time_series. If t_units is “ns” then the time is converted to seconds.
- window_sizeint, optional, default: 3
The number of data points in each sliding window. It should be an odd integer to ensure a symmetric window around the central point for central differences.
Returns:#
- derivativexarray.DataArray
An array containing the sliding derivative for each point in the time series. The length of this array matches the length of time_series. For points near the boundaries (where a full window cannot be formed), the result will be NaN.