Class AverageWaveform

java.lang.Object
PamUtils.avrgwaveform.AverageWaveform

public class AverageWaveform extends Object
Create average waveform and FFT spectrum.
Author:
Jamie Macaulay
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addWaveform(double[] waveform, float sR)
    Add a waveform to the average waveform and spectra.
    void
    addWaveform(double[] waveform, float sR, boolean normalise)
    Add a waveform to the average waveform and spectra.
    void
    addWaveform(double[] waveform, float sR, int maxFFTLen, boolean normalise)
    Add a waveform to the average waveform and spectra.
    void
    addWaveform(double minFreq, double maxFreq, double amplitude, float sampleRate2, int defaultFFTLen)
    Add to an average spectra when no raw data is present e.g.
    void
    Clear the current data, both the average wavefrom and spectrum.
    int
    Get the number of waveforms which were used to make the average.
    double[]
    Get the average spectra.
    double[]
    Get the average waveform.
    float
    Get the sample rate for the average spectra.
    double[]
    normalise(double[] waveform)
    Normalise the spectra or waveform.
    void
    setAverageSpectra(double[] parseAvrgeSpectrum)
    Set the average spectrum.
    void
    setSampleRate(float sampleRate)
    Set the sample rate for the average spectra.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AverageWaveform

      public AverageWaveform()
  • Method Details

    • addWaveform

      public void addWaveform(double[] waveform, float sR)
      Add a waveform to the average waveform and spectra. The spectra and waveform are averaged separately i.e. the spectra of the average waveform is not necessarily equal to the average spectra. This is to prevent constructive/destructive interference in averaging waveform from altering spectra results.
      Parameters:
      waveform - - the raw waveform to add the average
      sR - - the sample rate in samples per second
    • addWaveform

      public void addWaveform(double[] waveform, float sR, boolean normalise)
      Add a waveform to the average waveform and spectra. The spectra and waveform are averaged separately i.e. the spectra of the average waveform is not necessarily equal to the average spectra. This is to prevent constructive/destructive interference in averaging waveform from altering spectra results.
      Parameters:
      waveform - - the raw waveform to add the average
      sR - - the sample rate in samples per second
      normalise - - normalise waveforms before averaging.
    • addWaveform

      public void addWaveform(double[] waveform, float sR, int maxFFTLen, boolean normalise)
      Add a waveform to the average waveform and spectra. The spectra and waveform are averaged separately i.e. the spectra of the average waveform is not necessarily equal to the average spectra. This is to prevent constructive/destructive interference in averaging waveform from altering spectra results.
      Parameters:
      waveform - - the raw waveform to add the average
      sR - - the sample rate in samples per second
      maxFFTLen - the maximum FFT length.
      normalise - - normalise waveforms before averaging.
    • addWaveform

      public void addWaveform(double minFreq, double maxFreq, double amplitude, float sampleRate2, int defaultFFTLen)
      Add to an average spectra when no raw data is present e.g. CPOD. Here the average spectra is an amplitude weighted historgram of the bandwidth of the detection.
      Parameters:
      minFreq - - the minimum frequency in Hz
      maxFreq - - the maximum frequency in Hz
      amplitude - - the amplitude of the detection in dB
      sampleRate2 - - the sample rate in samples per second.
      defaultFFTLen - - the defaultFFT length.
    • getAverageWaveform

      public double[] getAverageWaveform()
      Get the average waveform. Not normalised.
      Returns:
      the average waveform
    • getAverageSpectra

      public double[] getAverageSpectra()
      Get the average spectra. Note this is the true average spectra and not just the FFT of the average waveform.
      Returns:
      the average spectrum.
    • getAverageCount

      public int getAverageCount()
      Get the number of waveforms which were used to make the average. .
      Returns:
      the number of waveforms in the average.
    • normalise

      public double[] normalise(double[] waveform)
      Normalise the spectra or waveform.
      Parameters:
      waveform - - the waveform or spectra to normalise.
      Returns:
      normalise so that maximum is 1.
    • clearAvrgData

      public void clearAvrgData()
      Clear the current data, both the average wavefrom and spectrum.
    • setAverageSpectra

      public void setAverageSpectra(double[] parseAvrgeSpectrum)
      Set the average spectrum. This will delete the current average spectrum.
      Parameters:
      parseAvrgeSpectrum - - the average spectrum to set.
    • getSampleRate

      public float getSampleRate()
      Get the sample rate for the average spectra.
      Returns:
      the sample rate in samples per second.
    • setSampleRate

      public void setSampleRate(float sampleRate)
      Set the sample rate for the average spectra.
      Parameters:
      the - sample rate in samples per second.