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 [3], 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 interp keyword argument
SPEDAS.tinterpFunction
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)
source
tinterp(A, B; interp=LinearInterpolation)

Interpolate A to times in B

source
SPEDAS.tinterp_nansFunction
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

source
SPEDAS.tsyncFunction
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:

  1. Finding the common time range between all input time series
  2. Extracting the subset of A within this common range
  3. Interpolating each series in Bs... to match the time points of the subset of A

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

source
SPEDAS.resampleFunction
resample(arr, n=DEFAULTS.resample; 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.

source
SPEDAS.tresampleFunction
tresample(da::DimArray, n=DEFAULTS.resample; dimtype=Ti)

Resample a DimArray specifically along its dimension of type dimtype to n points. Throws an error if no dimension of type dimtype is found in the array.

source

Utilities

SPEDAS.dropnaFunction
dropna(A, query)

Remove slices containing NaN values along dimensions other than query.

source