IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 26, 2017, 6:22:26 AM (9 years ago)
Author:
eugene
Message:

working on periodogram-fm.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20170822/src/opihi/cmd.data/periodogram-fm.c

    r40141 r40145  
    88  float mean, var, w, tau, P, Pc, Ps, Po;
    99  float C, S, cs, sn, cs2, sn2, ratio;
    10   Vector *time, *flux, *power, *period;
     10  Vector *time, *flux, *dflux, *power, *period;
    1111
    1212  VERBOSE = FALSE;
     
    1616  }
    1717
    18   if (argc != 7) {
    19     gprint (GP_ERR, "USAGE: periodogram (time) (flux) (minP) (maxP) (period) (power)\n");
     18  if (argc != 8) {
     19    gprint (GP_ERR, "USAGE: periodogram-fm (time) (flux) (dflux) (minP) (maxP) (period) (power)\n");
    2020    return (FALSE);
    2121  }
    2222 
    23   if ((time = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    24   if ((flux = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
    25   minP = atof(argv[3]);
    26   maxP = atof(argv[4]);
    27   if ((period = SelectVector (argv[5], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    28   if ((power = SelectVector (argv[6], ANYVECTOR, TRUE)) == NULL) return (FALSE);
     23  // XXX allow dflux to be dropped?
     24
     25  if ((time  = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     26  if ((flux  = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     27  if ((dflux = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) return (FALSE);
     28  minP = atof(argv[4]);
     29  maxP = atof(argv[5]);
     30  if ((period = SelectVector (argv[6], ANYVECTOR, TRUE)) == NULL) return (FALSE);
     31  if ((power  = SelectVector (argv[7], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    2932
    3033  REQUIRE_VECTOR_FLT (time, FALSE);
     
    6265  ResetVector (period, OPIHI_FLT, NP);
    6366
     67  // for testing, we are going to write out the terms explicitly
     68  // for optimization, some of the tri functions can be calculated more efficiently
     69  // by storing cos,sin(w t) and using some recurrence rules
     70
     71  // XXX consider choice of period or frequency step
    6472  P = minP;
    6573  while (P < maxP) {
     
    6876    /* find the period offset tau  */
    6977    tv = time[0].elements.Flt;
    70     cs = sn = 0;
     78    df = dflux[0].elements.Flt;
     79
     80    cs = sn = cs2 = sn2 = 0;
     81
    7182    for (i = 0; i < Npt; i++, tv++) {
     83      opihi_flt wt =
    7284      cs += cos (*tv*w*2);
    7385      sn += sin (*tv*2*2);
Note: See TracChangeset for help on using the changeset viewer.