Class UnscramblerSpectrumReader

  • 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, Serializable, Comparable

    public class UnscramblerSpectrumReader
    extends AbstractSpectrumReader
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Constructor Detail

      • UnscramblerSpectrumReader

        public UnscramblerSpectrumReader()
    • 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
      • 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!)
      • readXML

        protected Document readXML​(org.apache.commons.compress.archivers.zip.ZipFile archive,
                                   org.apache.commons.compress.archivers.zip.ZipArchiveEntry file)
                            throws Exception
        Parses the zip entry as XML.
        Parameters:
        archive - the zip archive
        file - the file to parse
        Returns:
        the parsed DOM document
        Throws:
        Exception - if parsing of XML fails
      • readBin

        protected gnu.trove.list.TFloatList readBin​(org.apache.commons.compress.archivers.zip.ZipFile archive,
                                                    org.apache.commons.compress.archivers.zip.ZipArchiveEntry file)
                                             throws Exception
        Reads the binary file all as floats and returns them.
        Parameters:
        archive - the archive to read from
        file - the binary file to read
        Returns:
        the floats from the file
        Throws:
        Exception - if reading the floats fails
      • listMatrixFiles

        protected Map<String,​String> listMatrixFiles​(org.apache.commons.compress.archivers.zip.ZipFile archive,
                                                           org.apache.commons.compress.archivers.zip.ZipArchiveEntry project)
                                                    throws Exception
        Parses the project.xml file and extracts the data matrices.
        Parameters:
        archive - the archive to load the project file from
        project - the entry with the project information
        Returns:
        the matrix files (target - name)
        Throws:
        Exception - if loading fails
      • determineSpectralRange

        protected List<String> determineSpectralRange​(List<String> headersCol,
                                                      Map<String,​adams.core.Range> ranges)
        Determines the range(s) that most likely contains the spectra.
        Parameters:
        headersCol - the column headers
        ranges - the ranges (name - range)
        Returns:
        the names of the ranges
      • generateSpectra

        protected void generateSpectra​(List<String> headersCol,
                                       List<String> headersRow,
                                       Map<String,​adams.core.Range> rangesCol,
                                       Map<String,​adams.core.Range> rangesRow,
                                       List<gnu.trove.list.TFloatList> dataRows)
        Generates the spectra from the parsed data.
        Parameters:
        headersCol - the headers for the columns
        headersRow - the headers for the rows
        rangesCol - the defined ranges
        dataRows - the float values per row
      • loadMatrix

        protected void loadMatrix​(org.apache.commons.compress.archivers.zip.ZipFile archive,
                                  org.apache.commons.compress.archivers.zip.ZipArchiveEntry target)
                           throws Exception
        Loads the specified matrix.
        Parameters:
        archive - the archive to load the matrix from
        target - the target matrix XML file to load
        Throws:
        Exception - if loading fails
      • readData

        protected void readData()
        Performs the actual reading.
        Specified by:
        readData in class adams.data.io.input.AbstractDataContainerReader<Spectrum>
      • 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