
import directive: import flanagan.math.FourierTransform;
Constructors 
public FourierTransform()  
public FourierTransform(double[] data)  
public FourierTransform(Complex[] data)  
Input the data array to be transformed  as a real data array 
public void setData(double[] data) 
as a complex data array (as Complex numbers) 
public void setData(Complex[] data)  
as complex data array (as alternating real and imaginary parts) 
public void setFftData(double[] fftData)  
Fast Fourier transform  Perform transform 
public void transform() 
Perform inverse transform 
public void inverse()  
Basic fft method 
public void basicFft(double[] data, int nn, int isign)  
Get the transformed data  as Complex 
public Complex[] getTransformedDataAsComplex() 
as alternating real and imaginary 
public double[] getTransformedDataAsAlternate()  
Get the original data  as Complex 
public Complex[] getComplexInputData() 
as alternating real and imaginary 
public double[] getAlternateInputData()  
Get data length  data length used 
public int getUsedDataLength() 
original data length 
public int getOriginalDataLength()  
Check data length  as integer power of two 
public static boolean checkPowerOfTwo(int n) 
as integer times an integer power of two 
public static int checkIntegerTimesPowerOfTwo(int n)  
Get nearest lower integer power of two 
public static int lastPowerOfTwo(int n)  
Get nearest higher integer power of two 
public static int nextPowerOfTwo(int n)  
Windowing the data  Choose window function 
public void setRectangular() public void setBartlett() public void setWelch() public void setHann() public void setHamming() public void setKaiser(double alpha) public void setKaiser() public void setGaussian(double alpha) public void setGaussian() 
Remove the window function  public void removeWindow()  
Get the current window option  public String getWindowOption()  
Get the window function weights  public double[] getWindowWeights()  
Sampling period 
public void setDeltaT(double deltaT) public double getDeltaT()  
Power Spectrum  Number of segments 
public void setSegmentNumber(int nSeg) public int getSegmentNumber() 
Segment length 
public void setSegmentLength(int length) public int getSegmentLength()  
Choose overlap option 
public void setOverLapOption(boolean option) public boolean getOverLapOption()  
Generate power spectrum 
public double[][] powerSpectrum() public double[][] powerSpectrum(String inputFileName)  
Get power spectral density (psd) estimates 
public double[][] getPowerSpectrumEstimate()  
Print the psd estimates to a text file 
public void printPowerSpectrum(String outputFileName) public void printPowerSpectrum()  
Display graph of the result 
public void plotPowerSpectrum(String graphName) public void plotPowerSpectrum(int lowPoint, String outputFileName) public void plotPowerSpectrum(int lowPoint, int highPoint, String outputFileName) public void plotPowerSpectrum(double lowFreq, String outputFileName) public void plotPowerSpectrum(double lowFreq, double highFreq, String outputFileName) public void plotPowerSpectrum() public void plotPowerSpectrum(int lowPoint) public void plotPowerSpectrum(int lowPoint, int highPoint) public void plotPowerSpectrum(double lowFreq) public void plotPowerSpectrum(double lowFreq, double highFreq)  
Display log graph of the result 
public void plotPowerLog(String graphName) public void plotPowerLog(int lowPoint, String outputFileName) public void plotPowerLog(int lowPoint, int highPoint, String outputFileName) public void plotPowerLog(double lowFreq, String outputFileName) public void plotPowerLog(double lowFreq, double highFreq, String outputFileName) public void plotPowerLog() public void plotPowerLog(int lowPoint) public void plotPowerLog(int lowPoint, int highPoint) public void plotPowerLog(double lowFreq) public void plotPowerLog(double lowFreq, double highFreq)  
Get number of psd points  public int getNumberOfPsdPoints()  
Calculate required number of data points 
public static int calcDataLength(boolean overlap, int segLen, int segNum)  
Correlation  Correlate two data sets 
public double[][] correlate(double[] data) public double[][] correlate(double[] data1, double[] data2) 
Get the correlation array 
public double[][] getCorrelation()  
Print the correlation to a text file 
public void printCorrelation(String outputFileName) public void printCorrelation()  
Display graph of the correlation 
public void plotCorrelation(String graphName) public void plotCorrelation()  
Change line option in graphs 
public void setPlotLineOption(int lineOption) public int getPlotLineOption()  
Short Time Fourier Transform  Spectrogram (TimeFrequency Representation)  Generate Short Time Fourier Transform 
public double[][] shortTime(int windowLength) public double[][] shortTime(double windowTime) 
Get TimeFrequency Matrix 
public double[][] getTimeFrequencyMatrix()  
Plot TimeFrequency Contour Map 
public void plotShortTime(String graphTitle) public void plotShortTime()  
Print TimeFrequency Transform to file 
public void printShortTime(String fileName) public void printShortTime()  
Get window length 
public int getShortTimeWindowLength()  
Get number of sample times 
public int getShortTimeNumberOfTimes()  
Get number of frequencies 
public int getShortTimeNumberOfFrequencies() 
public void setFftData(double[] fftData)
Usage:
ft.fftData(y);
The data may also be provided as an array of alternating real and imaginary parts of each complex number in the sequence of complex numbers to be transformed, i.e. in the above example, the double y[0] is the real part of the first complex number, y[1] is the imaginary part of the first complex number, y[2] is the real part of the second complex number and so on. This is input form has been included for compatability with other fft applications. All methods in this class will accept data entered in any of the three above forms.
Perform an inverse Fourier Transform
public void inverse()
Usage:
ft.inverse();
This is the standard method, in this class, for performing an inverse fast Fourier transform (fft). The data length must be a power of two; a warning mesage will be printed to screen if it is not and the data array will be first padded with zeros until a length equal to an integer power of two is reached. The transformed data may be accessed via getTransformedDataAsComplex() or getTransformedDataAsAlternate().
public void basicFft(double[] data, int nn, int isign)
Usage:
ft.basicFft(data, nn, isign);
This is the basic fft method accessed by both transform and inverse described above. It is based on the Numerical Recipes, C method, four1. This method would not normally be called directly but if it is the data must be in the form of alternating real and imaginary parts, as described in the third data input method descibed above. The integer nn must equal half the length of the data array data, i.e. must equal the number of complex numbers in the data to be transformed. The integer nn must be a power of 2. This method, basicFfft, does not check this. If the integer isign is set to 1 the the array data is overwritten with its discreet Fourier transform. If the integer isign is set to 1 the the array data is overwritten with nn times its inverse discreet Fourier transform. The transformed data is returned as an array of alternating real and imaginary parts of the complex transformed data. No data is returned by this method to the instance variable data arrays.
tData[0]  frequency = 0  
tData[1]  frequency = 1/(n.deltaT)  
tData[2]  frequency = 2/(n.deltaT)  
. . . . . .  . . . . . .  
tData[n/21]  frequency = (n/2  1)/(n.deltaT)  
tData[n/2]  frequency = aliased combination/(2.deltaT)  
tData[n/2+1]  frequency = (n/21)/(n.deltaT)  
tData[n/2+2]  frequency = (n/22)/(n.deltaT)  
. . . . . .  . . . . . .  
tData[n1]  frequency = 1/(n.deltaT) 
Get the transformed data as alternating real and imaginary parts
public double[] getTransformedDataAsAlternate()
Usage:
tData = ft.getTransformedDataAsAlternate();
This method returns the transformed data as an array of alternating real and imaginary parts of the transformed complex data. The data is ordered as:
tData[0]  real part  frequency = 0  
tData[1]  imaginary part  frequency = 0  
tData[2]  real part  frequency = 1/(n.deltaT)  
tData[3]  imaginary part  frequency = 1/(n.deltaT)  
tData[4]  real part  frequency = 2/(n.deltaT)  
tData[5]  imaginary part  frequency = 2/(n.deltaT)  
. . . . . .  . . . . . .  . . . . . .  
tData[n2]  real part  frequency = (n/2  1)/(n.deltaT)  
tData[n1]  imaginary part  frequency = (n/21)/(n.deltaT)  
tData[n]  real part  frequency = aliased combination/(2.deltaT)  
tData[n+1]  imaginary part  frequency = aliased combination/(2.deltaT)  
tData[n+2]  real part  frequency = (n/21)/(n.deltaT)  
tData[n+3]  imaginary part  frequency = (n/21)/(n.deltaT)  
tData[n+2]  real part  frequency = (n/22)/(n.deltaT)  
tData[n+3]  imaginary part  frequency = (n/22)/(n.deltaT)  
. . . . . .  . . . . . .  . . . . . .  
tData[2n2]  real part  frequency = 1/(n.deltaT)  
tData[2n1]  imaginary part  frequency = 1/(n.deltaT) 
Get the original data as alternating real and imaginary parts
public double[] getAlternateInputData()
Usage:
tData = ft.getAlternateInputData();
This method returns the original data as an array of alternating real and imaginary parts of the original complex data.
Get the original data length
public int getOriginalDataLength()
Usage:
lenOrig = ft.getOriginalDataLength();
This method returns the original length of the data array to be used in obtaining a transform. It may differ from the actual data length used as a result of point deletion (to give an even number) or zero padding to give a length that is an integer power of two.
Check that a data length is an integer multiplied by an integer power of two
public static int checkIntegerTimesPowerOfTwo(int n)
Usage:
mult = FourierTransform.checkIntegerTimesPowerOfTwo(n);
This method checks if the integer n is an integer times an integer power of two and returns the integer multiplier if it is. It returns zero if it is not.
Get the nearest lower integer that is an integer power of two
public static int lastPowerOfTwo(int n)
Usage:
lower = FourierTransform.lastPowerOfTwo(n);
This method returns the nearest integer power of two that is equal to or lower than argument, n.
Get the nearest higher integer that is an integer power of two
public static int nextPowerOfTwo(int n)
Usage:
higher = FourierTransform.nextPowerOfTwo(n);
This method returns the nearest integer power of two that is equal to or higher than argument, n.
Choose a window function
public void setRectangular()
Usage:
ft.setRectangular();
This method applies a rectangular window (also called square or boxcar window) to the data,
where w is the window function weight, 0 is the first point in the segment and n is the last point in the segment.
This is the default option if no window function is set.
public void setBartlett()
Usage:
ft.setBartlett();
This method applies a Bartlett window, i.e. a triangular window, to the data,
where w is the window function weight, 0 is the first point in the segment and n is the last point in the segment.
public void setWelch()
Usage:
ft.setWelch();
This method applies a Welch window to the data,
where w is the window function weight, 0 is the first point in the segment and n is the last point in the segment.
public void setHann()
Usage:
ft.setHann();
This method applies a Hann window (also called a van Hann or Hanning window) to the data,
where w is the window function weight, 0 is the first point in the segment and n is the last point in the segment.
public void setHamming()
Usage:
ft.setHamming();
This method applies a Hamming window to the data,
where w is the window function weight, 0 is the first point in the segment and n is the last point in the segment.
public void setKaiser(double alpha)
public void setKaiser()
Usage:
ft.setKaiser(alpha);
This method applies a Kaiser window to the data,
where w is the window function weight, 0 is the first point in the segment and n is the last point in the segment.
Usage:
ft.setKaiser();
This method applies a Kaiser window to the data,
where w is the window function weight, 0 is the first point in the segment and n is the last point in the segment and a default value of 2.0 is assigned to constant, alpha.
public void setGaussian(double alpha)
public void setGaussian()
Usage:
ft.setGaussian(alpha);
This method applies a Gaussian window to the data,
where w is the window function weight, 0 is the first point in the segment and n is the last point in the segment. The constant, alpha, must be equal to or greater than 2.0.
Usage:
ft.setGaussian();
This method applies a Gaussian window to the data,
where w is the window function weight, 0 is the first point in the segment and n is the last point in the segment and a default value of 2.5 is assigned to constant, alpha.
Remove the current window option
public void removeWindow()
Usage:
ft.removeWindow();
This method removes the current window option and replaces it with the rectangular window option.
get the window function weightsS
public double[] getWindowWeights()
Usage:
weights = ft.getWindowWeights();
This method returns the array of Window function weights, i.e. the w described above.
Get the current window option
public String getWindowOption()
Usage:
opt = ft.getWindowOption();
This method returns the Window function option as a String, e.g, "Rectangular". See immediately above for description of options.
Set the number of segments
public void setSegmentNumber(int nSeg)
Usage:
ft.setSegmentNumber(nSeg);
The number of the segments used in powerSpectrum is set by this method. If the length of the segment and hence the number of segments have already been set by calling setSegmentLength that calculated number will be overwritten by this later call to setSegmentNumber. If neither setSegmentNumber nor setSegmentLength are called the default value of the segment number is one and the default value of the segment length is the full data length.
public int getSegmentNumber()
Usage:
nSeg = ft.getSegmentNumber();
The number of the segments used in powerSpectrum is returned by this method.
public int getSegmentLength()
Usage:
length = ft.getSegmentLength();
The length of the segments used in powerSpectrum is returned by this method.
public boolean getOverLapOption()
Usage:
opt = ft.getOverLapOption();
This method returns the overlap option. See immediately above for description of options.
Usage:
psdEstimates = ft.powerSpectrum(inputFileName);
This method generates an estimation of a power spectrum of the windowed data entered, as the transform proceeds, from a text file (.txt), whose name is entered as this method's argument, inputFileName. Only one segment at a time is read in and only one segment is ever stored. The text file format is simply the data ordered as alternating real and imaginary parts:
real part (data point 0) imaginary part (data point 0)
real part (data point 1) imaginary part (data point 1)
real part (data point 2) imaginary part (data point 2)
. . . .
The data may be segmented and the segments may be overlapped.
If no segmentation is set, either by calling setSegmentNumber or setSegmentLength, the entered data is transformed as a single block.
Unlike powerSpectrum() (see above) limited data checking is performed on the data read in from a text file. The segment length is checked and if it is not an integer power of two the program is aborted. It is assumed that, in setting up the text file, the user has checked that the division into segments has been calculated correctly.
The estimations of the power spectral densities (psd) are stored as the mean square amplitude for each frequency equal to i/(segment length) cycles per grid point or cycles per unit time if the time interval (delta t) has been set. The frequencies are returned in the first row of the returned array, e.g. psdEstimates[0][[0], psdEstimates[0][[1], etc and the psd estimates are returned in the second row, e.g. psdEstimates[1][[0], psdEstimates[1][[1], etc.
Get the estimated power spectral dendities (psd)
public double[][] getPowerSpectrumEstimate()
Usage:
result = ft.getPowerSpectrumEstimate();
This method also returns the array of power spectral densities (psd) of the the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName) (see above).
Usage:
ft.printPowerSpectrum();
This method prints the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName) to a text file named FourierTransformPSD.txt. The output file is a time and date stamped text file listing the transform details and the mean square amplitudes at each frequency equal to i/(segment length) cycles per grid point or cycles per unit time if the sampling period has been set.
Usage:
ft.plotPowerSpectrum(lowPoint, graphTitle);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from point lowPoint to the highest point, as a plot of the mean square amplitude against cycles per grid point or cycles per unit time if the sampling period has been set. For example, ft.plotPowerSpectrum(1, graphTitle) would display all points except the first point i.e. point 0 [Java indices start at 0]. The plot is given the title held in the String graphTitle.
Usage:
ft.plotPowerSpectrum(lowPoint, highPoint, graphTitle);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from point lowPoint to point, highPoint, [Java indices start at 0] as a plot of the mean square amplitude against cycles per grid point or cycles per unit time if the sampling period has been set. The plot is given the title held in the String graphTitle.
Usage:
ft.plotPowerSpectrum(lowFreq, graphTitle);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from the frequency lowFreq to the highest frequency, as a plot of the mean square amplitude against cycles cycles per unit time. The sampling period must have been set if this method is to be called. If lowFreq is set equal to 1.0D the first point, i.e. the zero frequency point, will be ignored. The plot is given the title held in the String graphTitle.
Usage:
ft.plotPowerSpectrum(lowFreq, highFreq, graphTitle);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from the frequency lowFreq to the frequency, highFreq, as a plot of the mean square amplitude against cycles cycles per unit time. The sampling period must have been set if this method is to be called. If lowFreq is set equal to 1.0D the first point, i.e. the zero frequency point, will be ignored. The plot is given the title held in the String graphTitle.
Usage:
ft.plotPowerSpectrum();
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName) as a plot of the mean square amplitude against cycles per grid point or cycles per unit time if the sampling period has been set. The plot is given the title "Estimation of Power Spectrum".
Usage:
ft.plotPowerSpectrum(lowPoint);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from point lowPoint to the highest point, as a plot of the mean square amplitude against cycles per grid point or cycles per unit time if the sampling period has been set. For example, ft.plotPowerSpectrum(1) would display all points except the first point i.e. point 0 [Java indices start at 0]. The plot is given the title "Estimation of Power Spectrum".
Usage:
ft.plotPowerSpectrum(lowPoint, highPoint);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from point lowPoint to point, highPoint, [Java indices start at 0] as a plot of the mean square amplitude against cycles per grid point or cycles per unit time if the sampling period has been set. The plot is given the title "Estimation of Power Spectrum".
Usage:
ft.plotPowerSpectrum(lowFreq);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from the frequency lowFreq to the highest frequency, as a plot of the mean square amplitude against cycles cycles per unit time. The sampling period must have been set if this method is to be called. If lowFreq is set equal to 1.0D the first point, i.e. the zero frequency point, will be ignored. The plot is given the title "Estimation of Power Spectrum".
Usage:
ft.plotPowerSpectrum(lowFreq, highFreq);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from the frequency lowFreq to the frequency, highFreq, as a plot of the mean square amplitude against cycles cycles per unit time. The sampling period must have been set if this method is to be called. If lowFreq is set equal to 1.0D the first point, i.e. the zero frequency point, will be ignored. The plot is given the title "Estimation of Power Spectrum".
Display a log graph of the estimated power spectrum
public void plotPowerLog(String graphName)
public void plotPowerLog(int lowPoint, String outputFileName)
public void plotPowerLog(int lowPoint, int highPoint, String outputFileName)
public void plotPowerLog(double lowFreq, String outputFileName)
public void plotPowerLog(double lowFreq, double highFreq, String outputFileName)
public void plotPowerLog()
public void plotPowerLog(int lowPoint)
public void plotPowerLog(int lowPoint, int highPoint)
public void plotPowerLog(double lowFreq)
public void plotPowerLog(double lowFreq, double highFreq)
Usage:
ft.plotPowerLog(graphTitle);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName) as a plot of the log_{10}(mean square amplitude) against cycles per grid point or per unit time if the sampling period has been set. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title held in the String graphTitle.
Usage:
ft.plotPowerLog(lowPoint, graphTitle);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from point lowPoint to the highest point, as a plot of the log_{10}(mean square amplitude) against cycles per grid point or cycles per unit time if the sampling period has been set. For example, ft.plotPowerLog(1, graphTitle) would display all points except the first point i.e. point 0 [Java indices start at 0]. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title held in the String graphTitle.
Usage:
ft.plotPowerLog(lowPoint, highPoint, graphTitle);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from point lowPoint to point, highPoint, [Java indices start at 0] as a plot of the log_{10}(mean square amplitude) against cycles per grid point or cycles per unit time if the sampling period has been set. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title held in the String graphTitle.
Usage:
ft.plotPowerLog(lowFreq, graphTitle);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from the frequency lowFreq to the highest frequency, as a plot of the log_{10}(mean square amplitude) against cycles cycles per unit time. The sampling period must have been set if this method is to be called. If lowFreq is set equal to 1.0D the first point, i.e. the zero frequency point, will be ignored. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title held in the String graphTitle.
Usage:
ft.plotPowerLog(lowFreq, highFreq, graphTitle);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from the frequency lowFreq to the frequency, highFreq, as a plot of the log_{10}(mean square amplitude) against cycles cycles per unit time. The sampling period must have been set if this method is to be called. If lowFreq is set equal to 1.0D the first point, i.e. the zero frequency point, will be ignored. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title held in the String graphTitle.
Usage:
ft.plotPowerLog();
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName) as a plot of the log_{10}(mean square amplitude) against cycles per grid point or per unit time if the sampling period has been set. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title "Estimation of Power Spectrum".
Usage:
ft.plotPowerLog(lowPoint);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from point lowPoint to the highest point, as a plot of the log_{10}(mean square amplitude) against cycles per grid point or cycles per unit time if the sampling period has been set. For example, ft.plotPowerLog(1) would display all points except the first point i.e. point 0 [Java indices start at 0]. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title "Estimation of Power Spectrum".
Usage:
ft.plotPowerLog(lowPoint, highPoint);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from point lowPoint to point, highPoint, [Java indices start at 0] as a plot of the log_{10}(mean square amplitude) against cycles per grid point or cycles per unit time if the sampling period has been set. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title "Estimation of Power Spectrum".
Usage:
ft.plotPowerLog(lowFreq);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from the frequency lowFreq to the highest frequency, as a plot of the log_{10}(mean square amplitude) against cycles per unit time. The sampling period must have been set if this method is to be called. If lowFreq is set equal to 1.0D the first point, i.e. the zero frequency point, will be ignored. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title "Estimation of Power Spectrum".
Usage:
ft.plotPowerLog(lowFreq, highFreq);
This method displays a graph the power spectrum generated by powerSpectrum() or powerSpectrum(inputFileName), from the frequency lowFreq to the frequency, highFreq, as a plot of the log_{10}(mean square amplitude) against cycles per unit time. The sampling period must have been set if this method is to be called. If lowFreq is set equal to 1.0D the first point, i.e. the zero frequency point, will be ignored. Amplitudes of zero value are ignored, i.e. in effect, set equal to the minimum nonzero amplitude. The plot is given the title "Estimation of Power Spectrum".
public double getDeltaT()
Usage:
deltaT = ft.getDeltaT);
This method returns the value of the sampling period if this has been set.
Correlate two data sets
public double[][] correlate(double[] data)
public double[][] correlate(double[] data1, double[] data2)
Usage:
correlation = ft.correlate(data);
Returns the correlation beween two sets of real data of equal length, n. The first set must have previusly been entered via a constructor or a setrData method. The second data set is supplied as the argument of this method, (data in the above usage). The two data sets must be of the same length which must be an integer power of two. The returned two dimensional array of doubles, of length, n1 contains the correlation coefficients at each lag time in the second row, i.e. correlation[1][0], correlation[1][1], etc and the lag times in the first row, i.e. correlation[0][0], correlation[0][1], etc. It is ordered as:
Array Index  Lag time  
0  (n/2  1).deltaT  
1  (n/2  2).deltaT  
. . . . . .  . . . . . .  
n/2  2  deltaT  
n/2  1  0  
n/2  +deltaT  
. . . . . .  . . . . . .  
n  2  +(n/2  2).deltaT  
n  1  +(n/2  1).deltaT 
Usage:
correlation = ft.correlate(data1, data2);
Returns the correlation beween two sets of real data of equal length, n, both supplied as arguments of this method, (data1 and data2 in the above usage). The two data sets must be of the same length which must be an integer power of two. The returned two dimensional array of doubles, of length, n1 contains the correlation coefficients at each lag time in the second row, i.e. correlation[1][0], correlation[1][1], etc and the lag times in the first row, i.e. correlation[0][0], correlation[0][1], etc. It is ordered in the same manner as described immediately above. The sign convention of this method is that if the data1 lags data2, i.e. is shifted to the right of it, a peak will be displayed as a positive lag.
Get the correlation array
public double[][] getCorrelation()
Usage:
correlation = ft.getCorrelataion();
This method also returns the array of correlation coefficients generated by correlare(data) or correlate(data1, data2) (see above for description of array contents).
Print the correlation to a text file
public void printCorrelation(outputFileName)
public void printCorrelation()
Usage:
ft.printCorrelation(outputfilename);
This method prints the correlation generated by correlate(data) or correlate(data1, data2) to a text file whose name is held in the String outputTextFile. The output file is a time and date stamped text file listing the transform details and the correlation coefficients at each time lag.
Usage:
ft.printCorrelate();
This method prints the correlation generated by correlate(data) or correlate(data1, data2) to a text file named Correlation.txt.. The output file is a time and date stamped text file listing the transform details and the correlation coefficients at each time lag.
Display a graph of the correlation
public void plotCorrelation(graphTitle)
public void plotCorrelation()
Usage:
ft.plotCorrelation(graphTitle);
This method displays a graph the correlation coefficients generated by correlate(data) or correlate(data1, data2) as a plot of the correlation coefficients against the lag times (as grid intervals or time units if the sampling period has been set). The plot is given the title held in the String graphTitle.
Usage:
ft.plotCorrelation();
This method displays a graph the correlation coefficients generated by correlate(data) or correlate(data1, data2) as a plot of the correlation coefficients against the lag times (as grid intervals or time units if the sampling period has been set). The plot is given the title "Correlation Plot".
Get the line option
public int getPlotLineOption()
Usage:
lineOption = ft.getPlotLineOption();
This method gets the line option used in plotPowerSpectrum and plotCorrelation(). See immediately above for option descriptions.
SHORT TIME FOURIER TRANSFORM  SPECTROGRAM
Generate a spectrogram
public double[][] shortTime(int windowLength)
public double[][] shortTime(double windowTime)
Usage:
timeFrequency = ft.shortTime(windowLength);
Returns a time frequency matrix for a shorttime Fourier Transform of the data entered via a construcor or set data method (see above) with a moving window of a number of data points equal to the argument, windowLength. This length must be an integer power of two. The window set by one of the set window methods (see above) is applied to the moving window of this method. If no window function has been set a Gaussian window with alpha = 2.5 is applied. Elements 1 onwards of the first row of the returned matrix, i.e. timeFrequency[0][1], timeFrequency[0][2]... , contain the avearge time of the window, as time units if the sampling period, deltaT, has been set, or grid point averages if not. Elements 1 onwards of the first column, i.e. timeFrequency[1][0], timeFrequency[2][0]... , contain the frequencies, as cycles per unit time if the sampling period, deltaT, has been set, or as cycles per grid point if not. the zeroth, zeroth element, i.e. timeFrequency[0][0], is blank. All other elements contain the square amplitudes for each window position and each frequency, i.e. timeFrequency[i][j] contains the mean square amplitude for the frequency, timeFrequency[i][0], and the window centred on a time, timeFrequency[0][j].
Usage:
timeFrequency = ft.shortTime(windowTime);
Returns a time frequency matrix for a shorttime Fourier Transform of the data entered via a construcor or set data method (see above) with a moving window of a length, in time, equal to the argument, windowTime. This length is converted to the corresponding number of data points. If this number is not an integer power of two it is replaced by the nearest integer power of two. The window set by one of the set window methods (see above) is applied to the moving window of this method. If no window function has been set a Gaussian window with alpha = 2.5 is applied. Elements 1 onwards of the first row of the returned matrix, i.e. timeFrequency[0][1], timeFrequency[0][2]... , contain the avearge time of the window, as time units if the sampling period, deltaT, has been set, or grid point averages if not. Elements 1 onwards of the first column, i.e. timeFrequency[1][0], timeFrequency[2][0]... , contain the frequencies, as cycles per unit time if the sampling period, deltaT, has been set, or as cycles per grid point if not. the zeroth, zeroth element, i.e. timeFrequency[0][0], is blank. All other elements contain the square amplitudes for each window position and each frequency, i.e. timeFrequency[i][j] contains the mean square amplitude for the frequency, timeFrequency[i][0], and the window centred on a time, timeFrequency[0][j].
Get the TimeFrequency Matrix
public double[][] getTimeFrequencyMatrix()
Usage:
timeFrequency = ft.getTimeFrequencyMatrix();
This method also returns the timefrequency matrix generated by shortTime(window) (see immediately above for description of array contents).
Print the TimeFrequency matrix to a text file
public void printShortTime(String fileName)
public void printShortTime()
Usage:
ft.printShortTime(outputfilename);
This method prints the timefrequency matrix generated by shortTime(window) to a text file whose name is held in the String outputTextFile. The output file is a time and date stamped text file listing the transform details and the time frequency matrix. If there are more than 127 window times average values are taken to give 100 columns.
Usage:
ft.printshortTime();
This method prints the timefrequency matrix generated by shortTime(window) to a text file named ShortTime.txt. The output file is a time and date stamped text file listing the transform details and the time frequency matrix. If there are more than 127 window times average values are taken to give 100 columns.
Plot TimeFrequency Contour Map
public void plotShortTime(String graphTitle)
public void plotShortTime()
Usage:
ft.plotShortTime(graphTitle);
This method displays a contour plot the squared amplitudes of the timefrequency matrix generated by shortTime(window). The plot is given the title held in the String graphTitle.
Usage:
ft.plotShortTime();
This method displays a contour plot the squared amplitudes of the timefrequency matrix generated by shortTime(window)
Get the ShortTime Fourier Transform window length
public int getShortTimeWindowLength()
Usage:
windowLength = ft.getShortTimeWindowLength();
This method returns the shorttime Fourier transform window length, last used, as number of data points in the window.
Get the number of ShortTime Fourier Transform sample times
public int getShortTimeNumberOfTimes()
Usage:
sampleN = ftgetShortTimeNumberOfTimes();
This method returns the number of sample times in the shorttime Fourier transform.
Get the number of ShortTime Fourier Transform frequencies
public int getShortTimeNumberOfFrequencies()
Usage:
freqN = ft.getShortTimeNumberOfFrequencies();
This method returns the number of frequencies in the shorttime Fourier transform output.