IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 21, 2007, 3:38:16 PM (19 years ago)
Author:
eugene
Message:

boolean db extractions now working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/avextract.c

    r13443 r13454  
    33int avextract (int argc, char **argv) {
    44 
    5   int i, j, m, N, NPTS, last, Nfields;
     5  int i, j, n, m, Npts, NPTS, last, Nfields, Nreturn, Ncstack, Nstack;
    66  int Nsecfilt, mode;
    77  char *RegionName, *RegionList, *p;
     8  char **cstack;
     9  float *values;
    810
    911  Catalog catalog;
    1012  SkyList *skylist;
    1113  PhotCode *code;
    12   Vector *vec;
     14  Vector **vec;
    1315
    14   dvoFields *fields;
     16  dbField *fields;
     17  dbStack *stack;
    1518
    1619  /* defaults */
     
    2629  Nsecfilt = GetPhotcodeNsecfilt ();
    2730
     31  // remove skyregion options
     32  // XXX this needs to explicitly handle -qregion and -skyregion
     33  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
     34
    2835  // command-line is of the form: avextract field,field, field [where (field op value)...]
    2936
     
    3340
    3441  // parse the remainder of the line as a boolean math expression
    35   cstack = isolate_elements (argv-last, &argv[last], &Ncstack);
     42  cstack = isolate_elements (argc-last, &argv[last], &Ncstack);
    3643 
    3744  // construct the db Boolean math stack (frees cstack)
    38   dbStack = dbRPN (Ncstack, cstack, &NdbStack);
     45  stack = dbRPN (Ncstack, cstack, &Nstack);
    3946
    4047  Nreturn = Nfields;
    41   dbCheckStack (dbStack, NdbStack, DVO_TABLE_AVERAGE, &fields, &Nfields);
     48  dbCheckStack (stack, Nstack, DVO_TABLE_AVERAGE, &fields, &Nfields);
    4249  // XXX handle errors
    43 
    44   /* interpret command-line options */
    45   // this needs to explicitly handles -qregion and -skyregion
    46   if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
    4750
    4851  /* load region corresponding to selection above */
     
    5154  /* create output storage vectors */
    5255  ALLOCATE (values, float, Nfields);
    53   ALLOCATE (vec, Vector, Nreturn);
     56  ALLOCATE (vec, Vector *, Nreturn);
    5457  for (i = 0; i < Nreturn; i++) {
    5558    if ((vec[i] = SelectVector (fields[i].name, ANYVECTOR, TRUE)) == NULL) goto escape;
     
    7881      // XXX for measure values, this could be optimized for one loop over measures...
    7982      for (n = 0; n < Nfields; n++) {
    80         values[n] = ExtractAveragesNew (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], fields[n]);
     83        values[n] = dbExtractAverages (&catalog.average[j], &catalog.secfilt[j*Nsecfilt], &catalog.measure[m], &fields[n]);
    8184      }
    8285      // test the conditional statement
    83       if (!dbBooleanCond (dbStack, NdbStack, values, fields, Nfields)) continue;
     86      if (!dbBooleanCond (stack, Nstack, values)) continue;
    8487      for (n = 0; n < Nreturn; n++) {
    85         vec[n].elements[N] = values[n];
     88        vec[n][0].elements[Npts] = values[n];
    8689      }
    87       N++;
    88       if (N >= NPTS) {
     90      Npts++;
     91      if (Npts >= NPTS) {
    8992        NPTS += 2000;
    9093        for (n = 0; n < Nreturn; n++) {
    91           REALLOCATE (vec[n].elements, float, NPTS);
     94          REALLOCATE (vec[n][0].elements, float, NPTS);
    9295        }
    9396      }
     
    9699  }
    97100  for (n = 0; n < Nreturn; n++) {
    98     vec[n].Nelements = N;
    99     REALLOCATE (vec[n].elements, float, MAX(1,N));
     101    vec[n][0].Nelements = Npts;
     102    REALLOCATE (vec[n][0].elements, float, MAX(1,Npts));
    100103  }
     104
     105  // XXX free fields and stack
    101106
    102107  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
Note: See TracChangeset for help on using the changeset viewer.