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/vbin.c

    r7917 r20936  
    55  int i, j, n, N, Nin, Nout;
    66  int Normalize, Ignore;
    7   float *Vout, *Vin, IgnoreValue;
     7  opihi_flt *Vout, IgnoreValue;
    88  double scale;
    99  Vector *in, *out;
     
    4242  Nout = Nin / scale;
    4343
    44   REALLOCATE (out[0].elements, float, Nout);
    45   out[0].Nelements = Nout;
     44  // re-binning creates a float vector
     45  ResetVector (out, OPIHI_FLT, in[0].Nelements);
    4646
    47   Vin  = in[0].elements;
    48   Vout = out[0].elements;
    49   for (n = j = 0; j < Nout; j++, Vout++) {
    50     *Vout = 0;
    51     for (N = i = 0; (i < scale) && (n < Nin); n++, i++, Vin++) {
    52       if (!finite (*Vin)) continue;
    53       if (Ignore && (*Vin == IgnoreValue)) continue;
    54       *Vout += *Vin;
    55       N ++;
    56     }
    57     if (Normalize) {
    58       if (N > 0) {
    59         *Vout /= (float) N;
    60       } else {
    61         *Vout = 0;
     47  Vout = out[0].elements.Flt;
     48
     49  if (in[0].type == OPIHI_FLT) {
     50    opihi_flt *Vin  = in[0].elements.Flt;
     51    for (n = j = 0; j < Nout; j++, Vout++) {
     52      *Vout = 0;
     53      for (N = i = 0; (i < scale) && (n < Nin); n++, i++, Vin++) {
     54        if (!finite (*Vin)) continue;
     55        if (Ignore && (*Vin == IgnoreValue)) continue;
     56        *Vout += *Vin;
     57        N ++;
     58      }
     59      if (Normalize) {
     60        if (N > 0) {
     61          *Vout /= (opihi_flt) N;
     62        } else {
     63          *Vout = 0;
     64        }
     65      }
     66    }
     67  } else {
     68    opihi_int *Vin  = in[0].elements.Int;
     69    for (n = j = 0; j < Nout; j++, Vout++) {
     70      *Vout = 0;
     71      for (N = i = 0; (i < scale) && (n < Nin); n++, i++, Vin++) {
     72        if (!finite (*Vin)) continue;
     73        if (Ignore && (*Vin == IgnoreValue)) continue;
     74        *Vout += *Vin;
     75        N ++;
     76      }
     77      if (Normalize) {
     78        if (N > 0) {
     79          *Vout /= (opihi_flt) N;
     80        } else {
     81          *Vout = 0;
     82        }
    6283      }
    6384    }
Note: See TracChangeset for help on using the changeset viewer.