IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40308


Ignore:
Timestamp:
Jan 1, 2018, 9:36:48 AM (9 years ago)
Author:
eugene
Message:

add options to periodogram-fm

Location:
trunk/Ohana/src/opihi/cmd.data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/periodogram-fm.c

    r40165 r40308  
    88  if ((N = get_argument (argc, argv, "-v"))) {
    99    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]);
    1023    remove_argument (N, &argc, argv);
    1124  }
     
    5467
    5568  int Np = 0;
    56   int NP = 100;
     69  int NP = Nperiods;
    5770  ResetVector (power,  OPIHI_FLT, NP);
    5871  ResetVector (period, OPIHI_FLT, NP);
    5972
    6073  // for testing, we are going to write out the terms explicitly
    61   // for optimization, some of the tri functions can be calculated more efficiently
     74  // for optimization, some of the trig functions can be calculated more efficiently
    6275  // 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)));
    6381
    6482  // XXX consider choice of period or frequency step
    6583  double P = minP;
    66   while (P <= maxP) {
     84  for (Np = 0; Np < Nperiods; Np++) {
    6785    double w = 2*M_PI/P;
    6886   
     
    126144    power[0].elements.Flt[Np] = Po;
    127145    period[0].elements.Flt[Np] = P;
    128     Np ++;
    129146    if (Np >= NP) {
    130147      NP += 100;
     
    133150    }
    134151
    135     double ratio = 1 + 0.1*P/dTime;
     152    // double ratio = 1 + 0.1*P/dTime;
    136153
    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);
    138155
    139     P *= ratio;
     156    if (LINEAR) {
     157      P += dP;
     158    } else {
     159      P *= dP;
     160    }
    140161  }
    141162
  • trunk/Ohana/src/opihi/cmd.data/test/periodogram-fm.sh

    r40291 r40308  
    2525
    2626 periodogram_fm t f df 5 50 period power
     27
     28 peak -q period power
     29
     30 if (abs ($peakpos - $P) > 0.5)
     31   $PASS = 0
     32   echo "OFFSET: {$peakpos - $P}"
     33 end
     34
     35 if ($PLOT)
     36  lim period power; clear; box; line -c red70 -lw 3 $P 0 to $P $peakval; plot period power -x line
     37 end
     38end
     39
     40# test using even samples
     41macro test1a
     42 $PASS = 1
     43 break -auto off
     44
     45 local P PI
     46 $PI = 3.14159265359
     47 $P  = 15.0
     48
     49 delete -q t f period power
     50
     51 create t 0 100
     52 set f = sin(2*$PI*t/$P)
     53 set df = 0.01 + zero(f)
     54
     55 periodogram_fm t f df 5 50 period power -Nperiods 512
    2756
    2857 peak -q period power
Note: See TracChangeset for help on using the changeset viewer.