Package adams.data.io.input
Class UnscramblerSpectrumReader
- 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.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
-
-
Field Summary
Fields Modifier and Type Field Description static String
ENTRY_PROJECT
protected List<InputStream>
m_Streams
the streams to close at the end.-
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 UnscramblerSpectrumReader()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<String>
determineSpectralRange(List<String> headersCol, Map<String,adams.core.Range> ranges)
Determines the range(s) that most likely contains the spectra.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.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.String
globalInfo()
Returns a string describing the object.protected Map<String,String>
listMatrixFiles(org.apache.commons.compress.archivers.zip.ZipFile archive, org.apache.commons.compress.archivers.zip.ZipArchiveEntry project)
Parses the project.xml file and extracts the data matrices.protected void
loadMatrix(org.apache.commons.compress.archivers.zip.ZipFile archive, org.apache.commons.compress.archivers.zip.ZipArchiveEntry target)
Loads the specified matrix.static void
main(String[] args)
Runs the reader from the command-line.protected gnu.trove.list.TFloatList
readBin(org.apache.commons.compress.archivers.zip.ZipFile archive, org.apache.commons.compress.archivers.zip.ZipArchiveEntry file)
Reads the binary file all as floats and returns them.protected void
readData()
Performs the actual reading.protected Document
readXML(org.apache.commons.compress.archivers.zip.ZipFile archive, org.apache.commons.compress.archivers.zip.ZipArchiveEntry file)
Parses the zip entry as XML.-
Methods inherited from class adams.data.io.input.AbstractSpectrumReader
checkData, createDummyReport, defineOptions, formatTipText, getDefaultFormat, getDefaultInstrument, getDefaultKeepFormat, getDefaultUseAbsoluteSource, getFormat, getInstrument, getKeepFormat, getReaders, getUseAbsoluteSource, instrumentTipText, keepFormatTipText, postProcessData, runReader, setFormat, setInstrument, setKeepFormat, setUseAbsoluteSource, stopExecution, 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
-
ENTRY_PROJECT
public static final String ENTRY_PROJECT
- See Also:
- Constant Field Values
-
m_Streams
protected transient List<InputStream> m_Streams
the streams to close at the end.
-
-
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
-
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!)
-
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 archivefile
- 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 fromfile
- 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 fromproject
- 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 headersranges
- 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 columnsheadersRow
- the headers for the rowsrangesCol
- the defined rangesdataRows
- 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 fromtarget
- the target matrix XML file to load- Throws:
Exception
- if loading fails
-
readData
protected void readData()
Performs the actual reading.- Specified by:
readData
in classadams.data.io.input.AbstractDataContainerReader<Spectrum>
-
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
-
-