IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 7, 2008, 3:31:01 PM (18 years ago)
Author:
eugene
Message:

big update from eam_branch_20081124 with updates to Opihi math

File:
1 edited

Legend:

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

    r7917 r20936  
    44 
    55  int i, N, Npt, Np, NP, VERBOSE;
    6   float *tv, *fv;
     6  opihi_flt *tv, *fv;
    77  float minP, maxP, minT, maxT, dTime;
    88  float mean, var, w, tau, P, Pc, Ps, Po;
     
    2828  if ((power = SelectVector (argv[6], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    2929
     30  REQUIRE_VECTOR_FLT (time, FALSE);
     31  REQUIRE_VECTOR_FLT (flux, FALSE);
     32
    3033  /* find the max baseline, mean, and variance */
    31   minT = maxT = time[0].elements[0];
     34  minT = maxT = time[0].elements.Flt[0];
    3235  Npt = time[0].Nelements;
    33   tv = time[0].elements;
    34   fv = flux[0].elements;
     36  tv = time[0].elements.Flt;
     37  fv = flux[0].elements.Flt;
    3538  mean = var = 0;
    3639  for (i = 0; i < Npt; i++, tv++, fv++) {
     
    4043  }
    4144  mean = mean / Npt;
    42   fv = flux[0].elements;
     45  fv = flux[0].elements.Flt;
    4346  for (i = 0; i < Npt; i++, fv++) {
    4447    var += SQ(*fv - mean);
     
    5659  Np = 0;
    5760  NP = 100;
    58   REALLOCATE (power[0].elements, float, NP);
    59   REALLOCATE (period[0].elements, float, NP);
     61  ResetVector (power,  OPIHI_FLT, NP);
     62  ResetVector (period, OPIHI_FLT, NP);
    6063
    6164  P = minP;
     
    6467   
    6568    /* find the period offset tau  */
    66     tv = time[0].elements;
     69    tv = time[0].elements.Flt;
    6770    cs = sn = 0;
    6871    for (i = 0; i < Npt; i++, tv++) {
     
    7376     
    7477    /* find the power at this period */
    75     tv = time[0].elements;
    76     fv = flux[0].elements;
     78    tv = time[0].elements.Flt;
     79    fv = flux[0].elements.Flt;
    7780    cs = sn = cs2 = sn2 = 0;
    7881    for (i = 0; i < Npt; i++, tv++, fv++) {
     
    9093    Po = (Pc + Ps) / (2*var);
    9194
    92     power[0].elements[Np] = Po;
    93     period[0].elements[Np] = P;
     95    power[0].elements.Flt[Np] = Po;
     96    period[0].elements.Flt[Np] = P;
    9497    Np ++;
    9598    if (Np >= NP) {
    9699      NP += 100;
    97       REALLOCATE (power[0].elements, float, NP);
    98       REALLOCATE (period[0].elements, float, NP);
     100      REALLOCATE (power[0].elements.Flt, opihi_flt, NP);
     101      REALLOCATE (period[0].elements.Flt, opihi_flt, NP);
    99102    }
    100103
     
    106109  }
    107110
    108   power[0].Nelements = Np;
    109   period[0].Nelements = Np;
    110   REALLOCATE (power[0].elements, float, Np);
    111   REALLOCATE (period[0].elements, float, Np);
     111  ResetVector (power,  OPIHI_FLT, Np);
     112  ResetVector (period, OPIHI_FLT, Np);
    112113 
    113114  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.