Class FourierSinCosAnalysis

java.lang.Object
org.opensourcephysics.analysis.FourierSinCosAnalysis
All Implemented Interfaces:
Data

public class FourierSinCosAnalysis extends Object implements Data
FourierAnalysis adds gutter points to real data before performing a fast Fourier transform. Gutter points increase the number points in order to approximate a nonperiodic function. The FFT output is phase shifted to account for the fact that the FFT basis functions are defined on [0, 2*pi].
Version:
1.0
Author:
W. Christian
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    doAnalysis(double[] x, double[] y, int gutter)
    Fourier analyzes the given data y[] after adding gutter points at the start and end of the z[] array.
    The column names to be used in the data display tool
    double[][]
    Gets the frequencies, power, cos, and sin coefficients.
    double[][][]
    3D data is not available.
    Some elements (a Group, for instance) do not contain data, but a list of subelements which do.
    Gets the datasets that contain the result of the last Fourier analysis.
    Fill colors for Data interface.
    int
    Returns a unique identifier for this Data.
    Line colors for Data interface.
    Gets the dataset name.
    double[]
    Gets the frequencies of the Fourier spectrum.
    double[]
    Gets the angular frequencies of the Fourier spectrum.
    boolean
    Gets the radians flag.
    double[]
    repeatAnalysis(double[] y)
    Repeats the Fourier analysis of the real data y[] with the previously set scale and gutter.
    void
    setID(int id)
    Sets the ID number of this Data.
    void
    Sets a name that can be used to identify the dataset.
    void
    useRadians(boolean radians)
    Sets the radians flag for the frequency values of datasets.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • datasetID

      protected int datasetID
  • Constructor Details

    • FourierSinCosAnalysis

      public FourierSinCosAnalysis()
  • Method Details

    • doAnalysis

      public double[] doAnalysis(double[] x, double[] y, int gutter)
      Fourier analyzes the given data y[] after adding gutter points at the start and end of the z[] array.
      Parameters:
      x - double[]
      y - double[]
      gutter - int
      Returns:
      double[] the Fourier spectrum
    • getDataList

      public List<Data> getDataList()
      Some elements (a Group, for instance) do not contain data, but a list of subelements which do. This method is used by Data displaying tools to create as many pages as needed.
      Specified by:
      getDataList in interface Data
      Returns:
      A list of DataInformation elements, null if the element itself is a DataInformation
    • repeatAnalysis

      public double[] repeatAnalysis(double[] y)
      Repeats the Fourier analysis of the real data y[] with the previously set scale and gutter.
      Parameters:
      y - double[]
      Returns:
      double[] the Fourier sin/cos coefficients
    • getNaturalOmega

      public double[] getNaturalOmega()
      Gets the angular frequencies of the Fourier spectrum.
      Returns:
      double[]
    • getNaturalFreq

      public double[] getNaturalFreq()
      Gets the frequencies of the Fourier spectrum.
      Returns:
      double[]
    • useRadians

      public void useRadians(boolean radians)
      Sets the radians flag for the frequency values of datasets. Dataset x-values are either frequencies (cycles) or angular frequencies (radians) depending on the value of the radians flag.
      Parameters:
      radians - boolean
    • isRadians

      public boolean isRadians()
      Gets the radians flag. Radians is true if the dataset uses angular frequency as the x-coordinate.
      Returns:
      boolean
    • getDatasets

      public ArrayList<Dataset> getDatasets()
      Gets the datasets that contain the result of the last Fourier analysis. The power spectrum is contained in the first dataset. Sine coefficients are contained in the second dataset. Cosine coefficients are in the third dataset. Dataset x-values are either frequencies (cycles) or angular frequencies (radians) depending on the value of the radians flag.
      Specified by:
      getDatasets in interface Data
      Returns:
      list of Datasets
    • setName

      public void setName(String name)
      Sets a name that can be used to identify the dataset.
      Parameters:
      name - String
    • getColumnNames

      public String[] getColumnNames()
      The column names to be used in the data display tool
      Specified by:
      getColumnNames in interface Data
      Returns:
    • getName

      public String getName()
      Gets the dataset name.
      Specified by:
      getName in interface Data
      Returns:
      String
    • getLineColors

      public Color[] getLineColors()
      Line colors for Data interface.
      Specified by:
      getLineColors in interface Data
      Returns:
    • getFillColors

      public Color[] getFillColors()
      Fill colors for Data interface.
      Specified by:
      getFillColors in interface Data
      Returns:
    • getData2D

      public double[][] getData2D()
      Gets the frequencies, power, cos, and sin coefficients.
      Specified by:
      getData2D in interface Data
      Returns:
      double[][]
    • getData3D

      public double[][][] getData3D()
      3D data is not available.
      Specified by:
      getData3D in interface Data
      Returns:
      double[][][]
    • setID

      public void setID(int id)
      Sets the ID number of this Data.
      Specified by:
      setID in interface Data
      Parameters:
      id - the ID number
    • getID

      public int getID()
      Returns a unique identifier for this Data.
      Specified by:
      getID in interface Data
      Returns:
      the ID number