Changeset 40308 for trunk/Ohana/src/opihi/cmd.data/periodogram-fm.c
- Timestamp:
- Jan 1, 2018, 9:36:48 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/periodogram-fm.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/periodogram-fm.c
r40165 r40308 8 8 if ((N = get_argument (argc, argv, "-v"))) { 9 9 VERBOSE = TRUE; 10 remove_argument (N, &argc, argv); 11 } 12 13 int LINEAR = FALSE; 14 if ((N = get_argument (argc, argv, "-linear"))) { 15 LINEAR = TRUE; 16 remove_argument (N, &argc, argv); 17 } 18 19 int Nperiods = 1024; 20 if ((N = get_argument (argc, argv, "-Nperiods"))) { 21 remove_argument (N, &argc, argv); 22 Nperiods = atoi(argv[N]); 10 23 remove_argument (N, &argc, argv); 11 24 } … … 54 67 55 68 int Np = 0; 56 int NP = 100;69 int NP = Nperiods; 57 70 ResetVector (power, OPIHI_FLT, NP); 58 71 ResetVector (period, OPIHI_FLT, NP); 59 72 60 73 // for testing, we are going to write out the terms explicitly 61 // for optimization, some of the tri functions can be calculated more efficiently74 // for optimization, some of the trig functions can be calculated more efficiently 62 75 // by storing cos,sin(w t) and using some recurrence rules 76 77 // maxP = minP * dP^n [n = 0 -- Nperiods-1] 78 // log(maxP) = log(minP) + (Nperiods - 1) * log (dP) 79 // log(dP) = (log(maxP) - log(minP)) / (Nperiods - 1) 80 double dP = LINEAR ? (maxP - minP)/(Nperiods - 1) : pow(10.0, ((log10(maxP) - log10(minP))/(Nperiods - 1))); 63 81 64 82 // XXX consider choice of period or frequency step 65 83 double P = minP; 66 while (P <= maxP) {84 for (Np = 0; Np < Nperiods; Np++) { 67 85 double w = 2*M_PI/P; 68 86 … … 126 144 power[0].elements.Flt[Np] = Po; 127 145 period[0].elements.Flt[Np] = P; 128 Np ++;129 146 if (Np >= NP) { 130 147 NP += 100; … … 133 150 } 134 151 135 double ratio = 1 + 0.1*P/dTime;152 // double ratio = 1 + 0.1*P/dTime; 136 153 137 if (VERBOSE) gprint (GP_ERR, "tau: %f, P: %f, ratio: %f, dTime: %f, nextP: %f\n", tau, P, ratio, dTime, P*ratio);154 if (VERBOSE) gprint (GP_ERR, "tau: %f, P: %f, ratio: %f, dTime: %f, nextP: %f\n", tau, P, dP, dTime, P*dP); 138 155 139 P *= ratio; 156 if (LINEAR) { 157 P += dP; 158 } else { 159 P *= dP; 160 } 140 161 } 141 162
Note:
See TracChangeset
for help on using the changeset viewer.
