Package adams.data.timeseries
Class TimeseriesUtils
- java.lang.Object
-
- adams.data.container.DataContainerUtils
-
- adams.data.timeseries.TimeseriesUtils
-
public class TimeseriesUtils extends DataContainerUtils
Utility class for timeseries.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class adams.data.container.DataContainerUtils
DataContainerUtils.GapFilling
-
-
Field Summary
Fields Modifier and Type Field Description protected static TimeseriesPointComparator
m_Comparator
comparator for finding wavenumbers.
-
Constructor Summary
Constructors Constructor Description TimeseriesUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static void
add(Hashtable<Date,TimeseriesPoint> pool, Timeseries s)
Merges the given with the current data pool.static int
findClosestTimestamp(List<TimeseriesPoint> points, Date timestamp)
Returns the index in points closest to the given timestamp.static int[]
findEnclosingTimestamps(List<TimeseriesPoint> points, Date timestamp)
Returns the indices of points in m_Points that enclose the given timestamp.static int
findTimestamp(List<TimeseriesPoint> points, TimeseriesPoint p)
Returns the index in points of the given timeseries point, -1 if not found.static int
findTimestamp(List<TimeseriesPoint> points, Date timestamp)
Returns the index in points of the given timestamp.static TimeseriesPointComparator
getComparator()
Returns the comparator used for finding wave numbers.protected static Timeseries
getHeader(List<TimeseriesPoint> points)
Creates a header based on the given timeseries points.static Timeseries
intersect(Timeseries a, Timeseries b)
Returns a timeseries that contains all the points that are in "a" and in "b".static Timeseries
merge(Timeseries s1, Timeseries s2)
Merges the two timeseries ranges.static Timeseries
merge(List<Timeseries> list)
Merges the given timeseries.static Timeseries
minus(Timeseries a, Timeseries b)
Returns a timeseries that contains all the points that are in "a" but not in "b".static double[]
toDoubleArray(Timeseries c)
Returns the amplitudes as double array.static double[]
toDoubleArray(List<TimeseriesPoint> data)
Returns the amplitudes as double array.static Timeseries
union(Timeseries a, Timeseries b)
Returns the union of the two timeseries "a" and "b".
-
-
-
Field Detail
-
m_Comparator
protected static TimeseriesPointComparator m_Comparator
comparator for finding wavenumbers.
-
-
Method Detail
-
getComparator
public static TimeseriesPointComparator getComparator()
Returns the comparator used for finding wave numbers.- Returns:
- the comparator
-
getHeader
protected static Timeseries getHeader(List<TimeseriesPoint> points)
Creates a header based on the given timeseries points.- Parameters:
points
- the timeseries points to create the header for- Returns:
- the generated header
-
findTimestamp
public static int findTimestamp(List<TimeseriesPoint> points, TimeseriesPoint p)
Returns the index in points of the given timeseries point, -1 if not found.- Parameters:
points
- the list of timeseries points to search inp
- the point to get the index for- Returns:
- the index or -1 if not found
-
findTimestamp
public static int findTimestamp(List<TimeseriesPoint> points, Date timestamp)
Returns the index in points of the given timestamp.- Parameters:
points
- the vector of profile points to search intimestamp
- the timestamp to get the index for- Returns:
- the index
-
findClosestTimestamp
public static int findClosestTimestamp(List<TimeseriesPoint> points, Date timestamp)
Returns the index in points closest to the given timestamp.- Parameters:
points
- the list of timeseries points to search intimestamp
- the timestamp to get the closest index for- Returns:
- the index
-
findEnclosingTimestamps
public static int[] findEnclosingTimestamps(List<TimeseriesPoint> points, Date timestamp)
Returns the indices of points in m_Points that enclose the given timestamp. If the given timestamp happens to be an exact point, then this points will be stored at index 0. If no index could be determined, then -1 will be stored.- Parameters:
points
- the list of timeseries points to search intimestamp
- the timestamp to get the enclosing indices for- Returns:
- the indices
-
union
public static Timeseries union(Timeseries a, Timeseries b)
Returns the union of the two timeseries "a" and "b". All timeseries points from "a" are used, plus the ones from "b" that are not in "a".- Parameters:
a
- the first timeseriesb
- the second timeseries- Returns:
- the union
-
minus
public static Timeseries minus(Timeseries a, Timeseries b)
Returns a timeseries that contains all the points that are in "a" but not in "b". It is assumed that "b" is a subset of "a" and does not contain other wave numbers.- Parameters:
a
- the "full" timeseriesb
- the "subset" timeseries- Returns:
- the points missing in "b"
-
intersect
public static Timeseries intersect(Timeseries a, Timeseries b)
Returns a timeseries that contains all the points that are in "a" and in "b". The timeseries points in the result are taken from "a".- Parameters:
a
- the first timeseriesb
- the second timeseries- Returns:
- the points in "a" and "b"
-
add
protected static void add(Hashtable<Date,TimeseriesPoint> pool, Timeseries s)
Merges the given with the current data pool. New timeseries points don't override ones already in the pool, they only get added.- Parameters:
pool
- the current data pools
- the timeseries to merge with the pool
-
merge
public static Timeseries merge(Timeseries s1, Timeseries s2)
Merges the two timeseries ranges. The header of the first one is used for the output.- Parameters:
s1
- the first timeseriess2
- the second timeseries- Returns:
- the merged timeseries
-
merge
public static Timeseries merge(List<Timeseries> list)
Merges the given timeseries. The header of the first one is used for the output.- Parameters:
list
- the timeseries to merge- Returns:
- the merged timeseries
-
toDoubleArray
public static double[] toDoubleArray(Timeseries c)
Returns the amplitudes as double array.- Parameters:
c
- the timeseries to turn into a double array- Returns:
- the amplitudes as double array
-
toDoubleArray
public static double[] toDoubleArray(List<TimeseriesPoint> data)
Returns the amplitudes as double array.- Parameters:
data
- the timeseries points to turn into a double array- Returns:
- the amplitudes as double array
-
-