Time Series
See TimeseriesUtilities.jl for a collection of utilities and tutorials to simplify common time series analysis.
- outliers: remove spikes from signal.
Time Series Resampling Methods
The adjustment of a segment of time-series data set to produce a segment of data which is scientifically equivalent but with data sample timing strictly simultaneous with that of another data set is called “resampling”. Paschmann and Daly [2], Chapter 2
Time Series Interpolation
Flexible time series interpolation through the tinterp function.
This function supports interpolation for both vector-like and matrix-like time series. Other features include:
- Returns scalar value for single time point interpolation
- Returns DimArray for multiple time points interpolation, preserving metadata and dimensions.
- Customizable interpolation method through the
interpkeyword argument
TimeseriesUtilities.tinterp — Function
tinterp(A, old_times, new_times; interp=LinearInterpolation)Interpolate time series A at new time points new_times.
The interp constructor must accept (u, t; kws...) and return a callable object. Its syntax is compatible with DataInterpolations.jl.
Examples
# Interpolate at a single time point
tinterp(time_series, DateTime("2023-01-01T12:00:00"))
# Interpolate at multiple time points using cubic spline interpolation
new_times = DateTime("2023-01-01"):Hour(1):DateTime("2023-01-02")
tinterp(time_series, new_times; interp = CubicSpline)TimeseriesUtilities.tinterp_nans — Function
tinterp_nans(A; dim = nothing, kwargs...)Interpolate only the NaN values in A along dimension dim.
TimeseriesUtilities.tsync — Function
tsync(A, Bs...)Synchronize multiple time series to have the same time points.
This function aligns time series Bs... to match time points of A by:
- Finding common time range between all time series
- Extracting subset of
Awithin common range - Interpolating each series in
Bs...to match the time points of the subset ofA
Examples
A_sync, B_sync, C_sync = tsync(A, B, C)See also: tinterp, common_timerange
SPEDAS.resample — Function
resample(arr, n; dim=1, verbose=false)Resample an array along the dimension dim to n points. If the original length is less than or equal to n, the original array is returned unchanged.
SPEDAS.tresample — Function
tresample(da, n; dim=nothing)Resample a dimensioned array along its time dimension (or dim) to n points.