Package adams.data.io.input.foss
Class FossHelper
- java.lang.Object
-
- adams.data.io.input.foss.FossHelper
-
public class FossHelper extends Object
Helper for handling Foss cal files. Info used here is from studying .cal files with hex editor. Has been tested on many .cal files, but no guarantees.- Author:
- dale
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
FossHelper.FossFields
Stores non-spectral data for a row.
-
Field Summary
Fields Modifier and Type Field Description protected static int
count_offset
number of Rows in this file.protected static int
datapoint_offset
number of nir wavelengths.protected static int
deleted_offset
number of Rows in this file.protected static int
head_end
data header end.protected int
m_count
number of (non deleted) spectra.protected int
m_deleted
number of deleted rows in this file.protected int
m_num_points
number of spectral data points.protected int
m_ref_count
number of reference values per spectra.protected List<String>
m_ref_names
reference names.protected int
m_spectra_head_size
size of spectrum header (static).protected int
m_spectra_size
size of spectra data.protected int
m_spectra_tail_size
size of spectrum tail (static).protected static int
Npps_offset
protected static int
NSeg_offset
protected static int
reference_count
protected static int
reference_name_num
protected static int
reference_name_width
protected static int
reference_offset
protected static int
Wave_offset
protected static int
WaveType_offset
-
Constructor Summary
Constructors Constructor Description FossHelper(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
countDeleted()
How many deleted rows?int
getBlockSize()
Get block size of a row in bytes.int
getCount()
Number of non-deleted rows.FossHelper.FossFields
getFields(int i)
Get the non-spectral data for a given row.int
getNumDatapoints()
Number of spectral data points.int
getNumSegments()
get number of segmentsint
getRefCount()
number of reference values.List<String>
getReferenceNames()
Get names of references.float[]
getRefForRow(int i)
Get reference values for a row.int
getRefOffsetForRow(int i)
Get start of reference for given row.double[]
getSegmentEnd()
double[]
getSegmentInc()
int[]
getSegmentLengths()
double[]
getSegmentStart()
int
getSegmentsType()
Get segment type (00=TILFIL, 01=EQLSPC, 02=FILFIL, 03=SINSPAprotected int
getSpectraBlockSize()
Get size of the spectral data block.double[]
getSpectraForRow(int i)
Get spectrum of row.int
getSpectraOffsetForRow(int i)
Get start of spectrum for given row.int
getTotal()
Total number of rows, including deleted rows.double[]
getWavenumbers()
protected String
getZeroTerminatedString(int offset)
Build string until reaching zero termination.protected long
longFrom2Bytes(byte[] b, int offset)
Get long from 2 bytes LSByte first.static void
main(String[] args)
Test.boolean
processHeader()
Process the data from the cal file header.
-
-
-
Field Detail
-
count_offset
protected static int count_offset
number of Rows in this file.
-
deleted_offset
protected static int deleted_offset
number of Rows in this file.
-
datapoint_offset
protected static int datapoint_offset
number of nir wavelengths.
-
reference_count
protected static int reference_count
-
reference_offset
protected static int reference_offset
-
reference_name_width
protected static int reference_name_width
-
reference_name_num
protected static int reference_name_num
-
NSeg_offset
protected static int NSeg_offset
-
Npps_offset
protected static int Npps_offset
-
WaveType_offset
protected static int WaveType_offset
-
Wave_offset
protected static int Wave_offset
-
head_end
protected static int head_end
data header end.
-
m_count
protected int m_count
number of (non deleted) spectra.
-
m_num_points
protected int m_num_points
number of spectral data points.
-
m_ref_count
protected int m_ref_count
number of reference values per spectra.
-
m_spectra_head_size
protected int m_spectra_head_size
size of spectrum header (static).
-
m_spectra_size
protected int m_spectra_size
size of spectra data.
-
m_spectra_tail_size
protected int m_spectra_tail_size
size of spectrum tail (static).
-
m_deleted
protected int m_deleted
number of deleted rows in this file.
-
-
Method Detail
-
getFields
public FossHelper.FossFields getFields(int i)
Get the non-spectral data for a given row.- Parameters:
i
- row number- Returns:
-
getSpectraForRow
public double[] getSpectraForRow(int i)
Get spectrum of row.- Parameters:
i
- row num- Returns:
- spectrum as array
-
getRefForRow
public float[] getRefForRow(int i)
Get reference values for a row. Sorted as per getRefNames()- Parameters:
i
- row num- Returns:
- array of reference values
-
getBlockSize
public int getBlockSize()
Get block size of a row in bytes.- Returns:
- size of all data for a row
-
getSpectraBlockSize
protected int getSpectraBlockSize()
Get size of the spectral data block. (taking account of padding)- Returns:
- size of the spectral data block
-
getSpectraOffsetForRow
public int getSpectraOffsetForRow(int i)
Get start of spectrum for given row.- Parameters:
i
- row number- Returns:
- spectrum start
-
getRefOffsetForRow
public int getRefOffsetForRow(int i)
Get start of reference for given row.- Parameters:
i
- row number- Returns:
- ref values start
-
processHeader
public boolean processHeader()
Process the data from the cal file header.- Returns:
- true
-
getTotal
public int getTotal()
Total number of rows, including deleted rows.- Returns:
- total num rows
-
countDeleted
public int countDeleted()
How many deleted rows?- Returns:
- deleted rows?
-
getRefCount
public int getRefCount()
number of reference values.- Returns:
- ref count
-
getSegmentsType
public int getSegmentsType()
Get segment type (00=TILFIL, 01=EQLSPC, 02=FILFIL, 03=SINSPA- Returns:
- type
-
getNumSegments
public int getNumSegments()
get number of segments- Returns:
- num segments
-
getSegmentLengths
public int[] getSegmentLengths()
-
getSegmentStart
public double[] getSegmentStart()
-
getSegmentInc
public double[] getSegmentInc()
-
getSegmentEnd
public double[] getSegmentEnd()
-
getWavenumbers
public double[] getWavenumbers()
-
getReferenceNames
public List<String> getReferenceNames()
Get names of references.- Returns:
- reference names
-
getZeroTerminatedString
protected String getZeroTerminatedString(int offset)
Build string until reaching zero termination.- Parameters:
offset
- pos in file to start- Returns:
- string
-
getCount
public int getCount()
Number of non-deleted rows.- Returns:
- num rows
-
getNumDatapoints
public int getNumDatapoints()
Number of spectral data points.- Returns:
- num data points
-
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
-
-