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 classFossHelper.FossFieldsStores non-spectral data for a row.
-
Field Summary
Fields Modifier and Type Field Description protected static intcount_offsetnumber of Rows in this file.protected static intdatapoint_offsetnumber of nir wavelengths.protected static intdeleted_offsetnumber of Rows in this file.protected static inthead_enddata header end.protected intm_countnumber of (non deleted) spectra.protected intm_deletednumber of deleted rows in this file.protected intm_num_pointsnumber of spectral data points.protected intm_ref_countnumber of reference values per spectra.protected List<String>m_ref_namesreference names.protected intm_spectra_head_sizesize of spectrum header (static).protected intm_spectra_sizesize of spectra data.protected intm_spectra_tail_sizesize of spectrum tail (static).protected static intNpps_offsetprotected static intNSeg_offsetprotected static intreference_countprotected static intreference_name_numprotected static intreference_name_widthprotected static intreference_offsetprotected static intWave_offsetprotected static intWaveType_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 intbyte2UByte(byte by)Convert byte to unsigned byte.protected longconvertToLong(byte[] b, int offset)Convert 4 bytes to long.intcountDeleted()How many deleted rows?intgetBlockSize()Get block size of a row in bytes.intgetCount()Number of non-deleted rows.FossHelper.FossFieldsgetFields(int i)Get the non-spectral data for a given row.intgetNumDatapoints()Number of spectral data points.intgetNumSegments()get number of segmentsintgetRefCount()number of reference values.List<String>getReferenceNames()Get names of references.float[]getRefForRow(int i)Get reference values for a row.intgetRefOffsetForRow(int i)Get start of reference for given row.double[]getSegmentEnd()double[]getSegmentInc()int[]getSegmentLengths()double[]getSegmentStart()intgetSegmentsType()Get segment type (00=TILFIL, 01=EQLSPC, 02=FILFIL, 03=SINSPAprotected intgetSpectraBlockSize()Get size of the spectral data block.double[]getSpectraForRow(int i)Get spectrum of row.intgetSpectraOffsetForRow(int i)Get start of spectrum for given row.intgetTotal()Total number of rows, including deleted rows.double[]getWavenumbers()protected StringgetZeroTerminatedString(int offset)Build string until reaching zero termination.protected longlongFrom2Bytes(byte[] b, int offset)Get long from 2 bytes LSByte first.static voidmain(String[] args)Test.booleanprocessHeader()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
-
-