Class TimeSeriesUtil
Utility class for time series data operations.
public static class TimeSeriesUtil
- Inheritance
-
TimeSeriesUtil
- Inherited Members
Methods
FourierTransformApSeries(List<TimeValue>, TimeSpan, TimeSpan, int)
Performs a Fourier transform series on a list of time values and converts the results to amplitude-phase format.
public static List<AmpPhase> FourierTransformApSeries(this List<TimeValue> timeValueList, TimeSpan basePeriod, TimeSpan resolutionPeriod, int threadNum = 1)
Parameters
timeValueList
List<TimeValue>timeToValueList which the time length is closed to integral multiple of
basePeriod
. The offset part cause bias.basePeriod
TimeSpanperiod of 1st fourier transform parameter.
resolutionPeriod
TimeSpanperoid of last fourier transform parameter.
threadNum
intthread number. Set 0 to apply processor count. Set 1 for not creating additional thread during the function.
Returns
FourierTransformApSeries<TimeItem>(List<TimeItem>, TimeSpan, TimeSpan, Func<TimeItem, double>[], int)
Performs a Fourier transform series on a list of time-based items and converts the results to amplitude-phase format.
public static List<AmpPhase[]> FourierTransformApSeries<TimeItem>(this List<TimeItem> timeValueList, TimeSpan basePeriod, TimeSpan resolutionPeriod, Func<TimeItem, double>[] getValueFuncs, int threadNum = 1) where TimeItem : ITimeGetter
Parameters
timeValueList
List<TimeItem>timeToValueList which the time length is closed to integral multiple of
basePeriod
. The offset part cause bias.basePeriod
TimeSpanperiod of 1st fourier transform parameter.
resolutionPeriod
TimeSpanperoid of last fourier transform parameter.
getValueFuncs
Func<TimeItem, double>[]Array of functions to extract values from each time-based item
threadNum
intthread number. Set 0 to apply processor count. Set 1 for not creating additional thread during the function.
Returns
Type Parameters
TimeItem
The type of items that implement ITimeGetter
FourierTransformSeries(List<TimeValue>, TimeSpan, TimeSpan, int)
Performs a Fourier transform series on a list of time values, generating frequency domain data.
public static List<Vec2d> FourierTransformSeries(this List<TimeValue> fittedTimeValueList, TimeSpan basePeriod, TimeSpan resolutionPeriod, int threadNum = 1)
Parameters
fittedTimeValueList
List<TimeValue>timeToValueList which the time length is closed to integral multiple of
basePeriod
. The offset part cause bias.basePeriod
TimeSpanperiod of 1st fourier transform parameter.
resolutionPeriod
TimeSpanperoid of last fourier transform parameter.
threadNum
intthread number. Set 0 to apply processor count. Set 1 for not creating additional thread during the function.
Returns
FourierTransformSeries<TimeItem>(List<TimeItem>, TimeSpan, TimeSpan, Func<TimeItem, double>[], int)
Performs a Fourier transform series on a list of time-based items, generating frequency domain data for multiple value functions.
public static List<Vec2d[]> FourierTransformSeries<TimeItem>(this List<TimeItem> fittedTimeValueList, TimeSpan basePeriod, TimeSpan resolutionPeriod, Func<TimeItem, double>[] getValueFuncs, int threadNum = 1) where TimeItem : ITimeGetter
Parameters
fittedTimeValueList
List<TimeItem>timeToValueList which the time length is closed to integral multiple of
basePeriod
. The offset part cause bias.basePeriod
TimeSpanBase period. Effective period. Period of 1st fourier transform parameter. The period should be close and smaller than the full period.
resolutionPeriod
TimeSpanperoid of last fourier transform parameter.
getValueFuncs
Func<TimeItem, double>[]Array of functions to extract values from each time-based item
threadNum
intthread number. Set 0 to apply processor count. Set 1 for not creating additional thread during the function.
Returns
- List<Vec2d[]>
A list of arrays of 2D vectors containing the cosine and sine components for each frequency and value function
Type Parameters
TimeItem
The type of items that implement ITimeGetter
FourierTransformSingleton(List<TimeValue>, double)
Performs a Fourier transform at a specific angular frequency for a list of time values.
public static Vec2d FourierTransformSingleton(this List<TimeValue> fittedTimeValueList, double kw)
Parameters
fittedTimeValueList
List<TimeValue>The list of time-value pairs to transform
kw
doubleThe angular frequency to transform at
Returns
- Vec2d
A 2D vector containing the cosine and sine components of the transform
FourierTransformSingleton(List<TimeValue>, double, TimeSpan)
Get fourier transform parameter of indicated angular frequency kw
.
public static Vec2d FourierTransformSingleton(this List<TimeValue> fittedTimeValueList, double kw, TimeSpan fullPeriod)
Parameters
fittedTimeValueList
List<TimeValue>timeToValueList which the time length is closed to integral multiple of period. The offset part cause bias.
kw
doublemultiplication of K (number of angular frequency) and W (base angular frequency f2pi)
fullPeriod
TimeSpanThe full period of the time series.
Returns
- Vec2d
(parameter cos,parameter sin)
FourierTransformSingleton<TimeItem>(List<TimeItem>, double, Func<TimeItem, double>[])
Performs a Fourier transform at a specific angular frequency for a list of time-based items.
public static Vec2d[] FourierTransformSingleton<TimeItem>(this List<TimeItem> fittedTimeValueList, double kw, Func<TimeItem, double>[] getValueFuncs) where TimeItem : ITimeGetter
Parameters
fittedTimeValueList
List<TimeItem>The list of time-based items to transform
kw
doubleThe angular frequency to transform at
getValueFuncs
Func<TimeItem, double>[]Array of functions to extract values from each TimeItem
Returns
- Vec2d[]
An array of 2D vectors containing the cosine and sine components of the transform for each value function
Type Parameters
TimeItem
The type of items that implement ITimeGetter
FourierTransformSingleton<TimeItem>(List<TimeItem>, double, TimeSpan, Func<TimeItem, double>[])
Get fourier transform parameter of indicated frequency kw
.
public static Vec2d[] FourierTransformSingleton<TimeItem>(this List<TimeItem> fittedTimeValueList, double kw, TimeSpan fullPeriod, Func<TimeItem, double>[] getValueFuncs) where TimeItem : ITimeGetter
Parameters
fittedTimeValueList
List<TimeItem>timeToValueList which the time length is closed to integral multiple of period. The offset part cause bias.
kw
doublemultiplication of K and W
fullPeriod
TimeSpanperiod of 1st fourier transform parameter.
getValueFuncs
Func<TimeItem, double>[]Array of functions to extract values from each TimeItem.
Returns
- Vec2d[]
(parameter cos,parameter sin)
Type Parameters
TimeItem
GetAvgTimeInterval(List<TimeValue>)
Calculates the average time interval between consecutive TimeValue items in a list.
public static TimeSpan GetAvgTimeInterval(this List<TimeValue> timeValueList)
Parameters
Returns
- TimeSpan
The average time interval as a TimeSpan
GetFullPeriod<TimeItem>(IList<TimeItem>)
Gets the total time period covered by a collection of time-based items.
public static TimeSpan GetFullPeriod<TimeItem>(this IList<TimeItem> src) where TimeItem : ITimeGetter
Parameters
src
IList<TimeItem>The collection of time-based items
Returns
- TimeSpan
The time span between the first and last items, or TimeSpan.Zero if the collection is empty
Type Parameters
TimeItem
The type of items that implement ITimeGetter
GetInterpolatedAvgValueByTime(IEnumerable<KeyValuePair<double, double>>, double)
Get interpolated average value by time.
public static IEnumerable<KeyValuePair<double, double>> GetInterpolatedAvgValueByTime(this IEnumerable<KeyValuePair<double, double>> sortedTimeToValue, double timeInterval)
Parameters
sortedTimeToValue
IEnumerable<KeyValuePair<double, double>>sorted time to value. Key is time. Value is value.
timeInterval
doubletime interval
Returns
- IEnumerable<KeyValuePair<double, double>>
enumerable of (Key: time, Value: interpolated average value)
GetInterpolatedAvgValueByTime<Data>(IEnumerable<KeyValuePair<double, Data>>, double, Func<Data, Data, Data>, Func<Data, double, Data>)
Get interpolated average value by time.
public static IEnumerable<KeyValuePair<double, Data>> GetInterpolatedAvgValueByTime<Data>(this IEnumerable<KeyValuePair<double, Data>> sortedTimeToValue, double timeInterval, Func<Data, Data, Data> addingFunc, Func<Data, double, Data> scalingFunc)
Parameters
sortedTimeToValue
IEnumerable<KeyValuePair<double, Data>>sorted time to value. Key is time. Value is value.
timeInterval
doubletime interval
addingFunc
Func<Data, Data, Data>Function to add two values of type Data
scalingFunc
Func<Data, double, Data>Function to scale a value of type Data by a factor
Returns
- IEnumerable<KeyValuePair<double, Data>>
enumerable of (Key: time, Value: interpolated average value)
Type Parameters
Data
The type of data values
GetInterpolatedValueByTime(List<TimeValue>, TimeSpan)
Gets an interpolated value from a list of TimeValue objects at a specified time.
public static double GetInterpolatedValueByTime(this List<TimeValue> timeVsValueContour, TimeSpan t)
Parameters
timeVsValueContour
List<TimeValue>The list of TimeValue objects
t
TimeSpanThe time at which to interpolate
Returns
- double
The interpolated value at the specified time
GetInterpolatedValueByTime(SortedList<double, double>, double)
Gets an interpolated double value from a time-value contour at a specified time.
public static double GetInterpolatedValueByTime(this SortedList<double, double> timeVsValueContour, double t)
Parameters
timeVsValueContour
SortedList<double, double>The sorted list of time-value pairs
t
doubleThe time at which to interpolate
Returns
- double
The interpolated value at the specified time
GetInterpolatedValueByTime<T>(SortedList<double, T>, double, Func<T, T, T>, Func<T, double, T>)
Gets an interpolated value from a time-value contour at a specified time.
public static T GetInterpolatedValueByTime<T>(this SortedList<double, T> timeVsValueContour, double t, Func<T, T, T> addingFunc, Func<T, double, T> scalingFunc)
Parameters
timeVsValueContour
SortedList<double, T>The sorted list of time-value pairs
t
doubleThe time at which to interpolate
addingFunc
Func<T, T, T>Function to add two values of type T
scalingFunc
Func<T, double, T>Function to scale a value of type T by a factor
Returns
- T
The interpolated value at the specified time
Type Parameters
T
The type of values in the contour