public class RHUtilities
extends java.lang.Object
Constructor and Description |
---|
RHUtilities() |
Modifier and Type | Method and Description |
---|---|
static SpatialVector |
addDistanceToLatLong(SpatialVector startVec,
SpatialVector addVec)
Returns the straight-line distance (in meters) between two locations defined as longitude/latitude (in degrees)
|
static int |
bytesToInt(byte[] byteBuff)
converts a byte array into an integer
|
static short |
bytesToShort(byte[] byteBuff)
converts a byte array into a short
|
static java.lang.String |
byteToHexString(byte b)
returns the value of an unsigned byte as a hexadecimal string
|
static java.lang.String |
byteToHexString(byte b,
boolean signed)
returns the value of an unsigned byte as a hexadecimal string
|
static boolean |
checkValidTargets(java.util.List<TargetCaptureData> targetList)
lists the TargetCaptureData
|
static java.lang.String |
colorToHex(java.awt.Color c)
Utility method to convert a Color into a KML color ref
|
static void |
confirmBufferSize(byte[] byteBuff,
int minSize,
int maxSize)
returns whether the integer is an even number
|
static void |
confirmValidBuffer(byte[] byteBuff)
confirms that the byte buffer is not empty
|
static double |
doAngle180DegRange(double anAngleDeg)
Takes an angle in Degrees (°) and ranges it to between -180 and +180
|
static double |
doAngle2PiRadRange(double anAngleRad)
Takes an angle in Radians and ranges it to between 0 and Pi°
|
static double |
doAngle360DegRange(double anAngleDeg)
Takes an angle in Degrees (°) and ranges it to between 0 and 360
|
static double |
doAnglePiRadRange(double anAngleRad)
Takes an angle in Radians and ranges it to between -Pi and +Pi
|
static TargetCaptureData |
findBiggestTarget(java.util.List<TargetCaptureData> targetList)
finds the biggest target in the ;ist
|
static int |
get12BitValue(byte[] vals_2Byte) |
static int |
get16BitValue(byte[] vals_2Byte) |
static int |
get32BitValue(byte[] vals_4Byte) |
static boolean |
getBitFromByte(byte b,
int pos)
returns the value of the bit at a particular position within the byte
|
static java.lang.Iterable<TargetCaptureData> |
getByClosest(java.util.List<TargetCaptureData> newTCDs,
TargetCaptureData fromTCD,
int maxToGrab)
matches up individual TargetCaptureData ArrayLists based on past locations
|
static java.awt.geom.Rectangle2D |
getCenteredRectangle(java.awt.Point centPt,
double oLength,
double oWidth) |
static TargetCaptureData |
getClosest(java.util.List<TargetCaptureData> newTCDs,
TargetCaptureData fromTCD)
matches up individual TargetCaptureData ArrayLists based on past locations
|
static int |
getExponent(double aNumber)
returns the exponent in scientific notation
|
static java.io.File |
getFile(java.lang.String aStr)
user selects a file to load
|
static java.io.File |
getFileChooser()
user selects a file to open
|
static java.lang.String |
getFileDialog(java.lang.String aStr)
user selects a file to load
|
static PolarVector |
getHaversineDistance(SpatialVector Vec1,
SpatialVector Vec2)
Returns the straight-line distance (in meters) between two locations defined as longitude/latitude (in degrees)
|
static PolarVector |
getHaversineDistance(SpatialVector Vec1,
SpatialVector Vec2,
double radius)
Returns the Vector in meter distance and bearing degrees (counterclockwise from East)
between two locations defined as longitude/latitude (in degrees).
|
static int |
getIntAngleDeg(double anAngleDeg)
Returns an angle in Degrees (°) as an integer between -180 and 180
|
static double |
getMahalanobisDist(Matrix Pt1M,
Matrix Pt2M,
Matrix covMat)
returns the Mahalanobis Distance
|
static double |
getMahalanobisDistSquared(Matrix Pt1M,
Matrix Pt2M,
Matrix covMat)
returns the squared Mahalanobis Distance
|
static int |
getNValidTargets(java.util.List<TargetCaptureData> targetList)
examines for valid TargetCaptureData in the TargetCaptureData list
|
static int |
getNValidTargets(TargetCaptureData[] targetArray)
examines for valid TargetCaptureData in the TargetCaptureData array
|
static double |
getRaoSpacingCriticalValue(double p,
int df)
returns the critical value of the Rao spacing statistic
|
static double |
getRaoSpacingProbability(double raoSpacing,
int df)
returns the probability for Rao's Spacing Statistic for the variable using the currently
selected set of rows.
|
static java.awt.Rectangle |
getRectangle(java.awt.Point Pt1,
java.awt.Point Pt2) |
static int |
getSign(double aNumber)
Examines a double and returns its sign as an integer
|
static double |
getXYAngle(javax.vecmath.Point3f sPt,
javax.vecmath.Point3f ePt)
Return the heading in radians.
|
static double |
getXZAngle(javax.vecmath.Point3f sPt,
javax.vecmath.Point3f ePt)
Return the heading in radians.
|
static double |
getYZAngle(javax.vecmath.Point3f sPt,
javax.vecmath.Point3f ePt)
Return the heading in radians.
|
static double |
hypot(double a,
double b)
returns the sqrt(a^2 + b^2) without under/overflow
|
static double |
hypot(double a,
double b,
double c)
returns the sqrt(a^2 + b^2 + c^2)
|
static byte[] |
intToByteArray(int value)
Utility method to convert an int into bytes, padded to two characters.
|
static java.lang.String |
intToHex(int i)
Utility method to convert an int into hex, padded to two characters.
|
static boolean |
isBetween(double first,
double second,
double inside)
returns whether the last number is between the first two numbers
|
static boolean |
isBetween(SpatialVector first,
SpatialVector second,
SpatialVector inside)
returns whether the last vector is between the first two
|
static boolean |
isEven(int anInt)
returns whether the integer is an even number
|
static boolean |
isOdd(int anInt)
returns whether the integer is an even number
|
static void |
listByteArray(byte[] byteBuff) |
static void |
listByteArray(int aInt) |
static void |
listByteArray(short aShort) |
static void |
listPolyList(java.util.List<SGPolygon> targetList)
lists the TargetCaptureData
|
static void |
listPolyListLine(java.util.List<SGPolygon> targetList)
lists the TargetCaptureData
|
static void |
listRaoSpacingCriticalValueTable()
list the critical values of the Rao spacing statistic
|
static void |
listTargetCaptureDataList(java.util.List<TargetCaptureData> targetList)
lists the TargetCaptureData
|
static void |
listTargetCaptureDataListLine(java.util.List<TargetCaptureData> targetList)
lists the TargetCaptureData
|
static void |
listTargetCaptureDataListPolys(java.util.List<TargetCaptureData> targetList)
lists the polygons of the TargetCaptureData
|
static java.util.List<TargetCaptureData> |
matchUpByProximity(java.util.List<TargetCaptureData> newTCDs,
java.util.List<TargetCaptureData> oldTCDs)
matches up individual TargetCaptureData ArrayLists based on past locations
|
static java.lang.String |
octetBytesToStr(byte[] byteBuff)
converts a byte array of octets into a string
|
int[] |
process(float[] tSeries,
int windowSize,
float stringency)
A standard peak detector in time series.
|
static java.awt.image.BufferedImage |
readImageFromFile()
Load an BufferedImage from a file
|
static long |
roundDown(double aNumber)
returns the number rounded down to the next lower integer
|
static long |
roundUp(double aNumber)
returns the number rounded up to the next higher integer
|
static java.io.File |
saveFile(java.lang.String aStr)
user selects a file to save
|
static java.io.File |
saveFileChooser()
user selects a file to save
|
static java.lang.String |
saveFileDialog(java.lang.String aStr)
user selects a file to save
|
static java.io.File |
saveTimeNamedFile(java.lang.String aStr,
java.lang.String FT_extension)
user selects a file to save
|
static double |
shiftExponent(double aNumber,
int exponent)
returns the number after shifting a given number of exponents
|
static java.lang.String |
shortToHexString(short s)
returns the value of an short as a hexadecimal string
|
static java.lang.String |
shortToHexString(short s,
boolean signed)
returns the value of an short as a hexadecimal string
|
static int |
signedByteToInt(byte b)
returns the value of an unsigned byte as an integer
|
static int |
signedShortToInt(short s)
returns the value of an signed short as an integer
|
static long |
trunc(double aNumber)
returns the number truncated to the next lower integer
|
static int |
unsignedByteToInt(byte b)
returns the value of an unsigned byte as an integer
|
static int |
unsignedShortToInt(short s)
returns the value of an unsigned short as an integer
|
static int |
val_12Bit(byte[] byteBuff)
converts a 2 byte array, 12 bit value into an integer
|
public static int getSign(double aNumber)
aNumber
- the double value to examinepublic static int unsignedShortToInt(short s)
s
- unsigned shortpublic static int signedShortToInt(short s)
s
- signed shortpublic static int unsignedByteToInt(byte b)
b
- unsigned bytepublic static int signedByteToInt(byte b)
b
- unsigned bytepublic static int get32BitValue(byte[] vals_4Byte)
public static int get16BitValue(byte[] vals_2Byte)
public static int get12BitValue(byte[] vals_2Byte)
public static java.lang.String shortToHexString(short s)
s
- the short to convertpublic static java.lang.String shortToHexString(short s, boolean signed)
s
- the short to convertsigned
- is the short signedpublic static java.lang.String byteToHexString(byte b)
b
- unsigned bytepublic static java.lang.String byteToHexString(byte b, boolean signed)
b
- unsigned bytesigned
- is the byte signedpublic static boolean getBitFromByte(byte b, int pos)
b
- a bytepos
- position [0-7]public static java.lang.String intToHex(int i)
i
- Int to convertpublic static final byte[] intToByteArray(int value)
value
- the int to usepublic static java.lang.String colorToHex(java.awt.Color c)
c
- The color to convertpublic static int bytesToInt(byte[] byteBuff) throws java.lang.Exception
byteBuff
- the byte array to usejava.lang.Exception
public static short bytesToShort(byte[] byteBuff) throws java.lang.Exception
byteBuff
- the byte array to usejava.lang.Exception
public static java.lang.String octetBytesToStr(byte[] byteBuff) throws java.lang.Exception
byteBuff
- the byte array to usejava.lang.Exception
public static int val_12Bit(byte[] byteBuff) throws java.lang.Exception
byteBuff
- the byte array to usejava.lang.Exception
public static void listByteArray(byte[] byteBuff) throws java.lang.Exception
java.lang.Exception
public static void confirmValidBuffer(byte[] byteBuff) throws java.lang.Exception
byteBuff
- the byte arrayjava.lang.Exception
public static void confirmBufferSize(byte[] byteBuff, int minSize, int maxSize) throws java.lang.Exception
byteBuff
- the byte arrayminSize
- the minimum size of the byte buffermaxSize
- the maximum size of the byte bufferjava.lang.Exception
public static void listByteArray(short aShort) throws java.lang.Exception
java.lang.Exception
public static void listByteArray(int aInt) throws java.lang.Exception
java.lang.Exception
public static boolean isEven(int anInt)
anInt
- the integer to testpublic static boolean isOdd(int anInt)
anInt
- the integer to testpublic static boolean isBetween(SpatialVector first, SpatialVector second, SpatialVector inside)
first
- the first vectorsecond
- the first vectorinside
- the vector to testpublic static boolean isBetween(double first, double second, double inside)
first
- the first doublesecond
- the first doubleinside
- the double to testpublic static long roundUp(double aNumber)
aNumber
- the double value to round uppublic static long roundDown(double aNumber)
aNumber
- the double value to round downpublic static long trunc(double aNumber)
aNumber
- the double value to truncatepublic static int getExponent(double aNumber) throws java.lang.Exception
aNumber
- the double value for which the Exponent is obtainedjava.lang.Exception
public static double shiftExponent(double aNumber, int exponent)
aNumber
- numberexponent
- number of positions to shiftpublic static java.awt.geom.Rectangle2D getCenteredRectangle(java.awt.Point centPt, double oLength, double oWidth)
public static java.awt.Rectangle getRectangle(java.awt.Point Pt1, java.awt.Point Pt2)
public static java.awt.image.BufferedImage readImageFromFile() throws java.lang.Exception
java.lang.Exception
public static java.io.File getFileChooser() throws java.lang.Exception
java.lang.Exception
public static java.io.File saveFileChooser()
public static java.io.File getFile(java.lang.String aStr) throws java.lang.Exception
aStr
- the string to displayjava.lang.Exception
public static java.lang.String getFileDialog(java.lang.String aStr) throws java.lang.Exception
aStr
- the string to displayjava.lang.Exception
public static java.io.File saveTimeNamedFile(java.lang.String aStr, java.lang.String FT_extension) throws java.lang.Exception
aStr
- the string to displayjava.lang.Exception
public static java.io.File saveFile(java.lang.String aStr) throws java.lang.Exception
aStr
- the string to displayjava.lang.Exception
public static java.lang.String saveFileDialog(java.lang.String aStr) throws java.lang.Exception
aStr
- the string to displayjava.lang.Exception
public static int getIntAngleDeg(double anAngleDeg)
anAngleDeg
- the angle in degreespublic static double doAngle360DegRange(double anAngleDeg)
anAngleDeg
- the angle in degreespublic static double doAngle2PiRadRange(double anAngleRad)
anAngleRad
- the angle in Radianspublic static double doAngle180DegRange(double anAngleDeg)
anAngleDeg
- the angle in degreespublic static double doAnglePiRadRange(double anAngleRad)
anAngleRad
- the angle in Radianspublic static double hypot(double a, double b)
a
- a numberb
- a numberpublic static double hypot(double a, double b, double c)
a
- a numberb
- a numberc
- a numberpublic static double getXYAngle(javax.vecmath.Point3f sPt, javax.vecmath.Point3f ePt)
public static double getXZAngle(javax.vecmath.Point3f sPt, javax.vecmath.Point3f ePt)
public static double getYZAngle(javax.vecmath.Point3f sPt, javax.vecmath.Point3f ePt)
sPt
- start pointePt
- end pointpublic static PolarVector getHaversineDistance(SpatialVector Vec1, SpatialVector Vec2) throws java.lang.Exception
Vec1
- the first vectorVec2
- the first vectorjava.lang.Exception
public static PolarVector getHaversineDistance(SpatialVector Vec1, SpatialVector Vec2, double radius) throws java.lang.Exception
Vec1
- the first vectorVec2
- the first vectorradius
- the radius of the spherejava.lang.Exception
public static SpatialVector addDistanceToLatLong(SpatialVector startVec, SpatialVector addVec)
startVec
- the first vectoraddVec
- the first vectorpublic static boolean checkValidTargets(java.util.List<TargetCaptureData> targetList) throws java.lang.Exception
targetList
- the list of TargetCaptureDatajava.lang.Exception
public static int getNValidTargets(java.util.List<TargetCaptureData> targetList) throws java.lang.Exception
targetList
- the list of TargetCaptureDatajava.lang.Exception
public static int getNValidTargets(TargetCaptureData[] targetArray) throws java.lang.Exception
targetArray
- the array of TargetCaptureDatajava.lang.Exception
public static void listTargetCaptureDataListLine(java.util.List<TargetCaptureData> targetList) throws java.lang.Exception
targetList
- the list of TargetCaptureDatajava.lang.Exception
public static void listTargetCaptureDataList(java.util.List<TargetCaptureData> targetList) throws java.lang.Exception
targetList
- the list of TargetCaptureDatajava.lang.Exception
public static void listTargetCaptureDataListPolys(java.util.List<TargetCaptureData> targetList) throws java.lang.Exception
targetList
- the list of TargetCaptureDatajava.lang.Exception
public static void listPolyListLine(java.util.List<SGPolygon> targetList) throws java.lang.Exception
targetList
- the list of TargetCaptureDatajava.lang.Exception
public static void listPolyList(java.util.List<SGPolygon> targetList) throws java.lang.Exception
targetList
- the list of TargetCaptureDatajava.lang.Exception
public static TargetCaptureData findBiggestTarget(java.util.List<TargetCaptureData> targetList) throws java.lang.Exception
targetList
- the list of found targetsjava.lang.Exception
public static java.lang.Iterable<TargetCaptureData> getByClosest(java.util.List<TargetCaptureData> newTCDs, TargetCaptureData fromTCD, int maxToGrab)
newTCDs
- these objects were found in the previous framefromTCD
- the object to matchmaxToGrab
- the number of object to matchpublic static TargetCaptureData getClosest(java.util.List<TargetCaptureData> newTCDs, TargetCaptureData fromTCD)
newTCDs
- these objects were found in the previous framefromTCD
- the object to matchpublic static java.util.List<TargetCaptureData> matchUpByProximity(java.util.List<TargetCaptureData> newTCDs, java.util.List<TargetCaptureData> oldTCDs) throws java.lang.Exception
oldTCDs
- these objects were found in the previous framenewTCDs
- these objects were found in the current framejava.lang.Exception
public int[] process(float[] tSeries, int windowSize, float stringency)
The goal of this class is to identify peaks in a 1D time series (float[]). It simply implements G.K. Palshikar's Simple Algorithms for Peak Detection in Time-Series ( Proc. 1st Int. Conf. Advanced Data Analysis, Business Analytics and Intelligence (ICADABAI2009), Ahmedabad, 6-7 June 2009), We retained the first "spikiness" function he proposed, based on computing the max signed distance to left and right neighbors.
http://sites.google.com/site/girishpalshikar/Home/mypublications/ SimpleAlgorithmsforPeakDetectioninTimeSeriesACADABAI_2009.pdf
windowSize
- the window size to look for peaks. a neighborhood of +/- windowSize
will be inspected to search for peaks. Typical values start at 3.stringency
- threshold for peak values. Peak with values lower than
mean + stringency * std
will be rejected. Mean
and std
are calculated on the
spikiness function. Typical values range from 1 to 3.public static void listRaoSpacingCriticalValueTable()
public static double getRaoSpacingCriticalValue(double p, int df)
df
- the degrees of freedomp
- the p valuepublic static double getRaoSpacingProbability(double raoSpacing, int df) throws java.lang.Exception
raoSpacing
- Rao's Spacing Value for the samplejava.lang.Exception
public static double getMahalanobisDistSquared(Matrix Pt1M, Matrix Pt2M, Matrix covMat) throws java.lang.Exception
Pt1M
- the first coordinatePt2M
- the second coordinatecovMat
- the variance/covariance matrixjava.lang.Exception
RH, 2017