- Timestamp:
- May 21, 2007, 3:38:16 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/avextract.c
r13443 r13454 3 3 int avextract (int argc, char **argv) { 4 4 5 int i, j, m, N, NPTS, last, Nfields;5 int i, j, n, m, Npts, NPTS, last, Nfields, Nreturn, Ncstack, Nstack; 6 6 int Nsecfilt, mode; 7 7 char *RegionName, *RegionList, *p; 8 char **cstack; 9 float *values; 8 10 9 11 Catalog catalog; 10 12 SkyList *skylist; 11 13 PhotCode *code; 12 Vector * vec;14 Vector **vec; 13 15 14 dvoFields *fields; 16 dbField *fields; 17 dbStack *stack; 15 18 16 19 /* defaults */ … … 26 29 Nsecfilt = GetPhotcodeNsecfilt (); 27 30 31 // remove skyregion options 32 // XXX this needs to explicitly handle -qregion and -skyregion 33 if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape; 34 28 35 // command-line is of the form: avextract field,field, field [where (field op value)...] 29 36 … … 33 40 34 41 // parse the remainder of the line as a boolean math expression 35 cstack = isolate_elements (arg v-last, &argv[last], &Ncstack);42 cstack = isolate_elements (argc-last, &argv[last], &Ncstack); 36 43 37 44 // construct the db Boolean math stack (frees cstack) 38 dbStack = dbRPN (Ncstack, cstack, &NdbStack);45 stack = dbRPN (Ncstack, cstack, &Nstack); 39 46 40 47 Nreturn = Nfields; 41 dbCheckStack ( dbStack, NdbStack, DVO_TABLE_AVERAGE, &fields, &Nfields);48 dbCheckStack (stack, Nstack, DVO_TABLE_AVERAGE, &fields, &Nfields); 42 49 // XXX handle errors 43 44 /* interpret command-line options */45 // this needs to explicitly handles -qregion and -skyregion46 if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;47 50 48 51 /* load region corresponding to selection above */ … … 51 54 /* create output storage vectors */ 52 55 ALLOCATE (values, float, Nfields); 53 ALLOCATE (vec, Vector , Nreturn);56 ALLOCATE (vec, Vector *, Nreturn); 54 57 for (i = 0; i < Nreturn; i++) { 55 58 if ((vec[i] = SelectVector (fields[i].name, ANYVECTOR, TRUE)) == NULL) goto escape; … … 78 81 // XXX for measure values, this could be optimized for one loop over measures... 79 82 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]); 81 84 } 82 85 // test the conditional statement 83 if (!dbBooleanCond ( dbStack, NdbStack, values, fields, Nfields)) continue;86 if (!dbBooleanCond (stack, Nstack, values)) continue; 84 87 for (n = 0; n < Nreturn; n++) { 85 vec[n] .elements[N] = values[n];88 vec[n][0].elements[Npts] = values[n]; 86 89 } 87 N ++;88 if (N >= NPTS) {90 Npts++; 91 if (Npts >= NPTS) { 89 92 NPTS += 2000; 90 93 for (n = 0; n < Nreturn; n++) { 91 REALLOCATE (vec[n] .elements, float, NPTS);94 REALLOCATE (vec[n][0].elements, float, NPTS); 92 95 } 93 96 } … … 96 99 } 97 100 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)); 100 103 } 104 105 // XXX free fields and stack 101 106 102 107 SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
Note:
See TracChangeset
for help on using the changeset viewer.
