Changeset 34265 for trunk/ippTools/src/addtool.c
- Timestamp:
- Jul 31, 2012, 4:55:25 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/addtool.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/addtool.c
r34081 r34265 120 120 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 121 121 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 122 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 122 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 123 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 123 124 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 124 125 if (strcmp(stage, "cam")== 0) { 125 126 pxcamGetSearchArgs (config, where); 126 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); // define using camRun label 127 pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label 128 129 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 127 pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "=="); // define using camRun label 128 pxAddLabelSearchArgs (config, where, "-data_group","camRun.data_group", "=="); // define using camRun label 129 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 130 130 } 131 131 if (strcmp(stage, "stack")== 0) { 132 133 pxAddLabelSearchArgs (config, where, "-label", "stackRun.label", "=="); // define using camRun label 134 pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label 135 PXOPT_COPY_STR(config->args, where, "-reduction", "stackRun.reduction", "=="); 136 pxAddLabelSearchArgs (config, where, "-filter", "stackRun.filter", "=="); // define using camRun label 132 pxAddLabelSearchArgs (config, where, "-label", "stackRun.label", "=="); // define using camRun label 133 pxAddLabelSearchArgs (config, where, "-data_group","stackRun.data_group", "=="); // define using camRun label 134 PXOPT_COPY_STR(config->args, where, "-reduction", "stackRun.reduction", "=="); 135 pxAddLabelSearchArgs (config, where, "-filter", "stackRun.filter", "=="); // define using camRun label 137 136 } 138 137 if (strcmp(stage, "staticsky")== 0) { 139 140 pxAddLabelSearchArgs (config, where, "-label", "staticskyRun.label", "=="); // define using camRun label 141 pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label 142 PXOPT_COPY_STR(config->args, where, "-reduction", "staticskyyRun.reduction", "=="); 138 pxAddLabelSearchArgs (config, where, "-label", "staticskyRun.label", "=="); // define using camRun label 139 pxAddLabelSearchArgs (config, where, "-data_group","staticskyRun.data_group", "=="); // define using camRun label 140 PXOPT_COPY_STR(config->args, where, "-reduction", "staticskyRun.reduction", "=="); 143 141 //no filter here 144 142 } 143 if (strcmp(stage, "skycal")==0) { 144 pxAddLabelSearchArgs (config, where, "-label", "skycalRun.label", "=="); //define using skycalRun label 145 pxAddLabelSearchArgs (config, where, "-data_group","skycalRun.data_group", "=="); 146 PXOPT_COPY_STR(config->args, where, "-reduction", "skycalRun.reduction", "=="); 147 } 148 145 149 if (!psListLength(where->list)) { 146 150 psFree(where); … … 228 232 // user supplied dvodb 229 233 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 230 } else {231 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage);234 } else { 235 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_sky_id_multi.sql\n%s\n",stage); 232 236 // find the cam_id of all the exposures that we want to queue up. 233 237 bare_query = pxDataGet("addtool_find_sky_id_multi.sql"); 234 238 // inherit dvodb from camRun, avoid matching NULL 235 239 psStringAppend(&dvodb_string, "(staticskyRun.dvodb IS NOT NULL AND previous_dvodb = staticskyRun.dvodb)"); 236 } 237 } 240 } 241 } 242 243 if (strcmp(stage,"skycal") == 0) { 244 if (dvodb ) { 245 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument found (%s) using addtool_find_skycal_id_dvo.sql\n%s\n", dvodb,stage); 246 // find the skycal_id of all the exposures that we want to queue up. 247 bare_query = pxDataGet("addtool_find_skycal_id_dvo.sql"); 248 // user supplied dvodb 249 psStringAppend(&dvodb_string, "addRun.dvodb = '%s'", dvodb); 250 } else { 251 psTrace("addtool.c", PS_LOG_INFO, "dvodb argument not found using addtool_find_skycal_id.sql\n%s\n",stage); 252 // find the skycal_id of all the exposures that we want to queue up. 253 bare_query = pxDataGet("addtool_find_skycal_id.sql"); 254 // inherit dvodb from skycalRun, avoid matching NULL 255 psStringAppend(&dvodb_string, "(skycalRun.dvodb IS NOT NULL AND previous_dvodb = skycalRun.dvodb)"); 256 // this is silly, there is no dvodb in skycalRun...? 257 } 258 } 259 260 261 262 263 264 238 265 239 266 if (!bare_query) { … … 267 294 psStringAppend(&query, " AND (stackRun.magicked > 0)"); 268 295 } 269 // staticSky hasno magicked column.296 // staticSky/skycal have no magicked column. 270 297 } else { 271 298 //This picks only the unmagicked/uncensored ones … … 291 318 // psStringAppend(&query, " GROUP BY stack_id"); 292 319 // } 293 if (strcmp(stage,"staticsky") == 0) { 294 psStringAppend(&query, " GROUP BY sky_id, stack_id"); //some reason it needs this 295 } 296 320 if (strcmp(stage,"staticsky") == 0) { 321 psStringAppend(&query, " GROUP BY sky_id, stack_id"); //some reason it needs this 322 } 323 if (strcmp(stage,"skycal") == 0) { 324 psStringAppend(&query, " GROUP BY skycal_id, sky_id, stack_id "); //this needs checking, but I think it shoul be fine? it groups by lots of stuff (including stack - we only want one of each stack in there 325 } 297 326 298 327 psTrace("addtool.c", PS_LOG_INFO,"query: \n\n%s\n\n",query); … … 381 410 } 382 411 412 413 383 414 if (strcmp(stage,"staticsky") == 0) { 384 415 for (long i = 0; i < psArrayLength(output); i++) { … … 418 449 } 419 450 451 if (strcmp(stage,"skycal") == 0) { 452 for (long i = 0; i < psArrayLength(output); i++) { 453 psMetadata *md = output->data[i]; 454 455 skycalRunRow *row = skycalRunObjectFromMetadata(md); 456 457 if (!row) { 458 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 459 psFree(output); 460 return false; 461 } 462 463 if (!dvodb) { // there's no skycalRun.dvodb 464 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, skycal_id %" PRId64, row->label, row->skycal_id); 465 psFree(output); 466 return false; 467 } 468 if (!workdir && !row->workdir) { 469 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, skycal_id %" PRId64, row->label, row->skycal_id); 470 psFree(output); 471 return false; 472 } 473 474 psFree(row); 475 } 476 } 420 477 421 478 … … 572 629 } 573 630 574 631 if (strcmp(stage,"skycal") == 0) { 632 for (long i = 0; i < psArrayLength(output); i++) { 633 psMetadata *md = output->data[i]; 634 psS64 stage_id =0; 635 636 skycalRunRow *row = skycalRunObjectFromMetadata(md); 637 stage_id = row->skycal_id; 638 639 if (!row) { 640 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into skycalRun"); 641 psFree(output); 642 return false; 643 } 644 645 // queue the exp 646 if (!pxaddQueueByCamID(config, 647 stage, 648 stage_id, 649 0, 650 workdir ? workdir : row->workdir, 651 reduction ? reduction : row->reduction, 652 label ? label : row->label, 653 data_group ? data_group : (row->data_group ? row->data_group : (label ? label : row->label)), 654 dvodb ? dvodb : NULL, 655 note ? note : NULL, 656 image_only, 657 minidvodb, 658 minidvodb_group, 659 minidvodb_name 660 )) { 661 if (!psDBRollback(config->dbh)) { 662 psError(PS_ERR_UNKNOWN, false, "database error sfg"); 663 } 664 psError(PS_ERR_UNKNOWN, false, 665 "failed to trying to queue stage %s %" PRId64,stage, stage_id); 666 psFree(row); 667 psFree(output); 668 return false; 669 } 670 psFree(row); 671 } 672 } 673 575 674 576 675 … … 594 693 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 595 694 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 596 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "==");597 695 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 696 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 598 697 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 599 698 pxcamGetSearchArgs (config, where); // most search arguments based on camera … … 610 709 psString query = NULL; 611 710 if (strcmp(stage, "cam")==0) { 612 query = psStringCopy("UPDATE addRun JOIN camRun on cam_id = stage_id JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)");711 query = psStringCopy("UPDATE addRun JOIN camRun on cam_id = stage_id JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id)"); 613 712 } 614 713 if (strcmp(stage, "stack")==0) { 615 query = psStringCopy("UPDATE addRun JOIN stackRun on stack_id = stage_id");714 query = psStringCopy("UPDATE addRun JOIN stackRun on stack_id = stage_id"); 616 715 } 617 716 if (strcmp(stage, "staticsky")==0) { 618 query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id"); 619 } 620 717 query = psStringCopy("UPDATE addRun JOIN staticskyRun on sky_id = stage_id"); 718 } 719 if (strcmp(stage, "skycal")==0) { 720 query = psStringCopy("UPDATE addRun JOIN skycalRun on skycal_id = stage_id"); 721 } 722 621 723 622 724 // pxUpdateRun gets parameters from config->args and runs the update query … … 640 742 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 641 743 PXOPT_COPY_S64(config->args, where, "-sky_id", "staticskyRun.sky_id", "=="); 744 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 642 745 PXOPT_LOOKUP_STR(stage, config->args, "-stage", false, false); 643 746 pxcamGetSearchArgs (config, where); … … 650 753 651 754 if (strcmp(stage, "cam")==0) { 652 query = pxDataGet("addtool_find_pendingexp_cam.sql");755 query = pxDataGet("addtool_find_pendingexp_cam.sql"); 653 756 } 654 757 if (strcmp(stage, "stack")==0) { 655 query = pxDataGet("addtool_find_pendingexp_stack.sql");758 query = pxDataGet("addtool_find_pendingexp_stack.sql"); 656 759 } 657 760 if (strcmp(stage, "staticsky")==0) { 658 query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql"); 659 } 660 761 query = pxDataGet("addtool_find_pendingexp_staticsky_multi.sql"); 762 } 763 if (strcmp(stage, "skycal")==0) { 764 query = pxDataGet("addtool_find_pendingexp_skycal.sql"); 765 } 766 661 767 662 768 if (!query) { … … 676 782 psStringAppend(&query, " GROUP BY %s", "stack_id"); 677 783 } 678 //if (strcmp(stage, "staticsky") == 0) {679 ////this group by is needed to join against all the warps (to get camera)680 // psStringAppend(&query, " GROUP BY %s", "sky_id");681 //}784 if (strcmp(stage, "skycal") == 0) { 785 //this group by is needed to join against all the warps (to get camera) 786 psStringAppend(&query, " GROUP BY %s", "skycal_id"); 787 } 682 788 if (strcmp(stage, "staticsky") == 0) { 683 789 //this group by is needed to join against all the warps (to get camera) … … 881 987 882 988 if (strcmp (stage,"cam") == 0) { 883 query = pxDataGet("addtool_find_processedexp_cam.sql");989 query = pxDataGet("addtool_find_processedexp_cam.sql"); 884 990 } 885 991 if (strcmp (stage,"stack") == 0) { 886 query = pxDataGet("addtool_find_processedexp_stack.sql");992 query = pxDataGet("addtool_find_processedexp_stack.sql"); 887 993 } 888 994 if (strcmp (stage,"staticsky") == 0) { 889 query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql"); 995 query = pxDataGet("addtool_find_processedexp_staticsky_multi.sql"); 996 } 997 if (strcmp (stage,"skycal") == 0) { 998 query = pxDataGet("addtool_find_processedexp_skycal.sql"); 890 999 } 891 1000 … … 1000 1109 query = pxDataGet("addtool_revertprocessedexp_staticsky_multi.sql"); 1001 1110 } 1111 if (strcmp(stage, "skycal") == 0) { 1112 query = pxDataGet("addtool_revertprocessedexp_skycal.sql"); 1113 } 1002 1114 1003 1115
Note:
See TracChangeset
for help on using the changeset viewer.
