Class 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 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.
    • Constructor Detail

      • FossStdise

        public FossStdise​(byte[] bytes)
        Constructor.
        Parameters:
        bytes - byte array of .std file
    • 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 standardise
        fs - 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 unstandardise
        fs - 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 array
        offset - starting pos
        Returns:
        long
      • longFrom2Bytes

        protected long longFrom2Bytes​(byte[] b,
                                      int offset)
        Get long from 2 bytes LSByte first.
        Parameters:
        b - byte array
        offset - start in array
        Returns:
        long
      • main

        public static void main​(String[] args)
                         throws Exception
        TEST args0 foss std file to read.
        Parameters:
        args - commandline arguments
        Throws:
        Exception - if something goes wrong