- Timestamp:
- May 26, 2009, 1:59:32 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/camtool.c (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
- Property svn:mergeinfo changed
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src
- Property svn:ignore
-
old new 33 33 pstamptool 34 34 disttool 35 receivetool
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src/camtool.c
r23594 r24244 109 109 psMetadata *where = psMetadataAlloc(); 110 110 pxcamGetSearchArgs (config, where); 111 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label","==");112 PXOPT_COPY_STR(config->args, where, "-reduction", "c hipRun.reduction", "==");113 114 if (!psListLength(where->list) 115 &&!psMetadataLookupBool(NULL, config->args, "-all")) {111 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); 112 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 113 114 if (!psListLength(where->list) && 115 !psMetadataLookupBool(NULL, config->args, "-all")) { 116 116 psFree(where); 117 117 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); … … 137 137 // use psDBGenerateWhereSQL because the SQL yields an intermediate table 138 138 if (where && psListLength(where->list)) { 139 psString whereClause = psDBGenerateWhere SQL(where, NULL);140 psStringAppend(&query, " %s", whereClause);139 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 140 psStringAppend(&query, " AND %s", whereClause); 141 141 psFree(whereClause); 142 142 } … … 175 175 // old values in place (i.e., passing the values through). 176 176 177 // loop over our list of chipRun rows177 // if end_stage is warp (or NULL), check for valid tess_id 178 178 for (long i = 0; i < psArrayLength(output); i++) { 179 179 psMetadata *md = output->data[i]; 180 180 181 chipRunRow *row = chipRunObjectFromMetadata(md); 181 bool status; 182 char *end_stage = psMetadataLookupStr(&status, md, "end_stage"); 183 if (end_stage && strcasecmp(end_stage, "warp")) continue; 184 185 char *raw_tess_id = psMetadataLookupStr(&status, md, "tess_id"); 186 if (raw_tess_id || tess_id) continue; 187 188 char *label = psMetadataLookupStr(&status, md, "label"); 189 psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id"); 190 191 if (!status) { 192 psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id); 193 psFree(output); 194 return false; 195 } 196 } 197 198 // loop over our list of camRun rows 199 for (long i = 0; i < psArrayLength(output); i++) { 200 psMetadata *md = output->data[i]; 201 202 camRunRow *row = camRunObjectFromMetadata(md); 182 203 if (!row) { 183 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into c hipRun");204 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 184 205 psFree(output); 185 206 return false; … … 247 268 248 269 if (state) { 249 // set c hipRun.state to state270 // set camRun.state to state 250 271 if (!pxcamRunSetStateByQuery(config, where, state)) { 251 272 psFree(where); … … 255 276 256 277 if (label) { 257 // set c hipRun.label to label278 // set camRun.label to label 258 279 if (!pxcamRunSetLabelByQuery(config, where, label)) { 259 280 psFree(where); … … 275 296 pxcamGetSearchArgs (config, where); 276 297 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 277 PXOPT_COPY_STR(config->args, where, "-label","camRun.label", "==");298 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); 278 299 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 279 300 … … 289 310 // use psDBGenerateWhereSQL because the SQL yields an intermediate table 290 311 if (psListLength(where->list)) { 291 psString whereClause = psDBGenerateWhere SQL(where, NULL);292 psStringAppend(&query, " %s", whereClause);312 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 313 psStringAppend(&query, " AND %s", whereClause); 293 314 psFree(whereClause); 294 315 } … … 339 360 pxcamGetSearchArgs (config, where); 340 361 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 341 PXOPT_COPY_STR(config->args, where, "-label","camRun.label", "==");362 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); 342 363 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 343 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 344 PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "=="); 345 346 // XXX is this used? PXOPT_COPY_STR(config->args, where, "-class", "class", "=="); 364 PXOPT_COPY_S64(config->args, where, "-chip_id", "camRun.chip_id", "=="); 365 PXOPT_COPY_STR(config->args, where, "-class_id", "camProcessedExp.class_id", "=="); 347 366 348 367 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 356 375 // use psDBGenerateWhereSQL because the SQL yields an intermediate table 357 376 if (psListLength(where->list)) { 358 psString whereClause = psDBGenerateWhere SQL(where, NULL);359 psStringAppend(&query, " %s", whereClause);377 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 378 psStringAppend(&query, " AND %s", whereClause); 360 379 psFree(whereClause); 361 380 } … … 381 400 382 401 // negate simple so the default is true 383 if (!ippdbPrintMetadatas(stdout, output, "c hipProcessedImfile", !simple)) {402 if (!ippdbPrintMetadatas(stdout, output, "camProcessedExp", !simple)) { 384 403 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 385 404 psFree(output); … … 470 489 471 490 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 472 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 491 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 492 PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false); 473 493 474 494 // generate restrictions 475 495 psMetadata *where = psMetadataAlloc(); 476 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam _id", "==");496 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 477 497 478 498 psString query = pxDataGet("camtool_find_pendingexp.sql"); … … 484 504 // use psDBGenerateWhereSQL because the SQL yields an intermediate table 485 505 if (psListLength(where->list)) { 486 psString whereClaus = psDBGenerateWhere SQL(where, NULL);487 psStringAppend(&query, " %s", whereClaus);506 psString whereClaus = psDBGenerateWhereConditionSQL(where, NULL); 507 psStringAppend(&query, " AND %s", whereClaus); 488 508 psFree(whereClaus); 489 509 } … … 535 555 zpt_lq, 536 556 zpt_uq, 537 fwhm_major,538 fwhm_major_lq,539 fwhm_major_uq,540 fwhm_minor,541 fwhm_minor_lq,542 fwhm_minor_uq,543 544 iq_fwhm_major,545 iq_fwhm_major_err,546 iq_fwhm_minor,547 iq_fwhm_minor_err,557 fwhm_major, 558 fwhm_major_lq, 559 fwhm_major_uq, 560 fwhm_minor, 561 fwhm_minor_lq, 562 fwhm_minor_uq, 563 564 iq_fwhm_major, 565 iq_fwhm_major_err, 566 iq_fwhm_minor, 567 iq_fwhm_minor_err, 548 568 549 569 iq_m2, … … 578 598 n_astrom, 579 599 path_base, 580 code 600 fault, 601 quality 581 602 ); 582 603 … … 601 622 602 623 // NULL for end_stage means go as far as possible 603 // EAM : skip here if code!= 0624 // EAM : skip here if fault != 0 604 625 // Also, we can run fake even if tess_id is not defined 605 if ( code|| (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam"))) {626 if (fault || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam"))) { 606 627 psFree(row); 607 628 psFree(pendingRow); … … 656 677 pxcamGetSearchArgs (config, where); 657 678 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 658 PXOPT_COPY_STR(config->args, where, "-label","camRun.label", "==");679 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); 659 680 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 681 682 if (!psListLength(where->list) && 683 !psMetadataLookupBool(NULL, config->args, "-all")) { 684 psFree(where); 685 psError(PXTOOLS_ERR_DATA, false, "search parameters (or -all) are required"); 686 return false; 687 } 660 688 661 689 psString query = pxDataGet("camtool_find_processedexp.sql"); … … 669 697 psStringAppend(&query, " WHERE %s", whereClause); 670 698 psFree(whereClause); 699 } 700 701 // we either add AND (condition) or WHERE (condition): 702 if (where->list && faulted) { 703 // list only faulted rows 704 psStringAppend(&query, " %s", " AND camProcessedExp.fault != 0"); 705 } 706 if (where->list && !faulted) { 707 // don't list faulted rows 708 psStringAppend(&query, " %s", " AND camProcessedExp.fault = 0"); 709 } 710 if (!where->list && faulted) { 711 // list only faulted rows 712 psStringAppend(&query, " %s", " WHERE camProcessedExp.fault != 0"); 713 } 714 if (!where->list && !faulted) { 715 // don't list faulted rows 716 psStringAppend(&query, " %s", " WHERE camProcessedExp.fault = 0"); 671 717 } 672 718 psFree(where); 673 674 if (faulted) {675 // list only faulted rows676 psStringAppend(&query, " %s", "AND camProcessedExp.fault != 0");677 } else {678 // don't list faulted rows679 psStringAppend(&query, " %s", "AND camProcessedExp.fault = 0");680 }681 719 682 720 // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry … … 730 768 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 731 769 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 732 PXOPT_COPY_S16(config->args, where, "- code","camProcessedExp.fault", "==");770 PXOPT_COPY_S16(config->args, where, "-fault", "camProcessedExp.fault", "=="); 733 771 734 772 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { … … 818 856 PS_ASSERT_PTR_NON_NULL(config, false); 819 857 820 PXOPT_LOOKUP_S16( code, config->args, "-code", true, false);858 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 821 859 822 860 psMetadata *where = psMetadataAlloc(); … … 826 864 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 827 865 828 if (!pxSetFaultCode(config->dbh, "camProcessedExp", where, code)) {866 if (!pxSetFaultCode(config->dbh, "camProcessedExp", where, fault)) { 829 867 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 830 868 psFree (where); … … 915 953 916 954 psMetadata *where = psMetadataAlloc(); 917 PXOPT_COPY_STR(config->args, where, "-label", "label", "==");955 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); 918 956 919 957 psString query = pxDataGet("camtool_pendingcleanuprun.sql"); … … 980 1018 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "=="); 981 1019 } 982 PXOPT_COPY_STR(config->args, where, "-label", "label", "==");1020 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 983 1021 984 1022 psString query = pxDataGet("camtool_pendingcleanupexp.sql"); … … 1099 1137 char sqlFilename[80]; 1100 1138 } ExportTable; 1101 1139 1102 1140 int numExportTables = 2; 1103 1141 … … 1107 1145 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false); 1108 1146 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1147 PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false); 1109 1148 1110 1149 FILE *f = fopen (outfile, "w"); … … 1155 1194 } 1156 1195 if (!psArrayLength(output)) { 1157 ps Trace("regtool", PS_LOG_INFO, "no rows found");1196 psError(PS_ERR_UNKNOWN, true, "no rows found"); 1158 1197 psFree(output); 1159 return true; 1198 return false; 1199 } 1200 1201 if (clean) { 1202 if (!strcmp(tables[i].tableName, "camRun")) { 1203 if (!pxSetStateCleaned("camRun", "state", output)) { 1204 psFree(output); 1205 psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s", tables[i].tableName); 1206 return false; 1207 } 1208 } 1160 1209 } 1161 1210 … … 1179 1228 1180 1229 PS_ASSERT_PTR_NON_NULL(config, NULL); 1181 1230 1182 1231 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1183 1232 … … 1190 1239 psAssert (item, "entry not in input?"); 1191 1240 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1192 1241 1193 1242 psMetadataItem *entry = psListGet (item->data.list, 0); 1194 1243 assert (entry); … … 1199 1248 // fprintf (stdout, "---- cam run ----\n"); 1200 1249 // psMetadataPrint (stderr, entry->data.md, 1); 1201 1202 item = psMetadataLookup (input, "camProcessed Imfile");1250 1251 item = psMetadataLookup (input, "camProcessedExp"); 1203 1252 psAssert (item, "entry not in input?"); 1204 1253 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
Note:
See TracChangeset
for help on using the changeset viewer.
