Changeset 19579 for trunk/Ohana/src/opihi/dvo/mmextract.c
- Timestamp:
- Sep 16, 2008, 9:16:26 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dvo/mmextract.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.
