Examples

These examples demonstrate how to use the FFT operator.

The following example computes the spectrogram of a time series by using the FFT operator:


use com.teracloud.streams.timeseries.analysis::FFT;
composite Main {
  graph
    //Compute the spectogram spectrum
    stream<list<float64> magnitude> spectogramStream = FFT(sineStream) {
      window
        sineStream: sliding, count(128), count(10);
      param
        inputTimeSeries: sine;
        useHamming: true;
        resolution: 128u;
        algorithm: complextFFT;
      output
        spectogramStream:
          magnitude=magnitude();
    }
}

The following example returns FFT values as list of complex64 data types.


use com.teracloud.streams.timeseries.analysis::FFT;
composite Main {
  type
    ecgRawInput = tuple<float64 patientId,  float64 ecgValue>;
    fftResult = tuple<list<complex64> fft, list<float64> magnitude, list<float64> power>;
  graph
    stream <float64 id, list<float64> ecgValue> EcgRawInputRecord = FileSource() {
      param
        file : "ts.csv";
        format : csv;
    }
    
    stream<fftResult> FftResultRecord = FFT(EcgRawInputRecord) {
      param
        inputTimeSeries : ecgValue;
        useHamming : false;
        algorithm : complexFFT;
      output FftResultRecord :
        fft = FFTAsComplex(), magnitude = magnitude(), power = power();
    }
    
    () as PowerSink = FileSink(FftResultRecord) {
      param
        file: "FFT-power.csv";
        format: csv;
    }
}