Package adams.data.io.input.foss
Class FossStdise
- java.lang.Object
-
- adams.data.io.input.foss.FossStdise
-
public class FossStdise extends Object
Load, and perform standardisation/unstandardisation from foss standardisation file NOTE: Only does slope and intercept standardisation NOTE 2: Established by looking at .std files with hex editor. Use with caution- Version:
- $Revision: 2237 $
- Author:
- dale
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
datapoint_offset
number of wavelengths.protected static int
delta_offset_1segment
protected static int
delta_offset_2segments
start of intercepts.protected int
m_num_points
number of wavelengths.protected static int
segments_offset
start of segment data.
-
Constructor Summary
Constructors Constructor Description FossStdise(byte[] bytes)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
byte2UByte(byte by)
Convert byte to unsigned byte.protected long
convertToLong(byte[] b, int offset)
Convert 4 bytes to long.int
getCoefficientOffset()
Get start of coefficents.double[]
getCoefficients()
Get coefficients as array.double[]
getDataFromOffset(int i)
Get array of values starting from given offset.int
getDeltaOffset()
Get start of intercept data.static byte[]
getFileAsBytes(File f)
Get array of bytes from file.double[]
getIntercepts()
Get intercepts as array.int
getNumDatapoints()
Get number of nir wavelengths.int
getSegmentsOffset()
Get start of segments data.double[]
getSegs()
Get segments as array.String
iee754Dump(double[] bytes)
Testing: Dump array is iee754 encoded ints.protected long
longFrom2Bytes(byte[] b, int offset)
Get long from 2 bytes LSByte first.static void
main(String[] args)
TEST args0 foss std file to read.String
rawDump(double[] bytes)
Testing: output raw bytes.static double[]
standardise(double[] input, FossStdise fs)
standardise nir data according to coefficients and intercepts taken from .std file.static double[]
unstandardise(double[] input, FossStdise fs)
Unstandardise nir data according to coefficients and intercepts taken from .std file.
-
-
-
Field Detail
-
datapoint_offset
protected static int datapoint_offset
number of wavelengths.
-
segments_offset
protected static int segments_offset
start of segment data.
-
delta_offset_2segments
protected static int delta_offset_2segments
start of intercepts.
-
delta_offset_1segment
protected static int delta_offset_1segment
-
m_num_points
protected int m_num_points
number of wavelengths.
-
-
Method Detail
-
getSegmentsOffset
public int getSegmentsOffset()
Get start of segments data.- Returns:
- segments start
-
getDeltaOffset
public int getDeltaOffset()
Get start of intercept data.- Returns:
- intercept start
-
rawDump
public String rawDump(double[] bytes)
Testing: output raw bytes.- Parameters:
bytes
-- Returns:
-
iee754Dump
public String iee754Dump(double[] bytes)
Testing: Dump array is iee754 encoded ints.- Parameters:
bytes
-- Returns:
-
getCoefficientOffset
public int getCoefficientOffset()
Get start of coefficents.- Returns:
- coefficient offset
-
getDataFromOffset
public double[] getDataFromOffset(int i)
Get array of values starting from given offset. Size is number of wavelengths- Parameters:
i
- start from- Returns:
- double array
-
standardise
public static double[] standardise(double[] input, FossStdise fs)
standardise nir data according to coefficients and intercepts taken from .std file.- Parameters:
input
- byte array to standardisefs
- FossStdise- Returns:
- standardised data
-
unstandardise
public static double[] unstandardise(double[] input, FossStdise fs)
Unstandardise nir data according to coefficients and intercepts taken from .std file.- Parameters:
input
- byte array to unstandardisefs
- FossStdise- Returns:
- unstandardised data
-
getFileAsBytes
public static byte[] getFileAsBytes(File f)
Get array of bytes from file.- Parameters:
f
- file- Returns:
- byte array
-
getCoefficients
public double[] getCoefficients()
Get coefficients as array.- Returns:
- coefficients
-
getIntercepts
public double[] getIntercepts()
Get intercepts as array.- Returns:
- intercepts
-
getSegs
public double[] getSegs()
Get segments as array. TODO: Not currently processed!!- Returns:
- segments array
-
getNumDatapoints
public int getNumDatapoints()
Get number of nir wavelengths.- Returns:
- num wavelengths
-
byte2UByte
protected int byte2UByte(byte by)
Convert byte to unsigned byte.- Parameters:
by
- byte- Returns:
- unsigned byte
-
convertToLong
protected long convertToLong(byte[] b, int offset)
Convert 4 bytes to long. LSByte first- Parameters:
b
- byte arrayoffset
- starting pos- Returns:
- long
-
longFrom2Bytes
protected long longFrom2Bytes(byte[] b, int offset)
Get long from 2 bytes LSByte first.- Parameters:
b
- byte arrayoffset
- start in array- Returns:
- long
-
-