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

    r20819 r20936  
    66  int Nsecfilt, VERBOSE, loadImages, mosaicMode;
    77  char **cstack, name[1024];
    8   float *values;
     8  dbValue *values;
    99  void *Signal;
    1010
    1111  Catalog catalog;
    1212  SkyList *skylist;
    13   PhotCode *code;
    1413  Vector **vec;
    1514  dbField *fields;
     
    1817
    1918  /* defaults */
     19  vec = NULL;
     20  stack = NULL;
     21  fields = NULL;
     22  values = NULL;
    2023  skylist = NULL;
    21   code = NULL;
    22   fields = NULL;
    23   stack = NULL;
     24  selection = NULL;
    2425
    2526  if ((N = get_argument (argc, argv, "-h"))) goto help;
     
    4950  fields = dbCmdlineFields (argc, argv, DVO_TABLE_MEASURE, &last, &Nfields);
    5051  if (fields == NULL) return (FALSE);
     52  if (Nfields == 0) {
     53    FreeSkyRegionSelection (selection);
     54    dbFreeFields (fields, Nfields);
     55    dvo_catalog_free (&catalog);
     56    goto help;
     57  }
    5158
    5259  // examine line for 'where' or 'match to'.  'match to' is forbidden
     
    8895
    8996  /* create storage vector */
    90   ALLOCATE (values, float, Nfields);
     97  Npts = 0;
     98  NPTS = 1000;
     99  ALLOCATE (values, dbValue, Nfields);
    91100  ALLOCATE (vec, Vector *, Nreturn);
    92101  for (i = 0; i < Nreturn; i++) {
     
    97106    }
    98107    if ((vec[i] = SelectVector (name, ANYVECTOR, TRUE)) == NULL) goto escape;
    99   }
    100 
    101   Npts = 0;
    102   NPTS = 1;
     108    ResetVector (vec[i], fields[i].type, NPTS);
     109  }
    103110
    104111  // grab data from all selected sky regions
     
    139146        if (!dbBooleanCond (stack, Nstack, values)) continue;
    140147        for (n = 0; n < Nreturn; n++) {
    141           vec[n][0].elements[Npts] = values[n];
     148          if (vec[n][0].type == OPIHI_FLT) {
     149            vec[n][0].elements.Flt[Npts] = values[n].Flt;
     150          } else {
     151            vec[n][0].elements.Int[Npts] = values[n].Int;
     152          }
    142153          // fprintf (stderr, "keep : field: %s, value: %f\n", fields[n].name, values[n]);
    143154        }
     
    146157          NPTS += 2000;
    147158          for (n = 0; n < Nreturn; n++) {
    148             REALLOCATE (vec[n][0].elements, float, NPTS);
     159            REALLOCATE (vec[n][0].elements.Flt, opihi_flt, NPTS);
    149160          }
    150161        }
     
    161172
    162173  for (n = 0; n < Nreturn; n++) {
    163     vec[n][0].Nelements = Npts;
    164     REALLOCATE (vec[n][0].elements, float, MAX(1,Npts));
    165   }
    166 
     174    ResetVector (vec[n], fields[n].type, MAX(1,Npts));
     175  }
     176
     177  if (vec) free (vec);
     178  if (values) free (values);
    167179  dbFreeFields (fields, Nfields);
    168180  dbFreeStack (stack, Nstack);
     
    174186
    175187escape:
     188  if (vec) free (vec);
     189  free (values);
    176190  dbFreeFields (fields, Nfields);
    177191  dbFreeStack (stack, Nstack);
Note: See TracChangeset for help on using the changeset viewer.