IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 30, 2008, 7:45:21 AM (18 years ago)
Author:
eugene
Message:

modify functions to use both int and flt vectors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20081124/Ohana/src/opihi/cmd.data/peak.c

    r20839 r20857  
    2626    end   = atof (argv[4]);
    2727  } else {
    28     start = vecx[0].elements.Flt[0];
    29     end   = vecx[0].elements.Flt[vecx[0].Nelements - 1];
     28    start = (vecx[0].type == OPIHI_FLT) ? vecx[0].elements.Flt[0] : vecx[0].elements.Int[0];
     29    end   = (vecx[0].type == OPIHI_FLT) ? vecx[0].elements.Flt[vecx[0].Nelements - 1] : vecx[0].elements.Int[vecx[0].Nelements - 1];
    3030  }
    3131
    32   X = vecx[0].elements.Flt;
    33   Y = vecy[0].elements.Flt;
     32  imax = -1;
    3433
    35   imax = -1;
    36   xmax = *X;
    37   ymax = *Y;
    38   for (i = 1; i < vecx[0].Nelements-1; i++, X++, Y++) {
    39     if ((*X >= start) && (*X <= end)) {
    40       if ((imax == -1) || (*Y > ymax)) {
    41         xmax = *X;
    42         ymax = *Y;
    43         imax = i;
     34  if (vecx[0].type == OPIHI_FLT) {
     35    opihi_flt *X = vecx[0].elements.Flt;
     36    xmax = X[start];
     37    ymax = (vecy[0].type == OPIHI_FLT) ? vecy[0].elements.Flt[start] : vecy[0].elements.Int[start];
     38    for (i = 1; i < vecx[0].Nelements-1; i++, X++, Y++) {
     39      if ((*X >= start) && (*X <= end)) {
     40        if ((imax == -1) || (*Y > ymax)) {
     41          xmax = *X;
     42          ymax = (vecy[0].type == OPIHI_FLT) ? vecy[0].elements.Flt[i] : vecy[0].elements.Int[i];
     43          imax = i;
     44        }
    4445      }
    45     }
    46   }     
     46    }     
     47  } else {
     48    opihi_int *X = vecx[0].elements.Int;
     49    xmax = X[start];
     50    ymax = (vecy[0].type == OPIHI_FLT) ? vecy[0].elements.Flt[start] : vecy[0].elements.Int[start];
     51    for (i = 1; i < vecx[0].Nelements-1; i++, X++, Y++) {
     52      if ((*X >= start) && (*X <= end)) {
     53        if ((imax == -1) || (*Y > ymax)) {
     54          xmax = *X;
     55          ymax = (vecy[0].type == OPIHI_FLT) ? vecy[0].elements.Flt[i] : vecy[0].elements.Int[i];
     56          imax = i;
     57        }
     58      }
     59    }     
     60  }
    4761
    4862  set_variable ("peakval", ymax);
Note: See TracChangeset for help on using the changeset viewer.