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/dvo/mmextract.c

    r20856 r20857  
    88  int Nsecfilt, VERBOSE, loadImages, mosaicMode;
    99  char **cstack1, **cstack2, name1[1024], name2[1024];
    10   float *values, **table1, **table2;
     10  dbValue *values, **table1, **table2;
    1111  void *Signal;
    1212
     
    139139
    140140  /* create storage vector */
    141   ALLOCATE (values, float, Nfields);
     141  ALLOCATE (values, dbValue, Nfields);
    142142  ALLOCATE (vec, Vector *, Nreturn);
    143143
     
    152152    if ((vec[2*i+0] = SelectVector (name1, ANYVECTOR, TRUE)) == NULL) goto escape;
    153153    if ((vec[2*i+1] = SelectVector (name2, ANYVECTOR, TRUE)) == NULL) goto escape;
    154     ResetVector (vec[2*i+0], fields[i].type, NNN);
    155     ResetVector (vec[2*i+1], fields[i].type, NNN);
     154    ResetVector (vec[2*i+0], fields[i].type, fields[i].type);
     155    ResetVector (vec[2*i+1], fields[i].type, fields[i].type);
    156156  }
    157157
     
    160160
    161161  // we save the selected measures for each average to temporary tables 1 and 2
     162  // XXX need to deal with the INT / DBL difference here...
    162163  NTABLE = 100;
    163   ALLOCATE (table1, float *, Nreturn_base);
    164   ALLOCATE (table2, float *, Nreturn_base);
     164  ALLOCATE (table1, dbValue *, Nreturn_base);
     165  ALLOCATE (table2, dbValue *, Nreturn_base);
    165166  for (i = 0; i < Nreturn_base; i++) {
    166     ALLOCATE (table1[i], float, NTABLE);
    167     ALLOCATE (table2[i], float, NTABLE);
     167    ALLOCATE (table1[i], dbValue, NTABLE);
     168    ALLOCATE (table2[i], dbValue, NTABLE);
    168169  }
    169170
     
    196197        NTABLE = catalog.average[j].Nmeasure;
    197198        for (n = 0; n < Nreturn_base; n++) {
    198           REALLOCATE (table1[n], float, NTABLE);
    199           REALLOCATE (table2[n], float, NTABLE);
     199          REALLOCATE (table1[n], dbValue, NTABLE);
     200          REALLOCATE (table2[n], dbValue, NTABLE);
    200201        }
    201202      }
     
    208209        dbExtractMeasuresInitMeas (); // reset counters for saved fields
    209210        for (n = 0; n < Nfields; n++) {
     211          // values needs to be a pointer to a type with FLT and INT (with a union, we would save a bit of memory...)
    210212          values[n] = dbExtractMeasures (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
    211213        }
     
    234236        for (n2 = 0; n2 < Nt2; n2++) {
    235237          for (n = 0; n < Nreturn_base; n++) {
    236             vec[2*n+0][0].elements.Flt[Npts] = table1[n][n1];
    237             vec[2*n+1][0].elements.Flt[Npts] = table2[n][n2];
     238            if (vec[2*n+0][0].type == OPIHI_FLT) {
     239              vec[2*n+0][0].elements.Flt[Npts] = table1[n][n1].Flt;
     240              vec[2*n+1][0].elements.Flt[Npts] = table2[n][n2].Flt;
     241            } else {
     242              vec[2*n+0][0].elements.Int[Npts] = table1[n][n1].Int;
     243              vec[2*n+1][0].elements.Int[Npts] = table2[n][n2].Int;
     244            }
    238245          }
    239246          Npts++;
     
    241248            NPTS += 2000;
    242249            for (n = 0; n < Nreturn; n++) {
    243               REALLOCATE (vec[n][0].elements.Flt, opihi_flt, NPTS);
     250              if (vec[n][0].type == OPIHI_FLT) {
     251                REALLOCATE (vec[n][0].elements.Flt, opihi_flt, NPTS);
     252              } else {
     253                REALLOCATE (vec[n][0].elements.Int, opihi_int, NPTS);
     254              }
    244255            }
    245256          }
     
    257268  interrupt = FALSE;
    258269
     270  // free excess memory
    259271  for (n = 0; n < Nreturn; n++) {
    260272    vec[n][0].Nelements = Npts;
    261     REALLOCATE (vec[n][0].elements.Flt, opihi_flt, MAX(1,Npts));
     273    if (vec[n][0].type == OPIHI_FLT) {
     274      REALLOCATE (vec[n][0].elements.Flt, opihi_flt, MAX(1,Npts));
     275    } else {
     276      REALLOCATE (vec[n][0].elements.Int, opihi_int, MAX(1,Npts));
     277    }
    262278  }
    263279
Note: See TracChangeset for help on using the changeset viewer.