TimeseriesTools.AbstractTimeSeries
TimeseriesTools.AbstractToolsArray
TimeseriesTools.BinaryTimeSeries
TimeseriesTools.IrregularIndex
TimeseriesTools.IrregularTimeIndex
TimeseriesTools.IrregularTimeSeries
TimeseriesTools.MultidimensionalTimeSeries
TimeseriesTools.MultivariateTimeSeries
TimeseriesTools.RegularIndex
TimeseriesTools.RegularTimeIndex
TimeseriesTools.RegularTimeSeries
TimeseriesTools.SpikeTrain
TimeseriesTools.TDim
TimeseriesTools.TimeIndex
TimeseriesTools.ToolsDim
TimeseriesTools.ToolsDimension
TimeseriesTools.UnivariateTimeSeries
TimeseriesTools.Var
TimeseriesTools.TimeSeries
TimeseriesTools.TimeSeries
TimeseriesTools.TimeSeries
The TimeseriesTools
package provides a standardized collection of types designed for handling various types of time-series data. Defining consistent types for time series provides three key benefits:
- It simplifies the workspace and method signatures by aggregating much of the data that defines a time series into a single variable; thanks to the
DimensionalData.jl
package, one variable can hold the values of a time series, its time points, spatial coordinates, units, metadata, and more. - It facilitates generic functions that dispatch on the various types of time series; for instance, more efficient algorithms can be written for
RegularTimeSeries
types than forIrregularTimeSeries
types, but the same high-level functionality can be provided by the same generic function that dispatches these methods given the type of the input time series. - Most importantly, this intuitively aligns the structure of time-series data in code to mathematical conventions, which can vastly simplify the process of developing and interpreting programs. Many small complexities (Was this time series regularly sampled? What are the output frequencies of my Fourier transform? The units of my power spectrum?) are handled effortlessly, leaving room to focus on higher-level problems.
To achieve this, TimeseriesTools.jl defines a custom version of the DimensionalData.DimArray
and custom DimensionalData.Dimension
s:
x = Timeseries(1:10, rand(10))
x isa AbstractToolsArray # In most cases, an AbstractToolsArray behaves like a DimArray; see DimensionalData
x isa AbstractTimeSeries # An AbstractTimeSeries is an AbstractToolsArray...
lookup(x, 1) isa 𝑡 # ...where the first dimension is a custom TimeDim 𝑡
If a ToolsArray
or DimArray
has a 𝑡
as its first dimension, it will be rebuilt as a ToolsArray
(i.e. when using functions like eachcol
). There are a small number of other custom dimensions, all exported, that share this property and are subtypes of ToolsDimension
: e.g. 𝑥
, 𝑦
, 𝑧
, 𝑓
,Var
, Obs
. To define more of these ToolsDimension
s, use:
DimensionalData.@dim NewDim ToolsDim "NameOfNewDim"
Please note that functions operating on a ToolsArray
without a ToolsDimension
as the first or last dimension may NOT return a ToolsArray
, especially if they perform slicing and rebuilding. Be careful using the DimensionalData.Dim{:name}
syntax.
Below is a full list of types defined in this package.
TimeseriesTools.ToolsDimension
— TypeToolsDimension
A union of all Dimension
types that fall within the scope of TimeseriesTools
. Analogous to DimensionalData.Dimension
for dispatch purposes.
See also
TimeseriesTools.AbstractTimeSeries
— TypeAbstractTimeSeries{T, N, B}
A type alias for an AbstractDimArray with a time index.
TimeseriesTools.AbstractToolsArray
— TypeA local type to avoid overloading and piracy issues with DimensionalData.jl
TimeseriesTools.BinaryTimeSeries
— TypeBinaryTimeSeries
A type alias for a time series of bits.
TimeseriesTools.IrregularIndex
— TypeIrregularIndex
A type alias for an irregularly sampled dimension, wrapping an AbstractVector
.
TimeseriesTools.IrregularTimeIndex
— TypeIrregularTimeIndex
A type alias for a tuple of dimensions containing a TimeIndex
and any number of other dimensions.
TimeseriesTools.IrregularTimeSeries
— TypeIrregularTimeSeries
A type alias for a potentially irregularly sampled time series.
TimeseriesTools.MultidimensionalTimeSeries
— TypeA multidimensional time series has a regular sampling over a dimension other than time; a one-dimensional time series can be thought of as a field over an even grid in 1 dimension that fluctuates over time.
TimeseriesTools.MultivariateTimeSeries
— TypeMultivariateTimeSeries{T}
A type alias for a multivariate time series (A matrix, with a first Ti
dimension and an arbitrary second dimension).
TimeseriesTools.RegularIndex
— TypeRegularIndex
A type alias for a regularly sampled dimension, wrapping an AbstractRange
.
TimeseriesTools.RegularTimeIndex
— TypeRegularTimeIndex
A type alias for a tuple of dimensions containing a TimeIndex
and any number of other dimensions.
TimeseriesTools.RegularTimeSeries
— TypeRegularTimeSeries{T, N, B}
A type alias for a regularly sampled time series.
TimeseriesTools.SpikeTrain
— TypeSpikeTrain
A type alias for a spike-train time series, which contains spike times in the time dimension and true
for all values corresponding to a spike. The spike times can be retrieved with times(x)
.
TimeseriesTools.TDim
— TypeTDim{S, T}
The TimeseriesTools version of DimensionalData.Dim
(custom dimensions named with a symbol)
Examples
See also
TimeseriesTools.TimeIndex
— TypeTimeIndex
A type alias for a tuple containing a time dimension and any number of other dimensions.
TimeseriesTools.ToolsDim
— TypeToolsDim{T}
An abstract type for custom macro-defined dimensions in TimeseriesTools
. Analogous to DimensionalData.Dimension
for the purposes of DimensionalData.@dim
.
Examples
DimensionalData.@dim MyDim ToolsDim "My dimension" # Defines a new `ToolsDim <: ToolsDimension`
See also
TimeseriesTools.UnivariateTimeSeries
— TypeUnivariateTimeSeries{T}
A type alias for a time series with one variable (a vector with only a Ti
dimension).
TimeseriesTools.Var
— TypeVar
A DimensionalData.jl dimension representing the variables of a multivariate time series.
TimeseriesTools.TimeSeries
— MethodTimeSeries(t, x)
Constructs a univariate time series with time t
and data x
. Alteratively, use TS(t, x)
Examples
julia> using TimeseriesTools, Unitful;
julia> t = 1:100
julia> x = rand(100)
julia> ts = TimeSeries(t, x)
julia> ts isa typeintersect(UnivariateTimeSeries, RegularTimeSeries)
TimeseriesTools.TimeSeries
— MethodTimeSeries(t, f::Function)
Construct a time series by mapping a function f
over the time points t
.
TimeseriesTools.TimeSeries
— MethodTimeSeries(t, v, x)
Constructs a multivariate time series with time t, variable v, and data x.
Examples
julia> t = 1:100;
julia> v = [:a, :b, :c];
julia> x = rand(100, 3);
julia> mts = TimeSeries(t, v, x)
julia> mts isa typeintersect(MultivariateTimeSeries, RegularTimeSeries)