Time Series Utilities
The following utilities are designed to simplify common data analysis tasks for time series data. While most are thin wrappers around existing Julia functions, they ensure proper handling of metadata and dimensions.
Most of the utilities operate on the time dimension by default, but you can specify other dimensions using the dim
or query
parameter.
Statistics
SPEDAS.tmean
— Functiontmean(x; dim=nothing, query=nothing)
Calculate the arithmetic mean of x
along the dim
dimension.
It returns a value if x
is a vector along the dim
dimension, otherwise returns a DimArray
with the specified dimension dropped.
If dim
is not specified, it defaults to the query
dimension (dimension of type TimeDim
by default).
https://github.com/JuliaLang/julia/issues/54542
SPEDAS.tmedian
— Functiontmedian(x; dim=nothing, query=nothing)
Calculate the median of x
along the dim
dimension.
It returns a value if x
is a vector along the dim
dimension, otherwise returns a DimArray
with the specified dimension dropped.
If dim
is not specified, it defaults to the query
dimension (dimension of type TimeDim
by default).
SPEDAS.tsum
— Functiontsum(x; dim=nothing, query=nothing)
Calculate the sum of x
along the dim
dimension.
It returns a value if x
is a vector along the dim
dimension, otherwise returns a DimArray
with the specified dimension dropped.
If dim
is not specified, it defaults to the query
dimension (dimension of type TimeDim
by default).
SPEDAS.tvar
— Functiontvar(x; dim=nothing, query=nothing)
Calculate the variance of x
along the dim
dimension.
It returns a value if x
is a vector along the dim
dimension, otherwise returns a DimArray
with the specified dimension dropped.
If dim
is not specified, it defaults to the query
dimension (dimension of type TimeDim
by default).
SPEDAS.tstd
— Functiontstd(x; dim=nothing, query=nothing)
Calculate the standard deviation of x
along the dim
dimension.
It returns a value if x
is a vector along the dim
dimension, otherwise returns a DimArray
with the specified dimension dropped.
If dim
is not specified, it defaults to the query
dimension (dimension of type TimeDim
by default).
SPEDAS.tsem
— Functiontsem(x; dim=nothing, query=nothing)
Calculate the standard error of the mean of x
along the dim
dimension.
It returns a value if x
is a vector along the dim
dimension, otherwise returns a DimArray
with the specified dimension dropped.
If dim
is not specified, it defaults to the query
dimension (dimension of type TimeDim
by default).
Arithmetic
SPEDAS.tcross
— Functiontcross(x, y; dims=TimeDim, stack=nothing)
Compute the cross product of two (arrays of) vectors along the dims
dimension.
References:
- https://docs.xarray.dev/en/stable/generated/xarray.cross.html
SPEDAS.tderiv
— Functiontderiv(data, times; dims = 1)
Compute the time derivative of data
with respect to times
.
SPEDAS.tdot
— Functiontdot(x, y; dims=TimeDim)
Dot product of two arrays x
and y
along the dims
dimension.
SPEDAS.tsubtract
— Functiontsubtract(x, f=nanmedian; dims=timedim(x))
Subtract a statistic (default function f
: nanmedian
) along dimensions (default: time dimension) from x
.
Time-Domain Operations
SPEDAS.tclip
— Functiontclip(d, t0, t1; query=nothing, sort=false)
Clip a dimension or DimArray
to a time range [t0, t1]
.
For unordered dimensions, the dimension should be sorted before clipping (see tsort
).
SPEDAS.tview
— Functiontview(d, t0, t1)
View a dimension or DimArray
in time range [t0, t1]
.
SPEDAS.tmask
— Functiontmask(da, args...; kwargs...)
Non-mutable version of tmask!
. See also tmask!
.
SPEDAS.tshift
— Functiontshift(x; dim=TimeDim, t0=nothing, new_dim=nothing)
Shift the dim
of x
by t0
.