Changeset 19579
- Timestamp:
- Sep 16, 2008, 9:16:26 AM (18 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 7 edited
-
dvo/Makefile (modified) (1 diff)
-
dvo/avextract.c (modified) (2 diffs)
-
dvo/dbCmdlineFields.c (modified) (3 diffs)
-
dvo/init.c (modified) (2 diffs)
-
dvo/mextract.c (modified) (2 diffs)
-
dvo/mmextract.c (modified) (11 diffs)
-
include/dvoshell.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dvo/Makefile
r14401 r19579 78 78 $(SRC)/lightcurve.$(ARCH).o \ 79 79 $(SRC)/mextract.$(ARCH).o \ 80 $(SRC)/mmextract.$(ARCH).o \ 80 81 $(SRC)/photcodes.$(ARCH).o \ 81 82 $(SRC)/pmeasure.$(ARCH).o \ -
trunk/Ohana/src/opihi/dvo/avextract.c
r16936 r19579 3 3 int avextract (int argc, char **argv) { 4 4 5 int i, j, n, m, N, Npts, NPTS, last, Nfields, Nreturn, Ncstack, Nstack;5 int i, j, n, m, N, Npts, NPTS, last, next, state, Nfields, Nreturn, Ncstack, Nstack; 6 6 int Nsecfilt, mode, VERBOSE; 7 7 char **cstack, name[1024]; … … 48 48 fields = dbCmdlineFields (argc, argv, DVO_TABLE_AVERAGE, &last, &Nfields); 49 49 if (fields == NULL) return (FALSE); 50 51 // examine line for 'where' or 'match to'. 'match to' is forbidden 52 state = dbCmdlineConditions (argc, argv, last, &next); 53 if (state == DVO_DB_CMDLINE_ERROR) goto escape; 54 if (state == DVO_DB_CMDLINE_IS_MATCH) goto escape; // not allowed for mextract 50 55 51 56 // parse the remainder of the line as a boolean math expression -
trunk/Ohana/src/opihi/dvo/dbCmdlineFields.c
r19571 r19579 1 1 # include "dvoshell.h" 2 2 3 // identify the fields to be extracted (test for where, check syntax) 3 // check for 'where' or 'matched to'; return first field after the word, and the value 4 int dbCmdlineConditions (int argc, char **argv, int first, int *nextField) { 5 6 int isWhere, isMatch; 7 8 *nextField = argc; 9 10 // require 'where' or 'matched to' before boolean math 11 if (first == argc) return DVO_DB_CMDLINE_IS_END; 12 13 isWhere = !strcasecmp(argv[first], "where"); 14 isMatch = !strcasecmp(argv[first], "match"); 15 16 if (!isMatch && !isWhere) { 17 gprint (GP_ERR, "WHERE or MATCH TO\n"); 18 return DVO_DB_CMDLINE_ERROR; 19 } 20 if (isMatch && ((first + 1 >= argc - 1) || strcasecmp(argv[first+1], "to"))) { 21 gprint (GP_ERR, "missing boolean expression\n"); 22 return DVO_DB_CMDLINE_ERROR; 23 } 24 if (isWhere && (first >= argc - 1)) { 25 gprint (GP_ERR, "missing boolean expression\n"); 26 return DVO_DB_CMDLINE_ERROR; 27 } 28 29 if (isWhere) { 30 *nextField = first + 1; 31 return DVO_DB_CMDLINE_IS_WHERE; 32 } 33 34 if (isMatch) { 35 *nextField = first + 2; 36 return DVO_DB_CMDLINE_IS_MATCH; 37 } 38 39 gprint (GP_ERR, "programming error?\n"); 40 return DVO_DB_CMDLINE_ERROR; 41 } 42 43 // identify the fields to be extracted (check syntax) 44 // the 'last' pointer ends on the first word after the fields (where, match or EOL) 4 45 dbField *dbCmdlineFields (int argc, char **argv, int table, int *last, int *nfields) { 5 46 … … 15 56 16 57 // examine each argv[i] entry until we reach a 'where' or a 'matched' 17 for (i = 1; (i < argc) && strcasecmp (argv[i], "where") && strcasecmp (argv[i], "match ed"); i++) {58 for (i = 1; (i < argc) && strcasecmp (argv[i], "where") && strcasecmp (argv[i], "match"); i++) { 18 59 // split the word by "," 19 60 p = argv[i]; … … 50 91 } 51 92 52 // require 'where' or 'matched to' before boolean math53 // XXX push this to a test up one level54 if (i != argc) {55 if (strcasecmp(argv[i], "where")) {56 gprint (GP_ERR, "syntax error\n");57 free (fields);58 return (NULL);59 }60 if (i > argc - 2) {61 gprint (GP_ERR, "missing boolean expression\n");62 free (fields);63 return (NULL);64 }65 i++; // skip over the 'where'66 }67 68 93 *last = i; 69 94 *nfields = Nfields; -
trunk/Ohana/src/opihi/dvo/init.c
r16433 r19579 40 40 int lightcurve PROTO((int, char **)); 41 41 int mextract PROTO((int, char **)); 42 int mmextract PROTO((int, char **)); 42 43 int pcat PROTO((int, char **)); 43 44 int photcodes PROTO((int, char **)); … … 90 91 {1, "lightcurve", lightcurve, "extract lightcurve for a star"}, 91 92 {1, "mextract", mextract, "extract measure data values"}, 93 {1, "mmextract", mmextract, "extract joined measurements"}, 92 94 {1, "pcat", skycat, "plot catalog boundaries"}, 93 95 {1, "photcodes", photcodes, "list photometry codes"}, -
trunk/Ohana/src/opihi/dvo/mextract.c
r16936 r19579 3 3 int mextract (int argc, char **argv) { 4 4 5 int i, j, k, m, n, N, Npts, NPTS, last, Nfields, Nreturn, Ncstack, Nstack;5 int i, j, k, m, n, N, Npts, NPTS, last, next, state, Nfields, Nreturn, Ncstack, Nstack; 6 6 int Nsecfilt, VERBOSE, loadImages, mosaicMode; 7 7 char **cstack, name[1024]; … … 50 50 if (fields == NULL) return (FALSE); 51 51 52 // XXX add the skyregion limits as if it were a where statement 52 // examine line for 'where' or 'match to'. 'match to' is forbidden 53 state = dbCmdlineConditions (argc, argv, last, &next); 54 if (state == DVO_DB_CMDLINE_ERROR) goto escape; 55 if (state == DVO_DB_CMDLINE_IS_MATCH) goto escape; // not allowed for mextract 53 56 54 57 // parse the remainder of the line as a boolean math expression 55 cstack = isolate_elements (argc- last, &argv[last], &Ncstack);58 cstack = isolate_elements (argc-next, &argv[next], &Ncstack); 56 59 57 60 // construct the db Boolean math stack (frees cstack) -
trunk/Ohana/src/opihi/dvo/mmextract.c
r19570 r19579 3 3 int mmextract (int argc, char **argv) { 4 4 5 int i, j, k, m, n, N, Npts, NPTS, last, Nfields, Nreturn, Ncstack, Nstack; 5 int i, j, k, m, n, N, Npts, NPTS, last, next, state; 6 int Nfields, Nreturn, Nreturn_base, Ncstack1, Ncstack2, Nstack1, Nstack2; 7 int Nwhere, Iwhere, Nmatch, Imatch, NTABLE, Nt1, Nt2, n1, n2; 6 8 int Nsecfilt, VERBOSE, loadImages, mosaicMode; 7 char **cstack , name1[1024], name2[1024];8 float *values ;9 char **cstack1, **cstack2, name1[1024], name2[1024]; 10 float *values, **table1, **table2; 9 11 void *Signal; 10 12 … … 14 16 Vector **vec; 15 17 dbField *fields; 16 dbStack *stack; 18 dbStack *stack1; 19 dbStack *stack2; 17 20 SkyRegionSelection *selection; 18 21 … … 21 24 code = NULL; 22 25 fields = NULL; 23 stack = NULL; 26 stack1 = NULL; 27 stack2 = NULL; 24 28 25 29 if ((N = get_argument (argc, argv, "-h"))) goto help; … … 51 55 // -noauto means imageID is not matched 52 56 53 // parse the fields to be extracted and returned 57 // parse the fields to be extracted and returned : last points to end, or first 'where' or 'matched' 54 58 fields = dbCmdlineFields (argc, argv, DVO_TABLE_MEASURE, &last, &Nfields); 55 59 if (fields == NULL) return (FALSE); 56 60 57 // XXX require a 'where' and a 'matched to'? if not, all are cross-matched (that's ok) 58 // XXX add the skyregion limits as if it were a where statement 59 60 // need to find the location of 'where' and 'matched to' expressions 61 for (i = last; i < argc; i++) { 62 if (!strcasecmp (argv[i], "matched")) { 63 } 64 } 65 66 whereS = N; whereE = N; 67 matchS = N; matchE = N; 61 // examine line for 'where' and 'match to'. neither is required, but order is fixed 62 state = dbCmdlineConditions (argc, argv, last, &next); 63 if (state == DVO_DB_CMDLINE_ERROR) goto escape; 64 65 if (state == DVO_DB_CMDLINE_IS_END) { 66 Nwhere = Nmatch = 0; 67 Iwhere = Imatch = 0; 68 } 69 70 if (state == DVO_DB_CMDLINE_IS_MATCH) { 71 Nwhere = 0; 72 Iwhere = 0; 73 Imatch = next; 74 Nmatch = argc - next; 75 } 76 77 if (state == DVO_DB_CMDLINE_IS_WHERE) { 78 Iwhere = next; 79 // find the end or the 'match to' 80 for (last = next; (last < argc) && strcasecmp (argv[last], "match"); last++); 81 state = dbCmdlineConditions (argc, argv, last, &next); 82 if (state == DVO_DB_CMDLINE_ERROR) goto escape; 83 if (state == DVO_DB_CMDLINE_IS_WHERE) goto escape; 84 if (state == DVO_DB_CMDLINE_IS_END) { 85 Nwhere = argc - Iwhere; 86 Imatch = Nmatch = 0; 87 } else { 88 Nwhere = last - Iwhere; 89 Imatch = next; 90 Nmatch = argc - Imatch; 91 } 92 } 68 93 69 94 // parse the 'where' and 'matched to' segments of the line as boolean math expressions 70 cstack1 = isolate_elements (Nwhere, &argv[ whereS], &Ncstack1);71 cstack2 = isolate_elements (Nmatch, &argv[ matchS], &Ncstack2);95 cstack1 = isolate_elements (Nwhere, &argv[Iwhere], &Ncstack1); 96 cstack2 = isolate_elements (Nmatch, &argv[Imatch], &Ncstack2); 72 97 73 98 // construct the db Boolean math stack (frees cstack) … … 88 113 89 114 // add the skyregion limits to the where statement (or create) 90 dbAstroRegionLimits (&stack, &Nstack, selection, DVO_TABLE_MEASURE); 115 dbAstroRegionLimits (&stack1, &Nstack1, selection, DVO_TABLE_MEASURE); 116 dbAstroRegionLimits (&stack2, &Nstack2, selection, DVO_TABLE_MEASURE); 91 117 92 118 // parse stack elements into fields and scalars as needed … … 133 159 // we save the selected measures for each average to temporary tables 1 and 2 134 160 NTABLE = 100; 135 ALLOCATE (table1, double*, Nreturn_base);136 ALLOCATE (table2, double*, Nreturn_base);161 ALLOCATE (table1, float *, Nreturn_base); 162 ALLOCATE (table2, float *, Nreturn_base); 137 163 for (i = 0; i < Nreturn_base; i++) { 138 ALLOCATE (table1[i], double, NTABLE);139 ALLOCATE (table2[i], double, NTABLE);164 ALLOCATE (table1[i], float, NTABLE); 165 ALLOCATE (table2[i], float, NTABLE); 140 166 } 141 167 … … 188 214 for (n = 0; n < Nreturn_base; n++) { 189 215 table1[n][Nt1] = values[n]; 190 Nt1 ++;191 216 // fprintf (stderr, "keep : field: %s, value: %f\n", fields[n].name, values[n]); 192 217 } 218 Nt1 ++; 193 219 } 194 220 // test the second conditional statement … … 196 222 for (n = 0; n < Nreturn_base; n++) { 197 223 table2[n][Nt2] = values[n]; 198 Nt2 ++;199 224 // fprintf (stderr, "keep : field: %s, value: %f\n", fields[n].name, values[n]); 200 225 } 201 } 202 203 // XXX now do the join :: need to filter against automatch if -noauto is selected (record the index value k to test) 204 for (n1 = 0; n1 < Nt1; n1++) { 205 for (n2 = 0; n2 < Nt2; n2++) { 206 for (n = 0; n < Nreturn_base; n++) { 207 vec[n][0].elements[Npts] = table1[n][n1]; 208 } 209 for (n = 0; n < Nreturn_base; n++) { 210 vec[n+Nreturn_base][0].elements[Npts] = table2[n][n2]; 211 } 212 Npts++; 213 if (Npts >= NPTS) { 214 NPTS += 2000; 215 for (n = 0; n < Nreturn; n++) { 216 REALLOCATE (vec[n][0].elements, float, NPTS); 217 } 226 Nt2 ++; 227 } 228 } 229 230 // XXX now do the join :: need to filter against automatch if -noauto is selected (record the index value k to test) 231 for (n1 = 0; n1 < Nt1; n1++) { 232 for (n2 = 0; n2 < Nt2; n2++) { 233 for (n = 0; n < Nreturn_base; n++) { 234 vec[2*n+0][0].elements[Npts] = table1[n][n1]; 235 vec[2*n+1][0].elements[Npts] = table2[n][n2]; 236 } 237 Npts++; 238 if (Npts >= NPTS) { 239 NPTS += 2000; 240 for (n = 0; n < Nreturn; n++) { 241 REALLOCATE (vec[n][0].elements, float, NPTS); 218 242 } 219 243 } … … 221 245 } 222 246 } 247 223 248 dvo_catalog_free (&catalog); 224 249 // dbStackAllocPrint (); … … 235 260 } 236 261 262 for (n = 0; n < Nreturn_base; n++) { 263 free (table1[n]); 264 free (table2[n]); 265 } 266 free (table1); 267 free (table2); 268 269 free (values); 270 237 271 dbFreeFields (fields, Nfields); 238 dbFreeStack (stack, Nstack); 239 free (stack); 272 dbFreeStack (stack1, Nstack1); 273 dbFreeStack (stack2, Nstack2); 274 free (stack1); 275 free (stack2); 240 276 FreeImageSelection (); 241 277 SkyListFree (skylist); … … 245 281 escape: 246 282 dbFreeFields (fields, Nfields); 247 dbFreeStack (stack, Nstack); 248 free (stack); 283 dbFreeStack (stack1, Nstack1); 284 dbFreeStack (stack2, Nstack2); 285 free (stack1); 286 free (stack2); 249 287 FreeImageSelection (); 250 288 SkyListFree (skylist); -
trunk/Ohana/src/opihi/include/dvoshell.h
r17419 r19579 119 119 120 120 enum {DVO_TABLE_AVERAGE, DVO_TABLE_MEASURE}; 121 enum {DVO_DB_CMDLINE_ERROR, DVO_DB_CMDLINE_IS_END, DVO_DB_CMDLINE_IS_WHERE, DVO_DB_CMDLINE_IS_MATCH}; 121 122 122 123 // options for selecting the ra,dec limits of the db selections
Note:
See TracChangeset
for help on using the changeset viewer.
