Package adams.data.io.output
Class NIRSpectrumWriter
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.output.AbstractDataContainerWriter<Spectrum>
-
- adams.data.io.output.AbstractSpectrumWriter
-
- adams.data.io.output.NIRSpectrumWriter
-
- All Implemented Interfaces:
adams.core.AdditionalInformationHandler
,adams.core.CleanUpHandler
,adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.io.FileFormatHandler
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.ShallowCopySupporter<adams.data.io.output.AbstractDataContainerWriter>
,adams.core.SizeOfHandler
,Serializable
,Comparable
- Direct Known Subclasses:
CALSpectrumWriter
public class NIRSpectrumWriter extends AbstractSpectrumWriter
Writer that stores spectrums in the FOSS .nir Format.
Valid options are:
-D <int> (property: debugLevel) The greater the number the more additional info the scheme may output to the console (0 = off). default: 0 minimum: 0
-output <adams.core.io.PlaceholderFile> (property: output) The file to write the container to. default: ${TMP}/out.tmp
-instrumentName <java.lang.String> (property: instrumentName) Instrument Name. default: <not implemented>
-client <java.lang.String> (property: client) Client of Sample. default: client
-fileID <java.lang.String> (property: fileID) File ID. default: generated by ADAMS
-sampleID1 <java.lang.String> (property: sampleID1) Sample ID1. default:
-sampleID2 <java.lang.String> (property: sampleID2) Sample ID1. default:
-sampleID3 <java.lang.String> (property: sampleID3) Sample ID3. default:
-serialNo <java.lang.String> (property: serialNo) Serial Number of Instrument. default: 0000-0000-0000
-master <java.lang.String> (property: master) Serial Number of Master Instrument. default: 0000-0000-0000
-operator <java.lang.String> (property: operator) Instrument Operator. default: ADAMS
-productCode <java.lang.String> (property: productCode) Either the attribute name with the product code in it, or the actual product code to be used. default: 01
-productCodeFromField (property: productCodeFromField) Regex to find sample id. e.g 'sample_id'
-segments <adams.core.base.BaseInteger> [-segments ...] (property: segments) Segments. default: 1050
-increment <java.lang.Double> (property: increment) Increment default: 2.0
-firstXPoint <java.lang.Double> (property: firstXPoint) First wavenumber default: 3749.3428948242
-lastXPoint <java.lang.Double> (property: lastXPoint) Last wavenumber default: 9998.2477195313
-EOC <java.lang.Integer> (property: EOC) Number of EOC's per rev. default: 0
-timestamp <adams.core.base.BaseDateTime> (property: timestamp) The timestamp to use in the file; use 'NOW' for current time. default: NOW
- Version:
- $Revision: 2242 $
- Author:
- dale (dale at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_Client
Client name.protected Integer
m_EOC
Number of EOC's per rev (???).protected String
m_FileID
File ID.protected String
m_InstrumentName
The instrument name to put in ASC header.protected String
m_Master
Serial Number of Master Instrument.protected String
m_Operator
Operator name.protected String
m_ProductCode
Either the Field name with the product code in it, or the actual product code.protected Boolean
m_ProductCodeFromField
Get the product code from the Field named ProductCode in the Report?protected String
m_SampleID1
SampleID 1.protected String
m_SampleID2
SampleID 2.protected String
m_SampleID3
SampleID 3.protected adams.core.base.BaseInteger[]
m_Segments
Segment points.protected String
m_Serial
Serial Number of Instrument.protected adams.core.base.BaseDateTime
m_Timestamp
the timestamp to use in the file.protected adams.core.base.BaseFloat[]
m_WaveEnds
Segment ends.protected adams.core.base.BaseFloat[]
m_WaveStarts
Segment starting.protected adams.core.base.BaseFloat[]
m_WaveSteps
Increments.
-
Constructor Summary
Constructors Constructor Description NIRSpectrumWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canWriteMultiple()
Returns whether writing of multiple containers is supported.String
clientTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.String
endPointsTipText()
Returns the tip text for this property.String
EOCTipText()
Returns the tip text for this property.String
fileIDTipText()
Returns the tip text for this property.protected byte[]
genByteArray(Spectrum data)
Generate the byte array that makes up the .nir file.protected byte[]
genByteArray(List<Spectrum> datalist)
Generate the byte array that makes up the .nir file.String
getClient()
Get client.FossOutputHelper.ConstituentValues
getConstituentValues(Spectrum sp)
Create ConstituentValues for a spectrum.FossOutputHelper.DataBlock
getDataBlock(Spectrum sp)
Create a DataBlock from a spectrum.adams.core.base.BaseFloat[]
getEndPoints()
Get end points.Integer
getEOC()
Get number of EOC's per rev (whatever that is!!)String
getFileID()
Get file id.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.FossOutputHelper.Generalheader
getGeneralHeader(List<Spectrum> data)
Create GeneralHeader from list of Spectra.adams.core.base.BaseFloat[]
getIncrements()
Get increments.FossOutputHelper.InstrumentHeader
getInstrumentHeader()
Create InstrumentHeader using parameters.String
getInstrumentName()
Get instrument name.String
getMaster()
Get serial no of master.String
getOperator()
Get operator.String
getProductCode()
Get Product Code.Boolean
getProductCodeFromField()
Get product code from instance attribute?FossOutputHelper.SampleHeader
getSampleHeader(Spectrum sp, int pos)
Create a SampleHeader from a Spectrum and position in list/file.String
getSampleID1()
Get sample id1.String
getSampleID2()
Get sample id2.String
getSampleID3()
Get sample id3.FossOutputHelper.SampleInfo
getSampleInfo(Spectrum sp, int pos)
Create a SampleInfo for the file footer based on a Spectrum and it's position in list/file.adams.core.base.BaseInteger[]
getSegmentWidths()
Get segments.String
getSerialNo()
Get serial no.adams.core.base.BaseFloat[]
getStartPoints()
Get start points.adams.core.base.BaseDateTime
getTimestamp()
Get the timestamp to use in the file.String
globalInfo()
Returns a string describing the object.String
incrementsTipText()
Returns the tip text for this property.protected void
initialize()
Initializes the members.String
instrumentNameTipText()
Returns the tip text for this property.String
masterTipText()
Returns the tip text for this property.String
operatorTipText()
Returns the tip text for this property.String
productCodeFromFieldTipText()
Returns the tip text for this property.String
productCodeTipText()
Returns the tip text for this property.String
sampleID1TipText()
Returns the tip text for this property.String
sampleID2TipText()
Returns the tip text for this property.String
sampleID3TipText()
Returns the tip text for this property.String
segmentWidthsTipText()
Returns the tip text for this property.String
serialNoTipText()
Returns the tip text for this property.void
setClient(String client)
Set client.void
setEndPoints(adams.core.base.BaseFloat[] ep)
Set end points.void
setEOC(Integer eoc)
Set number of EOC's per revvoid
setFileID(String fileID)
Set file id.void
setIncrements(adams.core.base.BaseFloat[] in)
Set increments.void
setInstrumentName(String mInstrumentName)
Set instrument name.void
setMaster(String serialNo)
Set serial no of master.void
setOperator(String operator)
Set operator.void
setProductCode(String productCode)
Set product code.void
setProductCodeFromField(Boolean mGetProductCodeFromAttribute)
Set product code from instance attribute?void
setSampleID1(String sampleID)
Set sample id1.void
setSampleID2(String sampleID)
Set sample id2.void
setSampleID3(String sampleID)
Set sample id3.void
setSegmentWidths(adams.core.base.BaseInteger[] segments)
Set segments.void
setSerialNo(String serialNo)
Set serial no.void
setStartPoints(adams.core.base.BaseFloat[] sp)
Set start points.void
setTimestamp(adams.core.base.BaseDateTime value)
Set the timestamp to use in the file.String
startPointsTipText()
Returns the tip text for this property.String
timestampTipText()
Returns the tip text for this property.protected boolean
writeData(List<Spectrum> data)
Performs the actual writing.-
Methods inherited from class adams.data.io.output.AbstractSpectrumWriter
getWriters
-
Methods inherited from class adams.data.io.output.AbstractDataContainerWriter
checkData, cleanUp, compareTo, destroy, equals, forCommandLine, forName, getAdditionalInformation, getDefaultFormatExtension, getOutput, isOutputFile, outputTipText, reset, setOutput, shallowCopy, shallowCopy, write, write
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_FileID
protected String m_FileID
File ID.
-
m_InstrumentName
protected String m_InstrumentName
The instrument name to put in ASC header.
-
m_Serial
protected String m_Serial
Serial Number of Instrument.
-
m_SampleID1
protected String m_SampleID1
SampleID 1.
-
m_SampleID2
protected String m_SampleID2
SampleID 2.
-
m_SampleID3
protected String m_SampleID3
SampleID 3.
-
m_Master
protected String m_Master
Serial Number of Master Instrument.
-
m_ProductCode
protected String m_ProductCode
Either the Field name with the product code in it, or the actual product code. Decided by m_GetProductCodeFromAttribute.
-
m_Operator
protected String m_Operator
Operator name.
-
m_Client
protected String m_Client
Client name.
-
m_Segments
protected adams.core.base.BaseInteger[] m_Segments
Segment points.
-
m_WaveStarts
protected adams.core.base.BaseFloat[] m_WaveStarts
Segment starting.
-
m_WaveSteps
protected adams.core.base.BaseFloat[] m_WaveSteps
Increments.
-
m_WaveEnds
protected adams.core.base.BaseFloat[] m_WaveEnds
Segment ends.
-
m_ProductCodeFromField
protected Boolean m_ProductCodeFromField
Get the product code from the Field named ProductCode in the Report? Otherwise use the ProductCode string directly.
-
m_EOC
protected Integer m_EOC
Number of EOC's per rev (???).
-
m_Timestamp
protected adams.core.base.BaseDateTime m_Timestamp
the timestamp to use in the file.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.data.io.output.AbstractDataContainerWriter<Spectrum>
-
getIncrements
public adams.core.base.BaseFloat[] getIncrements()
Get increments.- Returns:
- increments.
-
setIncrements
public void setIncrements(adams.core.base.BaseFloat[] in)
Set increments.- Parameters:
in
- increments.
-
incrementsTipText
public String incrementsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getEndPoints
public adams.core.base.BaseFloat[] getEndPoints()
Get end points.- Returns:
- end points.
-
setEndPoints
public void setEndPoints(adams.core.base.BaseFloat[] ep)
Set end points.- Parameters:
ep
- end points .
-
endPointsTipText
public String endPointsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getStartPoints
public adams.core.base.BaseFloat[] getStartPoints()
Get start points.- Returns:
- start points.
-
setStartPoints
public void setStartPoints(adams.core.base.BaseFloat[] sp)
Set start points.- Parameters:
sp
- start points .
-
startPointsTipText
public String startPointsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getSegmentWidths
public adams.core.base.BaseInteger[] getSegmentWidths()
Get segments.- Returns:
- segments.
-
setSegmentWidths
public void setSegmentWidths(adams.core.base.BaseInteger[] segments)
Set segments.- Parameters:
segments
- segments .
-
segmentWidthsTipText
public String segmentWidthsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getProductCodeFromField
public Boolean getProductCodeFromField()
Get product code from instance attribute? Or use as string.- Returns:
- Get product code from instance attribute?
-
setProductCodeFromField
public void setProductCodeFromField(Boolean mGetProductCodeFromAttribute)
Set product code from instance attribute? Or use as string.- Parameters:
mGetProductCodeFromAttribute
- Set product code from instance attribute?
-
productCodeFromFieldTipText
public String productCodeFromFieldTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getProductCode
public String getProductCode()
Get Product Code.- Returns:
- product code
-
setProductCode
public void setProductCode(String productCode)
Set product code.- Parameters:
productCode
- product code.
-
productCodeTipText
public String productCodeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getMaster
public String getMaster()
Get serial no of master.- Returns:
- serial no of master.
-
setMaster
public void setMaster(String serialNo)
Set serial no of master.- Parameters:
serialNo
- serial no of master.
-
masterTipText
public String masterTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getSerialNo
public String getSerialNo()
Get serial no.- Returns:
- serial no.
-
setSerialNo
public void setSerialNo(String serialNo)
Set serial no.- Parameters:
serialNo
- serial no.
-
serialNoTipText
public String serialNoTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getClient
public String getClient()
Get client.- Returns:
- client.
-
setClient
public void setClient(String client)
Set client.- Parameters:
client
- client.
-
clientTipText
public String clientTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getOperator
public String getOperator()
Get operator.- Returns:
- operator.
-
setOperator
public void setOperator(String operator)
Set operator.- Parameters:
operator
- operator.
-
operatorTipText
public String operatorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getSampleID1
public String getSampleID1()
Get sample id1.- Returns:
- sample id1.
-
setSampleID1
public void setSampleID1(String sampleID)
Set sample id1.- Parameters:
sampleID
- sampleID1
-
sampleID1TipText
public String sampleID1TipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getSampleID2
public String getSampleID2()
Get sample id2.- Returns:
- sample id2.
-
setSampleID2
public void setSampleID2(String sampleID)
Set sample id2.- Parameters:
sampleID
- sampleID2
-
sampleID2TipText
public String sampleID2TipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getSampleID3
public String getSampleID3()
Get sample id3.- Returns:
- sample id3.
-
setSampleID3
public void setSampleID3(String sampleID)
Set sample id3.- Parameters:
sampleID
- sampleID3
-
sampleID3TipText
public String sampleID3TipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getFileID
public String getFileID()
Get file id.- Returns:
- file id.
-
setFileID
public void setFileID(String fileID)
Set file id.- Parameters:
fileID
- file ID
-
fileIDTipText
public String fileIDTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getInstrumentName
public String getInstrumentName()
Get instrument name.- Returns:
- instrument name
-
setInstrumentName
public void setInstrumentName(String mInstrumentName)
Set instrument name.- Parameters:
mInstrumentName
- instrument name
-
instrumentNameTipText
public String instrumentNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getEOC
public Integer getEOC()
Get number of EOC's per rev (whatever that is!!)- Returns:
- numbe of EOC's per rev
-
setEOC
public void setEOC(Integer eoc)
Set number of EOC's per rev- Parameters:
eoc
- number of EOC's per rev
-
EOCTipText
public String EOCTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getTimestamp
public adams.core.base.BaseDateTime getTimestamp()
Get the timestamp to use in the file.- Returns:
- the timestamp
-
setTimestamp
public void setTimestamp(adams.core.base.BaseDateTime value)
Set the timestamp to use in the file.- Parameters:
value
- the timestamp
-
timestampTipText
public String timestampTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.core.option.AbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescription
in interfaceadams.core.io.FileFormatHandler
- Specified by:
getFormatDescription
in classadams.data.io.output.AbstractDataContainerWriter<Spectrum>
- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensions
in interfaceadams.core.io.FileFormatHandler
- Specified by:
getFormatExtensions
in classadams.data.io.output.AbstractDataContainerWriter<Spectrum>
- Returns:
- the extension(s) (without the dot!)
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classadams.core.option.AbstractOptionHandler
-
getGeneralHeader
public FossOutputHelper.Generalheader getGeneralHeader(List<Spectrum> data)
Create GeneralHeader from list of Spectra.- Parameters:
data
- list of Spectra- Returns:
- GeneralHeader
-
getInstrumentHeader
public FossOutputHelper.InstrumentHeader getInstrumentHeader()
Create InstrumentHeader using parameters.- Returns:
- InstrumentHeader
-
getSampleHeader
public FossOutputHelper.SampleHeader getSampleHeader(Spectrum sp, int pos)
Create a SampleHeader from a Spectrum and position in list/file.- Parameters:
sp
- spectrumpos
- position- Returns:
- SampleHeader
-
getDataBlock
public FossOutputHelper.DataBlock getDataBlock(Spectrum sp)
Create a DataBlock from a spectrum.- Parameters:
sp
- spectrum- Returns:
- DataBlock
-
getConstituentValues
public FossOutputHelper.ConstituentValues getConstituentValues(Spectrum sp)
Create ConstituentValues for a spectrum.- Parameters:
sp
- spectrum- Returns:
- ConstituentValues
-
getSampleInfo
public FossOutputHelper.SampleInfo getSampleInfo(Spectrum sp, int pos)
Create a SampleInfo for the file footer based on a Spectrum and it's position in list/file.- Parameters:
sp
- Spectrumpos
- position- Returns:
- SampleInfo
-
genByteArray
protected byte[] genByteArray(List<Spectrum> datalist) throws Exception
Generate the byte array that makes up the .nir file.- Parameters:
datalist
- the Spectra to write.- Returns:
- byte array.
- Throws:
Exception
-
genByteArray
protected byte[] genByteArray(Spectrum data)
Generate the byte array that makes up the .nir file.- Parameters:
data
- the data to write- Returns:
- ASC file as string.
-
canWriteMultiple
public boolean canWriteMultiple()
Returns whether writing of multiple containers is supported.- Overrides:
canWriteMultiple
in classAbstractSpectrumWriter
- Returns:
- true if multiple containers are supported
-
-