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 intdatapoint_offsetnumber of wavelengths.protected static intdelta_offset_1segmentprotected static intdelta_offset_2segmentsstart of intercepts.protected intm_num_pointsnumber of wavelengths.protected static intsegments_offsetstart 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 intbyte2UByte(byte by)Convert byte to unsigned byte.protected longconvertToLong(byte[] b, int offset)Convert 4 bytes to long.intgetCoefficientOffset()Get start of coefficents.double[]getCoefficients()Get coefficients as array.double[]getDataFromOffset(int i)Get array of values starting from given offset.intgetDeltaOffset()Get start of intercept data.static byte[]getFileAsBytes(File f)Get array of bytes from file.double[]getIntercepts()Get intercepts as array.intgetNumDatapoints()Get number of nir wavelengths.intgetSegmentsOffset()Get start of segments data.double[]getSegs()Get segments as array.Stringiee754Dump(double[] bytes)Testing: Dump array is iee754 encoded ints.protected longlongFrom2Bytes(byte[] b, int offset)Get long from 2 bytes LSByte first.static voidmain(String[] args)TEST args0 foss std file to read.StringrawDump(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
-
-