Changeset 35196 for trunk/ippTools/src/releasetool.c
- Timestamp:
- Feb 21, 2013, 1:44:26 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/releasetool.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/releasetool.c
r35152 r35196 201 201 return false; 202 202 } 203 PXOPT_LOOKUP_STR(release_state, config->args, "-set_release_state", true, false); 203 PXOPT_LOOKUP_STR(release_state, config->args, "-set_release_state", false, false); 204 PXOPT_LOOKUP_S32(priority, config->args, "-set_priority", false, false); 205 if (!release_state && !priority) { 206 psError(PXTOOLS_ERR_CONFIG, true, "at least one of -set_release_staate and -set_priority is required\n"); 207 return false; 208 } 204 209 205 210 psMetadata *where = psMetadataAlloc(); … … 208 213 PXOPT_COPY_STR(config->args, where, "-releaseName", "releaseName", "=="); 209 214 210 psString query = NULL; 211 psStringAppend(&query, "UPDATE ippRelease SET release_state = '%s'", release_state); 215 psString sep = ""; 216 psString comma = ", "; 217 psString query = psStringCopy("UPDATE ippRelease SET"); 218 if (release_state) { 219 psStringAppend(&query, "%s release_state = '%s'", sep, release_state); 220 sep = comma; 221 } 222 if (priority != 0) { 223 psStringAppend(&query, "%s priority = %d", sep, priority); 224 sep = comma; 225 } 212 226 213 227 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); … … 334 348 PXOPT_LOOKUP_STR(state, config->args, "-set_state", true, false); 335 349 PXOPT_LOOKUP_U32(flags, config->args, "-set_flags", false, false); 350 PXOPT_LOOKUP_F32(zpt_obs, config->args, "-set_zpt_obs", false, false); 351 PXOPT_LOOKUP_F32(zpt_stdev, config->args, "-set_zpt_stdev", false, false); 336 352 PXOPT_LOOKUP_STR(path_base, config->args, "-set_path_base", false, false); 353 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 337 354 338 355 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); … … 398 415 psS64 chip_id = psMetadataLookupS64(&status, md, "chip_id"); 399 416 psS64 cam_id = psMetadataLookupS64(&status, md, "cam_id"); 400 psF32 zpt_obs = psMetadataLookupF32(&status, md, "zpt_obs"); 401 psF32 zpt_stdev = psMetadataLookupF32(&status, md, "zpt_stdev"); 417 // if zpt_obs or zpt_stdev were not supplied use the results from the camRun 418 if (!isfinite(zpt_obs)) { 419 zpt_obs = psMetadataLookupF32(&status, md, "zpt_obs"); 420 } 421 if (!isfinite(zpt_stdev)) { 422 zpt_stdev = psMetadataLookupF32(&status, md, "zpt_stdev"); 423 } 402 424 403 425 if (!relExpInsert(config->dbh, … … 412 434 zpt_stdev, 413 435 path_base, 436 fault, 414 437 now, // registered 415 438 now // time_stamp … … 546 569 psMetadata *where = psMetadataAlloc(); 547 570 548 PXOPT_COPY_STR(config->args, where, "-label", "skycalRun.label", "=="); 549 PXOPT_COPY_STR(config->args, where, "-data_group", "skycalRun.data_group", "=="); 550 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skcalRun.skycal_id", "=="); 551 552 // Insure that at least one of the skcalRun selectors is supplied 571 bool includeSkycal = false; 572 573 PXOPT_COPY_S64(config->args, where, "-skycal_id", "skycalRun.skycal_id", "=="); 574 PXOPT_COPY_STR(config->args, where, "-skycal_label", "skycalRun.label", "=="); 575 PXOPT_COPY_STR(config->args, where, "-skycal_data_group", "skycalRun.data_group", "=="); 576 if (psListLength(where->list)) { 577 includeSkycal = true; 578 } 579 580 PXOPT_COPY_STR(config->args, where, "-label", "stackRun.label", "=="); 581 PXOPT_COPY_STR(config->args, where, "-data_group", "stackRun.data_group", "=="); 582 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 583 584 // Insure that at least one of the skycalRun selectors is supplied 553 585 if (!psListLength(where->list)) { 554 586 psFree(where); … … 557 589 } 558 590 559 PXOPT_COPY_S64(config->args, where, "-stack_id", "stackRun.stack_id", "=="); 560 PXOPT_COPY_STR(config->args, where, "-tess_id", "stackRun.tess_id", "=="); 561 PXOPT_COPY_STR(config->args, where, "-skycell_id", "stackRun.skycell_id", "=="); 591 // PXOPT_COPY_STR(config->args, where, "-tess_id", "stackRun.tess_id", "=="); 592 // PXOPT_COPY_STR(config->args, where, "-skycell_id", "stackRun.skycell_id", "=="); 562 593 563 594 // insure that at least one of these is supplied to select the release … … 580 611 PXOPT_LOOKUP_F32(zpt_obs, config->args, "-set_zpt_obs", false, false); 581 612 PXOPT_LOOKUP_F32(zpt_stdev, config->args, "-set_zpt_stdev", false, false); 582 PXOPT_LOOKUP_F32(fwhm_major, config->args, "-set_fwhm_major", false, false);583 613 PXOPT_LOOKUP_STR(path_base, config->args, "-set_path_base", false, false); 614 PXOPT_LOOKUP_S16(fault, config->args, "-set_fault", false, false); 584 615 585 616 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); … … 587 618 588 619 // find the parameters of all the exposures that we want to add to the release 589 psString query = pxDataGet("releasetool_definerelstack.sql"); 620 psString query; 621 622 if (includeSkycal) { 623 query = pxDataGet("releasetool_definerelstack_with_skycal.sql"); 624 } else { 625 query = pxDataGet("releasetool_definerelstack.sql"); 626 } 590 627 if (!query) { 591 628 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); … … 620 657 if (pretend) { 621 658 // negative simple so the default is true 622 if (!ippdbPrintMetadatas(stdout, output, " chipRun", !simple)) {659 if (!ippdbPrintMetadatas(stdout, output, "relstack", !simple)) { 623 660 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 624 661 psFree(output); … … 642 679 bool status = true; 643 680 psS32 rel_id = psMetadataLookupS32(&status, md, "rel_id"); 681 psS64 stack_id = psMetadataLookupS64(&status, md, "stack_id"); 644 682 psS64 skycal_id = psMetadataLookupS64(&status, md, "skycal_id"); 645 683 psString skycell_id = psMetadataLookupStr(&status, md, "skycell_id"); 646 684 psString tess_id = psMetadataLookupStr(&status, md, "tess_id"); 647 psString state = psMetadataLookupStr(&status, md, "state");685 psString filter = psMetadataLookupStr(&status, md, "filter"); 648 686 649 687 // use skycal zero point measurement if not supplied with arguments 650 688 psF32 sc_zpt_obs = psMetadataLookupF32(&status, md, "zpt_obs"); 651 689 psF32 sc_zpt_stdev = psMetadataLookupF32(&status, md, "zpt_stdev"); 690 psF32 stack_mjd_obs = psMetadataLookupF32(&status, md, "mjd_obs"); 691 692 psU32 mjd_obs = 0; 693 if (!strcmp(stack_type, "nightly")) { 694 // only for nightly stacks do we set mjd_obs to a non zero value 695 // We use integer day because this is part of the key that is used 696 // to make sure entries are unique 697 // KEY (rel_id, tess_id, skycell_id, filter, mjd_obs), 698 // 1 entry per release, skycell, filter and mjd_obs. 699 // mjd_obs is zero for deep and reference stacks 700 mjd_obs = (psU32) stack_mjd_obs; 701 } 652 702 653 703 if (!relStackInsert(config->dbh, 654 704 0, // relstack_id (auto increment) 655 705 rel_id, 706 stack_id, 656 707 skycal_id, 657 708 skycell_id, 658 709 tess_id, 710 filter, 659 711 state, 660 712 flags, 661 713 stack_type, 662 isfinite(zpt_obs) ? zpt_obs: sc_zpt_obs,714 isfinite(zpt_obs) ? zpt_obs : sc_zpt_obs, 663 715 isfinite(zpt_stdev) ? zpt_stdev : sc_zpt_stdev, 664 fwhm_major,716 mjd_obs, 665 717 path_base, 718 fault, 666 719 now, // registered 667 720 now // time_stamp … … 671 724 } 672 725 psError(PS_ERR_UNKNOWN, false, 673 "failed to trying to insert rel Exp for skycal_id %" PRId64, skycal_id);726 "failed to trying to insert relStack for stack_id %" PRId64, stack_id); 674 727 psFree(output); 675 728 psFree(now); … … 705 758 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin","rawExp.dateobs", ">="); 706 759 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); 707 PXOPT_COPY_F32(config->args, where, "-fwhm_min", " camProcessedExp.fwhm_major", ">=");708 PXOPT_COPY_F32(config->args, where, "-fwhm_max", " camProcessedExp.fwhm_major", "<=");709 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_ name", "==");760 PXOPT_COPY_F32(config->args, where, "-fwhm_min", "skycalResult.fwhm_major", ">="); 761 PXOPT_COPY_F32(config->args, where, "-fwhm_max", "skycalresult.fwhm_major", "<="); 762 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_ame", "=="); 710 763 PXOPT_COPY_S64(config->args, where, "-exp_id", "relExp.exp_id", "=="); 711 764 PXOPT_COPY_S64(config->args, where, "-chip_id", "relExp.chip_id", "==");
Note:
See TracChangeset
for help on using the changeset viewer.
