Changeset 16170 for trunk/ippTools/src/dettool.c
- Timestamp:
- Jan 20, 2008, 3:48:37 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool.c (modified) (99 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool.c
r15866 r16170 92 92 static bool register_detrendMode(pxConfig *config); 93 93 94 static detNormalizedStatImfileRow *detStackedToDetNormalizedStatImfile(pxConfig *config, detStackedImfileRow *stackedImfile);95 static detNormalizedImfileRow *detNormalizedStatToDetNormalizedmfile(pxConfig *config, detNormalizedStatImfileRow *statImfile);96 static detResidExpRow *mdToDetResidExp(pxConfig *config, psMetadata *row);97 94 static detRunSummaryRow *mdToDetRunSummary(pxConfig *config, psMetadata *row); 98 95 //static psArray *validDetInputClassIds(pxConfig *config, const char *det_id); … … 212 209 PS_ASSERT_PTR_NON_NULL(config, NULL); 213 210 214 psString query = psStringCopy( 211 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 212 213 psString query = psStringCopy( 215 214 "SELECT" 216 215 " rawExp.*" … … 247 246 } 248 247 249 bool simple = false;250 {251 bool status = false;252 simple = psMetadataLookupBool(&status, config->args, "-simple");253 if (!status) {254 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");255 return false;256 }257 }258 259 248 // negative simple so the default is true 260 249 if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) { … … 271 260 static bool definebytagMode(pxConfig *config) 272 261 { 273 bool status = false;274 275 262 PS_ASSERT_PTR_NON_NULL(config, false); 276 263 277 264 // what type of detRun is this? 278 // det_type is required 279 psString det_type = psMetadataLookupStr(&status, config->args, "-det_type"); 280 if (!status) { 281 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_type"); 282 return false; 283 } 284 if (!det_type) { 285 psError(PS_ERR_UNKNOWN, true, "-det_type is required"); 286 return false; 287 } 265 // required 266 PXOPT_LOOKUP_STR(det_type, config->args, "-det_type", true, false); 267 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 288 268 289 269 // optional 290 psString filelevel = psMetadataLookupStr(&status, config->args, "-filelevel"); 291 if (!status) { 292 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filelevel"); 293 return false; 294 } 295 296 psString workdir = psMetadataLookupStr(&status, config->args, "-workdir"); 297 if (!status) { 298 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -workdir"); 299 return false; 300 } 301 if (!workdir) { 302 psError(PS_ERR_UNKNOWN, true, "-workdir is required"); 303 return false; 304 } 305 306 // optional 307 psString mode = psMetadataLookupStr(&status, config->args, "-mode"); 308 if (!status) { 309 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -mode"); 310 return false; 311 } 270 PXOPT_LOOKUP_STR(filelevel, config->args, "-filelevel", false, false); 271 PXOPT_LOOKUP_STR(mode, config->args, "-mode", false, false); 312 272 // check mode 313 273 if (mode && !isValidMode(config, mode)) { … … 315 275 return false; 316 276 } 317 psString camera = psMetadataLookupStr(&status, config->args, "-inst"); 318 if (!status) { 319 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -inst"); 320 return false; 321 } 322 323 psString telescope = psMetadataLookupStr(&status, config->args, "-telescope"); 324 if (!status) { 325 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -telescope"); 326 return false; 327 } 328 329 psString exp_type = psMetadataLookupStr(&status, config->args, "-exp_type"); 330 if (!status) { 331 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_type"); 332 return false; 333 } 334 335 psString filter = psMetadataLookupStr(&status, config->args, "-filter"); 336 if (!status) { 337 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter"); 338 return false; 339 } 340 341 psF32 airmass_min = psMetadataLookupF32(&status, config->args, "-airmass_min"); 342 if (!status) { 343 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass_min"); 344 return false; 345 } 346 347 psF32 airmass_max = psMetadataLookupF32(&status, config->args, "-airmass_max"); 348 if (!status) { 349 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass_max"); 350 return false; 351 } 352 353 psF32 exp_time_min = psMetadataLookupF32(&status, config->args, "-exp_time_min"); 354 if (!status) { 355 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time_min"); 356 return false; 357 } 358 359 psF32 exp_time_max = psMetadataLookupF32(&status, config->args, "-exp_time_max"); 360 if (!status) { 361 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time_max"); 362 return false; 363 } 364 365 psF32 ccd_temp_min = psMetadataLookupF32(&status, config->args, "-ccd_temp_min"); 366 if (!status) { 367 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ccd_temp_min"); 368 return false; 369 } 370 371 psF32 ccd_temp_max = psMetadataLookupF32(&status, config->args, "-ccd_temp_max"); 372 if (!status) { 373 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ccd_temp_max"); 374 return false; 375 } 376 377 psF64 posang_min = psMetadataLookupF32(&status, config->args, "-posang_min"); 378 if (!status) { 379 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -posang_min"); 380 return false; 381 } 382 383 psF64 posang_max = psMetadataLookupF32(&status, config->args, "-posang_max"); 384 if (!status) { 385 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -posang_max"); 386 return false; 387 } 388 psF64 solang_min = psMetadataLookupF32(&status, config->args, "-solang_min"); 389 if (!status) { 390 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -solang_min"); 391 return false; 392 } 393 394 psF64 solang_max = psMetadataLookupF32(&status, config->args, "-solang_max"); 395 if (!status) { 396 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -solang_max"); 397 return false; 398 } 399 400 psTime *registered = NULL; 401 { 402 psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered"); 403 if (!status) { 404 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -registered"); 405 return false; 406 } 407 // pass through NULL as this is an optional field 408 if (registeredStr) { 409 registered = psTimeFromISO(registeredStr, PS_TIME_UTC); 410 if (!registered) { 411 psError(PS_ERR_UNKNOWN, false, "error in time format %s", registeredStr); 412 return false; 413 } 414 } else { 415 registered = NULL; 416 } 417 } 418 419 psTime *time_begin = NULL; 420 { 421 psString time_beginStr = psMetadataLookupStr(&status, config->args, "-time_begin"); 422 if (!status) { 423 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -time_begin"); 424 return false; 425 } 426 // pass through NULL as this is an optional field 427 if (time_beginStr) { 428 time_begin = psTimeFromISO(time_beginStr, PS_TIME_UTC); 429 if (!time_begin) { 430 psError(PS_ERR_UNKNOWN, false, "error in time format %s", time_beginStr); 431 return false; 432 } 433 } else { 434 time_begin = NULL; 435 } 436 } 437 438 psTime *time_end = NULL; 439 { 440 psString time_endStr = psMetadataLookupStr(&status, config->args, "-time_end"); 441 if (!status) { 442 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -time_end"); 443 return false; 444 } 445 // pass through NULL as this is an optional field 446 if (time_endStr) { 447 time_end = psTimeFromISO(time_endStr, PS_TIME_UTC); 448 if (!time_end) { 449 psError(PS_ERR_UNKNOWN, false, "error in time format %s", time_endStr); 450 return false; 451 } 452 } else { 453 time_end = NULL; 454 } 455 } 456 457 psTime *use_begin = NULL; 458 { 459 psString use_beginStr = psMetadataLookupStr(&status, config->args, "-use_begin"); 460 if (!status) { 461 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -use_begin"); 462 return false; 463 } 464 // pass through NULL as this is an optional field 465 if (use_beginStr) { 466 use_begin = psTimeFromISO(use_beginStr, PS_TIME_UTC); 467 if (!use_begin) { 468 psError(PS_ERR_UNKNOWN, false, "error in time format %s", use_beginStr); 469 return false; 470 } 471 } else { 472 use_begin = NULL; 473 } 474 } 475 476 psTime *use_end = NULL; 477 { 478 psString use_endStr = psMetadataLookupStr(&status, config->args, "-use_end"); 479 if (!status) { 480 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -use_end"); 481 return false; 482 } 483 // pass through NULL as this is an optional field 484 if (use_endStr) { 485 use_end = psTimeFromISO(use_endStr, PS_TIME_UTC); 486 if (!use_end) { 487 psError(PS_ERR_UNKNOWN, false, "error in time format %s", use_endStr); 488 return false; 489 } 490 } else { 491 use_end = NULL; 492 } 493 } 494 495 psString reduction = psMetadataLookupStr(&status, config->args, "-reduction"); 496 if (!status) { 497 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -reduction"); 498 return false; 499 } 500 501 psString label = psMetadataLookupStr(&status, config->args, "-label"); 502 if (!status) { 503 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label"); 504 return false; 505 } 277 PXOPT_LOOKUP_STR(camera, config->args, "-inst", false, false); 278 PXOPT_LOOKUP_STR(telescope, config->args, "-telescope", false, false); 279 PXOPT_LOOKUP_STR(exp_type, config->args, "-exp_type", false, false); 280 PXOPT_LOOKUP_STR(filter, config->args, "-filter", false, false); 281 282 PXOPT_LOOKUP_F32(airmass_min, config->args, "-airmass_min", false, false); 283 PXOPT_LOOKUP_F32(airmass_max, config->args, "-airmass_max", false, false); 284 PXOPT_LOOKUP_F32(exp_time_min, config->args, "-exp_time_min", false, false); 285 PXOPT_LOOKUP_F32(exp_time_max, config->args, "-exp_time_max", false, false); 286 PXOPT_LOOKUP_F32(ccd_temp_min, config->args, "-ccd_temp_min", false, false); 287 PXOPT_LOOKUP_F32(ccd_temp_max, config->args, "-ccd_temp_max", false, false); 288 PXOPT_LOOKUP_F64(posang_min, config->args, "-posang_min", false, false); 289 PXOPT_LOOKUP_F64(posang_max, config->args, "-posang_max", false, false); 290 PXOPT_LOOKUP_F64(solang_min, config->args, "-solang_min", false, false); 291 PXOPT_LOOKUP_F64(solang_max, config->args, "-solang_max", false, false); 292 PXOPT_LOOKUP_TIME(time_begin, config->args, "-time_begin", false, false); 293 PXOPT_LOOKUP_TIME(time_end, config->args, "-time_end", false, false); 294 PXOPT_LOOKUP_TIME(use_begin, config->args, "-use_begin", false, false); 295 PXOPT_LOOKUP_TIME(use_end, config->args, "-use_end", false, false); 296 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 297 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 298 299 // default 300 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 301 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 506 302 507 303 // we have to support multipe exp_ids … … 608 404 0 // parent 609 405 ); 610 psFree(registered);611 psFree(time_begin);612 psFree(time_end);613 psFree(use_begin);614 psFree(use_end);615 406 psS64 det_id = psDBLastInsertID(config->dbh); 616 407 … … 645 436 psError(PS_ERR_UNKNOWN, false, "database error"); 646 437 return false; 647 }648 649 bool simple = false;650 {651 bool status = false;652 simple = psMetadataLookupBool(&status, config->args, "-simple");653 if (!status) {654 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");655 return false;656 }657 438 } 658 439 … … 721 502 static bool definebyqueryMode(pxConfig *config) 722 503 { 723 bool status = false; 724 725 PS_ASSERT_PTR_NON_NULL(config, false); 726 727 // what type of detRun is this? 728 // det_type is required 729 psString det_type = psMetadataLookupStr(&status, config->args, "-det_type"); 730 if (!status) { 731 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_type"); 732 return false; 733 } 734 if (!det_type) { 735 psError(PS_ERR_UNKNOWN, true, "-det_type is required"); 736 return false; 737 } 504 PS_ASSERT_PTR_NON_NULL(config, false); 505 506 // required 507 PXOPT_LOOKUP_STR(det_type, config->args, "-det_type", true, false); 508 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 509 PXOPT_LOOKUP_STR(camera, config->args, "-inst", true, false); 738 510 739 511 // optional 740 psString filelevel = psMetadataLookupStr(&status, config->args, "-filelevel"); 741 if (!status) { 742 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filelevel"); 743 return false; 744 } 745 746 psString workdir = psMetadataLookupStr(&status, config->args, "-workdir"); 747 if (!status) { 748 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -workdir"); 749 return false; 750 } 751 if (!workdir) { 752 psError(PS_ERR_UNKNOWN, true, "-workdir is required"); 753 return false; 754 } 755 psString camera = psMetadataLookupStr(&status, config->args, "-inst"); 756 if (!status) { 757 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -inst"); 758 return false; 759 } 760 if (!camera) { 761 psError(PS_ERR_UNKNOWN, false, "-inst is required"); 762 return false; 763 } 512 PXOPT_LOOKUP_STR(mode, config->args, "-mode", false, false); 513 // check mode 514 if (mode && !isValidMode(config, mode)) { 515 psError(PS_ERR_UNKNOWN, false, "invalud mode"); 516 return false; 517 } 518 PXOPT_LOOKUP_STR(filelevel, config->args, "-filelevel", false, false); 519 PXOPT_LOOKUP_STR(telescope, config->args, "-telescope", false, false); 520 PXOPT_LOOKUP_STR(filter, config->args, "-filter", false, false); 521 PXOPT_LOOKUP_F32(airmass_min, config->args, "-airmass_min", false, false); 522 PXOPT_LOOKUP_F32(airmass_max, config->args, "-airmass_max", false, false); 523 PXOPT_LOOKUP_F32(exp_time_min, config->args, "-exp_time_min", false, false); 524 PXOPT_LOOKUP_F32(exp_time_max, config->args, "-exp_time_max", false, false); 525 PXOPT_LOOKUP_F32(ccd_temp_min, config->args, "-ccd_temp_min", false, false); 526 PXOPT_LOOKUP_F32(ccd_temp_max, config->args, "-ccd_temp_max", false, false); 527 PXOPT_LOOKUP_F64(posang_min, config->args, "-posang_min", false, false); 528 PXOPT_LOOKUP_F64(posang_max, config->args, "-posang_max", false, false); 529 PXOPT_LOOKUP_F64(solang_min, config->args, "-solang_min", false, false); 530 PXOPT_LOOKUP_F64(solang_max, config->args, "-solang_max", false, false); 531 532 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 533 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 534 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 535 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 536 537 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 538 PXOPT_LOOKUP_TIME(time_begin, config->args, "-time_begin", false, false); 539 PXOPT_LOOKUP_TIME(time_end, config->args, "-time_end", false, false); 540 PXOPT_LOOKUP_TIME(use_begin, config->args, "-use_begin", false, false); 541 PXOPT_LOOKUP_TIME(use_end, config->args, "-use_end", false, false); 764 542 765 543 psMetadata *where = psMetadataAlloc(); 766 { 767 bool status = false; 768 psString exp_type = psMetadataLookupStr(&status, config->args, "-select_exp_type"); 769 if (!status) { 770 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_exp_type"); 771 return false; 772 } 773 if (exp_type) { 774 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_type", 0, "==", exp_type)) { 775 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_type"); 776 psFree(where); 777 return false; 778 } 779 } 780 781 // map -inst -> camera 782 psString camera = psMetadataLookupStr(&status, config->args, "-select_inst"); 783 if (!status) { 784 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_inst"); 785 return false; 786 } 787 if (camera) { 788 if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==", camera)) { 789 psError(PS_ERR_UNKNOWN, false, "failed to add item inst"); 790 psFree(where); 791 return false; 792 } 793 } 794 795 psString telescope = psMetadataLookupStr(&status, config->args, "-select_telescope"); 796 if (!status) { 797 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_telescope"); 798 return false; 799 } 800 if (telescope) { 801 if (!psMetadataAddStr(where, PS_LIST_TAIL, "telescope", 0, "==", telescope)) { 802 psError(PS_ERR_UNKNOWN, false, "failed to add item telescope"); 803 psFree(where); 804 return false; 805 } 806 } 807 808 psString filter = psMetadataLookupStr(&status, config->args, "-select_filter"); 809 if (!status) { 810 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_filter"); 811 return false; 812 } 813 if (filter) { 814 if (!psMetadataAddStr(where, PS_LIST_TAIL, "filter", 0, "==", filter)) { 815 psError(PS_ERR_UNKNOWN, false, "failed to add item filter"); 816 psFree(where); 817 return false; 818 } 819 } 820 821 psString uri = psMetadataLookupStr(&status, config->args, "-select_uri"); 822 if (!status) { 823 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_uri"); 824 return false; 825 } 826 if (uri) { 827 if (!psMetadataAddStr(where, PS_LIST_TAIL, "uri", 0, "==", uri)) { 828 psError(PS_ERR_UNKNOWN, false, "failed to add item uri"); 829 psFree(where); 830 return false; 831 } 832 } 833 834 psString dateobs_begin = psMetadataLookupStr(&status, config->args, "-select_dateobs_begin"); 835 if (!status) { 836 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_dateobs_begin"); 837 psFree(where); 838 return false; 839 } 840 if (dateobs_begin) { 841 psTime *time = psTimeFromISO(dateobs_begin, PS_TIME_UTC); 842 if (!time) { 843 psError(PS_ERR_UNKNOWN, false, "error in time format %s", dateobs_begin); 844 psFree(time); 845 psFree(where); 846 return false; 847 } 848 if (!psMetadataAddTime(where, PS_LIST_TAIL, "dateobs", PS_META_DUPLICATE_OK, ">=", time)) { 849 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs"); 850 psFree(time); 851 psFree(where); 852 return false; 853 } 854 psFree(time); 855 } 856 857 psString dateobs_end = psMetadataLookupStr(&status, config->args, "-select_dateobs_end"); 858 if (!status) { 859 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_dateobs_end"); 860 psFree(where); 861 return false; 862 } 863 if (dateobs_end) { 864 psTime *time = psTimeFromISO(dateobs_end, PS_TIME_UTC); 865 if (!time) { 866 psError(PS_ERR_UNKNOWN, false, "error in time format %s", dateobs_end); 867 psFree(time); 868 psFree(where); 869 return false; 870 } 871 if (!psMetadataAddTime(where, PS_LIST_TAIL, "dateobs", PS_META_DUPLICATE_OK, "<", time)) { 872 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs"); 873 psFree(time); 874 psFree(where); 875 return false; 876 } 877 psFree(time); 878 } 879 880 /** selection based on airmass range **/ 881 psF32 select_airmass_min = psMetadataLookupF32(&status, config->args, "-select_airmass_min"); 882 if (!status) { 883 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_airmass_min"); 884 psFree(where); 885 return false; 886 } 887 if (isfinite(select_airmass_min)) { 888 if (!psMetadataAddF32(where, PS_LIST_TAIL, "airmass", PS_META_DUPLICATE_OK, ">=", select_airmass_min)) { 889 psError(PS_ERR_UNKNOWN, false, "failed to add item airmass"); 890 psFree(where); 891 return false; 892 } 893 } 894 psF32 select_airmass_max = psMetadataLookupF32(&status, config->args, "-select_airmass_max"); 895 if (!status) { 896 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_airmass_max"); 897 psFree(where); 898 return false; 899 } 900 if (isfinite(select_airmass_max)) { 901 if (!psMetadataAddF32(where, PS_LIST_TAIL, "airmass", PS_META_DUPLICATE_OK, "<=", select_airmass_max)) { 902 psError(PS_ERR_UNKNOWN, false, "failed to add item airmass"); 903 psFree(where); 904 return false; 905 } 906 } 907 908 psF32 select_sat_pixel_frac_max = psMetadataLookupF32(&status, config->args, "-select_sat_pixel_frac_max"); 909 if (!status) { 910 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_sat_pixel_frac_max"); 911 psFree(where); 912 return false; 913 } 914 if (isfinite(select_sat_pixel_frac_max)) { 915 if (!psMetadataAddF32(where, PS_LIST_TAIL, "sat_pixel_frac", PS_META_DUPLICATE_OK, "<=", select_sat_pixel_frac_max)) { 916 psError(PS_ERR_UNKNOWN, false, "failed to add item sat_pixel_frac"); 917 psFree(where); 918 return false; 919 } 920 } 921 922 /** selection based on exp_time range **/ 923 psF32 select_exp_time_min = psMetadataLookupF32(&status, config->args, "-select_exp_time_min"); 924 if (!status) { 925 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_exp_time_min"); 926 psFree(where); 927 return false; 928 } 929 if (isfinite(select_exp_time_min)) { 930 if (!psMetadataAddF32(where, PS_LIST_TAIL, "exp_time", PS_META_DUPLICATE_OK, ">=", select_exp_time_min)) { 931 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_time"); 932 psFree(where); 933 return false; 934 } 935 } 936 psF32 select_exp_time_max = psMetadataLookupF32(&status, config->args, "-select_exp_time_max"); 937 if (!status) { 938 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_exp_time_max"); 939 psFree(where); 940 return false; 941 } 942 if (isfinite(select_exp_time_max)) { 943 if (!psMetadataAddF32(where, PS_LIST_TAIL, "exp_time", PS_META_DUPLICATE_OK, "<=", select_exp_time_max)) { 944 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_time"); 945 psFree(where); 946 return false; 947 } 948 } 949 950 /** selection based on ccd_temp range **/ 951 psF32 select_ccd_temp_min = psMetadataLookupF32(&status, config->args, "-select_ccd_temp_min"); 952 if (!status) { 953 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_ccd_temp_min"); 954 psFree(where); 955 return false; 956 } 957 if (isfinite(select_ccd_temp_min)) { 958 if (!psMetadataAddF32(where, PS_LIST_TAIL, "ccd_temp", PS_META_DUPLICATE_OK, ">=", select_ccd_temp_min)) { 959 psError(PS_ERR_UNKNOWN, false, "failed to add item ccd_temp"); 960 psFree(where); 961 return false; 962 } 963 } 964 psF32 select_ccd_temp_max = psMetadataLookupF32(&status, config->args, "-select_ccd_temp_max"); 965 if (!status) { 966 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_ccd_temp_max"); 967 psFree(where); 968 return false; 969 } 970 if (isfinite(select_ccd_temp_max)) { 971 if (!psMetadataAddF32(where, PS_LIST_TAIL, "ccd_temp", PS_META_DUPLICATE_OK, "<=", select_ccd_temp_max)) { 972 psError(PS_ERR_UNKNOWN, false, "failed to add item ccd_temp"); 973 psFree(where); 974 return false; 975 } 976 } 977 978 /** selection based on posang **/ 979 psF32 select_posang_min = psMetadataLookupF32(&status, config->args, "-select_posang_min"); 980 if (!status) { 981 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_posang_min"); 982 psFree(where); 983 return false; 984 } 985 if (isfinite(select_posang_min)) { 986 if (!psMetadataAddF32(where, PS_LIST_TAIL, "posang", PS_META_DUPLICATE_OK, ">=", select_posang_min)) { 987 psError(PS_ERR_UNKNOWN, false, "failed to add item posang"); 988 psFree(where); 989 return false; 990 } 991 } 992 psF32 select_posang_max = psMetadataLookupF32(&status, config->args, "-select_posang_max"); 993 if (!status) { 994 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_posang_max"); 995 psFree(where); 996 return false; 997 } 998 if (isfinite(select_posang_max)) { 999 if (!psMetadataAddF32(where, PS_LIST_TAIL, "posang", PS_META_DUPLICATE_OK, "<=", select_posang_max)) { 1000 psError(PS_ERR_UNKNOWN, false, "failed to add item posang"); 1001 psFree(where); 1002 return false; 1003 } 1004 } 1005 1006 /** selection based on solang **/ 1007 psF32 select_solang_min = psMetadataLookupF32(&status, config->args, "-select_solang_min"); 1008 if (!status) { 1009 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_solang_min"); 1010 psFree(where); 1011 return false; 1012 } 1013 if (isfinite(select_solang_min)) { 1014 if (!psMetadataAddF32(where, PS_LIST_TAIL, "solang", PS_META_DUPLICATE_OK, ">=", select_solang_min)) { 1015 psError(PS_ERR_UNKNOWN, false, "failed to add item solang"); 1016 psFree(where); 1017 return false; 1018 } 1019 } 1020 psF32 select_solang_max = psMetadataLookupF32(&status, config->args, "-select_solang_max"); 1021 if (!status) { 1022 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -select_solang_max"); 1023 psFree(where); 1024 return false; 1025 } 1026 if (isfinite(select_solang_max)) { 1027 if (!psMetadataAddF32(where, PS_LIST_TAIL, "solang", PS_META_DUPLICATE_OK, "<=", select_solang_max)) { 1028 psError(PS_ERR_UNKNOWN, false, "failed to add item solang"); 1029 psFree(where); 1030 return false; 1031 } 1032 } 1033 1034 } 544 PXOPT_COPY_STR(config->args, where, "-select_exp_type", "exp_type", "=="); 545 // map -inst -> camera 546 PXOPT_COPY_STR(config->args, where, "-select_inst", "camera", "=="); 547 PXOPT_COPY_STR(config->args, where, "-select_telescope", "telescope", "=="); 548 PXOPT_COPY_STR(config->args, where, "-select_filter", "filter", "=="); 549 PXOPT_COPY_STR(config->args, where, "-select_uri", "uri", "=="); 550 PXOPT_COPY_TIME(config->args, where, "-select_dateobs_begin", "dateobs", ">="); 551 PXOPT_COPY_TIME(config->args, where, "-select_dateobs_end", "dateobs", "<"); 552 PXOPT_COPY_F32(config->args, where, "-select_airmass_min", "airmass", ">="); 553 PXOPT_COPY_F32(config->args, where, "-select_airmass_max", "airmass", "<="); 554 PXOPT_COPY_F32(config->args, where, "-select_sat_pixel_frac_max", "sat_pixel_frac", "<="); 555 PXOPT_COPY_F32(config->args, where, "-select_exp_time_min", "exp_time", ">="); 556 PXOPT_COPY_F32(config->args, where, "-select_exp_time_max", "exp_time", "<="); 557 PXOPT_COPY_F32(config->args, where, "-select_ccd_temp_min", "ccd_temp", ">="); 558 PXOPT_COPY_F32(config->args, where, "-select_ccd_temp_max", "ccd_temp", "<="); 559 PXOPT_COPY_F32(config->args, where, "-select_posang_min", "posang", ">="); 560 PXOPT_COPY_F32(config->args, where, "-select_posang_max", "posang", "<="); 561 PXOPT_COPY_F32(config->args, where, "-select_solang_min", "solang", ">="); 562 PXOPT_COPY_F32(config->args, where, "-select_solang_max", "solang", "<="); 1035 563 1036 564 if (!psListLength(where->list)) { … … 1043 571 // like to assign values to so I've seperated them but prepending set- to 1044 572 // the assigned values 1045 1046 // optional1047 psString mode = psMetadataLookupStr(&status, config->args, "-mode");1048 if (!status) {1049 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -mode");1050 return false;1051 }1052 // check mode1053 if (mode && !isValidMode(config, mode)) {1054 psError(PS_ERR_UNKNOWN, false, "invalud mode");1055 return false;1056 }1057 1058 psString telescope = psMetadataLookupStr(&status, config->args, "-telescope");1059 if (!status) {1060 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -telescope");1061 return false;1062 }1063 1064 psString filter = psMetadataLookupStr(&status, config->args, "-filter");1065 if (!status) {1066 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter");1067 return false;1068 }1069 1070 psF32 airmass_min = psMetadataLookupF32(&status, config->args, "-airmass_min");1071 if (!status) {1072 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass_min");1073 return false;1074 }1075 1076 psF32 airmass_max = psMetadataLookupF32(&status, config->args, "-airmass_max");1077 if (!status) {1078 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass_max");1079 return false;1080 }1081 1082 psF32 exp_time_min = psMetadataLookupF32(&status, config->args, "-exp_time_min");1083 if (!status) {1084 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time_min");1085 return false;1086 }1087 1088 psF32 exp_time_max = psMetadataLookupF32(&status, config->args, "-exp_time_max");1089 if (!status) {1090 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time_max");1091 return false;1092 }1093 1094 psF32 ccd_temp_min = psMetadataLookupF32(&status, config->args, "-ccd_temp_min");1095 if (!status) {1096 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ccd_temp_min");1097 return false;1098 }1099 1100 psF32 ccd_temp_max = psMetadataLookupF32(&status, config->args, "-ccd_temp_max");1101 if (!status) {1102 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ccd_temp_max");1103 return false;1104 }1105 1106 psF64 posang_min = psMetadataLookupF32(&status, config->args, "-posang_min");1107 if (!status) {1108 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -posang_min");1109 return false;1110 }1111 1112 psF64 posang_max = psMetadataLookupF32(&status, config->args, "-posang_max");1113 if (!status) {1114 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -posang_max");1115 return false;1116 }1117 1118 psF64 solang_min = psMetadataLookupF32(&status, config->args, "-solang_min");1119 if (!status) {1120 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -solang_min");1121 return false;1122 }1123 1124 psF64 solang_max = psMetadataLookupF32(&status, config->args, "-solang_max");1125 if (!status) {1126 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -solang_max");1127 return false;1128 }1129 1130 psTime *registered = NULL;1131 {1132 psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered");1133 if (!status) {1134 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -registered");1135 return false;1136 }1137 // pass through NULL as this is an optional field1138 if (registeredStr) {1139 registered = psTimeFromISO(registeredStr, PS_TIME_UTC);1140 if (!registered) {1141 psError(PS_ERR_UNKNOWN, false, "error in time format %s", registeredStr);1142 return false;1143 }1144 } else {1145 registered = NULL;1146 }1147 }1148 1149 psTime *time_begin = NULL;1150 {1151 psString time_beginStr = psMetadataLookupStr(&status, config->args, "-time_begin");1152 if (!status) {1153 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -time_begin");1154 return false;1155 }1156 // pass through NULL as this is an optional field1157 if (time_beginStr) {1158 time_begin = psTimeFromISO(time_beginStr, PS_TIME_UTC);1159 if (!time_begin) {1160 psError(PS_ERR_UNKNOWN, false, "error in time format %s", time_beginStr);1161 return false;1162 }1163 } else {1164 time_begin = NULL;1165 }1166 }1167 1168 psTime *time_end = NULL;1169 {1170 psString time_endStr = psMetadataLookupStr(&status, config->args, "-time_end");1171 if (!status) {1172 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -time_end");1173 return false;1174 }1175 // pass through NULL as this is an optional field1176 if (time_endStr) {1177 time_end = psTimeFromISO(time_endStr, PS_TIME_UTC);1178 if (!time_end) {1179 psError(PS_ERR_UNKNOWN, false, "error in time format %s", time_endStr);1180 return false;1181 }1182 } else {1183 time_end = NULL;1184 }1185 }1186 1187 psTime *use_begin = NULL;1188 {1189 psString use_beginStr = psMetadataLookupStr(&status, config->args, "-use_begin");1190 if (!status) {1191 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -use_begin");1192 return false;1193 }1194 // pass through NULL as this is an optional field1195 if (use_beginStr) {1196 use_begin = psTimeFromISO(use_beginStr, PS_TIME_UTC);1197 if (!use_begin) {1198 psError(PS_ERR_UNKNOWN, false, "error in time format %s", use_beginStr);1199 return false;1200 }1201 } else {1202 use_begin = NULL;1203 }1204 }1205 1206 psTime *use_end = NULL;1207 {1208 psString use_endStr = psMetadataLookupStr(&status, config->args, "-use_end");1209 if (!status) {1210 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -use_end");1211 return false;1212 }1213 // pass through NULL as this is an optional field1214 if (use_endStr) {1215 use_end = psTimeFromISO(use_endStr, PS_TIME_UTC);1216 if (!use_end) {1217 psError(PS_ERR_UNKNOWN, false, "error in time format %s", use_endStr);1218 return false;1219 }1220 } else {1221 use_end = NULL;1222 }1223 }1224 1225 psString reduction = psMetadataLookupStr(&status, config->args, "-reduction");1226 if (!status) {1227 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -reduction");1228 return false;1229 }1230 1231 psString label = psMetadataLookupStr(&status, config->args, "-label");1232 if (!status) {1233 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label");1234 return false;1235 }1236 1237 bool simple = psMetadataLookupBool(&status, config->args, "-simple");1238 if (!status) {1239 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1240 psFree(registered);1241 psFree(use_begin);1242 psFree(use_end);1243 return false;1244 }1245 1246 bool pretend = psMetadataLookupBool(&status, config->args, "-pretend");1247 if (!status) {1248 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -pretend");1249 psFree(registered);1250 psFree(use_begin);1251 psFree(use_end);1252 return false;1253 }1254 573 1255 574 // search for rawExps with the specified options … … 1259 578 if (!detrendExps) { 1260 579 psError(PS_ERR_UNKNOWN, false, "database error"); 1261 psFree(registered);1262 psFree(use_begin);1263 psFree(use_end);1264 580 return false; 1265 581 } … … 1267 583 psTrace("dettool", PS_LOG_INFO, "no rows found"); 1268 584 psFree(detrendExps); 1269 psFree(registered);1270 psFree(use_begin);1271 psFree(use_end);1272 585 return true; 1273 586 } … … 1283 596 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1284 597 psFree(detrendExps); 1285 psFree(registered);1286 psFree(use_begin);1287 psFree(use_end);1288 598 return false; 1289 599 } 1290 600 psFree(detrendExps); 1291 psFree(registered);1292 psFree(use_begin);1293 psFree(use_end);1294 601 return true; 1295 602 } … … 1299 606 psError(PS_ERR_UNKNOWN, false, "database error"); 1300 607 psFree(detrendExps); 1301 psFree(registered);1302 psFree(use_begin);1303 psFree(use_end);1304 608 return false; 1305 609 } … … 1338 642 0 // parent 1339 643 ); 1340 psFree(registered);1341 psFree(time_begin);1342 psFree(time_end);1343 psFree(use_end);1344 psFree(use_begin);1345 psFree(use_end);1346 644 psS64 det_id = psDBLastInsertID(config->dbh); 1347 645 … … 1417 715 static bool definebydetrunMode(pxConfig *config) 1418 716 { 1419 bool status = false; 1420 1421 PS_ASSERT_PTR_NON_NULL(config, false); 1422 1423 // det_id is the only required input 1424 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 1425 if (!status) { 1426 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 1427 return false; 1428 } 1429 if (!det_id) { 1430 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 1431 return false; 1432 } 717 PS_ASSERT_PTR_NON_NULL(config, false); 718 719 // required 720 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 721 722 // optional 723 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 724 PXOPT_LOOKUP_STR(det_type, config->args, "-set_det_type", false, false); 725 PXOPT_LOOKUP_STR(mode, config->args, "-set_mode", false, false); 726 // check mode 727 if (mode && !isValidMode(config, mode)) { 728 psError(PS_ERR_UNKNOWN, false, "invalud mode"); 729 return false; 730 } 731 PXOPT_LOOKUP_STR(camera, config->args, "-set_inst", false, false); 732 PXOPT_LOOKUP_STR(telescope, config->args, "-set_telescope", false, false); 733 PXOPT_LOOKUP_STR(exp_type, config->args, "-set_exp_type", false, false); 734 PXOPT_LOOKUP_STR(filelevel, config->args, "-set_filelevel", false, false); 735 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 736 PXOPT_LOOKUP_STR(filter, config->args, "-set_filter", false, false); 737 738 PXOPT_LOOKUP_F32(airmass_min, config->args, "-set_airmass_min", false, false); 739 PXOPT_LOOKUP_F32(airmass_max, config->args, "-set_airmass_max", false, false); 740 PXOPT_LOOKUP_F32(exp_time_min, config->args, "-set_exp_time_min", false, false); 741 PXOPT_LOOKUP_F32(exp_time_max, config->args, "-set_exp_time_max", false, false); 742 PXOPT_LOOKUP_F32(ccd_temp_min, config->args, "-set_ccd_temp_min", false, false); 743 PXOPT_LOOKUP_F32(ccd_temp_max, config->args, "-set_ccd_temp_max", false, false); 744 PXOPT_LOOKUP_F32(posang_min, config->args, "-set_posang_min", false, false); 745 PXOPT_LOOKUP_F32(posang_max, config->args, "-set_posang_max", false, false); 746 PXOPT_LOOKUP_F32(solang_min, config->args, "-set_solang_min", false, false); 747 PXOPT_LOOKUP_F32(solang_max, config->args, "-set_solang_max", false, false); 748 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 749 PXOPT_LOOKUP_TIME(registered, config->args, "-set_registered", false, false); 750 PXOPT_LOOKUP_TIME(time_begin, config->args, "-set_time_begin", false, false); 751 PXOPT_LOOKUP_TIME(time_end, config->args, "-set_end", false, false); 752 PXOPT_LOOKUP_TIME(use_begin, config->args, "-use_begin", false, false); 753 PXOPT_LOOKUP_TIME(use_end, config->args, "-use_end", false, false); 754 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 755 1433 756 1434 757 // lookup the detRun that we will be basing this one on … … 1467 790 1468 791 // walk through the optional values and update the detRun as required 1469 psString det_type = psMetadataLookupStr(&status, config->args, "-set_det_type");1470 if (!status) {1471 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_det_type");1472 return false;1473 }1474 792 if (det_type) { 1475 793 psFree(detRun->det_type); … … 1477 795 } 1478 796 1479 psString mode = psMetadataLookupStr(&status, config->args, "-set_mode");1480 if (!status) {1481 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_mode");1482 return false;1483 }1484 // check mode1485 if (mode && !isValidMode(config, mode)) {1486 psError(PS_ERR_UNKNOWN, false, "invalud mode");1487 return false;1488 }1489 797 if (mode) { 1490 798 psFree(detRun->mode); … … 1492 800 } 1493 801 1494 psString camera = psMetadataLookupStr(&status, config->args, "-set_inst");1495 if (!status) {1496 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_inst");1497 return false;1498 }1499 802 if (camera) { 1500 803 psFree(detRun->camera); … … 1502 805 } 1503 806 1504 psString telescope = psMetadataLookupStr(&status, config->args, "-set_telescope");1505 if (!status) {1506 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_telescope");1507 return false;1508 }1509 807 if (telescope) { 1510 808 psFree(detRun->telescope); … … 1512 810 } 1513 811 1514 psString exp_type = psMetadataLookupStr(&status, config->args, "-set_exp_type");1515 if (!status) {1516 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_exp_type");1517 return false;1518 }1519 812 if (exp_type) { 1520 813 psFree(detRun->exp_type); … … 1522 815 } 1523 816 1524 psString filelevel = psMetadataLookupStr(&status, config->args, "-set_filelevel");1525 if (!status) {1526 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_filelevel");1527 return false;1528 }1529 817 if (filelevel) { 1530 818 psFree(detRun->filelevel); … … 1532 820 } 1533 821 1534 psString workdir = psMetadataLookupStr(&status, config->args, "-set_workdir");1535 if (!status) {1536 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_workdir");1537 return false;1538 }1539 822 if (workdir) { 1540 823 psFree(detRun->workdir); … … 1542 825 } 1543 826 1544 psString filter = psMetadataLookupStr(&status, config->args, "-set_filter");1545 if (!status) {1546 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_filter");1547 return false;1548 }1549 827 if (filter) { 1550 828 psFree(detRun->filter); … … 1552 830 } 1553 831 1554 psF32 airmass_min = psMetadataLookupF32(&status, config->args, "-set_airmass_min");1555 if (!status) {1556 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_airmass_min");1557 return false;1558 }1559 832 if (!isnan(airmass_min)) { 1560 833 detRun->airmass_min = airmass_min; 1561 834 } 1562 835 1563 psF32 airmass_max = psMetadataLookupF32(&status, config->args, "-set_airmass_max");1564 if (!status) {1565 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_airmass_max");1566 return false;1567 }1568 836 if (!isnan(airmass_max)) { 1569 837 detRun->airmass_max = airmass_max; 1570 838 } 1571 839 1572 psF32 exp_time_min = psMetadataLookupF32(&status, config->args, "-set_exp_time_min");1573 if (!status) {1574 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_exp_time_min");1575 return false;1576 }1577 840 if (!isnan(exp_time_min)) { 1578 841 detRun->exp_time_min = exp_time_min; 1579 842 } 1580 843 1581 psF32 exp_time_max = psMetadataLookupF32(&status, config->args, "-set_exp_time_max");1582 if (!status) {1583 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_exp_time_max");1584 return false;1585 }1586 844 if (!isnan(exp_time_max)) { 1587 845 detRun->exp_time_max = exp_time_max; 1588 846 } 1589 847 1590 psF32 ccd_temp_min = psMetadataLookupF32(&status, config->args, "-set_ccd_temp_min");1591 if (!status) {1592 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_ccd_temp_min");1593 return false;1594 }1595 848 if (!isnan(ccd_temp_min)) { 1596 849 detRun->ccd_temp_min = ccd_temp_min; 1597 850 } 1598 851 1599 psF32 ccd_temp_max = psMetadataLookupF32(&status, config->args, "-set_ccd_temp_max");1600 if (!status) {1601 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_ccd_temp_max");1602 return false;1603 }1604 852 if (!isnan(ccd_temp_max)) { 1605 853 detRun->ccd_temp_max = ccd_temp_max; 1606 854 } 1607 855 1608 psF64 posang_min = psMetadataLookupF32(&status, config->args, "-set_posang_min");1609 if (!status) {1610 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_posang_min");1611 return false;1612 }1613 856 if (!isnan(posang_min)) { 1614 857 detRun->posang_min = posang_min; 1615 858 } 1616 859 1617 psF64 posang_max = psMetadataLookupF32(&status, config->args, "-set_posang_max");1618 if (!status) {1619 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_posang_max");1620 return false;1621 }1622 860 if (!isnan(posang_max)) { 1623 861 detRun->posang_max = posang_max; 1624 862 } 1625 863 1626 psF64 solang_min = psMetadataLookupF32(&status, config->args, "-set_solang_min");1627 if (!status) {1628 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_solang_min");1629 return false;1630 }1631 864 if (!isnan(solang_min)) { 1632 865 detRun->solang_min = solang_min; 1633 866 } 1634 867 1635 psF64 solang_max = psMetadataLookupF32(&status, config->args, "-set_solang_max");1636 if (!status) {1637 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_solang_max");1638 return false;1639 }1640 868 if (!isnan(solang_max)) { 1641 869 detRun->solang_max = solang_max; 1642 870 } 1643 871 1644 psString label = psMetadataLookupStr(&status, config->args, "-set_label");1645 if (!status) {1646 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_label");1647 return false;1648 }1649 872 if (label) { 873 psFree(detRun->label); 1650 874 detRun->label = label; 1651 875 } 1652 876 1653 psTime *registered = NULL; 1654 { 1655 psString registeredStr = psMetadataLookupStr(&status, config->args, "-set_registered"); 1656 if (!status) { 1657 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_registered"); 1658 return false; 1659 } 1660 // pass through NULL as this is an optional field 1661 if (registeredStr) { 1662 psFree(detRun->registered); 1663 registered = psTimeFromISO(registeredStr, PS_TIME_UTC); 1664 detRun->registered = psMemIncrRefCounter(registered); 1665 psFree(registered); 1666 } 1667 } 1668 1669 psTime *time_begin = NULL; 1670 { 1671 psString time_beginStr = psMetadataLookupStr(&status, config->args, "-set_time_begin"); 1672 if (!status) { 1673 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_time_begin"); 1674 return false; 1675 } 1676 // pass through NULL as this is an optional field 1677 if (time_beginStr) { 1678 psFree(detRun->time_begin); 1679 time_begin = psTimeFromISO(time_beginStr, PS_TIME_UTC); 1680 detRun->time_begin = psMemIncrRefCounter(time_begin); 1681 psFree(time_begin); 1682 } 1683 } 1684 1685 psTime *time_end = NULL; 1686 { 1687 psString time_endStr = psMetadataLookupStr(&status, config->args, "-set_time_end"); 1688 if (!status) { 1689 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_time_end"); 1690 return false; 1691 } 1692 // pass through NULL as this is an optional field 1693 if (time_endStr) { 1694 psFree(detRun->time_end); 1695 time_end = psTimeFromISO(time_endStr, PS_TIME_UTC); 1696 detRun->time_end = psMemIncrRefCounter(time_end); 1697 psFree(time_end); 1698 } 1699 } 1700 1701 psTime *use_begin = NULL; 1702 { 1703 psString use_beginStr = psMetadataLookupStr(&status, config->args, "-set_use_begin"); 1704 if (!status) { 1705 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_use_begin"); 1706 return false; 1707 } 1708 // pass through NULL as this is an optional field 1709 if (use_beginStr) { 1710 psFree(detRun->use_begin); 1711 use_begin = psTimeFromISO(use_beginStr, PS_TIME_UTC); 1712 detRun->use_begin = psMemIncrRefCounter(use_begin); 1713 psFree(use_begin); 1714 } 1715 } 1716 1717 psTime *use_end = NULL; 1718 { 1719 psString use_endStr = psMetadataLookupStr(&status, config->args, "-set_use_end"); 1720 if (!status) { 1721 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_use_end"); 1722 return false; 1723 } 1724 // pass through NULL as this is an optional field 1725 if (use_endStr) { 1726 psFree(detRun->use_end); 1727 use_end = psTimeFromISO(use_endStr, PS_TIME_UTC); 1728 detRun->use_end = psMemIncrRefCounter(use_end); 1729 psFree(use_end); 1730 } 1731 } 1732 1733 psString reduction = psMetadataLookupStr(&status, config->args, "-set_reduction"); 1734 if (!status) { 1735 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -set_reduction"); 1736 return false; 1737 } 877 if (registered) { 878 psFree(detRun->registered); 879 detRun->registered = psMemIncrRefCounter(registered); 880 } 881 882 if (time_begin) { 883 psFree(detRun->time_begin); 884 detRun->time_begin = psMemIncrRefCounter(time_begin); 885 } 886 887 if (time_end) { 888 psFree(detRun->time_end); 889 detRun->time_end = psMemIncrRefCounter(time_end); 890 } 891 892 if (use_begin) { 893 psFree(detRun->use_begin); 894 detRun->use_begin = psMemIncrRefCounter(use_begin); 895 } 896 897 if (use_end) { 898 psFree(detRun->use_end); 899 detRun->use_end = psMemIncrRefCounter(use_end); 900 } 901 1738 902 if (reduction) { 1739 903 psFree(detRun->reduction); … … 1745 909 psMetadata *time_filter = psMetadataAlloc(); 1746 910 1747 { 1748 psString timeStr = psMetadataLookupStr(&status, config->args, "-filter_input_begin"); 1749 if (!status) { 1750 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter_input_begin"); 1751 return false; 1752 } 1753 // pass through NULL as this is an optional field 1754 if (timeStr) { 1755 psTime *time = psTimeFromISO(timeStr, PS_TIME_UTC); 1756 if (!psMetadataAddTime(time_filter, PS_LIST_TAIL, "dateobs", PS_META_DUPLICATE_OK, ">=", time)) { 1757 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs"); 1758 psFree(time); 1759 psFree(time_filter); 1760 return false; 1761 } 1762 psFree(time); 1763 } 1764 } 1765 1766 { 1767 psString timeStr = psMetadataLookupStr(&status, config->args, "-filter_input_end"); 1768 if (!status) { 1769 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter_input_end"); 1770 return false; 1771 } 1772 // pass through NULL as this is an optional field 1773 if (timeStr) { 1774 psTime *time = psTimeFromISO(timeStr, PS_TIME_UTC); 1775 if (!psMetadataAddTime(time_filter, PS_LIST_TAIL, "dateobs", PS_META_DUPLICATE_OK, "<", time)) { 1776 psError(PS_ERR_UNKNOWN, false, "failed to add item dateobs"); 1777 psFree(time); 1778 psFree(time_filter); 1779 return false; 1780 } 1781 psFree(time); 1782 } 1783 } 1784 911 // XXX: possible mem leak: PXOPT_COPY* will free time_filter but NOTHING 912 // that has previously been allocated 913 PXOPT_COPY_TIME(config->args, time_filter, "-filter_input_begin", "dateobs", ">="); 914 PXOPT_COPY_TIME(config->args, time_filter, "-filter_input_end", "dateobs", "<"); 1785 915 1786 916 // start a transaction so we don't end up with childlessed det_ids … … 1840 970 } 1841 971 1842 bool simple = false;1843 {1844 bool status = false;1845 simple = psMetadataLookupBool(&status, config->args, "-simple");1846 if (!status) {1847 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1848 return false;1849 }1850 }1851 1852 972 // print the new det_id 1853 973 psArray *newDetRuns = NULL; … … 1890 1010 PS_ASSERT_PTR_NON_NULL(config, false); 1891 1011 1012 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1013 1892 1014 // XXX fix the hard coding of the table name 1893 1015 psArray *runs = psDBSelectRows(config->dbh, "detRun", config->where, 0); … … 1910 1032 } 1911 1033 1912 bool simple = false;1913 {1914 bool status = false;1915 simple = psMetadataLookupBool(&status, config->args, "-simple");1916 if (!status) {1917 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");1918 return false;1919 }1920 }1921 1922 1034 // negative simple so the default is true 1923 1035 if (!ippdbPrintMetadatas(stdout, runs, "detRun", !simple)) { … … 1936 1048 PS_ASSERT_PTR_NON_NULL(config, false); 1937 1049 1938 bool status = false; 1939 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 1940 if (!status) { 1941 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 1942 return false; 1943 } 1050 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1051 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1944 1052 1945 1053 psString query = psStringCopy( … … 1993 1101 } 1994 1102 1995 bool simple = false;1996 {1997 bool status = false;1998 simple = psMetadataLookupBool(&status, config->args, "-simple");1999 if (!status) {2000 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");2001 psFree(output);2002 return false;2003 }2004 }2005 2006 1103 // negative simple so the default is true 2007 1104 if (!ippdbPrintMetadatas(stdout, output, "detRun", !simple)) { … … 2032 1129 PS_ASSERT_PTR_NON_NULL(config, false); 2033 1130 1131 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1132 2034 1133 // select detInputExp.* 2035 1134 // select rawExp.* … … 2068 1167 } 2069 1168 2070 bool simple = false;2071 {2072 bool status = false;2073 simple = psMetadataLookupBool(&status, config->args, "-simple");2074 if (!status) {2075 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");2076 return false;2077 }2078 }2079 2080 1169 // negative simple so the default is true 2081 1170 if (!ippdbPrintMetadatas(stdout, output, "detInputExp", !simple)) { … … 2093 1182 { 2094 1183 PS_ASSERT_PTR_NON_NULL(config, false); 1184 1185 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2095 1186 2096 1187 psString query = pxDataGet("dettool_raw.sql"); … … 2124 1215 } 2125 1216 2126 bool simple = false;2127 {2128 bool status = false;2129 simple = psMetadataLookupBool(&status, config->args, "-simple");2130 if (!status) {2131 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");2132 return false;2133 }2134 }2135 2136 1217 // negative simple so the default is true 2137 1218 if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) { … … 2150 1231 PS_ASSERT_PTR_NON_NULL(config, false); 2151 1232 2152 bool status = false; 2153 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 2154 if (!status) { 2155 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 2156 return false; 2157 } 1233 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1234 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2158 1235 2159 1236 psString query = pxDataGet("dettool_toprocessedimfile.sql"); … … 2192 1269 psFree(output); 2193 1270 return true; 2194 }2195 2196 bool simple = false;2197 {2198 bool status = false;2199 simple = psMetadataLookupBool(&status, config->args, "-simple");2200 if (!status) {2201 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");2202 return false;2203 }2204 1271 } 2205 1272 … … 2267 1334 // det_id, exp_id, class_id, uri, recipe, -bg, -bg_stdev 2268 1335 // are required 2269 bool status = false; 2270 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 2271 if (!status) { 2272 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 2273 return false; 2274 } 2275 if (!det_id) { 2276 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 2277 return false; 2278 } 2279 psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id"); 2280 if (!status) { 2281 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id"); 2282 return false; 2283 } 2284 if (!exp_id) { 2285 psError(PS_ERR_UNKNOWN, true, "-exp_id is required"); 2286 return false; 2287 } 2288 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 2289 if (!status) { 2290 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 2291 return false; 2292 } 2293 if (!class_id) { 2294 psError(PS_ERR_UNKNOWN, true, "-class_id is required"); 2295 return false; 2296 } 2297 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 2298 if (!status) { 2299 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 2300 return false; 2301 } 2302 if (!uri) { 2303 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 2304 return false; 2305 } 2306 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 2307 if (!status) { 2308 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip"); 2309 return false; 2310 } 2311 if (!recipe) { 2312 psError(PS_ERR_UNKNOWN, true, "-recip is required"); 2313 return false; 2314 } 2315 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 2316 if (!status) { 2317 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 2318 return false; 2319 } 2320 //if (isnan(bg)) { 2321 //psError(PS_ERR_UNKNOWN, true, "-bg is required"); 2322 //return false; 2323 //} 2324 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 2325 if (!status) { 2326 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 2327 return false; 2328 } 2329 //if (isnan(bg_stdev)) { 2330 // psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required"); 2331 // return false; 2332 //} 2333 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 2334 if (!status) { 2335 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 2336 return false; 2337 } 2338 1336 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 1337 PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", true, false); 1338 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 1339 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 1340 PXOPT_LOOKUP_STR(recipe, config->args, "-recip", true, false); 1341 2339 1342 // optional 2340 psF64 fringe_0 = psMetadataLookupF64(&status, config->args, "-fringe_0"); 2341 if (!status) { 2342 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_0"); 2343 return false; 2344 } 2345 psF64 fringe_1 = psMetadataLookupF64(&status, config->args, "-fringe_1"); 2346 if (!status) { 2347 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_1"); 2348 return false; 2349 } 2350 psF64 fringe_2 = psMetadataLookupF64(&status, config->args, "-fringe_2"); 2351 if (!status) { 2352 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_2"); 2353 return false; 2354 } 2355 2356 psF64 user_1 = psMetadataLookupF64(&status, config->args, "-user_1"); 2357 if (!status) { 2358 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_1"); 2359 return false; 2360 } 2361 psF64 user_2 = psMetadataLookupF64(&status, config->args, "-user_2"); 2362 if (!status) { 2363 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_2"); 2364 return false; 2365 } 2366 psF64 user_3 = psMetadataLookupF64(&status, config->args, "-user_3"); 2367 if (!status) { 2368 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_3"); 2369 return false; 2370 } 2371 psF64 user_4 = psMetadataLookupF64(&status, config->args, "-user_4"); 2372 if (!status) { 2373 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_4"); 2374 return false; 2375 } 2376 psF64 user_5 = psMetadataLookupF64(&status, config->args, "-user_5"); 2377 if (!status) { 2378 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_5"); 2379 return false; 2380 } 2381 2382 psString path_base = psMetadataLookupStr(&status, config->args, "-path_base"); 2383 if (!status) { 2384 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base"); 2385 return false; 2386 } 1343 PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false); 1344 PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false); 1345 PXOPT_LOOKUP_F64(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 1346 PXOPT_LOOKUP_F64(fringe_0, config->args, "-fringe_0", false, false); 1347 PXOPT_LOOKUP_F64(fringe_1, config->args, "-fringe_1", false, false); 1348 PXOPT_LOOKUP_F64(fringe_2, config->args, "-fringe_2", false, false); 1349 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 1350 PXOPT_LOOKUP_F64(user_2, config->args, "-user_2", false, false); 1351 PXOPT_LOOKUP_F64(user_3, config->args, "-user_3", false, false); 1352 PXOPT_LOOKUP_F64(user_4, config->args, "-user_4", false, false); 1353 PXOPT_LOOKUP_F64(user_5, config->args, "-user_5", false, false); 1354 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 1355 1356 // default values 1357 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 2387 1358 2388 1359 // find the matching rawImfile by exp_id/class_id … … 2396 1367 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 2397 1368 psFree(where); 2398 return false;2399 }2400 2401 // default values2402 psS16 code = psMetadataLookupS16(&status, config->args, "-code");2403 if (!status) {2404 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");2405 1369 return false; 2406 1370 } … … 2453 1417 PS_ASSERT_PTR_NON_NULL(config, false); 2454 1418 2455 bool status = false; 2456 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 2457 if (!status) { 2458 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 2459 return false; 2460 } 1419 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1420 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2461 1421 2462 1422 psString query = pxDataGet("dettool_toprocessedexp.sql"); … … 2500 1460 } 2501 1461 2502 bool simple = false;2503 {2504 bool status = false;2505 simple = psMetadataLookupBool(&status, config->args, "-simple");2506 if (!status) {2507 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");2508 return false;2509 }2510 }2511 2512 1462 // negative simple so the default is true 2513 1463 if (!ippdbPrintMetadatas(stdout, output, "detPendingProcessedExp", !simple)) { … … 2528 1478 // det_id, exp_id, recip, -bg, -bg_stdev 2529 1479 // are required 2530 bool status = false; 2531 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 2532 if (!status) { 2533 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 2534 return false; 2535 } 2536 if (!det_id) { 2537 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 2538 return false; 2539 } 2540 psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id"); 2541 if (!status) { 2542 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id"); 2543 return false; 2544 } 2545 if (!exp_id) { 2546 psError(PS_ERR_UNKNOWN, true, "-exp_id is required"); 2547 return false; 2548 } 2549 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 2550 if (!status) { 2551 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip"); 2552 return false; 2553 } 2554 if (!recipe) { 2555 psError(PS_ERR_UNKNOWN, true, "-recip is required"); 2556 return false; 2557 } 2558 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 2559 if (!status) { 2560 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 2561 return false; 2562 } 2563 //if (isnan(bg)) { 2564 // psError(PS_ERR_UNKNOWN, true, "-bg is required"); 2565 // return false; 2566 //} 2567 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 2568 if (!status) { 2569 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 2570 return false; 2571 } 2572 //if (isnan(bg_stdev)) { 2573 // psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required"); 2574 // return false; 2575 //} 2576 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 2577 if (!status) { 2578 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 2579 return false; 2580 } 1480 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 1481 PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", true, false); 1482 PXOPT_LOOKUP_STR(recipe, config->args, "-recip", true, false); 1483 2581 1484 // optional 2582 psF64 fringe_0 = psMetadataLookupF64(&status, config->args, "-fringe_0"); 2583 if (!status) { 2584 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_0"); 2585 return false; 2586 } 2587 psF64 fringe_1 = psMetadataLookupF64(&status, config->args, "-fringe_1"); 2588 if (!status) { 2589 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_1"); 2590 return false; 2591 } 2592 psF64 fringe_2 = psMetadataLookupF64(&status, config->args, "-fringe_2"); 2593 if (!status) { 2594 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_2"); 2595 return false; 2596 } 2597 2598 psF64 user_1 = psMetadataLookupF64(&status, config->args, "-user_1"); 2599 if (!status) { 2600 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_1"); 2601 return false; 2602 } 2603 psF64 user_2 = psMetadataLookupF64(&status, config->args, "-user_2"); 2604 if (!status) { 2605 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_2"); 2606 return false; 2607 } 2608 psF64 user_3 = psMetadataLookupF64(&status, config->args, "-user_3"); 2609 if (!status) { 2610 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_3"); 2611 return false; 2612 } 2613 psF64 user_4 = psMetadataLookupF64(&status, config->args, "-user_4"); 2614 if (!status) { 2615 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_4"); 2616 return false; 2617 } 2618 psF64 user_5 = psMetadataLookupF64(&status, config->args, "-user_5"); 2619 if (!status) { 2620 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_5"); 2621 return false; 2622 } 2623 2624 psString path_base = psMetadataLookupStr(&status, config->args, "-path_base"); 2625 if (!status) { 2626 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base"); 2627 return false; 2628 } 2629 1485 PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false); 1486 PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false); 1487 PXOPT_LOOKUP_F64(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 1488 PXOPT_LOOKUP_F64(fringe_0, config->args, "-fringe_0", false, false); 1489 PXOPT_LOOKUP_F64(fringe_1, config->args, "-fringe_1", false, false); 1490 PXOPT_LOOKUP_F64(fringe_2, config->args, "-fringe_2", false, false); 1491 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 1492 PXOPT_LOOKUP_F64(user_2, config->args, "-user_2", false, false); 1493 PXOPT_LOOKUP_F64(user_3, config->args, "-user_3", false, false); 1494 PXOPT_LOOKUP_F64(user_4, config->args, "-user_4", false, false); 1495 PXOPT_LOOKUP_F64(user_5, config->args, "-user_5", false, false); 1496 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false); 1497 2630 1498 // default values 2631 psS16 code = psMetadataLookupS16(&status, config->args, "-code"); 2632 if (!status) { 2633 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 2634 return false; 2635 } 1499 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 2636 1500 2637 1501 psString query = psStringCopy( … … 2727 1591 PS_ASSERT_PTR_NON_NULL(config, false); 2728 1592 2729 bool status = false; 2730 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 2731 if (!status) { 2732 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 2733 return false; 2734 } 2735 2736 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 2737 if (!status) { 2738 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 2739 return false; 2740 } 1593 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1594 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1595 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 2741 1596 2742 1597 psString query = psStringCopy("SELECT * FROM detProcessedExp"); … … 2781 1636 } 2782 1637 2783 bool simple = false;2784 {2785 bool status = false;2786 simple = psMetadataLookupBool(&status, config->args, "-simple");2787 if (!status) {2788 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");2789 return false;2790 }2791 }2792 2793 1638 // negative simple so the default is true 2794 1639 if (!ippdbPrintMetadatas(stdout, output, "detProcessedExp", !simple)) { … … 2840 1685 PS_ASSERT_PTR_NON_NULL(config, false); 2841 1686 2842 bool status = false; 2843 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 2844 if (!status) { 2845 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 2846 return false; 2847 } 1687 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1688 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2848 1689 2849 1690 psString query = pxDataGet("dettool_tostacked.sql"); … … 2887 1728 } 2888 1729 2889 bool simple = false;2890 {2891 bool status = false;2892 simple = psMetadataLookupBool(&status, config->args, "-simple");2893 if (!status) {2894 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");2895 return false;2896 }2897 }2898 2899 1730 // negative simple so the default is true 2900 1731 if (!ippdbPrintMetadatas(stdout, output, "detPendingStackedImfile", !simple)) { … … 2914 1745 2915 1746 char *value = NULL; 2916 bool status = false; 2917 2918 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 2919 if (!status) { 2920 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 2921 return false; 2922 } 2923 2924 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 2925 if (!status) { 2926 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 2927 return false; 2928 } 1747 1748 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1749 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1750 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 2929 1751 2930 1752 psString query = psStringCopy( … … 2947 1769 2948 1770 // add the two required restrictions: detRun.state and detRun.mode 2949 if ((value = psMetadataLookupStr(&status, config->args, "-select_state"))) { 2950 psStringAppend(&query, " detRun.state = '%s'", value); 2951 } else { 2952 psStringAppend(&query, " detRun.state = 'run'"); 2953 } 2954 if ((value = psMetadataLookupStr(&status, config->args, "-select_mode"))) { 2955 psStringAppend(&query, " AND detRun.mode = '%s'", value); 2956 } else { 2957 psStringAppend(&query, " AND detRun.mode = 'master'"); 1771 { 1772 bool status; 1773 if ((value = psMetadataLookupStr(&status, config->args, "-select_state"))) { 1774 psStringAppend(&query, " detRun.state = '%s'", value); 1775 } else { 1776 psStringAppend(&query, " detRun.state = 'run'"); 1777 } 1778 if ((value = psMetadataLookupStr(&status, config->args, "-select_mode"))) { 1779 psStringAppend(&query, " AND detRun.mode = '%s'", value); 1780 } else { 1781 psStringAppend(&query, " AND detRun.mode = 'master'"); 1782 } 2958 1783 } 2959 1784 … … 3010 1835 } 3011 1836 3012 bool simple = false;3013 {3014 bool status = false;3015 simple = psMetadataLookupBool(&status, config->args, "-simple");3016 if (!status) {3017 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");3018 return false;3019 }3020 }3021 3022 1837 // negative simple so the default is true 3023 1838 if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) { … … 3070 1885 3071 1886 // det_id, class_id, uri, & recipe are required 3072 bool status = false; 3073 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 3074 if (!status) { 3075 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 3076 return false; 3077 } 3078 if (!det_id) { 3079 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 3080 return false; 3081 } 3082 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 3083 if (!status) { 3084 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 3085 return false; 3086 } 3087 if (!class_id) { 3088 psError(PS_ERR_UNKNOWN, true, "-class_id is required"); 3089 return false; 3090 } 3091 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 3092 if (!status) { 3093 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 3094 return false; 3095 } 3096 if (!uri) { 3097 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 3098 return false; 3099 } 3100 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 3101 if (!status) { 3102 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip"); 3103 return false; 3104 } 3105 if (!recipe) { 3106 psError(PS_ERR_UNKNOWN, true, "-recip is required"); 3107 return false; 3108 } 3109 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 3110 if (!status) { 3111 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 3112 return false; 3113 } 3114 //if (isnan(bg)) { 3115 // psError(PS_ERR_UNKNOWN, true, "-bg is required"); 3116 // return false; 3117 //} 3118 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 3119 if (!status) { 3120 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 3121 return false; 3122 } 3123 //if (isnan(bg_stdev)) { 3124 // psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required"); 3125 // return false; 3126 //} 3127 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 3128 if (!status) { 3129 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 3130 return false; 3131 } 3132 3133 // optional values 3134 psF64 user_1 = psMetadataLookupF64(&status, config->args, "-user_1"); 3135 if (!status) { 3136 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_1"); 3137 return false; 3138 } 3139 psF64 user_2 = psMetadataLookupF64(&status, config->args, "-user_2"); 3140 if (!status) { 3141 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_2"); 3142 return false; 3143 } 3144 psF64 user_3 = psMetadataLookupF64(&status, config->args, "-user_3"); 3145 if (!status) { 3146 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_3"); 3147 return false; 3148 } 3149 psF64 user_4 = psMetadataLookupF64(&status, config->args, "-user_4"); 3150 if (!status) { 3151 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_4"); 3152 return false; 3153 } 3154 psF64 user_5 = psMetadataLookupF64(&status, config->args, "-user_5"); 3155 if (!status) { 3156 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_5"); 3157 return false; 3158 } 1887 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 1888 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 1889 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 1890 PXOPT_LOOKUP_STR(recipe, config->args, "-recip", true, false); 1891 1892 // optional 1893 PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false); 1894 PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false); 1895 PXOPT_LOOKUP_F64(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 1896 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 1897 PXOPT_LOOKUP_F64(user_2, config->args, "-user_2", false, false); 1898 PXOPT_LOOKUP_F64(user_3, config->args, "-user_3", false, false); 1899 PXOPT_LOOKUP_F64(user_4, config->args, "-user_4", false, false); 1900 PXOPT_LOOKUP_F64(user_5, config->args, "-user_5", false, false); 3159 1901 3160 1902 // default values 3161 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration"); 3162 if (!status) { 3163 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration"); 3164 return false; 3165 } 3166 3167 psS16 code = psMetadataLookupS16(&status, config->args, "-code"); 3168 if (!status) { 3169 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 3170 return false; 3171 } 1903 PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false); 1904 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 3172 1905 3173 1906 // correlate the class_id against the input exposure(s) … … 3246 1979 PS_ASSERT_PTR_NON_NULL(config, false); 3247 1980 3248 bool status = false; 3249 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 3250 if (!status) { 3251 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 3252 return false; 3253 } 3254 3255 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 3256 if (!status) { 3257 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 3258 return false; 3259 } 1981 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1982 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1983 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 3260 1984 3261 1985 // select detStackedImfile.* … … 3313 2037 } 3314 2038 3315 bool simple = false;3316 {3317 bool status = false;3318 simple = psMetadataLookupBool(&status, config->args, "-simple");3319 if (!status) {3320 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");3321 psFree(output);3322 return false;3323 }3324 }3325 3326 2039 // negative simple so the default is true 3327 2040 if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) { … … 3372 2085 PS_ASSERT_PTR_NON_NULL(config, false); 3373 2086 3374 bool status = false; 3375 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 3376 if (!status) { 3377 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 3378 return false; 3379 } 2087 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2088 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 3380 2089 3381 2090 psString query = pxDataGet("dettool_tonormalizedstat.sql"); … … 3419 2128 } 3420 2129 3421 bool simple = false;3422 {3423 bool status = false;3424 simple = psMetadataLookupBool(&status, config->args, "-simple");3425 if (!status) {3426 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");3427 return false;3428 }3429 }3430 3431 2130 // negative simple so the default is true 3432 2131 if (!ippdbPrintMetadatas(stdout, output, "detPendingNormStatImfile", !simple)) { … … 3445 2144 PS_ASSERT_PTR_NON_NULL(config, NULL); 3446 2145 3447 // select * from detStackedImfile 3448 // by det_id, iteration, class_id 3449 // where det_id, iteration, class_id is not in detNormalizedStatImfile 3450 psString query = psStringCopy( 3451 "SELECT DISTINCT" 3452 " detStackedImfile.*" 3453 " FROM detStackedImfile" 3454 " LEFT JOIN detNormalizedStatImfile" 3455 " USING(det_id, iteration, class_id)" 3456 " WHERE" 3457 " detNormalizedStatImfile.det_id IS NULL" 3458 " AND detNormalizedStatImfile.iteration IS NULL" 3459 " AND detNormalizedStatImfile.class_id IS NULL" 3460 ); 3461 3462 if (config->where) { 3463 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "detStackedImfile"); 3464 psStringAppend(&query, " AND %s", whereClause); 3465 psFree(whereClause); 3466 } 3467 3468 if (!p_psDBRunQuery(config->dbh, query)) { 3469 psError(PS_ERR_UNKNOWN, false, "database error"); 3470 psFree(query); 3471 return false; 3472 } 3473 psFree(query); 3474 3475 psArray *output = p_psDBFetchResult(config->dbh); 3476 if (!output) { 3477 psError(PS_ERR_UNKNOWN, false, "database error"); 3478 return false; 3479 } 3480 if (!psArrayLength(output)) { 3481 psTrace("dettool", PS_LOG_INFO, "no rows found"); 3482 psFree(output); 3483 return true; 3484 } 3485 3486 // start a transaction so it's all rows or nothing 3487 if (!psDBTransaction(config->dbh)) { 3488 psError(PS_ERR_UNKNOWN, false, "database error"); 3489 psFree(output); 3490 return false; 3491 } 3492 3493 for (long i = 0; i < psArrayLength(output); i++) { 3494 psMetadata *row = output->data[i]; 3495 // convert metadata into a detStackedImfile object 3496 detStackedImfileRow *stackedImfile = detStackedImfileObjectFromMetadata(row); 3497 // convert detStackedImfile object into a detNormalizedStat object 3498 detNormalizedStatImfileRow *stat = detStackedToDetNormalizedStatImfile(config, stackedImfile); 3499 psFree(stackedImfile); 3500 if (!stat) { 3501 if (!psDBRollback(config->dbh)) { 3502 psError(PS_ERR_UNKNOWN, false, "database error"); 3503 } 3504 psError(PS_ERR_UNKNOWN, false, "failed to convert detStackedImfile to detNormalizedStatImfile"); 3505 psFree(output); 3506 return false; 3507 } 3508 // insert detNormlized Stat object into the database 3509 if (!detNormalizedStatImfileInsertObject(config->dbh, stat)) { 3510 if (!psDBRollback(config->dbh)) { 3511 psError(PS_ERR_UNKNOWN, false, "database error"); 3512 } 3513 psError(PS_ERR_UNKNOWN, false, "database error"); 3514 psFree(stat); 3515 psFree(output); 3516 } 3517 psFree(stat); 3518 } 3519 3520 psFree(output); 3521 3522 if (!psDBCommit(config->dbh)) { 3523 psError(PS_ERR_UNKNOWN, false, "database error"); 3524 return false; 3525 } 3526 3527 return true; 3528 } 3529 3530 static detNormalizedStatImfileRow *detStackedToDetNormalizedStatImfile(pxConfig *config, detStackedImfileRow *stackedImfile) 3531 { 3532 PS_ASSERT_PTR_NON_NULL(config, NULL); 3533 PS_ASSERT_PTR_NON_NULL(stackedImfile, NULL); 3534 3535 bool status = false; 3536 psF32 norm = psMetadataLookupF32(&status, config->args, "-norm"); 3537 if (!status) { 3538 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -norm"); 3539 return false; 3540 } 3541 //if (isnan(norm)) { 3542 // psError(PS_ERR_UNKNOWN, true, "-norm is required"); 3543 // return false; 3544 //} 3545 3546 // default values 3547 psS16 code = psMetadataLookupS16(&status, config->args, "-code"); 3548 if (!status) { 3549 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 3550 return false; 3551 } 3552 3553 return detNormalizedStatImfileRowAlloc( 3554 stackedImfile->det_id, 3555 stackedImfile->iteration, 3556 stackedImfile->class_id, 2146 // required 2147 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 2148 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 2149 2150 // optional 2151 PXOPT_LOOKUP_F32(norm, config->args, "-norm", false, false); 2152 2153 // default 2154 PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false); 2155 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 2156 2157 if (!detNormalizedStatImfileInsert(config->dbh, 2158 (psS64)atoll(det_id), 2159 iteration, 2160 class_id, 3557 2161 norm, 3558 2162 code 3559 ); 2163 )) { 2164 psError(PS_ERR_UNKNOWN, false, "database error"); 2165 return false; 2166 } 2167 2168 return true; 3560 2169 } 3561 2170 … … 3565 2174 PS_ASSERT_PTR_NON_NULL(config, false); 3566 2175 3567 bool status = false; 3568 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 3569 if (!status) { 3570 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 3571 return false; 3572 } 3573 3574 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 3575 if (!status) { 3576 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 3577 return false; 3578 } 2176 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2177 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2178 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 3579 2179 3580 2180 psString query = pxDataGet("dettool_normalizedstat.sql"); … … 3623 2223 } 3624 2224 3625 bool simple = false;3626 {3627 bool status = false;3628 simple = psMetadataLookupBool(&status, config->args, "-simple");3629 if (!status) {3630 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");3631 psFree(output);3632 return false;3633 }3634 }3635 3636 2225 // negative simple so the default is true 3637 2226 if (!ippdbPrintMetadatas(stdout, output, "detNormalizedStatImfile", !simple)) { … … 3681 2270 PS_ASSERT_PTR_NON_NULL(config, false); 3682 2271 3683 bool status = false; 3684 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 3685 if (!status) { 3686 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 3687 return false; 3688 } 2272 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2273 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 3689 2274 3690 2275 // select detNormalizedStatImfile.* … … 3755 2340 } 3756 2341 3757 bool simple = false;3758 {3759 bool status = false;3760 simple = psMetadataLookupBool(&status, config->args, "-simple");3761 if (!status) {3762 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");3763 psFree(output);3764 return false;3765 }3766 }3767 3768 2342 // negative simple so the default is true 3769 2343 if (!ippdbPrintMetadatas(stdout, output, "detPendingNormImfile", !simple)) { … … 3873 2447 PS_ASSERT_PTR_NON_NULL(config, false); 3874 2448 3875 // make sure that there is a respondoing entry in detNormalizedStatImfile 3876 // select * from detNormalizedStatImfile 3877 // by det_id, iteration, class_id 3878 // where det_id, iteration, class_id is not in detNormalizedImfile 3879 psString query = psStringCopy( 3880 "SELECT" 3881 " detNormalizedStatImfile.*" 3882 " FROM detNormalizedStatImfile" 3883 " LEFT JOIN detNormalizedImfile" 3884 " USING(det_id, iteration, class_id)" 3885 " WHERE" 3886 " detNormalizedImfile.det_id IS NULL" 3887 " AND detNormalizedImfile.iteration IS NULL" 3888 " AND detNormalizedImfile.class_id IS NULL" 3889 ); 3890 3891 { 3892 // build a query to search by det_id, iteration, class_id 3893 psMetadata *where = psMetadataAlloc(); 3894 bool status = false; 3895 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 3896 if (!status) { 3897 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 3898 psFree(where); 3899 psFree(query); 3900 return false; 3901 } 3902 if (det_id) { 3903 if (!psMetadataAddStr(where, PS_LIST_TAIL, "det_id", 0, "==", det_id)) { 3904 psError(PS_ERR_UNKNOWN, false, "failed to add item det_id"); 3905 psFree(where); 3906 psFree(query); 3907 return false; 3908 } 3909 } 3910 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration"); 3911 if (!status) { 3912 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration"); 3913 psFree(where); 3914 psFree(query); 3915 return false; 3916 } 3917 // always set iteration 3918 if (!psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==", iteration)) { 3919 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration"); 3920 psFree(where); 3921 psFree(query); 3922 return false; 3923 } 3924 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 3925 if (!status) { 3926 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 3927 psFree(where); 3928 psFree(query); 3929 return false; 3930 } 3931 if (class_id) { 3932 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) { 3933 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 3934 psFree(where); 3935 psFree(query); 3936 return false; 3937 } 3938 } 3939 3940 // there's not 3941 psString whereClause = psDBGenerateWhereConditionSQL(where, "detNormalizedStatImfile"); 3942 psFree(where); 3943 if (whereClause) { 3944 psStringAppend(&query, " AND %s", whereClause); 3945 psFree(whereClause); 3946 } 3947 } 3948 3949 if (!p_psDBRunQuery(config->dbh, query)) { 3950 psError(PS_ERR_UNKNOWN, false, "database error"); 3951 psFree(query); 3952 return false; 3953 } 3954 psFree(query); 3955 3956 psArray *output = p_psDBFetchResult(config->dbh); 3957 if (!output) { 3958 psError(PS_ERR_UNKNOWN, false, "database error"); 3959 return false; 3960 } 3961 if (!psArrayLength(output)) { 3962 psTrace("dettool", PS_LOG_INFO, "no rows found"); 3963 psFree(output); 3964 return true; 3965 } 3966 3967 // start a transaction so it's all rows or nothing 3968 if (!psDBTransaction(config->dbh)) { 3969 psError(PS_ERR_UNKNOWN, false, "database error"); 3970 psFree(output); 3971 return false; 3972 } 3973 3974 for (long i = 0; i < psArrayLength(output); i++) { 3975 psMetadata *row = output->data[i]; 3976 // convert metadata into a detNormalizedStatImfile object 3977 detNormalizedStatImfileRow *statImfile = detNormalizedStatImfileObjectFromMetadata(row); 3978 // convert detNormalizedStatImfile object into a detNormalizedImfile 3979 detNormalizedImfileRow *normalizedImfile = detNormalizedStatToDetNormalizedmfile(config, statImfile); 3980 psFree(statImfile); 3981 if (!normalizedImfile) { 3982 if (!psDBRollback(config->dbh)) { 3983 psError(PS_ERR_UNKNOWN, false, "database error"); 3984 } 3985 psError(PS_ERR_UNKNOWN, false, "failed to convert detStackedImfile to detNormalizedStatImfile"); 3986 psFree(output); 3987 return false; 3988 } 3989 // insert detNormlized Stat object into the database 3990 if (!detNormalizedImfileInsertObject(config->dbh, normalizedImfile)) { 3991 if (!psDBRollback(config->dbh)) { 3992 psError(PS_ERR_UNKNOWN, false, "database error"); 3993 } 3994 psError(PS_ERR_UNKNOWN, false, "database error"); 3995 psFree(normalizedImfile); 3996 psFree(output); 3997 } 3998 psFree(normalizedImfile); 3999 } 4000 4001 psFree(output); 4002 4003 if (!psDBCommit(config->dbh)) { 2449 // required 2450 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 2451 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 2452 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 2453 2454 // optional 2455 PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false); 2456 PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false); 2457 PXOPT_LOOKUP_F64(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 2458 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 2459 PXOPT_LOOKUP_F64(user_2, config->args, "-user_2", false, false); 2460 PXOPT_LOOKUP_F64(user_3, config->args, "-user_3", false, false); 2461 PXOPT_LOOKUP_F64(user_4, config->args, "-user_4", false, false); 2462 PXOPT_LOOKUP_F64(user_5, config->args, "-user_5", false, false); 2463 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 2464 2465 // default values 2466 PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false); 2467 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 2468 2469 if (!detNormalizedImfileInsert(config->dbh, 2470 (psS64)atoll(det_id), 2471 iteration, 2472 class_id, 2473 uri, 2474 bg, 2475 bg_stdev, 2476 bg_mean_stdev, 2477 user_1, 2478 user_2, 2479 user_3, 2480 user_4, 2481 user_5, 2482 path_base, 2483 code 2484 )) { 4004 2485 psError(PS_ERR_UNKNOWN, false, "database error"); 4005 2486 return false; … … 4014 2495 PS_ASSERT_PTR_NON_NULL(config, false); 4015 2496 4016 bool status = false; 4017 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 4018 if (!status) { 4019 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 4020 return false; 4021 } 4022 4023 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 4024 if (!status) { 4025 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 4026 return false; 4027 } 2497 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2498 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2499 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 4028 2500 4029 2501 psString query = psStringCopy( … … 4083 2555 } 4084 2556 4085 bool simple = false;4086 {4087 bool status = false;4088 simple = psMetadataLookupBool(&status, config->args, "-simple");4089 if (!status) {4090 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");4091 return false;4092 }4093 }4094 4095 2557 // negative simple so the default is true 4096 2558 if (!ippdbPrintMetadatas(stdout, output, "detNormalizedImfile", !simple)) { … … 4142 2604 PS_ASSERT_PTR_NON_NULL(config, false); 4143 2605 4144 bool status = false; 4145 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 4146 if (!status) { 4147 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 4148 return false; 4149 } 2606 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2607 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 4150 2608 4151 2609 psString query = pxDataGet("dettool_tonormalizedexp.sql"); … … 4189 2647 } 4190 2648 4191 bool simple = false;4192 {4193 bool status = false;4194 simple = psMetadataLookupBool(&status, config->args, "-simple");4195 if (!status) {4196 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");4197 return false;4198 }4199 }4200 4201 2649 // negative simple so the default is true 4202 2650 if (!ippdbPrintMetadatas(stdout, output, "detPendingNormExp", !simple)) { … … 4215 2663 PS_ASSERT_PTR_NON_NULL(config, false); 4216 2664 4217 // det_id, recip, -bg, -bg_stdev 4218 // are required 4219 bool status = false; 4220 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 4221 if (!status) { 4222 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 4223 return false; 4224 } 4225 if (!det_id) { 4226 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 4227 return false; 4228 } 4229 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 4230 if (!status) { 4231 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip"); 4232 return false; 4233 } 4234 if (!recipe) { 4235 psError(PS_ERR_UNKNOWN, true, "-recip is required"); 4236 return false; 4237 } 4238 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 4239 if (!status) { 4240 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 4241 return false; 4242 } 4243 //if (isnan(bg)) { 4244 // psError(PS_ERR_UNKNOWN, true, "-bg is required"); 4245 // return false; 4246 //} 4247 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 4248 if (!status) { 4249 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 4250 return false; 4251 } 4252 //if (isnan(bg_stdev)) { 4253 // psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required"); 4254 // return false; 4255 //} 4256 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 4257 if (!status) { 4258 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 4259 return false; 4260 } 2665 // required 2666 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 2667 PXOPT_LOOKUP_STR(recipe, config->args, "-recip", true, false); 4261 2668 4262 2669 // optional 4263 psF64 user_1 = psMetadataLookupF64(&status, config->args, "-user_1"); 4264 if (!status) { 4265 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_1"); 4266 return false; 4267 } 4268 psF64 user_2 = psMetadataLookupF64(&status, config->args, "-user_2"); 4269 if (!status) { 4270 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_2"); 4271 return false; 4272 } 4273 psF64 user_3 = psMetadataLookupF64(&status, config->args, "-user_3"); 4274 if (!status) { 4275 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_3"); 4276 return false; 4277 } 4278 psF64 user_4 = psMetadataLookupF64(&status, config->args, "-user_4"); 4279 if (!status) { 4280 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_4"); 4281 return false; 4282 } 4283 psF64 user_5 = psMetadataLookupF64(&status, config->args, "-user_5"); 4284 if (!status) { 4285 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_5"); 4286 return false; 4287 } 4288 4289 // iteration has a default value 4290 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration"); 4291 if (!status) { 4292 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration"); return false; 4293 } 4294 4295 psS16 code = psMetadataLookupS16(&status, config->args, "-code"); 4296 if (!status) { 4297 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 4298 return false; 4299 } 4300 4301 // optional 4302 psString path_base = psMetadataLookupStr(&status, config->args, "-path_base"); 4303 if (!status) { 4304 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base"); 4305 return false; 4306 } 2670 PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false); 2671 PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false); 2672 PXOPT_LOOKUP_F64(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 2673 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 2674 PXOPT_LOOKUP_F64(user_2, config->args, "-user_2", false, false); 2675 PXOPT_LOOKUP_F64(user_3, config->args, "-user_3", false, false); 2676 PXOPT_LOOKUP_F64(user_4, config->args, "-user_4", false, false); 2677 PXOPT_LOOKUP_F64(user_5, config->args, "-user_5", false, false); 2678 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 2679 2680 // default values 2681 PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false); 2682 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 4307 2683 4308 2684 psString query = pxDataGet("dettool_tonormalizedexp.sql"); … … 4336 2712 psFree(output); 4337 2713 4338 // create a new detProcessedImfile object4339 detNormalizedExpRow *detRow = detNormalizedExpRowAlloc(4340 (psS 32)atoll(det_id),2714 // insert the new row into the detProcessedImfile table 2715 if (!detNormalizedExpInsert(config->dbh, 2716 (psS64)atoll(det_id), 4341 2717 iteration, 4342 2718 recipe, … … 4351 2727 path_base, 4352 2728 code 4353 ); 4354 4355 // insert the new row into the detProcessedImfile table 4356 if (!detNormalizedExpInsertObject(config->dbh, detRow)) { 4357 psError(PS_ERR_UNKNOWN, false, "database error"); 4358 psFree(detRow); 4359 return false; 4360 } 4361 4362 psFree(detRow); 2729 )) { 2730 psError(PS_ERR_UNKNOWN, false, "database error"); 2731 return false; 2732 } 4363 2733 4364 2734 return true; … … 4370 2740 PS_ASSERT_PTR_NON_NULL(config, false); 4371 2741 4372 bool status = false; 4373 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 4374 if (!status) { 4375 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 4376 return false; 4377 } 4378 4379 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 4380 if (!status) { 4381 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 4382 return false; 4383 } 2742 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2743 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2744 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 4384 2745 4385 2746 psString query = psStringCopy( … … 4433 2794 } 4434 2795 4435 bool simple = false;4436 {4437 bool status = false;4438 simple = psMetadataLookupBool(&status, config->args, "-simple");4439 if (!status) {4440 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");4441 return false;4442 }4443 }4444 4445 2796 // negative simple so the default is true 4446 2797 if (!ippdbPrintMetadatas(stdout, output, "detNormalizedExp", !simple)) { … … 4455 2806 } 4456 2807 4457 4458 static detNormalizedImfileRow *detNormalizedStatToDetNormalizedmfile(pxConfig *config, detNormalizedStatImfileRow *statImfile)4459 {4460 PS_ASSERT_PTR_NON_NULL(config, NULL);4461 PS_ASSERT_PTR_NON_NULL(statImfile, NULL);4462 4463 bool status = false;4464 psString uri = psMetadataLookupStr(&status, config->args, "-uri");4465 if (!status) {4466 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri");4467 return false;4468 }4469 if (!uri) {4470 psError(PS_ERR_UNKNOWN, true, "-uri is required");4471 return false;4472 }4473 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");4474 if (!status) {4475 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg");4476 return false;4477 }4478 //if (isnan(bg)) {4479 // psError(PS_ERR_UNKNOWN, true, "-bg is required");4480 // return false;4481 //}4482 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev");4483 if (!status) {4484 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev");4485 return false;4486 }4487 //if (isnan(bg_stdev)) {4488 // psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required");4489 // return false;4490 //}4491 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev");4492 if (!status) {4493 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev");4494 return false;4495 }4496 // optional4497 psF64 user_1 = psMetadataLookupF64(&status, config->args, "-user_1");4498 if (!status) {4499 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_1");4500 return false;4501 }4502 psF64 user_2 = psMetadataLookupF64(&status, config->args, "-user_2");4503 if (!status) {4504 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_2");4505 return false;4506 }4507 psF64 user_3 = psMetadataLookupF64(&status, config->args, "-user_3");4508 if (!status) {4509 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_3");4510 return false;4511 }4512 psF64 user_4 = psMetadataLookupF64(&status, config->args, "-user_4");4513 if (!status) {4514 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_4");4515 return false;4516 }4517 psF64 user_5 = psMetadataLookupF64(&status, config->args, "-user_5");4518 if (!status) {4519 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_5");4520 return false;4521 }4522 4523 // optional4524 psString path_base = psMetadataLookupStr(&status, config->args, "-path_base");4525 if (!status) {4526 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base");4527 return false;4528 }4529 4530 // default values4531 psS16 code = psMetadataLookupS16(&status, config->args, "-code");4532 if (!status) {4533 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");4534 return false;4535 }4536 4537 return detNormalizedImfileRowAlloc(4538 statImfile->det_id,4539 statImfile->iteration,4540 statImfile->class_id,4541 uri,4542 bg,4543 bg_stdev,4544 bg_mean_stdev,4545 user_1,4546 user_2,4547 user_3,4548 user_4,4549 user_5,4550 path_base,4551 code4552 );4553 }4554 2808 4555 2809 … … 4590 2844 PS_ASSERT_PTR_NON_NULL(config, false); 4591 2845 4592 bool status = false; 4593 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 4594 if (!status) { 4595 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 4596 return false; 4597 } 2846 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2847 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 4598 2848 4599 2849 psString query = pxDataGet("dettool_toresidimfile.sql"); … … 4637 2887 } 4638 2888 4639 bool simple = false;4640 {4641 bool status = false;4642 simple = psMetadataLookupBool(&status, config->args, "-simple");4643 if (!status) {4644 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");4645 psFree(output);4646 return false;4647 }4648 }4649 4650 2889 // negative simple so the default is true 4651 2890 if (!ippdbPrintMetadatas(stdout, output, "detPendingResidImfile", !simple)) { … … 4665 2904 PS_ASSERT_PTR_NON_NULL(config, false); 4666 2905 4667 bool status = false; 4668 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 4669 if (!status) { 4670 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 4671 return false; 4672 } 4673 if (!det_id) { 4674 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 4675 return false; 4676 } 4677 4678 // defaults to 0 4679 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration"); 4680 if (!status) { 4681 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration"); 4682 return false; 4683 } 4684 4685 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 4686 if (!status) { 4687 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 4688 return false; 4689 } 4690 if (!class_id) { 4691 psError(PS_ERR_UNKNOWN, false, "-class_id is required"); 4692 return false; 4693 } 4694 4695 psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id"); 4696 if (!status) { 4697 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id"); 4698 return false; 4699 } 4700 if (!exp_id) { 4701 psError(PS_ERR_UNKNOWN, true, "-exp_id is required"); 4702 return false; 4703 } 4704 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 4705 if (!status) { 4706 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 4707 return false; 4708 } 4709 if (!uri) { 4710 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 4711 return false; 4712 } 4713 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 4714 if (!status) { 4715 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip"); 4716 return false; 4717 } 4718 if (!recipe) { 4719 psError(PS_ERR_UNKNOWN, true, "-recip is required"); 4720 return false; 4721 } 4722 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 4723 if (!status) { 4724 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 4725 return false; 4726 } 4727 //if (isnan(bg)) { 4728 // psError(PS_ERR_UNKNOWN, true, "-bg is required"); 4729 // return false; 4730 //} 4731 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 4732 if (!status) { 4733 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 4734 return false; 4735 } 4736 //if (isnan(bg_stdev)) { 4737 // psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required"); 4738 // return false; 4739 //} 4740 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 4741 if (!status) { 4742 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 4743 return false; 4744 } 4745 psF64 bg_skewness = psMetadataLookupF64(&status, config->args, "-bg_skewness"); 4746 if (!status) { 4747 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_skewness"); 4748 return false; 4749 } 4750 psF64 bg_kurtosis = psMetadataLookupF64(&status, config->args, "-bg_kurtosis"); 4751 if (!status) { 4752 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_kurtosis"); 4753 return false; 4754 } 4755 psF64 bin_stdev = psMetadataLookupF64(&status, config->args, "-bin_stdev"); 4756 if (!status) { 4757 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bin_stdev"); 4758 return false; 4759 } 2906 // required 2907 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 2908 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 2909 PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", true, false); 2910 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 2911 PXOPT_LOOKUP_STR(recipe, config->args, "-recip", true, false); 4760 2912 4761 2913 // optional 4762 psString path_base = psMetadataLookupStr(&status, config->args, "-path_base"); 4763 if (!status) { 4764 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base"); 4765 return false; 4766 } 4767 4768 // optional 4769 psF64 fringe_0 = psMetadataLookupF64(&status, config->args, "-fringe_0"); 4770 if (!status) { 4771 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_0"); 4772 return false; 4773 } 4774 psF64 fringe_1 = psMetadataLookupF64(&status, config->args, "-fringe_1"); 4775 if (!status) { 4776 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_1"); 4777 return false; 4778 } 4779 psF64 fringe_2 = psMetadataLookupF64(&status, config->args, "-fringe_2"); 4780 if (!status) { 4781 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_2"); 4782 return false; 4783 } 4784 4785 psF64 fringe_resid_0 = psMetadataLookupF64(&status, config->args, "-fringe_resid_0"); 4786 if (!status) { 4787 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_resid_0"); 4788 return false; 4789 } 4790 psF64 fringe_resid_1 = psMetadataLookupF64(&status, config->args, "-fringe_resid_1"); 4791 if (!status) { 4792 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_resid_1"); 4793 return false; 4794 } 4795 psF64 fringe_resid_2 = psMetadataLookupF64(&status, config->args, "-fringe_resid_2"); 4796 if (!status) { 4797 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_resid_2"); 4798 return false; 4799 } 4800 4801 psF64 user_1 = psMetadataLookupF64(&status, config->args, "-user_1"); 4802 if (!status) { 4803 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_1"); 4804 return false; 4805 } 4806 psF64 user_2 = psMetadataLookupF64(&status, config->args, "-user_2"); 4807 if (!status) { 4808 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_2"); 4809 return false; 4810 } 4811 psF64 user_3 = psMetadataLookupF64(&status, config->args, "-user_3"); 4812 if (!status) { 4813 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_3"); 4814 return false; 4815 } 4816 psF64 user_4 = psMetadataLookupF64(&status, config->args, "-user_4"); 4817 if (!status) { 4818 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_4"); 4819 return false; 4820 } 4821 psF64 user_5 = psMetadataLookupF64(&status, config->args, "-user_5"); 4822 if (!status) { 4823 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_5"); 4824 return false; 4825 } 2914 PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false); 2915 PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false); 2916 PXOPT_LOOKUP_F64(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 2917 PXOPT_LOOKUP_F64(bg_skewness, config->args, "-bg_skewness", false, false); 2918 PXOPT_LOOKUP_F64(bg_kurtosis, config->args, "-bg_kurtosis", false, false); 2919 PXOPT_LOOKUP_F64(bin_stdev, config->args, "-bin_stdev", false, false); 2920 2921 PXOPT_LOOKUP_F64(fringe_0, config->args, "-fringe_0", false, false); 2922 PXOPT_LOOKUP_F64(fringe_1, config->args, "-fringe_1", false, false); 2923 PXOPT_LOOKUP_F64(fringe_2, config->args, "-fringe_2", false, false); 2924 PXOPT_LOOKUP_F64(fringe_resid_0, config->args, "-fringe_resid_0", false, false); 2925 PXOPT_LOOKUP_F64(fringe_resid_1, config->args, "-fringe_resid_1", false, false); 2926 PXOPT_LOOKUP_F64(fringe_resid_2, config->args, "-fringe_resid_2", false, false); 2927 2928 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 2929 PXOPT_LOOKUP_F64(user_2, config->args, "-user_2", false, false); 2930 PXOPT_LOOKUP_F64(user_3, config->args, "-user_3", false, false); 2931 PXOPT_LOOKUP_F64(user_4, config->args, "-user_4", false, false); 2932 PXOPT_LOOKUP_F64(user_5, config->args, "-user_5", false, false); 2933 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 4826 2934 4827 2935 // default values 4828 psS16 code = psMetadataLookupS16(&status, config->args, "-code"); 4829 if (!status) { 4830 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 4831 return false; 4832 } 4833 4834 // create a new detResidImfileRow and insert it 4835 if (!detResidImfileInsert( 4836 config->dbh, 2936 PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false); 2937 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 2938 2939 if (!detResidImfileInsert(config->dbh, 4837 2940 (psS64)atoll(det_id), 4838 2941 iteration, … … 4868 2971 } 4869 2972 2973 4870 2974 static bool residimfileMode(pxConfig *config) 4871 2975 { 4872 2976 PS_ASSERT_PTR_NON_NULL(config, false); 4873 2977 4874 char *value = NULL; 4875 bool status = false; 4876 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 4877 if (!status) { 4878 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 4879 return false; 4880 } 4881 4882 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 4883 if (!status) { 4884 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 4885 return false; 4886 } 2978 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2979 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2980 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 4887 2981 4888 2982 // select detResidImfile.* … … 4905 2999 // NOTE the above WHERE is completed with the following line: 4906 3000 3001 char *value = NULL; 3002 4907 3003 // add the two required restrictions: detRun.state and detRun.mode 3004 bool status; 4908 3005 if ((value = psMetadataLookupStr(&status, config->args, "-select_state"))) { 4909 3006 psStringAppend(&query, " detRun.state = '%s'", value); … … 4951 3048 } 4952 3049 4953 bool simple = false;4954 {4955 bool status = false;4956 simple = psMetadataLookupBool(&status, config->args, "-simple");4957 if (!status) {4958 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");4959 psFree(output);4960 return false;4961 }4962 }4963 4964 3050 // negative simple so the default is true 4965 3051 if (!ippdbPrintMetadatas(stdout, output, "rawResidImfile", !simple)) { … … 5018 3104 */ 5019 3105 5020 5021 bool status = false; 5022 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 5023 if (!status) { 5024 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 5025 return false; 5026 } 3106 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 3107 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 5027 3108 5028 3109 psString query = pxDataGet("dettool_toresidexp.sql"); … … 5066 3147 } 5067 3148 5068 bool simple = false;5069 {5070 bool status = false;5071 simple = psMetadataLookupBool(&status, config->args, "-simple");5072 if (!status) {5073 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");5074 return false;5075 }5076 }5077 5078 3149 // negative simple so the default is true 5079 3150 if (!ippdbPrintMetadatas(stdout, output, "detPendingResidExp", !simple)) { … … 5091 3162 { 5092 3163 PS_ASSERT_PTR_NON_NULL(config, false); 3164 3165 // required 3166 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 3167 PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", true, false); 3168 PXOPT_LOOKUP_STR(recipe, config->args, "-recip", true, false); 3169 3170 // optional 3171 PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false); 3172 PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false); 3173 PXOPT_LOOKUP_F64(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 3174 PXOPT_LOOKUP_F64(bg_skewness, config->args, "-bg_skewness", false, false); 3175 PXOPT_LOOKUP_F64(bg_kurtosis, config->args, "-bg_kurtosis", false, false); 3176 PXOPT_LOOKUP_F64(bin_stdev, config->args, "-bin_stdev", false, false); 3177 3178 PXOPT_LOOKUP_F64(fringe_0, config->args, "-fringe_0", false, false); 3179 PXOPT_LOOKUP_F64(fringe_1, config->args, "-fringe_1", false, false); 3180 PXOPT_LOOKUP_F64(fringe_2, config->args, "-fringe_2", false, false); 3181 PXOPT_LOOKUP_F64(fringe_resid_0, config->args, "-fringe_resid_0", false, false); 3182 PXOPT_LOOKUP_F64(fringe_resid_1, config->args, "-fringe_resid_1", false, false); 3183 PXOPT_LOOKUP_F64(fringe_resid_2, config->args, "-fringe_resid_2", false, false); 3184 3185 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 3186 PXOPT_LOOKUP_F64(user_2, config->args, "-user_2", false, false); 3187 PXOPT_LOOKUP_F64(user_3, config->args, "-user_3", false, false); 3188 PXOPT_LOOKUP_F64(user_4, config->args, "-user_4", false, false); 3189 PXOPT_LOOKUP_F64(user_5, config->args, "-user_5", false, false); 3190 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 3191 3192 // default values 3193 PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false); 3194 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 3195 PXOPT_LOOKUP_BOOL(reject, config->args, "-reject", false); 5093 3196 5094 3197 /* … … 5099 3202 */ 5100 3203 5101 5102 // select detRun.det_id5103 // select detRun.iteration5104 // select detRun.det_type5105 // select detInputExp.exp_id5106 // select detInputExp.include5107 // by:5108 // find the current iteration bassed on det_id5109 // find all exp_ids in the current det_id/iteration from detInputExp5110 // compare to detInputExp.imfiles to derResidImfile by class_id5111 // and:5112 // detResidImfile.{det_id, iteration, exp_id} is not in detResidExp5113 5114 3204 psString query = pxDataGet("dettool_toresidexp.sql"); 5115 3205 if (!query) { … … 5121 3211 // build a query to search by det_id, iteration, exp_id 5122 3212 psMetadata *where = psMetadataAlloc(); 5123 bool status = false; 5124 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 5125 if (!status) { 5126 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 5127 return false; 5128 } 5129 if (!det_id) { 5130 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 5131 return false; 5132 } 5133 if (!psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", (psS64)atoll(det_id))) { 5134 psError(PS_ERR_UNKNOWN, false, "failed to add item det_id"); 5135 psFree(where); 5136 psFree(query); 5137 return false; 5138 } 5139 5140 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration"); 5141 if (!status) { 5142 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration"); 5143 psFree(where); 5144 psFree(query); 5145 return false; 5146 } 5147 // always set iteration 5148 if (!psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==", iteration)) { 5149 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration"); 5150 psFree(where); 5151 psFree(query); 5152 return false; 5153 } 5154 psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id"); 5155 if (!status) { 5156 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id"); 5157 psFree(where); 5158 psFree(query); 5159 return false; 5160 } 5161 if (exp_id) { 5162 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) { 5163 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 5164 psFree(where); 5165 psFree(query); 5166 return false; 5167 } 5168 } 3213 3214 PXOPT_COPY_STR(config->args, where, "-det_id", "det_id", "=="); 3215 PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "=="); 3216 PXOPT_COPY_STR(config->args, where, "-exp_id", "exp_id", "=="); 3217 5169 3218 5170 3219 // there's not … … 5195 3244 return false; 5196 3245 } 5197 5198 // start a transaction so it's all rows or nothing5199 if (!psDBTransaction(config->dbh)) {5200 psError(PS_ERR_UNKNOWN, false, "database error");5201 psFree(output);5202 return false;5203 }5204 5205 for (long i = 0; i < psArrayLength(output); i++) {5206 psMetadata *row = output->data[i];5207 // convert metadata into a detResidExp object5208 detResidExpRow *residExp = mdToDetResidExp(config, row);5209 if (!residExp) {5210 if (!psDBRollback(config->dbh)) {5211 psError(PS_ERR_UNKNOWN, false, "database error");5212 }5213 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata to detResidExp");5214 psFree(output);5215 return false;5216 }5217 // insert detResidExp object into the database5218 if (!detResidExpInsertObject(config->dbh, residExp)) {5219 if (!psDBRollback(config->dbh)) {5220 psError(PS_ERR_UNKNOWN, false, "database error");5221 }5222 psError(PS_ERR_UNKNOWN, false, "database error");5223 psFree(residExp);5224 psFree(output);5225 }5226 psFree(residExp);5227 }5228 5229 3246 psFree(output); 5230 3247 5231 if (!psDBCommit(config->dbh)) { 5232 psError(PS_ERR_UNKNOWN, false, "database error"); 5233 return false; 5234 } 5235 5236 return true; 5237 } 5238 5239 static detResidExpRow *mdToDetResidExp(pxConfig *config, psMetadata *row) 5240 { 5241 PS_ASSERT_PTR_NON_NULL(config, NULL); 5242 PS_ASSERT_PTR_NON_NULL(row, NULL); 5243 5244 bool status = false; 5245 // values from row 5246 psS64 det_id = psMetadataLookupS64(&status, row, "det_id"); 5247 if (!status) { 5248 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for det_id"); 5249 return false; 5250 } 5251 //if (isnan(det_id)) { 5252 // psError(PS_ERR_UNKNOWN, true, "det_id is required"); 5253 // return false; 5254 //} 5255 psS32 iteration = psMetadataLookupS32(&status, row, "iteration"); 5256 if (!status) { 5257 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for iteration"); 5258 return false; 5259 } 5260 psS64 exp_id = psMetadataLookupS64(&status, row, "exp_id"); 5261 if (!status) { 5262 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_id"); 5263 return false; 5264 } 5265 if (!exp_id) { 5266 psError(PS_ERR_UNKNOWN, true, "exp_id is required"); 5267 return false; 5268 } 5269 5270 // values from config 5271 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 5272 if (!status) { 5273 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip"); 5274 return false; 5275 } 5276 if (!recipe) { 5277 psError(PS_ERR_UNKNOWN, true, "-recip is required"); 5278 return false; 5279 } 5280 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 5281 if (!status) { 5282 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 5283 return false; 5284 } 5285 //if (isnan(bg)) { 5286 // psError(PS_ERR_UNKNOWN, true, "-bg is required"); 5287 // return false; 5288 //} 5289 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 5290 if (!status) { 5291 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 5292 return false; 5293 } 5294 //if (isnan(bg_stdev)) { 5295 // psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required"); 5296 // return false; 5297 //} 5298 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 5299 if (!status) { 5300 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 5301 return false; 5302 } 5303 psF64 bg_skewness = psMetadataLookupF64(&status, config->args, "-bg_skewness"); 5304 if (!status) { 5305 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_skewness"); 5306 return false; 5307 } 5308 psF64 bg_kurtosis = psMetadataLookupF64(&status, config->args, "-bg_kurtosis"); 5309 if (!status) { 5310 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_kurtosis"); 5311 return false; 5312 } 5313 psF64 bin_stdev = psMetadataLookupF64(&status, config->args, "-bin_stdev"); 5314 if (!status) { 5315 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bin_stdev"); 5316 return false; 5317 } 5318 // optional 5319 psF64 fringe_0 = psMetadataLookupF64(&status, config->args, "-fringe_0"); 5320 if (!status) { 5321 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_0"); 5322 return false; 5323 } 5324 psF64 fringe_1 = psMetadataLookupF64(&status, config->args, "-fringe_1"); 5325 if (!status) { 5326 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_1"); 5327 return false; 5328 } 5329 psF64 fringe_2 = psMetadataLookupF64(&status, config->args, "-fringe_2"); 5330 if (!status) { 5331 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_2"); 5332 return false; 5333 } 5334 5335 psF64 fringe_resid_0 = psMetadataLookupF64(&status, config->args, "-fringe_resid_0"); 5336 if (!status) { 5337 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_resid_0"); 5338 return false; 5339 } 5340 psF64 fringe_resid_1 = psMetadataLookupF64(&status, config->args, "-fringe_resid_1"); 5341 if (!status) { 5342 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_resid_1"); 5343 return false; 5344 } 5345 psF64 fringe_resid_2 = psMetadataLookupF64(&status, config->args, "-fringe_resid_2"); 5346 if (!status) { 5347 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -fringe_resid_2"); 5348 return false; 5349 } 5350 5351 psF64 user_1 = psMetadataLookupF64(&status, config->args, "-user_1"); 5352 if (!status) { 5353 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_1"); 5354 return false; 5355 } 5356 psF64 user_2 = psMetadataLookupF64(&status, config->args, "-user_2"); 5357 if (!status) { 5358 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_2"); 5359 return false; 5360 } 5361 psF64 user_3 = psMetadataLookupF64(&status, config->args, "-user_3"); 5362 if (!status) { 5363 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_3"); 5364 return false; 5365 } 5366 psF64 user_4 = psMetadataLookupF64(&status, config->args, "-user_4"); 5367 if (!status) { 5368 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_4"); 5369 return false; 5370 } 5371 psF64 user_5 = psMetadataLookupF64(&status, config->args, "-user_5"); 5372 if (!status) { 5373 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_5"); 5374 return false; 5375 } 5376 5377 // optional 5378 bool reject = psMetadataLookupBool(&status, config->args, "-reject"); 5379 if (!status) { 5380 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -reject"); 5381 return false; 5382 } 5383 psString path_base = psMetadataLookupStr(&status, config->args, "-path_base"); 5384 if (!status) { 5385 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base"); 5386 return false; 5387 } 5388 if (!path_base) { 5389 psError(PS_ERR_UNKNOWN, true, "-path_base is required"); 5390 return false; 5391 } 5392 5393 // default values 5394 psS16 code = psMetadataLookupS16(&status, config->args, "-code"); 5395 if (!status) { 5396 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 5397 return false; 5398 } 5399 5400 // create a new detResidImfileRow and insert it 5401 return detResidExpRowAlloc( 5402 det_id, 3248 if (!detResidExpInsert(config->dbh, 3249 (psS64)atoll(det_id), 5403 3250 iteration, 5404 exp_id,3251 (psS64)atoll(exp_id), 5405 3252 recipe, 5406 3253 bg, … … 5424 3271 !reject, 5425 3272 code 5426 ); 3273 )) { 3274 psError(PS_ERR_UNKNOWN, false, "database error"); 3275 return false; 3276 } 3277 3278 return true; 5427 3279 } 5428 3280 … … 5431 3283 PS_ASSERT_PTR_NON_NULL(config, false); 5432 3284 5433 bool status = false; 5434 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 5435 if (!status) { 5436 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 5437 return false; 5438 } 5439 5440 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 5441 if (!status) { 5442 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 5443 return false; 5444 } 3285 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 3286 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 3287 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 5445 3288 5446 3289 psString query = psStringCopy( … … 5497 3340 } 5498 3341 5499 bool simple = false;5500 {5501 bool status = false;5502 simple = psMetadataLookupBool(&status, config->args, "-simple");5503 if (!status) {5504 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");5505 return false;5506 }5507 }5508 5509 3342 // negative simple so the default is true 5510 3343 if (!ippdbPrintMetadatas(stdout, output, "detResidExp", !simple)) { … … 5556 3389 PS_ASSERT_PTR_NON_NULL(config, false); 5557 3390 5558 bool status = false; 5559 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 5560 if (!status) { 5561 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 5562 return false; 5563 } 3391 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 3392 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 5564 3393 5565 3394 /* which returns a list of detrend runs (with detrend id, iteration and … … 5607 3436 } 5608 3437 5609 bool simple = false;5610 {5611 bool status = false;5612 simple = psMetadataLookupBool(&status, config->args, "-simple");5613 if (!status) {5614 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");5615 return false;5616 }5617 }5618 5619 3438 // negative simple so the default is true 5620 3439 if (!ippdbPrintMetadatas(stdout, output, "detRejectExp", !simple)) { … … 5633 3452 PS_ASSERT_PTR_NON_NULL(config, false); 5634 3453 3454 PXOPT_LOOKUP_BOOL(reject, config->args, "-reject", false); 3455 5635 3456 // build a query to search by det_id, iteration, exp_id 5636 3457 psMetadata *where = psMetadataAlloc(); 5637 bool status = false; 5638 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 5639 if (!status) { 5640 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 5641 psFree(where); 5642 return false; 5643 } 5644 if (det_id) { 5645 if (!psMetadataAddStr(where, PS_LIST_TAIL, "det_id", 0, "==", det_id)) { 5646 psError(PS_ERR_UNKNOWN, false, "failed to add item det_id"); 5647 psFree(where); 5648 return false; 5649 } 5650 } 5651 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration"); 5652 if (!status) { 5653 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration"); 5654 psFree(where); 5655 return false; 5656 } 5657 // always where iteration 5658 if (!psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==", iteration)) { 5659 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration"); 5660 psFree(where); 5661 return false; 5662 } 5663 psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id"); 5664 if (!status) { 5665 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id"); 5666 psFree(where); 5667 return false; 5668 } 5669 if (exp_id) { 5670 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) { 5671 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 5672 psFree(where); 5673 return false; 5674 } 5675 } 3458 PXOPT_COPY_STR(config->args, where, "-det_id", "det_id", "=="); 3459 PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "=="); 3460 PXOPT_COPY_STR(config->args, where, "-exp_id", "exp_id", "=="); 5676 3461 5677 3462 // find the values we're going to set … … 5679 3464 // remove the '-' prefix 5680 3465 psMetadata *set = psMetadataAlloc(); 5681 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 5682 if (!status) { 5683 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip"); 5684 psFree(set); 5685 psFree(where); 5686 return false; 5687 } 5688 if (recipe) { 5689 if (!psMetadataAddStr(set, PS_LIST_TAIL, "recipe", 0, "==", recipe)) { 5690 psError(PS_ERR_UNKNOWN, false, "failed to add item recipe"); 5691 psFree(set); 5692 psFree(where); 5693 return false; 5694 } 5695 } 5696 5697 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 5698 if (!status) { 5699 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 5700 psFree(set); 5701 psFree(where); 5702 return false; 5703 } 5704 if (!isnan(bg)) { 5705 if (!psMetadataAddF64(set, PS_LIST_TAIL, "bg", 0, "==", bg)) { 5706 psError(PS_ERR_UNKNOWN, false, "failed to add item bg"); 5707 psFree(set); 5708 psFree(where); 5709 return false; 5710 } 5711 } 5712 5713 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 5714 if (!status) { 5715 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 5716 psFree(set); 5717 psFree(where); 5718 return false; 5719 } 5720 if (!isnan(bg_stdev)) { 5721 if (!psMetadataAddF64(set, PS_LIST_TAIL, "bg_stdev", 0, "==", bg_stdev)) { 5722 psError(PS_ERR_UNKNOWN, false, "failed to add item bg_stdev"); 5723 psFree(set); 5724 psFree(where); 5725 return false; 5726 } 5727 } 5728 5729 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 5730 if (!status) { 5731 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 5732 psFree(set); 5733 psFree(where); 5734 return false; 5735 } 5736 if (!isnan(bg_mean_stdev)) { 5737 if (!psMetadataAddF64(set, PS_LIST_TAIL, "bg_mean_stdev", 0, "==", bg_mean_stdev)) { 5738 psError(PS_ERR_UNKNOWN, false, "failed to add item bg_mean_stdev"); 5739 psFree(set); 5740 psFree(where); 5741 return false; 5742 } 5743 } 5744 5745 psString path_base = psMetadataLookupStr(&status, config->args, "-path_base"); 5746 if (!status) { 5747 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base"); 5748 psFree(set); 5749 psFree(where); 5750 return false; 5751 } 5752 if (path_base) { 5753 if (!psMetadataAddStr(set, PS_LIST_TAIL, "path_base", 0, "==", path_base)) { 5754 psError(PS_ERR_UNKNOWN, false, "failed to add item path_base"); 5755 psFree(set); 5756 psFree(where); 5757 return false; 5758 } 5759 } 5760 5761 bool reject = psMetadataLookupBool(&status, config->args, "-reject"); 5762 if (!status) { 5763 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -reject"); 5764 psFree(set); 5765 psFree(where); 5766 return false; 5767 } 3466 // XXX if PXOPT_COPY_* errors here the where md will leak 3467 PXOPT_COPY_STR(config->args, set, "-recip", "recipe", "=="); 3468 PXOPT_COPY_F64(config->args, set, "-bg", "bg", "=="); 3469 PXOPT_COPY_F64(config->args, set, "-bg_stdev", "bg_stdev", "=="); 3470 PXOPT_COPY_F64(config->args, set, "-bg_mean_stdev", "bg_mean_stdev", "=="); 3471 PXOPT_COPY_STR(config->args, set, "-path_base", "path_base", "=="); 3472 3473 // this can't be PXOPT_ macro-ized as reject is !'d 5768 3474 if (!psMetadataAddBool(set, PS_LIST_TAIL, "accept", 0, "==", !reject)) { 5769 3475 psError(PS_ERR_UNKNOWN, false, "failed to add item accept"); … … 5790 3496 5791 3497 // required 5792 bool status = false; 5793 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 5794 if (!status) { 5795 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 5796 return false; 5797 } 5798 if (!det_id) { 5799 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 5800 return false; 5801 } 3498 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 5802 3499 5803 3500 // optional 5804 bool again = psMetadataLookupBool(&status, config->args, "-again"); 5805 if (!status) { 5806 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -again"); 5807 return false; 5808 } 3501 PXOPT_LOOKUP_BOOL(again, config->args, "-again", false); 5809 3502 5810 3503 psString query = pxDataGet("dettool_find_completed_runs.sql"); … … 5814 3507 } 5815 3508 3509 // build a query to search by det_id, iteration, exp_id 3510 psMetadata *where = psMetadataAlloc(); 3511 PXOPT_COPY_STR(config->args, where, "-det_id", "det_id", "=="); 3512 PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "=="); 3513 5816 3514 { 5817 // build a query to search by det_id, iteration, exp_id5818 psMetadata *where = psMetadataAlloc();5819 bool status = false;5820 if (det_id) {5821 if (!psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", (psS64)atoll(det_id))) {5822 psError(PS_ERR_UNKNOWN, false, "failed to add item det_id");5823 psFree(where);5824 psFree(query);5825 return false;5826 }5827 }5828 psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");5829 if (!status) {5830 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");5831 psFree(where);5832 psFree(query);5833 return false;5834 }5835 // always set iteration5836 if (!psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==", iteration)) {5837 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");5838 psFree(where);5839 psFree(query);5840 return false;5841 }5842 5843 3515 // there's not 5844 3516 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); … … 5946 3618 } 5947 3619 5948 // from config->args5949 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg");5950 if (!status) {5951 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg");5952 return NULL;5953 }5954 //if (isnan(bg)) {5955 // psError(PS_ERR_UNKNOWN, true, "-bg is required");5956 // return NULL;5957 //}5958 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev");5959 if (!status) {5960 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev");5961 return NULL;5962 }5963 //if (isnan(bg_stdev)) {5964 // psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required");5965 // return NULL;5966 //}5967 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev");5968 if (!status) {5969 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev");5970 return NULL;5971 }5972 3620 // optional 5973 bool accept = psMetadataLookupBool(&status, config->args, "-accept"); 5974 if (!status) { 5975 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -accept"); 5976 return NULL; 5977 } 3621 PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false); 3622 PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false); 3623 PXOPT_LOOKUP_F64(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 5978 3624 // default values 5979 psS16 code = psMetadataLookupS16(&status, config->args, "-code"); 5980 if (!status) { 5981 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 5982 return false; 5983 } 3625 PXOPT_LOOKUP_BOOL(accept, config->args, "-accept", false); 3626 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 5984 3627 5985 3628 return detRunSummaryRowAlloc( … … 5998 3641 PS_ASSERT_PTR_NON_NULL(config, false); 5999 3642 6000 bool status = false; 6001 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 6002 if (!status) { 6003 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -limit"); 6004 return false; 6005 } 6006 6007 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 6008 if (!status) { 6009 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -faulted"); 6010 return false; 6011 } 3643 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 3644 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 3645 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 6012 3646 6013 3647 psString query = psStringCopy( … … 6062 3696 } 6063 3697 6064 bool simple = false;6065 {6066 bool status = false;6067 simple = psMetadataLookupBool(&status, config->args, "-simple");6068 if (!status) {6069 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");6070 return false;6071 }6072 }6073 6074 3698 // negative simple so the default is true 6075 3699 if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) { … … 6124 3748 // XXX this isn't strictly nessicary but not having the det_id complicates 6125 3749 // incrementing the iteration number 6126 bool status = false; 6127 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 6128 if (!status) { 6129 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 6130 return false; 6131 } 6132 if (!det_id) { 6133 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 6134 return false; 6135 } 3750 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 3751 3752 PXOPT_LOOKUP_BOOL(again, config->args, "-again", false); 3753 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); 6136 3754 // either -rerun or -state must be specified 6137 bool again = psMetadataLookupBool(&status, config->args, "-again");6138 if (!status) {6139 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -again");6140 return false;6141 }6142 psString state = psMetadataLookupStr(&status, config->args, "-state");6143 if (!status) {6144 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state");6145 return false;6146 }6147 3755 if (!(again || state)) { 6148 3756 psError(PS_ERR_UNKNOWN, true, "either -again or -state must be specified"); … … 6283 3891 6284 3892 // det_id is required 6285 bool status = false; 6286 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 6287 if (!status) { 6288 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 6289 return false; 6290 } 6291 if (!det_id) { 6292 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 6293 return false; 6294 } 3893 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 6295 3894 6296 3895 // we have to support multipe exp_ids … … 6443 4042 PS_ASSERT_PTR_NON_NULL(config, false); 6444 4043 6445 // required options 6446 bool status = false; 6447 psString det_type = psMetadataLookupStr(&status, config->args, "-det_type"); 6448 if (!status) { 6449 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_type"); 6450 return false; 6451 } 6452 if (!det_type) { 6453 psError(PS_ERR_UNKNOWN, true, "-det_type is required"); 6454 return false; 6455 } 6456 6457 psString filelevel = psMetadataLookupStr(&status, config->args, "-filelevel"); 6458 if (!status) { 6459 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filelevel"); 6460 return false; 6461 } 6462 if (!filelevel) { 6463 psError(PS_ERR_UNKNOWN, true, "-filelevel is required"); 6464 return false; 6465 } 6466 6467 psString workdir = psMetadataLookupStr(&status, config->args, "-workdir"); 6468 if (!status) { 6469 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -workdir"); 6470 return false; 6471 } 6472 6473 psString camera = psMetadataLookupStr(&status, config->args, "-inst"); 6474 if (!status) { 6475 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -inst"); 6476 return false; 6477 } 6478 6479 psString telescope = psMetadataLookupStr(&status, config->args, "-telescope"); 6480 if (!status) { 6481 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -telescope"); 6482 return false; 6483 } 6484 6485 psString exp_type = psMetadataLookupStr(&status, config->args, "-exp_type"); 6486 if (!status) { 6487 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_type"); 6488 return false; 6489 } 6490 6491 psString filter = psMetadataLookupStr(&status, config->args, "-filter"); 6492 if (!status) { 6493 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter"); 6494 return false; 6495 } 6496 6497 psF32 airmass_min = psMetadataLookupF32(&status, config->args, "-airmass_min"); 6498 if (!status) { 6499 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass_min"); 6500 return false; 6501 } 6502 6503 psF32 airmass_max = psMetadataLookupF32(&status, config->args, "-airmass_max"); 6504 if (!status) { 6505 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass_max"); 6506 return false; 6507 } 6508 6509 psF32 exp_time_min = psMetadataLookupF32(&status, config->args, "-exp_time_min"); 6510 if (!status) { 6511 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time_min"); 6512 return false; 6513 } 6514 6515 psF32 exp_time_max = psMetadataLookupF32(&status, config->args, "-exp_time_max"); 6516 if (!status) { 6517 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time_max"); 6518 return false; 6519 } 6520 6521 psF32 ccd_temp_min = psMetadataLookupF32(&status, config->args, "-ccd_temp_min"); 6522 if (!status) { 6523 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ccd_temp_min"); 6524 return false; 6525 } 6526 6527 psF32 ccd_temp_max = psMetadataLookupF32(&status, config->args, "-ccd_temp_max"); 6528 if (!status) { 6529 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ccd_temp_max"); 6530 return false; 6531 } 6532 6533 psF64 posang_min = psMetadataLookupF32(&status, config->args, "-posang_min"); 6534 if (!status) { 6535 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -posang_min"); 6536 return false; 6537 } 6538 6539 psF64 posang_max = psMetadataLookupF32(&status, config->args, "-posang_max"); 6540 if (!status) { 6541 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -posang_max"); 6542 return false; 6543 } 6544 6545 psF64 solang_min = psMetadataLookupF32(&status, config->args, "-solang_min"); 6546 if (!status) { 6547 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -solang_min"); 6548 return false; 6549 } 6550 6551 psF64 solang_max = psMetadataLookupF32(&status, config->args, "-solang_max"); 6552 if (!status) { 6553 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -solang_max"); 6554 return false; 6555 } 6556 6557 psTime *registered = NULL; 6558 { 6559 psString registeredStr = psMetadataLookupStr(&status, config->args, "-registered"); 6560 if (!status) { 6561 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -registered"); 6562 return false; 6563 } 6564 // pass through NULL as this is an optional field 6565 if (registeredStr) { 6566 registered = psTimeFromISO(registeredStr, PS_TIME_UTC); 6567 } else { 6568 registered = NULL; 6569 } 6570 } 6571 6572 psTime *time_begin = NULL; 6573 { 6574 psString time_beginStr = psMetadataLookupStr(&status, config->args, "-time_begin"); 6575 if (!status) { 6576 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -time_begin"); 6577 return false; 6578 } 6579 // pass through NULL as this is an optional field 6580 if (time_beginStr) { 6581 time_begin = psTimeFromISO(time_beginStr, PS_TIME_UTC); 6582 } else { 6583 time_begin = NULL; 6584 } 6585 } 6586 6587 psTime *time_end = NULL; 6588 { 6589 psString time_endStr = psMetadataLookupStr(&status, config->args, "-time_end"); 6590 if (!status) { 6591 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -time_end"); 6592 return false; 6593 } 6594 // pass through NULL as this is an optional field 6595 if (time_endStr) { 6596 time_end = psTimeFromISO(time_endStr, PS_TIME_UTC); 6597 } else { 6598 time_end = NULL; 6599 } 6600 } 6601 6602 psTime *use_begin = NULL; 6603 { 6604 psString use_beginStr = psMetadataLookupStr(&status, config->args, "-use_begin"); 6605 if (!status) { 6606 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -use_begin"); 6607 return false; 6608 } 6609 // pass through NULL as this is an optional field 6610 if (use_beginStr) { 6611 use_begin = psTimeFromISO(use_beginStr, PS_TIME_UTC); 6612 } else { 6613 use_begin = NULL; 6614 } 6615 } 6616 6617 psTime *use_end = NULL; 6618 { 6619 psString use_endStr = psMetadataLookupStr(&status, config->args, "-use_end"); 6620 if (!status) { 6621 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -use_end"); 6622 return false; 6623 } 6624 // pass through NULL as this is an optional field 6625 if (use_endStr) { 6626 use_end = psTimeFromISO(use_endStr, PS_TIME_UTC); 6627 } else { 6628 use_end = NULL; 6629 } 6630 } 6631 6632 psString parent = psMetadataLookupStr(&status, config->args, "-parent"); 6633 if (!status) { 6634 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -parent"); 6635 return false; 6636 } 6637 6638 psString label = psMetadataLookupStr(&status, config->args, "-label"); 6639 if (!status) { 6640 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -label"); 6641 return false; 6642 } 4044 // required 4045 PXOPT_LOOKUP_STR(det_type, config->args, "-det_type", true, false); 4046 PXOPT_LOOKUP_STR(filelevel, config->args, "-filelevel", false, false); 4047 4048 // optional 4049 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false); 4050 PXOPT_LOOKUP_STR(camera, config->args, "-inst", false, false); 4051 PXOPT_LOOKUP_STR(telescope, config->args, "-telescope", false, false); 4052 PXOPT_LOOKUP_STR(exp_type, config->args, "-exp_type", false, false); 4053 PXOPT_LOOKUP_STR(filter, config->args, "-filter", false, false); 4054 PXOPT_LOOKUP_F32(airmass_min, config->args, "-airmass_min", false, false); 4055 PXOPT_LOOKUP_F32(airmass_max, config->args, "-airmass_max", false, false); 4056 PXOPT_LOOKUP_F32(exp_time_min, config->args, "-exp_time_min", false, false); 4057 PXOPT_LOOKUP_F32(exp_time_max, config->args, "-exp_time_max", false, false); 4058 PXOPT_LOOKUP_F32(ccd_temp_min, config->args, "-ccd_temp_min", false, false); 4059 PXOPT_LOOKUP_F32(ccd_temp_max, config->args, "-ccd_temp_max", false, false); 4060 PXOPT_LOOKUP_F64(posang_min, config->args, "-posang_min", false, false); 4061 PXOPT_LOOKUP_F64(posang_max, config->args, "-posang_max", false, false); 4062 PXOPT_LOOKUP_F64(solang_min, config->args, "-solang_min", false, false); 4063 PXOPT_LOOKUP_F64(solang_max, config->args, "-solang_max", false, false); 4064 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 4065 PXOPT_LOOKUP_TIME(time_begin, config->args, "-time_begin", false, false); 4066 PXOPT_LOOKUP_TIME(time_end, config->args, "-time_end", false, false); 4067 PXOPT_LOOKUP_TIME(use_begin, config->args, "-use_begin", false, false); 4068 PXOPT_LOOKUP_TIME(use_end, config->args, "-use_end", false, false); 4069 PXOPT_LOOKUP_STR(parent, config->args, "-parent", false, false); 4070 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 4071 4072 // default 4073 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 6643 4074 6644 4075 if (!psDBTransaction(config->dbh)) { … … 6683 4114 psError(PS_ERR_UNKNOWN, false, "database error"); 6684 4115 } 6685 psFree(registered); 6686 return false; 6687 } 6688 psFree(registered); 4116 return false; 4117 } 6689 4118 6690 4119 // print the new detRun … … 6719 4148 } 6720 4149 6721 bool simple = false;6722 {6723 bool status = false;6724 simple = psMetadataLookupBool(&status, config->args, "-simple");6725 if (!status) {6726 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");6727 return false;6728 }6729 }6730 6731 4150 // negative simple so the default is true 6732 4151 if (!ippdbPrintMetadatas(stdout, detRuns, "detRun", !simple)) { … … 6744 4163 PS_ASSERT_PTR_NON_NULL(config, false); 6745 4164 6746 // required options 6747 bool status = false; 6748 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); 6749 if (!status) { 6750 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id"); 6751 return false; 6752 } 6753 if (!det_id) { 6754 psError(PS_ERR_UNKNOWN, true, "-det_id is required"); 6755 return false; 6756 } 6757 6758 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 6759 if (!status) { 6760 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 6761 return false; 6762 } 6763 if (!class_id) { 6764 psError(PS_ERR_UNKNOWN, true, "-class_id is required"); 6765 return false; 6766 } 6767 6768 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 6769 if (!status) { 6770 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 6771 return false; 6772 } 6773 if (!uri) { 6774 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 6775 return false; 6776 } 6777 6778 // everything else is optional 6779 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 6780 if (!status) { 6781 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 6782 return false; 6783 } 6784 6785 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 6786 if (!status) { 6787 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 6788 return false; 6789 } 6790 6791 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 6792 if (!status) { 6793 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 6794 return false; 6795 } 6796 6797 psF64 user_1 = psMetadataLookupF64(&status, config->args, "-user_1"); 6798 if (!status) { 6799 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_1"); 6800 return false; 6801 } 6802 psF64 user_2 = psMetadataLookupF64(&status, config->args, "-user_2"); 6803 if (!status) { 6804 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_2"); 6805 return false; 6806 } 6807 psF64 user_3 = psMetadataLookupF64(&status, config->args, "-user_3"); 6808 if (!status) { 6809 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_3"); 6810 return false; 6811 } 6812 psF64 user_4 = psMetadataLookupF64(&status, config->args, "-user_4"); 6813 if (!status) { 6814 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_4"); 6815 return false; 6816 } 6817 psF64 user_5 = psMetadataLookupF64(&status, config->args, "-user_5"); 6818 if (!status) { 6819 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -user_5"); 6820 return false; 6821 } 6822 6823 psString path_base = psMetadataLookupStr(&status, config->args, "-path_base"); 6824 if (!status) { 6825 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -path_base"); 6826 return false; 6827 } 4165 // required 4166 PXOPT_LOOKUP_STR(det_id, config->args, "-det_id", true, false); 4167 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 4168 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); 4169 4170 // optional 4171 PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false); 4172 PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false); 4173 PXOPT_LOOKUP_F64(bg_mean_stdev, config->args, "-bg_mean_stdev", false, false); 4174 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 4175 PXOPT_LOOKUP_F64(user_2, config->args, "-user_2", false, false); 4176 PXOPT_LOOKUP_F64(user_3, config->args, "-user_3", false, false); 4177 PXOPT_LOOKUP_F64(user_4, config->args, "-user_4", false, false); 4178 PXOPT_LOOKUP_F64(user_5, config->args, "-user_5", false, false); 4179 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 6828 4180 6829 4181 if (!detRegisteredImfileInsert(config->dbh, 6830 (psS64)atoll(det_id),6831 0, // the iteration is fixed at 06832 class_id,6833 uri,6834 bg,6835 bg_stdev,6836 bg_mean_stdev,6837 user_1,6838 user_2,6839 user_3,6840 user_4,6841 user_5,6842 path_base,6843 0 // fault code6844 )) {4182 (psS64)atoll(det_id), 4183 0, // the iteration is fixed at 0 4184 class_id, 4185 uri, 4186 bg, 4187 bg_stdev, 4188 bg_mean_stdev, 4189 user_1, 4190 user_2, 4191 user_3, 4192 user_4, 4193 user_5, 4194 path_base, 4195 0 // fault code 4196 )) { 6845 4197 psError(PS_ERR_UNKNOWN, false, "database error"); 6846 4198 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
