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
timeValueListList<TimeValue>timeToValueList which the time length is closed to integral multiple of
basePeriod. The offset part cause bias.basePeriodTimeSpanperiod of 1st fourier transform parameter.
resolutionPeriodTimeSpanperoid of last fourier transform parameter.
threadNumintthread 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
timeValueListList<TimeItem>timeToValueList which the time length is closed to integral multiple of
basePeriod. The offset part cause bias.basePeriodTimeSpanperiod of 1st fourier transform parameter.
resolutionPeriodTimeSpanperoid of last fourier transform parameter.
getValueFuncsFunc<TimeItem, double>[]Array of functions to extract values from each time-based item
threadNumintthread number. Set 0 to apply processor count. Set 1 for not creating additional thread during the function.
Returns
Type Parameters
TimeItemThe 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
fittedTimeValueListList<TimeValue>timeToValueList which the time length is closed to integral multiple of
basePeriod. The offset part cause bias.basePeriodTimeSpanperiod of 1st fourier transform parameter.
resolutionPeriodTimeSpanperoid of last fourier transform parameter.
threadNumintthread 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
fittedTimeValueListList<TimeItem>timeToValueList which the time length is closed to integral multiple of
basePeriod. The offset part cause bias.basePeriodTimeSpanBase period. Effective period. Period of 1st fourier transform parameter. The period should be close and smaller than the full period.
resolutionPeriodTimeSpanperoid of last fourier transform parameter.
getValueFuncsFunc<TimeItem, double>[]Array of functions to extract values from each time-based item
threadNumintthread 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
TimeItemThe 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
fittedTimeValueListList<TimeValue>The list of time-value pairs to transform
kwdoubleThe 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
fittedTimeValueListList<TimeValue>timeToValueList which the time length is closed to integral multiple of period. The offset part cause bias.
kwdoublemultiplication of K (number of angular frequency) and W (base angular frequency f2pi)
fullPeriodTimeSpanThe 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
fittedTimeValueListList<TimeItem>The list of time-based items to transform
kwdoubleThe angular frequency to transform at
getValueFuncsFunc<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
TimeItemThe 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
fittedTimeValueListList<TimeItem>timeToValueList which the time length is closed to integral multiple of period. The offset part cause bias.
kwdoublemultiplication of K and W
fullPeriodTimeSpanperiod of 1st fourier transform parameter.
getValueFuncsFunc<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
srcIList<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
TimeItemThe 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
sortedTimeToValueIEnumerable<KeyValuePair<double, double>>sorted time to value. Key is time. Value is value.
timeIntervaldoubletime 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
sortedTimeToValueIEnumerable<KeyValuePair<double, Data>>sorted time to value. Key is time. Value is value.
timeIntervaldoubletime interval
addingFuncFunc<Data, Data, Data>Function to add two values of type Data
scalingFuncFunc<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
DataThe 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
timeVsValueContourList<TimeValue>The list of TimeValue objects
tTimeSpanThe 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
timeVsValueContourSortedList<double, double>The sorted list of time-value pairs
tdoubleThe 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
timeVsValueContourSortedList<double, T>The sorted list of time-value pairs
tdoubleThe time at which to interpolate
addingFuncFunc<T, T, T>Function to add two values of type T
scalingFuncFunc<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
TThe type of values in the contour