Class 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
    • 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.
    • Constructor Detail

      • RowWiseSpreadSheetSpectrumReader

        public RowWiseSpreadSheetSpectrumReader()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.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 interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class AbstractSpectrumReader
      • getFormatDescription

        public String getFormatDescription()
        Returns a string describing the format (used in the file chooser).
        Specified by:
        getFormatDescription in interface adams.core.io.FileFormatHandler
        Specified by:
        getFormatDescription in class adams.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 interface adams.core.io.FileFormatHandler
        Specified by:
        getFormatExtensions in class adams.data.io.input.AbstractDataContainerReader<Spectrum>
        Returns:
        the extension (without the dot!)
      • getActualFormatExtensions

        public String[] getActualFormatExtensions()
        Returns the underlying format extensions.
        Specified by:
        getActualFormatExtensions in interface adams.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 analyze
        cols - 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 analyze
        cols - the columns
        Returns:
        the fields
      • readData

        protected void readData()
        Performs the actual reading.
        Specified by:
        readData in class adams.data.io.input.AbstractDataContainerReader<Spectrum>
      • stopExecution

        public void stopExecution()
        Stops the execution.
        Specified by:
        stopExecution in interface adams.core.Stoppable
        Overrides:
        stopExecution in class AbstractSpectrumReader
      • main

        public static void main​(String[] args)
        Runs the reader from the command-line. If the option AbstractSpectrumReader.OPTION_OUTPUTDIR is specified then the read spectra get output as .spec files in that directory.
        Parameters:
        args - the command-line options to use