Package adams.data.io.input
Class RowWiseSpreadSheetSpectrumReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.input.AbstractDataContainerReader<Spectrum>
-
- adams.data.io.input.AbstractSpectrumReader
-
- adams.data.io.input.RowWiseSpreadSheetSpectrumReader
-
- 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.input.AbstractDataContainerReader>
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.data.io.input.MetaFileReader
,Serializable
,Comparable
public class RowWiseSpreadSheetSpectrumReader extends AbstractSpectrumReader implements adams.data.io.input.MetaFileReader
Reads spectra from rows in a spreadsheet obtained with the specified spreadsheet reader.
Sample ID and sample data columns get removed automatically from the range of wave columns.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING min-user-mode: Expert
-input <adams.core.io.PlaceholderFile> (property: input) The file to read and turn into a container. default: ${CWD}
-create-dummy-report <boolean> (property: createDummyReport) If true, then a dummy report is created if none present. default: false
-instrument <java.lang.String> (property: instrument) The name of the instrument that generated the spectra (if not already present in data). default: unknown
-format <java.lang.String> (property: format) The data format string. default: NIR
-keep-format <boolean> (property: keepFormat) If enabled the format obtained from the file is not replaced by the format defined here. default: false
-use-absolute-source <boolean> (property: useAbsoluteSource) If enabled the source report field stores the absolute file name rather than just the name. default: false
-reader <adams.data.io.input.SpreadSheetReader> (property: reader) The spreadsheet reader to use for reading the raw data. default: adams.data.io.input.CsvSpreadSheetReader -data-row-type adams.data.spreadsheet.DenseDataRow -spreadsheet-type adams.data.spreadsheet.DefaultSpreadSheet
-row-finder <adams.data.spreadsheet.rowfinder.RowFinder> (property: rowFinder) The row finder to use for optionally filtering the rows. default: adams.data.spreadsheet.rowfinder.AllFinder
-sample-id-column <adams.data.spreadsheet.SpreadSheetColumnIndex> (property: sampleIDColumn) The column containing the sample ID. default: example: An index is a number starting with 1; column names (case-sensitive) as well as the following placeholders can be used: first, second, third, last_2, last_1, last; numeric indices can be enforced by preceding them with '#' (eg '#12'); column names can be surrounded by double quotes.
-wave-columns <adams.data.spreadsheet.SpreadSheetColumnRange> (property: waveColumns) The columns containing the wave amplitudes. default: example: A range is a comma-separated list of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(...)' inverts the range '...'; column names (case-sensitive) as well as the following placeholders can be used: first, second, third, last_2, last_1, last; numeric indices can be enforced by preceding them with '#' (eg '#12'); column names can be surrounded by double quotes.
-header-contains-wave-number <boolean> (property: headerContainsWaveNumber) The columns containing the wave amplitudes. default: false
-wave-number-regexp <adams.core.base.BaseRegExp> (property: waveNumberRegExp) The regular expression to identify the wave number (1st group is used). default: (.*) more: https://docs.oracle.com/javase/tutorial/essential/regex/ https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/regex/Pattern.html
-sample-data-columns <adams.data.spreadsheet.SpreadSheetColumnRange> (property: sampleDataColumns) The columns containing the sample data. default: example: A range is a comma-separated list of single 1-based indices or sub-ranges of indices ('start-end'); 'inv(...)' inverts the range '...'; column names (case-sensitive) as well as the following placeholders can be used: first, second, third, last_2, last_1, last; numeric indices can be enforced by preceding them with '#' (eg '#12'); column names can be surrounded by double quotes.
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RowWiseSpreadSheetSpectrumReader.ChunkedSheetIterator
Iterator for chunked spreadsheet readers.static class
RowWiseSpreadSheetSpectrumReader.MultiSheetIterator
Iterator for multi-sheet readers.static class
RowWiseSpreadSheetSpectrumReader.SheetIterator
Ancestor for sheet iterators.static class
RowWiseSpreadSheetSpectrumReader.SingleSheetIterator
Iterator for single-sheet readers.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_HeaderContainsWaveNumber
whether the column header is the wave number.protected adams.data.io.input.SpreadSheetReader
m_Reader
the spreadsheet reader to use.protected adams.data.spreadsheet.rowfinder.RowFinder
m_RowFinder
the row finder to use.protected adams.data.spreadsheet.SpreadSheetColumnRange
m_SampleDataColumns
the range of columns containing sample data.protected adams.data.spreadsheet.SpreadSheetColumnIndex
m_SampleIDColumn
the column containing the sample ID.protected adams.data.spreadsheet.SpreadSheetColumnRange
m_WaveColumns
the range of columns containing wave amplitudes.protected adams.core.base.BaseRegExp
m_WaveNumberRegExp
the regular expression to extract the wave number from the header (first group is used).-
Fields inherited from class adams.data.io.input.AbstractSpectrumReader
m_Format, m_Instrument, m_KeepFormat, m_Stopped, m_UseAbsoluteSource, OPTION_OUTPUTDIR
-
-
Constructor Summary
Constructors Constructor Description RowWiseSpreadSheetSpectrumReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.String[]
getActualFormatExtensions()
Returns the underlying format extensions.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.boolean
getHeaderContainsWaveNumber()
Returns whether to extract the wave number from the header columns.adams.data.io.input.SpreadSheetReader
getReader()
Returns the spreadsheet reader in use.adams.data.spreadsheet.rowfinder.RowFinder
getRowFinder()
Returns the row finder to use for filtering the rows.adams.data.spreadsheet.SpreadSheetColumnRange
getSampleDataColumns()
Returns the columns containing the sample data.adams.data.spreadsheet.SpreadSheetColumnIndex
getSampleIDColumn()
Returns the column containing the sample ID.adams.data.spreadsheet.SpreadSheetColumnRange
getWaveColumns()
Returns the columns containing the wave amplitudes.adams.core.base.BaseRegExp
getWaveNumberRegExp()
Returns the regular expression to identify the wave number (1st group is used).String
globalInfo()
Returns a string describing the object.String
headerContainsWaveNumberTipText()
Returns the tip text for this property.protected List<adams.data.report.Field>
identifySampleData(adams.data.spreadsheet.SpreadSheet sheet, int[] cols)
Returns the sample data fields.protected gnu.trove.list.array.TFloatArrayList
identifyWaveNumbers(adams.data.spreadsheet.SpreadSheet sheet, int[] cols)
Indentifies the wave numbers.static void
main(String[] args)
Runs the reader from the command-line.protected void
readData()
Performs the actual reading.String
readerTipText()
Returns the tip text for this property.String
rowFinderTipText()
Returns the tip text for this property.String
sampleDataColumnsTipText()
Returns the tip text for this property.String
sampleIDColumnTipText()
Returns the tip text for this property.void
setHeaderContainsWaveNumber(boolean value)
Sets whether to extract the wave number from the header columns.void
setReader(adams.data.io.input.SpreadSheetReader value)
Sets the spreadsheet reader to use.void
setRowFinder(adams.data.spreadsheet.rowfinder.RowFinder value)
Sets the row finder to use for filtering the rows.void
setSampleDataColumns(adams.data.spreadsheet.SpreadSheetColumnRange value)
Sets the columns containing the sample data.void
setSampleIDColumn(adams.data.spreadsheet.SpreadSheetColumnIndex value)
Sets the column containing the sample ID.void
setWaveColumns(adams.data.spreadsheet.SpreadSheetColumnRange value)
Sets the columns containing the wave amplitudes.void
setWaveNumberRegExp(adams.core.base.BaseRegExp value)
Sets the regular expression to identify the wave number (1st group is used).void
stopExecution()
Stops the execution.String
waveColumnsTipText()
Returns the tip text for this property.String
waveNumberRegExpTipText()
Returns the tip text for this property.-
Methods inherited from class adams.data.io.input.AbstractSpectrumReader
checkData, createDummyReport, formatTipText, getDefaultFormat, getDefaultInstrument, getDefaultKeepFormat, getDefaultUseAbsoluteSource, getFormat, getInstrument, getKeepFormat, getReaders, getUseAbsoluteSource, instrumentTipText, keepFormatTipText, postProcessData, runReader, setFormat, setInstrument, setKeepFormat, setUseAbsoluteSource, useAbsoluteSourceTipText
-
Methods inherited from class adams.data.io.input.AbstractDataContainerReader
cleanUp, compareTo, createDummyReportTipText, destroy, doRead, equals, getAdditionalInformation, getCreateDummyReport, getDefaultFormatExtension, getInput, initialize, inputTipText, isInputFile, read, reset, setCreateDummyReport, setInput, shallowCopy, shallowCopy
-
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_Reader
protected adams.data.io.input.SpreadSheetReader m_Reader
the spreadsheet reader to use.
-
m_RowFinder
protected adams.data.spreadsheet.rowfinder.RowFinder m_RowFinder
the row finder to use.
-
m_SampleIDColumn
protected adams.data.spreadsheet.SpreadSheetColumnIndex m_SampleIDColumn
the column containing the sample ID.
-
m_WaveColumns
protected adams.data.spreadsheet.SpreadSheetColumnRange m_WaveColumns
the range of columns containing wave amplitudes.
-
m_HeaderContainsWaveNumber
protected boolean m_HeaderContainsWaveNumber
whether the column header is the wave number.
-
m_WaveNumberRegExp
protected adams.core.base.BaseRegExp m_WaveNumberRegExp
the regular expression to extract the wave number from the header (first group is used).
-
m_SampleDataColumns
protected adams.data.spreadsheet.SpreadSheetColumnRange m_SampleDataColumns
the range of columns containing sample data.
-
-
Method Detail
-
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
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classAbstractSpectrumReader
-
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.input.AbstractDataContainerReader<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.input.AbstractDataContainerReader<Spectrum>
- Returns:
- the extension (without the dot!)
-
getActualFormatExtensions
public String[] getActualFormatExtensions()
Returns the underlying format extensions.- Specified by:
getActualFormatExtensions
in interfaceadams.data.io.input.MetaFileReader
- Returns:
- the format extensions (excluding dot)
-
setReader
public void setReader(adams.data.io.input.SpreadSheetReader value)
Sets the spreadsheet reader to use.- Parameters:
value
- the reader
-
getReader
public adams.data.io.input.SpreadSheetReader getReader()
Returns the spreadsheet reader in use.- Returns:
- the reader
-
readerTipText
public String readerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setRowFinder
public void setRowFinder(adams.data.spreadsheet.rowfinder.RowFinder value)
Sets the row finder to use for filtering the rows.- Parameters:
value
- the row finder
-
getRowFinder
public adams.data.spreadsheet.rowfinder.RowFinder getRowFinder()
Returns the row finder to use for filtering the rows.- Returns:
- the row finder
-
rowFinderTipText
public String rowFinderTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setSampleIDColumn
public void setSampleIDColumn(adams.data.spreadsheet.SpreadSheetColumnIndex value)
Sets the column containing the sample ID.- Parameters:
value
- the column
-
getSampleIDColumn
public adams.data.spreadsheet.SpreadSheetColumnIndex getSampleIDColumn()
Returns the column containing the sample ID.- Returns:
- the column
-
sampleIDColumnTipText
public String sampleIDColumnTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setWaveColumns
public void setWaveColumns(adams.data.spreadsheet.SpreadSheetColumnRange value)
Sets the columns containing the wave amplitudes.- Parameters:
value
- the columns
-
getWaveColumns
public adams.data.spreadsheet.SpreadSheetColumnRange getWaveColumns()
Returns the columns containing the wave amplitudes.- Returns:
- the columns
-
waveColumnsTipText
public String waveColumnsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setHeaderContainsWaveNumber
public void setHeaderContainsWaveNumber(boolean value)
Sets whether to extract the wave number from the header columns.- Parameters:
value
- true if to extract
-
getHeaderContainsWaveNumber
public boolean getHeaderContainsWaveNumber()
Returns whether to extract the wave number from the header columns.- Returns:
- true if to extract
-
headerContainsWaveNumberTipText
public String headerContainsWaveNumberTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setWaveNumberRegExp
public void setWaveNumberRegExp(adams.core.base.BaseRegExp value)
Sets the regular expression to identify the wave number (1st group is used).- Parameters:
value
- the expression
-
getWaveNumberRegExp
public adams.core.base.BaseRegExp getWaveNumberRegExp()
Returns the regular expression to identify the wave number (1st group is used).- Returns:
- the expression
-
waveNumberRegExpTipText
public String waveNumberRegExpTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setSampleDataColumns
public void setSampleDataColumns(adams.data.spreadsheet.SpreadSheetColumnRange value)
Sets the columns containing the sample data.- Parameters:
value
- the columns
-
getSampleDataColumns
public adams.data.spreadsheet.SpreadSheetColumnRange getSampleDataColumns()
Returns the columns containing the sample data.- Returns:
- the columns
-
sampleDataColumnsTipText
public String sampleDataColumnsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
identifyWaveNumbers
protected gnu.trove.list.array.TFloatArrayList identifyWaveNumbers(adams.data.spreadsheet.SpreadSheet sheet, int[] cols)
Indentifies the wave numbers.- Parameters:
sheet
- the spreadsheet to analyzecols
- the columns- Returns:
- the wave numbers
-
identifySampleData
protected List<adams.data.report.Field> identifySampleData(adams.data.spreadsheet.SpreadSheet sheet, int[] cols)
Returns the sample data fields.- Parameters:
sheet
- the sheet to analyzecols
- the columns- Returns:
- the fields
-
readData
protected void readData()
Performs the actual reading.- Specified by:
readData
in classadams.data.io.input.AbstractDataContainerReader<Spectrum>
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceadams.core.Stoppable
- Overrides:
stopExecution
in classAbstractSpectrumReader
-
main
public static void main(String[] args)
Runs the reader from the command-line. If the optionAbstractSpectrumReader.OPTION_OUTPUTDIR
is specified then the read spectra get output as .spec files in that directory.- Parameters:
args
- the command-line options to use
-
-