Package adams.data.sequence
Class XYSequenceUtils
- java.lang.Object
-
- adams.data.container.DataContainerUtils
-
- adams.data.sequence.XYSequenceUtils
-
public class XYSequenceUtils extends DataContainerUtils
Utility class for XY sequences.- 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 XYSequencePointComparator
m_Comparator
comparator for finding wavenumbers.
-
Constructor Summary
Constructors Constructor Description XYSequenceUtils()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static void
add(Hashtable<Number,XYSequencePoint> pool, XYSequence s)
Merges the given sequence with the current data pool.static int
countRegions(List<XYSequencePoint> points, double start, double end, boolean positive)
Counts the positive or negative regions between the given points (incl.static int
countSignChanges(List<XYSequencePoint> points, double start, double end)
Counts the sign changes in the given data between the given points (incl.static int
findClosestX(List<XYSequencePoint> points, double x)
Returns the index in m_Points closest to the given x value.static int[]
findClosestXs(List<XYSequencePoint> points, double x, double wobble)
Returns the indices of m_Points closest to the given x value.static int[]
findEnclosingXs(List<XYSequencePoint> points, double x)
Returns the indices of points in m_Points that enclose the given x value.static int
findX(List<XYSequencePoint> points, double x)
Returns the index in m_Points of the given x value.static int
findX(List<XYSequencePoint> points, XYSequencePoint p)
Returns the index in m_Points of the given sequence point.XYSequencePointComparator
getComparator()
Returns the comparator used for finding x values.static XYSequence
getConsecutiveRegion(List<XYSequencePoint> points, XYSequencePoint lastEnd, XYSequencePoint end)
Returns a region for the given range, starting just after the x value of "lastEnd" and ending (including) at "end".protected static XYSequence
getHeader(List<XYSequencePoint> points)
Creates a header based on the current sequence points.static double[]
getHistogram(List<XYSequencePoint> points, int numBins)
Generates data for a histogram display.static XYSequence
getRegion(List<XYSequencePoint> points, XYSequencePoint start, XYSequencePoint end)
Returns a region for the given range, including both, start and end point.static XYSequence
merge(XYSequence s1, XYSequence s2)
Merges the two sequences.static XYSequence
merge(List<XYSequence> list)
Merges the given sequences.
-
-
-
Field Detail
-
m_Comparator
protected static XYSequencePointComparator m_Comparator
comparator for finding wavenumbers.
-
-
Method Detail
-
getComparator
public XYSequencePointComparator getComparator()
Returns the comparator used for finding x values.- Returns:
- the comparator
-
getHeader
protected static XYSequence getHeader(List<XYSequencePoint> points)
Creates a header based on the current sequence points.- Parameters:
points
- the data to process- Returns:
- the generated header
-
findX
public static int findX(List<XYSequencePoint> points, XYSequencePoint p)
Returns the index in m_Points of the given sequence point.- Parameters:
points
- the points to processp
- the point to get the index for- Returns:
- the index
-
findX
public static int findX(List<XYSequencePoint> points, double x)
Returns the index in m_Points of the given x value.- Parameters:
points
- the points to processx
- the x value to get the index for- Returns:
- the index
-
findClosestX
public static int findClosestX(List<XYSequencePoint> points, double x)
Returns the index in m_Points closest to the given x value.- Parameters:
points
- the data to processx
- the x value to get the closest index for- Returns:
- the index
-
findClosestXs
public static int[] findClosestXs(List<XYSequencePoint> points, double x, double wobble)
Returns the indices of m_Points closest to the given x value.- Parameters:
points
- the data to processx
- the x value to get the closest index forwobble
- the wobble factor to allow left and right- Returns:
- the indices
-
findEnclosingXs
public static int[] findEnclosingXs(List<XYSequencePoint> points, double x)
Returns the indices of points in m_Points that enclose the given x value. If the given x value 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 data to processx
- the x value to get the enclosing indices for- Returns:
- the indices
-
getConsecutiveRegion
public static XYSequence getConsecutiveRegion(List<XYSequencePoint> points, XYSequencePoint lastEnd, XYSequencePoint end)
Returns a region for the given range, starting just after the x value of "lastEnd" and ending (including) at "end".- Parameters:
points
- the data to processlastEnd
- the last end point, if null then the first sequence point will be the first point included.end
- the last point to include in the region, if null then the last point in the data is used.- Returns:
- the generated region
-
getRegion
public static XYSequence getRegion(List<XYSequencePoint> points, XYSequencePoint start, XYSequencePoint end)
Returns a region for the given range, including both, start and end point.- Parameters:
points
- the data to processstart
- the starting point, if null the first point in the data is used.end
- the last point to include in the region, if null then the last point in the data is used.- Returns:
- the generated region
-
countSignChanges
public static int countSignChanges(List<XYSequencePoint> points, double start, double end)
Counts the sign changes in the given data between the given points (incl. the borders).- Parameters:
points
- the data to processstart
- the x value to start withend
- the last x value- Returns:
- the number of changes in sign
-
countRegions
public static int countRegions(List<XYSequencePoint> points, double start, double end, boolean positive)
Counts the positive or negative regions between the given points (incl. the borders).- Parameters:
points
- the data to processstart
- the x value to start withend
- the last x valuepositive
- if true then positive regions are counted otherwise negative ones- Returns:
- the number of positive/negative regions
-
getHistogram
public static double[] getHistogram(List<XYSequencePoint> points, int numBins)
Generates data for a histogram display. It counts how many sequence points have the same y value in the currently stored sequence.- Parameters:
points
- the data to processnumBins
- the number of bins to generate- Returns:
- the histogram data
-
add
protected static void add(Hashtable<Number,XYSequencePoint> pool, XYSequence s)
Merges the given sequence with the current data pool. New sequence points don't override ones already in the pool, they only get added.- Parameters:
pool
- the current data pools
- the sequence to merge with the pool
-
merge
public static XYSequence merge(XYSequence s1, XYSequence s2)
Merges the two sequences. The header of the first one is used for the output.- Parameters:
s1
- the first sequences2
- the second sequence- Returns:
- the merged sequence
-
merge
public static XYSequence merge(List<XYSequence> list)
Merges the given sequences. THe header of the first one is used for the output.- Parameters:
list
- the sequences to merge- Returns:
- the merged sequence
-
-