Class TimeseriesUtils


  • public class TimeseriesUtils
    extends DataContainerUtils
    Utility class for timeseries.
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • TimeseriesUtils

        public TimeseriesUtils()
    • 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 in
        p - 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 in
        timestamp - 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 in
        timestamp - 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 in
        timestamp - 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 timeseries
        b - 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" timeseries
        b - 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 timeseries
        b - 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 pool
        s - 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 timeseries
        s2 - 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