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.DataContainerWriter>,adams.core.SizeOfHandler,adams.data.io.output.DataContainerWriter<Spectrum>,adams.data.io.output.StreamableBinaryDataContainerWriter<Spectrum>,adams.data.io.output.StreamableDataContainerWriter<Spectrum>,Serializable,Comparable
- Direct Known Subclasses:
CALSpectrumWriter
public class NIRSpectrumWriter extends AbstractSpectrumWriter implements adams.data.io.output.StreamableBinaryDataContainerWriter<Spectrum>
Writer that stores spectra 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
- Author:
- dale (dale at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringm_ClientClient name.protected Integerm_EOCNumber of EOC's per rev (???).protected Stringm_FileIDFile ID.protected Stringm_InstrumentNameThe instrument name to put in ASC header.protected Stringm_MasterSerial Number of Master Instrument.protected Stringm_OperatorOperator name.protected Stringm_ProductCodeEither the Field name with the product code in it, or the actual product code.protected Booleanm_ProductCodeFromFieldGet the product code from the Field named ProductCode in the Report?protected Stringm_SampleID1SampleID 1.protected Stringm_SampleID2SampleID 2.protected Stringm_SampleID3SampleID 3.protected adams.core.base.BaseInteger[]m_SegmentsSegment points.protected Stringm_SerialSerial Number of Instrument.protected adams.core.base.BaseDateTimem_Timestampthe timestamp to use in the file.protected adams.core.base.BaseFloat[]m_WaveEndsSegment ends.protected adams.core.base.BaseFloat[]m_WaveStartsSegment starting.protected adams.core.base.BaseFloat[]m_WaveStepsIncrements.
-
Constructor Summary
Constructors Constructor Description NIRSpectrumWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanWriteMultiple()Returns whether writing of multiple containers is supported.StringclientTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.StringendPointsTipText()Returns the tip text for this property.StringEOCTipText()Returns the tip text for this property.StringfileIDTipText()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.StringgetClient()Get client.FossOutputHelper.ConstituentValuesgetConstituentValues(Spectrum sp)Create ConstituentValues for a spectrum.FossOutputHelper.DataBlockgetDataBlock(Spectrum sp)Create a DataBlock from a spectrum.adams.core.base.BaseFloat[]getEndPoints()Get end points.IntegergetEOC()Get number of EOC's per rev (whatever that is!!)StringgetFileID()Get file id.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.FossOutputHelper.GeneralheadergetGeneralHeader(List<Spectrum> data)Create GeneralHeader from list of Spectra.adams.core.base.BaseFloat[]getIncrements()Get increments.FossOutputHelper.InstrumentHeadergetInstrumentHeader()Create InstrumentHeader using parameters.StringgetInstrumentName()Get instrument name.StringgetMaster()Get serial no of master.StringgetOperator()Get operator.StringgetProductCode()Get Product Code.BooleangetProductCodeFromField()Get product code from instance attribute?FossOutputHelper.SampleHeadergetSampleHeader(Spectrum sp, int pos)Create a SampleHeader from a Spectrum and position in list/file.StringgetSampleID1()Get sample id1.StringgetSampleID2()Get sample id2.StringgetSampleID3()Get sample id3.FossOutputHelper.SampleInfogetSampleInfo(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.StringgetSerialNo()Get serial no.adams.core.base.BaseFloat[]getStartPoints()Get start points.adams.core.base.BaseDateTimegetTimestamp()Get the timestamp to use in the file.StringglobalInfo()Returns a string describing the object.StringincrementsTipText()Returns the tip text for this property.protected voidinitialize()Initializes the members.StringinstrumentNameTipText()Returns the tip text for this property.StringmasterTipText()Returns the tip text for this property.StringoperatorTipText()Returns the tip text for this property.StringproductCodeFromFieldTipText()Returns the tip text for this property.StringproductCodeTipText()Returns the tip text for this property.StringsampleID1TipText()Returns the tip text for this property.StringsampleID2TipText()Returns the tip text for this property.StringsampleID3TipText()Returns the tip text for this property.StringsegmentWidthsTipText()Returns the tip text for this property.StringserialNoTipText()Returns the tip text for this property.voidsetClient(String client)Set client.voidsetEndPoints(adams.core.base.BaseFloat[] ep)Set end points.voidsetEOC(Integer eoc)Set number of EOC's per revvoidsetFileID(String fileID)Set file id.voidsetIncrements(adams.core.base.BaseFloat[] in)Set increments.voidsetInstrumentName(String mInstrumentName)Set instrument name.voidsetMaster(String serialNo)Set serial no of master.voidsetOperator(String operator)Set operator.voidsetProductCode(String productCode)Set product code.voidsetProductCodeFromField(Boolean mGetProductCodeFromAttribute)Set product code from instance attribute?voidsetSampleID1(String sampleID)Set sample id1.voidsetSampleID2(String sampleID)Set sample id2.voidsetSampleID3(String sampleID)Set sample id3.voidsetSegmentWidths(adams.core.base.BaseInteger[] segments)Set segments.voidsetSerialNo(String serialNo)Set serial no.voidsetStartPoints(adams.core.base.BaseFloat[] sp)Set start points.voidsetTimestamp(adams.core.base.BaseDateTime value)Set the timestamp to use in the file.StringstartPointsTipText()Returns the tip text for this property.StringtimestampTipText()Returns the tip text for this property.booleanwrite(OutputStream stream, Spectrum data)Performs checks and writes the data to the stream.booleanwrite(OutputStream stream, List<Spectrum> data)Performs checks and writes the data to the stream.protected booleanwriteData(List<Spectrum> data)Performs the actual writing.-
Methods inherited from class adams.data.io.output.AbstractSpectrumWriter
getWriters, outputTipText
-
Methods inherited from class adams.data.io.output.AbstractDataContainerWriter
checkData, cleanUp, compareTo, destroy, equals, forCommandLine, forName, getAdditionalInformation, getDefaultFormatExtension, getOutput, isOutputFile, 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
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Comparable
compareTo
-
Methods inherited from interface adams.data.io.output.DataContainerWriter
getOutput, isOutputFile, outputTipText, setOutput, write, write
-
-
-
-
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:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin 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:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin 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:
getFormatDescriptionin interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatDescriptionin 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:
getFormatExtensionsin interfaceadams.core.io.FileFormatHandler- Specified by:
getFormatExtensionsin classadams.data.io.output.AbstractDataContainerWriter<Spectrum>- Returns:
- the extension(s) (without the dot!)
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein 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.- Specified by:
canWriteMultiplein interfaceadams.data.io.output.DataContainerWriter<Spectrum>- Overrides:
canWriteMultiplein classAbstractSpectrumWriter- Returns:
- true if multiple containers are supported
-
writeData
protected boolean writeData(List<Spectrum> data)
Performs the actual writing.- Specified by:
writeDatain classadams.data.io.output.AbstractDataContainerWriter<Spectrum>- Parameters:
data- the data to write- Returns:
- success
-
write
public boolean write(OutputStream stream, Spectrum data)
Performs checks and writes the data to the stream.- Specified by:
writein interfaceadams.data.io.output.StreamableDataContainerWriter<Spectrum>- Parameters:
stream- the stream to write todata- the data to write- Returns:
- true if successfully written
- See Also:
write(OutputStream stream, List)
-
write
public boolean write(OutputStream stream, List<Spectrum> data)
Performs checks and writes the data to the stream.- Specified by:
writein interfaceadams.data.io.output.StreamableDataContainerWriter<Spectrum>- Parameters:
stream- the stream to write todata- the data to write- Returns:
- true if successfully written
-
-