Class InstanceToSpectrum

  • All Implemented Interfaces:
    adams.core.AdditionalInformationHandler, adams.core.CleanUpHandler, adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.QuickInfoSupporter, adams.core.ShallowCopySupporter<adams.flow.core.Actor>, adams.core.SizeOfHandler, adams.core.Stoppable, adams.core.StoppableWithFeedback, adams.core.VariablesInspectionHandler, adams.event.VariableChangeListener, adams.flow.core.Actor, adams.flow.core.ErrorHandler, adams.flow.core.InputConsumer, adams.flow.core.OutputProducer, Serializable, Comparable

    public class InstanceToSpectrum
    extends adams.flow.transformer.AbstractTransformer
    Converts a weka.core.Instance to a Spectrum.
    By default, the wave numbers start at 0 and use an increment of 1.
    If 'first' and 'last' wave number are supplied, the step size is calculated based on the number of amplitudes present in the Instance.
    If only 'first' wave number is supplied, then the supplied wave step size is used.
    'first' and 'last' get ignored if a value of less than 0 is supplied.

    Input/output:
    - accepts:
       weka.core.Instance
    - generates:
       knir.data.spectrum.Spectrum


    Valid options are:

    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -name <java.lang.String> (property: name)
        The name of the actor.
        default: InstanceToSpectrum
     
    -annotation <adams.core.base.BaseText> (property: annotations)
        The annotations to attach to this actor.
        default: 
     
    -skip <boolean> (property: skip)
        If set to true, transformation is skipped and the input token is just forwarded 
        as it is.
        default: false
     
    -stop-flow-on-error <boolean> (property: stopFlowOnError)
        If set to true, the flow gets stopped in case this actor encounters an error;
         useful for critical actors.
        default: false
     
    -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
     
    -sampleID <java.lang.String> (property: sampleID)
        Regex to find sample id. e.g 'sample_id'
        default: sample_id
     
    -getProductCodeFromAttribute <java.lang.Boolean> (property: getProductCodeFromAttribute)
        Regex to find sample id. e.g 'sample_id'
        default: false
     
    -spectralDataAttributes <java.lang.String> (property: spectralDataAttributes)
        Regex to choose attributes to use as spectum amplitudes'
        default: amplitude.*
     
    -first-wave <float> (property: firstWave)
        The starting point for the wave numbers, ignored if less than 0.
        default: -1.0
     
    -last-wave <float> (property: lastWave)
        The end point for the wave numbers, ignored if less than 0.
        default: -1.0
     
    -wave-step <float> (property: waveStep)
        The step size for the wave numbers to use, if 'lastWave' is not defined.
        default: 1.0
        minimum: 0.0
     
    Version:
    $Revision: 2242 $
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected float m_FirstWave
      the first wave number.
      protected float m_LastWave
      the last wave number.
      protected String m_ProductCode
      Either the attribute name with the product code in it, or the actual product code.
      protected Boolean m_ProductCodeFromAttribute
      Get the product code from the attribute named ProductCode in the Instance?
      protected String m_SampleIDregex
      Regex to find sample id. e.g "sampleID"
      protected String m_SpectralData
      Regex to find spectral data. e.g "amplitude
      protected float m_WaveStep
      the wave number step.
      • Fields inherited from class adams.flow.transformer.AbstractTransformer

        BACKUP_INPUT, BACKUP_OUTPUT, m_InputToken, m_OutputToken
      • Fields inherited from class adams.flow.core.AbstractActor

        m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_LoggingPrefix, m_Name, m_Parent, m_ScopeHandler, m_Self, m_Silent, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
      • Fields inherited from class adams.core.option.AbstractOptionHandler

        m_OptionManager
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
      • Fields inherited from interface adams.flow.core.Actor

        FILE_EXTENSION, FILE_EXTENSION_GZ
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Class[] accepts()
      Returns the class that the consumer accepts.
      void defineOptions()
      Adds options to the internal list of options.
      protected String doExecute()
      Executes the flow item.
      String firstWaveTipText()
      Returns the tip text for this property.
      Class[] generates()
      Returns the class of objects that it generates.
      float getFirstWave()
      Returns the starting point for the wave numbers.
      Boolean getGetProductCodeFromAttribute()
      Get product code from instance attribute?
      float getLastWave()
      Returns the end point for the wave numbers.
      String getProductCode()
      Get Product Code.
      String getProductCodeFromAttributeTipText()
      Returns the tip text for this property.
      String getSampleID()
      Get sample id regex.
      String getSpectralDataAttributes()
      Get which attributes to use for spectral data.
      float getWaveStep()
      Returns the step size for the wave numbers, if lastWave is not defined.
      String globalInfo()
      Returns a string describing the object.
      String lastWaveTipText()
      Returns the tip text for this property.
      String productCodeTipText()
      Returns the tip text for this property.
      String sampleIDTipText()
      Returns the tip text for this property.
      void setFirstWave​(float value)
      Sets the starting point for the wave numbers.
      void setGetProductCodeFromAttribute​(Boolean mGetProductCodeFromAttribute)
      Set product code from instance attribute?
      void setLastWave​(float value)
      Sets the end point for the wave numbers.
      void setProductCode​(String productCode)
      Set product code.
      void setSampleID​(String mSampleIDregex)
      Get sample id regex.
      void setSpectralDataAttributes​(String mSpectralData)
      Set which attributes to use for spectral data.
      void setWaveStep​(float value)
      Sets the step size for the wave numbers, if lastWave is not defined.
      String spectralDataAttributesTipText()
      Returns the tip text for this property.
      String waveStepTipText()
      Returns the tip text for this property.
      • Methods inherited from class adams.flow.transformer.AbstractTransformer

        backupState, currentInput, execute, hasInput, hasPendingOutput, input, output, postExecute, restoreState, wrapUp
      • Methods inherited from class adams.flow.core.AbstractActor

        annotationsTipText, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, configureLogger, destroy, equals, finalUpdateVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getQuickInfo, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, initialize, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, performVariableChecks, preExecute, pruneBackup, pruneBackup, reset, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, silentTipText, sizeOf, skipTipText, stopExecution, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
      • 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

        getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled
      • Methods inherited from interface adams.flow.core.Actor

        cleanUp, compareTo, destroy, equals, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getQuickInfo, getRoot, getScopeHandler, getSilent, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setName, setParent, setSilent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, stopExecution, stopExecution, toCommandLine, variableChanged
      • Methods inherited from interface adams.core.AdditionalInformationHandler

        getAdditionalInformation
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel, setLoggingLevel
      • Methods inherited from interface adams.core.logging.LoggingSupporter

        getLogger, isLoggingEnabled
      • Methods inherited from interface adams.core.option.OptionHandler

        cleanUpOptions, getOptionManager
      • Methods inherited from interface adams.core.VariablesInspectionHandler

        canInspectOptions
    • Field Detail

      • m_ProductCode

        protected String m_ProductCode
        Either the attribute name with the product code in it, or the actual product code. Decided by m_GetProductCodeFromAttribute.
      • m_ProductCodeFromAttribute

        protected Boolean m_ProductCodeFromAttribute
        Get the product code from the attribute named ProductCode in the Instance? Otherwise use the ProductCode string directly.
      • m_SampleIDregex

        protected String m_SampleIDregex
        Regex to find sample id. e.g "sampleID"
      • m_SpectralData

        protected String m_SpectralData
        Regex to find spectral data. e.g "amplitude.*"
      • m_FirstWave

        protected float m_FirstWave
        the first wave number.
      • m_LastWave

        protected float m_LastWave
        the last wave number.
      • m_WaveStep

        protected float m_WaveStep
        the wave number step.
    • Constructor Detail

      • InstanceToSpectrum

        public InstanceToSpectrum()
    • 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 adams.flow.core.AbstractActor
      • getSampleID

        public String getSampleID()
        Get sample id regex.
        Returns:
        sample id regex
      • setSampleID

        public void setSampleID​(String mSampleIDregex)
        Get sample id regex.
        Parameters:
        mSampleIDregex - sample id regex
      • sampleIDTipText

        public String sampleIDTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getGetProductCodeFromAttribute

        public Boolean getGetProductCodeFromAttribute()
        Get product code from instance attribute? Or use as string.
        Returns:
        Get product code from instance attribute?
      • setGetProductCodeFromAttribute

        public void setGetProductCodeFromAttribute​(Boolean mGetProductCodeFromAttribute)
        Set product code from instance attribute? Or use as string.
        Parameters:
        mGetProductCodeFromAttribute - Set product code from instance attribute?
      • getProductCodeFromAttributeTipText

        public String getProductCodeFromAttributeTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • getSpectralDataAttributes

        public String getSpectralDataAttributes()
        Get which attributes to use for spectral data.
        Returns:
        regex attribute name.
      • setSpectralDataAttributes

        public void setSpectralDataAttributes​(String mSpectralData)
        Set which attributes to use for spectral data.
        Parameters:
        mSpectralData - regex attribute name.
      • spectralDataAttributesTipText

        public String spectralDataAttributesTipText()
        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.
      • setFirstWave

        public void setFirstWave​(float value)
        Sets the starting point for the wave numbers. Ignored if less than zero.
        Parameters:
        value - the first wave number
      • getFirstWave

        public float getFirstWave()
        Returns the starting point for the wave numbers. Ignored if less than zero.
        Returns:
        the first wave number
      • firstWaveTipText

        public String firstWaveTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setLastWave

        public void setLastWave​(float value)
        Sets the end point for the wave numbers. Ignored if less than zero.
        Parameters:
        value - the last wave number
      • getLastWave

        public float getLastWave()
        Returns the end point for the wave numbers. Ignored if less than zero.
        Returns:
        the last wave number
      • lastWaveTipText

        public String lastWaveTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setWaveStep

        public void setWaveStep​(float value)
        Sets the step size for the wave numbers, if lastWave is not defined.
        Parameters:
        value - the step size
      • getWaveStep

        public float getWaveStep()
        Returns the step size for the wave numbers, if lastWave is not defined.
        Returns:
        the step size
      • waveStepTipText

        public String waveStepTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • accepts

        public Class[] accepts()
        Returns the class that the consumer accepts.
        Returns:
        weka.core.Instance.class
      • generates

        public Class[] generates()
        Returns the class of objects that it generates.
        Returns:
        knir.data.spectrum.Spectrum.class
      • doExecute

        protected String doExecute()
        Executes the flow item.
        Specified by:
        doExecute in class adams.flow.core.AbstractActor
        Returns:
        null if everything is fine, otherwise error message