- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/camtool.c (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ippTools/src
- Property svn:ignore
-
old new 1 *.la 2 *.lo 1 3 .deps 2 4 .gdb_history … … 4 6 Makefile 5 7 Makefile.in 8 addtool 9 caltool 10 camtool 11 chiptool 6 12 config.h 7 13 config.h.in 8 stamp-h1 9 *.la 10 *.lo 14 detselect 15 dettool 16 difftool 17 disttool 18 dqstatstool 19 faketool 20 flatcorr 21 guidetool 22 magicdstool 23 magictool 24 pstamptool 25 pubtool 26 pxadmin 27 pxdata.c 28 pxinject 11 29 pxtoolsErrorCodes.c 12 30 pxtoolsErrorCodes.h 13 pxadmin14 pxinject15 pztool16 31 pzgetexp 17 32 pzgetimfiles 33 pztool 34 receivetool 18 35 regtool 19 guidetool 20 chiptool 21 camtool 36 stacktool 37 stamp-h1 22 38 warptool 23 difftool24 stacktool25 faketool26 dettool27 detselect28 pxdata.c29 magictool30 magicdstool31 caltool32 flatcorr33 pstamptool34 disttool35 receivetool36 37 pubtool
-
- Property svn:ignore
-
branches/simtest_nebulous_branches/ippTools/src/camtool.c
r24681 r27840 109 109 psMetadata *where = psMetadataAlloc(); 110 110 pxcamGetSearchArgs (config, where); 111 pxAddLabelSearchArgs (config, where, "-label", "c amRun.label", "==");112 PXOPT_COPY_STR(config->args, where, "-reduction", "c amRun.reduction", "==");111 pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "=="); // define using chipRun label 112 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 113 113 114 114 if (!psListLength(where->list) && 115 115 !psMetadataLookupBool(NULL, config->args, "-all")) { 116 116 psFree(where); 117 psError(PXTOOLS_ERR_ DATA, false, "search parameters are required");117 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 118 118 return false; 119 119 } … … 121 121 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 122 122 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 123 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 124 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 123 125 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 124 126 PXOPT_LOOKUP_STR(expgroup, config->args, "-set_expgroup", false, false); … … 126 128 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 127 129 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 130 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 128 131 129 132 // find the exp_id of all the exposures that we want to queue up. 130 133 psString query = pxDataGet("camtool_find_chip_id.sql"); 131 134 if (!query) { 132 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");135 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 133 136 psFree(where); 134 137 return false; … … 181 184 bool status; 182 185 char *end_stage = psMetadataLookupStr(&status, md, "end_stage"); 183 if (end_stage && strcasecmp(end_stage, "warp")) continue;186 if (end_stage && strcasecmp(end_stage, "warp")) continue; 184 187 185 188 char *raw_tess_id = psMetadataLookupStr(&status, md, "tess_id"); 186 if (raw_tess_id || tess_id) continue;189 if (raw_tess_id || tess_id) continue; 187 190 188 191 char *label = psMetadataLookupStr(&status, md, "label"); … … 190 193 191 194 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);195 psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id); 193 196 psFree(output); 194 197 return false; … … 196 199 } 197 200 198 // loop over our list of c amRun rows201 // loop over our list of chipRun rows 199 202 for (long i = 0; i < psArrayLength(output); i++) { 200 203 psMetadata *md = output->data[i]; 201 204 202 c amRunRow *row = camRunObjectFromMetadata(md);205 chipRunRow *row = chipRunObjectFromMetadata(md); 203 206 if (!row) { 204 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into c amRun");207 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun"); 205 208 psFree(output); 206 209 return false; … … 212 215 workdir ? workdir : row->workdir, 213 216 label ? label : row->label, 217 data_group ? data_group: row->data_group, 218 dist_group ? dist_group: row->dist_group, 214 219 reduction ? reduction : row->reduction, 215 220 expgroup ? expgroup : row->expgroup, 216 221 dvodb ? dvodb : row->dvodb, 217 222 tess_id ? tess_id : row->tess_id, 218 end_stage ? end_stage : row->end_stage 223 end_stage ? end_stage : row->end_stage, 224 row->magicked, 225 note 219 226 )) { 220 227 if (!psDBRollback(config->dbh)) { … … 248 255 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 249 256 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 257 PXOPT_COPY_STR(config->args, where, "-data_group","camRun.data_group", "=="); 250 258 PXOPT_COPY_STR(config->args, where, "-state", "camRun.state", "=="); 251 259 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 252 260 253 if (!psListLength(where->list) 254 && !psMetadataLookupBool(NULL, config->args, "-all")) { 261 if (!psListLength(where->list)) { 255 262 psFree(where); 256 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 257 return false; 258 } 259 260 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 261 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 262 263 if ((!state) && (!label)) { 264 psError(PXTOOLS_ERR_DATA, false, "parameters are required"); 265 psFree(where); 266 return false; 267 } 268 269 if (state) { 270 // set camRun.state to state 271 if (!pxcamRunSetStateByQuery(config, where, state)) { 272 psFree(where); 273 return false; 274 } 275 } 276 277 if (label) { 278 // set camRun.label to label 279 if (!pxcamRunSetLabelByQuery(config, where, label)) { 280 psFree(where); 281 return false; 282 } 283 } 284 263 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 264 return false; 265 } 266 psString query = psStringCopy("UPDATE camRun JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)"); 267 268 // pxUpdateRun gets parameters from config->args and updates 269 bool result = pxUpdateRun(config, where, &query, "camRun", "cam_id", "camProcessedExp", true); 270 if (!result) { 271 psError(psErrorCodeLast(), false, "pxUpdateRun failed"); 272 } 273 274 psFree(query); 285 275 psFree(where); 286 276 287 return true;277 return result; 288 278 } 289 279 … … 304 294 psString query = pxDataGet("camtool_find_pendingexp.sql"); 305 295 if (!query) { 306 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");296 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 307 297 return false; 308 298 } … … 369 359 psString query = pxDataGet("camtool_find_pendingimfile.sql"); 370 360 if (!query) { 371 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");361 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 372 362 return false; 373 363 } … … 491 481 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 492 482 PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false); 493 494 PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false); 483 484 // Get this from the chipRun 485 // PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false); 495 486 496 487 // generate restrictions … … 500 491 psString query = pxDataGet("camtool_find_pendingexp.sql"); 501 492 if (!query) { 502 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");493 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 503 494 return false; 504 495 } … … 535 526 return false; 536 527 } 528 529 bool status; 530 psS64 chip_magicked = psMetadataLookupS64(&status, output->data[0], "chip_magicked"); 537 531 538 532 camRunRow *pendingRow = camRunObjectFromMetadata(output->data[0]); … … 615 609 } 616 610 617 // since there is only one exp per 'new' set camRun.state = 'full' 618 if (!pxcamRunSetState(config, row->cam_id, "full", magicked)) { 619 psError(PS_ERR_UNKNOWN, false, "failed to change camRun.state for cam_id: %" PRId64, row->cam_id); 620 psFree(row); 621 psFree(pendingRow); 622 return false; 623 } 624 625 // NULL for end_stage means go as far as possible 626 // EAM : skip here if fault != 0 627 // Also, we can run fake even if tess_id is not defined 628 if (fault || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam"))) { 611 if (fault) { 629 612 psFree(row); 630 613 psFree(pendingRow); … … 635 618 return true; 636 619 } 620 // else continue on... 621 622 // since there is only one exp per 'new' set camRun.state = 'full' 623 // propagate magicked state from chipRun 624 if (!pxcamRunSetState(config, row->cam_id, "full", chip_magicked)) { 625 psError(PS_ERR_UNKNOWN, false, "failed to change camRun.state for cam_id: %" PRId64, row->cam_id); 626 psFree(row); 627 psFree(pendingRow); 628 return false; 629 } 637 630 psFree(row); 638 // else continue on... 631 632 // EAM: NULL for end_stage means go as far as possible 633 // Also, we can run fake even if tess_id is not defined 634 if (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam")) { 635 psFree(pendingRow); 636 if (!psDBCommit(config->dbh)) { 637 psError(PS_ERR_UNKNOWN, false, "database error"); 638 return false; 639 } 640 return true; 641 } 639 642 640 643 if (!pxfakeQueueByCamID(config, … … 642 645 pendingRow->workdir, 643 646 pendingRow->label, 647 pendingRow->data_group, 648 pendingRow->dist_group, 644 649 pendingRow->reduction, 645 650 pendingRow->expgroup, 646 651 pendingRow->dvodb, 647 652 pendingRow->tess_id, 648 pendingRow->end_stage 653 pendingRow->end_stage, 654 NULL // note does not propagate 649 655 )) { 650 656 // rollback … … 656 662 return false; 657 663 } 664 658 665 psFree(pendingRow); 659 666 … … 674 681 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 675 682 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 683 PXOPT_LOOKUP_BOOL(pstamp_order, config->args, "-pstamp_order", false); 676 684 677 685 // generate restrictions … … 680 688 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 681 689 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); 690 pxAddLabelSearchArgs (config, where, "-data_group", "camRun.data_group", "LIKE"); 682 691 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 683 692 684 if (!psListLength(where->list) && 693 psString where2 = NULL; 694 if (!pxspaceAddWhere(config, &where2, "rawExp")) { 695 psError(psErrorCodeLast(), false, "pxSpaceAddWhere failed"); 696 return false; 697 } 698 if (!pxmagicAddWhere(config, &where2, "chipRun")) { 699 psError(psErrorCodeLast(), false, "pxSpaceAddWhere failed"); 700 return false; 701 } 702 if (!psListLength(where->list) && !where2 && 685 703 !psMetadataLookupBool(NULL, config->args, "-all")) { 686 704 psFree(where); 687 psError(PXTOOLS_ERR_ DATA, false, "search parameters (or -all) are required");705 psError(PXTOOLS_ERR_CONFIG, false, "search parameters (or -all) are required"); 688 706 return false; 689 707 } … … 691 709 psString query = pxDataGet("camtool_find_processedexp.sql"); 692 710 if (!query) { 693 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");711 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 694 712 return false; 695 713 } … … 699 717 psStringAppend(&query, " WHERE %s", whereClause); 700 718 psFree(whereClause); 701 } 719 } 702 720 703 721 // we either add AND (condition) or WHERE (condition): … … 705 723 // list only faulted rows 706 724 psStringAppend(&query, " %s", " AND camProcessedExp.fault != 0"); 707 } 725 } 708 726 if (where->list && !faulted) { 709 727 // don't list faulted rows … … 713 731 // list only faulted rows 714 732 psStringAppend(&query, " %s", " WHERE camProcessedExp.fault != 0"); 715 } 733 } 716 734 if (!where->list && !faulted) { 717 735 // don't list faulted rows … … 719 737 } 720 738 psFree(where); 721 722 // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry 723 psStringAppend(&query, " ORDER BY cam_id"); 739 if (where2) { 740 psStringAppend(&query, " %s", where2); 741 psFree(where2); 742 } 743 744 745 if (pstamp_order) { 746 // put runs in order of exposure id with newest chip Runs first 747 // The postage stamp parser depends on this behavior 748 psStringAppend(&query, " ORDER BY exp_id, cam_id DESC"); 749 } 724 750 725 751 // treat limit == 0 as "no limit" … … 774 800 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { 775 801 psFree(where); 776 psError(PXTOOLS_ERR_ DATA, false, "search parameters are required");802 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 777 803 return false; 778 804 } … … 787 813 psString query = pxDataGet("camtool_reset_faulted_runs.sql"); 788 814 if (!query) { 789 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");815 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 790 816 psFree(where); 791 817 return false; … … 819 845 psError(PS_ERR_UNKNOWN, false, "database error"); 820 846 } 821 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");847 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 822 848 psFree(where); 823 849 return false; … … 959 985 psString query = pxDataGet("camtool_pendingcleanuprun.sql"); 960 986 if (!query) { 961 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");987 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 962 988 return false; 963 989 } … … 1024 1050 psString query = pxDataGet("camtool_pendingcleanupexp.sql"); 1025 1051 if (!query) { 1026 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1052 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1027 1053 return false; 1028 1054 } … … 1085 1111 psString query = pxDataGet("camtool_donecleanup.sql"); 1086 1112 if (!query) { 1087 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1113 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1088 1114 return false; 1089 1115 } … … 1155 1181 } 1156 1182 1183 if (!pxExportVersion(config, f)) { 1184 psError(PS_ERR_UNKNOWN, false, "failed to write dbversion output file"); 1185 return false; 1186 } 1187 1157 1188 psMetadata *where = psMetadataAlloc(); 1158 1189 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "=="); … … 1166 1197 psString query = pxDataGet(tables[i].sqlFilename); 1167 1198 if (!query) { 1168 psError(PXTOOLS_ERR_ DATA, false, "failed to retreive SQL statement");1199 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1169 1200 return false; 1170 1201 } … … 1235 1266 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false); 1236 1267 1237 fprintf (stdout, "---- input ----\n"); 1268 #ifdef notdef 1269 fprintf (stderr, "---- input ----\n"); 1238 1270 psMetadataPrint (stderr, input, 1); 1271 #endif 1272 1273 if (!pxCheckImportVersion(config, input)) { 1274 psError(PS_ERR_UNKNOWN, false, "pxCheckImportVersion failed"); 1275 return false; 1276 } 1239 1277 1240 1278 psMetadataItem *item = psMetadataLookup (input, "camRun");
Note:
See TracChangeset
for help on using the changeset viewer.
