00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _ORSA_FFT_H_
00026 #define _ORSA_FFT_H_
00027
00028 #include "orsa_analysis.h"
00029 #include "orsa_orbit.h"
00030
00031 #include <vector>
00032
00033 #include <fftw.h>
00034
00035 #include <gsl/gsl_vector.h>
00036 #include <gsl/gsl_min.h>
00037
00038 namespace orsa {
00039
00040
00041 typedef struct gsl_d1_minimization_parameters {
00042 fftw_complex * pointer_points_sequence;
00043 int size;
00044 } gsl_d1_minimization_parameters;
00045
00046 class FFTDataStructure {
00047 public:
00048 double time,amplitude,phase;
00049 virtual ~FFTDataStructure() {};
00050 };
00051
00052 class FFTDataStream : public std::vector<FFTDataStructure> {
00053 public:
00054 double timestep;
00055 };
00056
00057 class FFTPowerSpectrumBaseElement {
00058 public:
00059 double frequency;
00060 double power;
00061 };
00062
00063 class FFTPowerSpectrum : public std::vector<FFTPowerSpectrumBaseElement> {};
00064
00065 class Peak {
00066 public:
00067 inline void Set(double f, double a, double p) {
00068 frequency = f;
00069 amplitude = a;
00070 phase = p;
00071 }
00072
00073 public:
00074
00075
00076
00077
00078
00079
00080
00081 inline bool operator < (const Peak &p) const {
00082 return (p.amplitude < amplitude);
00083 }
00084
00085 public:
00086 double frequency,amplitude,phase;
00087
00088 public:
00089 fftw_complex phiR, phiL;
00090
00091 public:
00092 virtual ~Peak() {};
00093 };
00094
00095
00096 enum FFTSearch {HK=0,D,PQ,NODE,ANOMALY,ANOMALY_PHASE,A_M,TESTING};
00097
00098 enum FFTSearchAmplitude {A,E,I,SIN_I,TAN_I_2,ONE};
00099 enum FFTSearchPhase {OMEGA_NODE,OMEGA_PERICENTER,OMEGA_TILDE,MM,LAMBDA,ZERO};
00100
00101 enum FFTAlgorithm {
00102 algo_FFT,
00103 algo_FFTB,
00104 algo_MFT,
00105 algo_FMFT1,
00106 algo_FMFT2
00107 };
00108
00109
00110 class FFT : public Analysis {
00111
00112 public:
00113 FFT(OrbitStream&, FFTPowerSpectrum&, std::vector<Peak>&, FFTDataStream&);
00114
00115 void Search(FFTSearch,FFTAlgorithm=algo_FFT);
00116 void Search(FFTSearchAmplitude,FFTSearchPhase,FFTAlgorithm=algo_FFT);
00117
00118 private:
00119 void Search_FFT();
00120 void Search_FFTB();
00121 void Search_MFT();
00122 void Search_FMFT1();
00123 void Search_FMFT2();
00124
00125 void Search_FMFT_main();
00126
00127 public:
00128
00129
00130
00131 public:
00132 std::vector<int> candidate_bin;
00133
00134 public:
00135 double relative_amplitude;
00136
00137 private:
00138 double default_peak_reset_frequency;
00139 double default_peak_reset_amplitude;
00140 double default_peak_reset_phase;
00141
00142 public:
00143 bool HiResSpectrum;
00144
00145 private:
00146 void FillDataStream(FFTSearch);
00147 void FillDataStream(FFTSearchAmplitude,FFTSearchPhase);
00148 void ComputeCommonPowerSpectrum();
00149 void ComputeCommonReconstructedSignal();
00150
00151 public:
00152 gsl_d1_minimization_parameters par;
00153 gsl_function F;
00154 gsl_min_fminimizer *s;
00155 const gsl_min_fminimizer_type *T;
00156
00157 protected:
00158 std::vector<double> psd;
00159 FFTPowerSpectrum *fps;
00160
00161 std::vector<Peak> *peaks;
00162 OrbitStream *os;
00163
00164 FFTDataStream *reconstructed_data_stream;
00165
00166 public:
00167 FFTDataStream data_stream;
00168
00169 public:
00170 unsigned int nfreq;
00171 };
00172
00173 }
00174
00175 #endif // _ORSA_FFT_H_
00176