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
SPEDAS.tinterp — Function
tinterp(A, t; interp=LinearInterpolation)Interpolate time series A at time point(s) t using interp (default: LinearInterpolation) method. Returns interpolated value for single time point or DimArray for multiple time points.
See DataInterpolations.jl for available interpolation methods.
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)tinterp(A, B; interp=LinearInterpolation)Interpolate A to times in B
SPEDAS.tinterp_nans — Function
tinterp_nans(da::AbstractDimArray; query=timeDimType, kwargs...)Interpolate only the NaN values in da along the specified dimensions query. Non-NaN values are preserved exactly as they are.
See also interpolate_nans
SPEDAS.tsync — Function
tsync(A, Bs...)Synchronize multiple time series to have the same time points.
This function aligns the time series Bs... to match the time points of A by:
- Finding the common time range between all input time series
- Extracting the subset of
Awithin this common range - Interpolating each series in
Bs...to match the time points of the subset ofA
Returns a tuple containing the synchronized time series, with the first element being the subset of A and subsequent elements being the interpolated versions of Bs....
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::DimArray, n; dim = nothing, query=nothing)Resample a DimArray specifically along its dimension dim or query to n points. Throws an error if no dimension of type dimtype is found in the array.