Changeset 23594 for branches/cnb_branches/cnb_branch_20090301/ippTools/src
- Timestamp:
- Mar 29, 2009, 6:15:31 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 29 edited
-
. (modified) (1 prop)
-
ippTools/src (modified) (1 prop)
-
ippTools/src/Makefile.am (modified) (3 diffs)
-
ippTools/src/camtool.c (modified) (8 diffs)
-
ippTools/src/camtoolConfig.c (modified) (5 diffs)
-
ippTools/src/chiptool.c (modified) (8 diffs)
-
ippTools/src/chiptoolConfig.c (modified) (3 diffs)
-
ippTools/src/difftool.c (modified) (35 diffs)
-
ippTools/src/difftool.h (modified) (1 diff)
-
ippTools/src/difftoolConfig.c (modified) (3 diffs)
-
ippTools/src/disttool.c (modified) (5 diffs)
-
ippTools/src/disttoolConfig.c (modified) (2 diffs)
-
ippTools/src/magicdstool.c (modified) (12 diffs)
-
ippTools/src/magicdstoolConfig.c (modified) (2 diffs)
-
ippTools/src/magictool.c (modified) (4 diffs)
-
ippTools/src/pxcam.c (modified) (2 diffs)
-
ippTools/src/pxchip.c (modified) (6 diffs)
-
ippTools/src/pxchip.h (modified) (1 diff)
-
ippTools/src/pxerrors.c (modified) (2 diffs)
-
ippTools/src/pxtools.h (modified) (8 diffs)
-
ippTools/src/pxwarp.c (modified) (2 diffs)
-
ippTools/src/pxwarp.h (modified) (1 diff)
-
ippTools/src/pztool.c (modified) (11 diffs)
-
ippTools/src/pztool.h (modified) (1 diff)
-
ippTools/src/pztoolConfig.c (modified) (3 diffs)
-
ippTools/src/regtool.c (modified) (11 diffs)
-
ippTools/src/regtoolConfig.c (modified) (4 diffs)
-
ippTools/src/warptool.c (modified) (13 diffs)
-
ippTools/src/warptoolConfig.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src
- Property svn:ignore
-
old new 32 32 flatcorr 33 33 pstamptool 34 disttool
-
- Property svn:ignore
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src/Makefile.am
r20789 r23594 6 6 dettool \ 7 7 difftool \ 8 disttool \ 8 9 flatcorr \ 9 10 magictool \ … … 45 46 dettool.h \ 46 47 difftool.h \ 48 disttool.h \ 47 49 flatcorr.h \ 48 50 faketool.h \ … … 152 154 difftoolConfig.c 153 155 156 disttool_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(IPPDB_CFLAGS) 157 disttool_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(IPPDB_LIBS) libpxtools.la 158 disttool_SOURCES = \ 159 disttool.c \ 160 disttoolConfig.c 161 154 162 stacktool_CFLAGS = $(PSLIB_CFLAGS) $(PSMODULES_CFLAGS) $(IPPDB_CFLAGS) 155 163 stacktool_LDADD = $(PSLIB_LIBS) $(PSMODULES_LIBS) $(IPPDB_LIBS) libpxtools.la -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/camtool.c
r23352 r23594 109 109 psMetadata *where = psMetadataAlloc(); 110 110 pxcamGetSearchArgs (config, where); 111 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 111 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "=="); 112 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 112 113 113 114 if (!psListLength(where->list) … … 223 224 224 225 psMetadata *where = psMetadataAlloc(); 225 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");226 226 pxcamGetSearchArgs (config, where); 227 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 228 PXOPT_COPY_STR(config->args, where, "-state", "camRun.state", "=="); 227 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 228 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 229 PXOPT_COPY_STR(config->args, where, "-state", "camRun.state", "=="); 230 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 229 231 230 232 if (!psListLength(where->list) … … 271 273 272 274 psMetadata *where = psMetadataAlloc(); 273 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");274 275 pxcamGetSearchArgs (config, where); 275 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 276 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 277 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 278 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 276 279 277 280 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 334 337 335 338 psMetadata *where = psMetadataAlloc(); 336 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");337 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");338 PXOPT_COPY_STR(config->args, where, "-class", "class", "==");339 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");340 339 pxcamGetSearchArgs (config, where); 341 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 340 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 341 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 342 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 343 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 344 PXOPT_COPY_STR(config->args, where, "-class_id", "chipProcessedImfile.class_id", "=="); 345 346 // XXX is this used? PXOPT_COPY_STR(config->args, where, "-class", "class", "=="); 342 347 343 348 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 649 654 // generate restrictions 650 655 psMetadata *where = psMetadataAlloc(); 651 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");652 656 pxcamGetSearchArgs (config, where); 653 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 657 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 658 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 659 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 654 660 655 661 psString query = pxDataGet("camtool_find_processedexp.sql"); … … 674 680 } 675 681 682 // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry 683 psStringAppend(&query, " ORDER BY cam_id"); 684 676 685 // treat limit == 0 as "no limit" 677 686 if (limit) { … … 681 690 } 682 691 683 // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry684 psStringAppend(&query, "\nORDER BY cam_id");685 686 692 if (!p_psDBRunQuery(config->dbh, query)) { 687 693 psError(PS_ERR_UNKNOWN, false, "database error"); … … 720 726 721 727 psMetadata *where = psMetadataAlloc(); 722 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "==");723 728 pxcamGetSearchArgs (config, where); 724 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 725 PXOPT_COPY_S16(config->args, where, "-code", "camProcessedExp.fault", "=="); 729 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 730 PXOPT_COPY_STR(config->args, where, "-label", "camRun.label", "=="); 731 PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "=="); 732 PXOPT_COPY_S16(config->args, where, "-code", "camProcessedExp.fault", "=="); 726 733 727 734 if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/camtoolConfig.c
r23352 r23594 52 52 psMetadata *definebyqueryArgs = psMetadataAlloc(); 53 53 pxcamSetSearchArgs(definebyqueryArgs); 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "search by chipRun label", NULL); 55 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "search by chipRun reduction class", NULL); 55 56 56 57 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir", NULL); … … 68 69 // XXX need to allow multiple exp_ids 69 70 psMetadata *updaterunArgs = psMetadataAlloc(); 71 pxcamSetSearchArgs(updaterunArgs); 70 72 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 71 pxcamSetSearchArgs(updaterunArgs); 72 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 73 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search for state", NULL); 74 73 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 74 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by camRun state", NULL); 75 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction", 0, "search by camRun reduction class", NULL); 75 76 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 76 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL);77 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL);77 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 78 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 78 79 79 80 // -pendingexp 80 81 psMetadata *pendingexpArgs = psMetadataAlloc(); 81 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0);82 82 pxcamSetSearchArgs(pendingexpArgs); 83 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 83 psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 84 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 85 psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-reduction", 0, "search by camRun reduction class", NULL); 84 86 psMetadataAddU64(pendingexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 85 87 psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); … … 87 89 // -pendingimfile 88 90 psMetadata *pendingimfileArgs = psMetadataAlloc(); 89 psMetadataAddS64(pendingimfileArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0);90 91 pxcamSetSearchArgs(pendingimfileArgs); 91 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 92 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class", 0, "search by class", NULL); 92 psMetadataAddS64(pendingimfileArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0); 93 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 94 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-reduction",0, "search by camRun reduction class", NULL); 93 95 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class_id", 0, "search by class ID", NULL); 94 psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 96 psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 97 98 // XXX is this used? psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class", 0, "search by class", NULL); 95 99 96 100 // -addprocessedexp … … 165 169 // -processedexp 166 170 psMetadata *processedexpArgs = psMetadataAlloc(); 167 psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0);168 171 pxcamSetSearchArgs(processedexpArgs); 169 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 172 psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 173 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 174 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-reduction",0, "search by camRun reduction class", NULL); 170 175 171 176 psMetadataAddU64(processedexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); … … 178 183 // XXX need to allow multiple exp_ids 179 184 psMetadata *revertprocessedexpArgs = psMetadataAlloc(); 180 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0);181 185 pxcamSetSearchArgs(revertprocessedexpArgs); 182 psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-label", 0, "search for label", NULL); 186 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 187 psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-label", 0, "search by camRun label", NULL); 188 psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-reduction",0, "search by camRun reduction class", NULL); 189 psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0); 183 190 184 191 psMetadataAddBool(revertprocessedexpArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 185 psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0);186 192 187 193 // -updateprocessedexp -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptool.c
r23352 r23594 209 209 return false; 210 210 } 211 211 // 212 212 // queue the exp 213 213 if (!pxchipQueueByExpTag(config, exp_id, workdir, label, reduction, expgroup, dvodb, tess_id, end_stage)) { … … 415 415 PXOPT_LOOKUP_F32(n_cr, config->args, "-n_cr", false, false); 416 416 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 417 PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false); 417 418 418 419 // default values … … 490 491 path_base, 491 492 code, 492 0 // magic_ds_id493 magicked 493 494 )) { 494 495 // rollback … … 540 541 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 541 542 PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "LIKE"); 543 PXOPT_COPY_S32(config->args, where, "-magicked", "chipRun.magicked", "=="); 542 544 543 545 psString query = pxDataGet("chiptool_processedimfile.sql"); … … 1137 1139 } 1138 1140 1139 // set chipRun.state to 'stop' 1140 if (!pxchipRunSetState(config, chipRun->chip_id, "full" )) {1141 // set chipRun.state to 'stop' and update the magicked state 1142 if (!pxchipRunSetState(config, chipRun->chip_id, "full", chipRun->magicked)) { 1141 1143 psError(PS_ERR_UNKNOWN, false, "failed to change chipRun.state for chip_id: %" PRId64, chipRun->chip_id); 1142 1144 psFree(chipRun); … … 1209 1211 } 1210 1212 1213 psString set_magic = ""; 1214 if (!strcmp(data_state, "full")) { 1215 // copy the magicked state from the input to the output when transitioning to full state 1216 set_magic = "\n , chipProcessedImfile.magicked = rawImfile.magicked"; 1217 } 1218 1211 1219 // note only updates if chipRun.state = run_state 1212 if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, class_id, run_state)) { 1220 // XXX note that we have removed this constraint for now 1221 if (!p_psDBRunQueryF(config->dbh, query, data_state, set_magic, chip_id, class_id)) { 1222 psFree(query); 1213 1223 psError(PS_ERR_UNKNOWN, false, "database error"); 1214 1224 // rollback … … 1227 1237 query = pxDataGet("chiptool_change_exp_state.sql"); 1228 1238 if (!p_psDBRunQueryF(config->dbh, query, data_state, chip_id, data_state)) { 1239 psFree(query); 1229 1240 // rollback 1230 1241 if (!psDBRollback(config->dbh)) { … … 1234 1245 return false; 1235 1246 } 1247 psFree(query); 1236 1248 1237 1249 if (!psDBCommit(config->dbh)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptoolConfig.c
r23352 r23594 66 66 pxchipSetSearchArgs (updaterunArgs); 67 67 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip ID", 0); 68 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "se tstate", NULL);68 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by state", NULL); 69 69 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 70 70 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); … … 147 147 psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-path_base", 0, "define base output location", NULL); 148 148 psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0); 149 psMetadataAddBool(addprocessedimfileArgs, PS_LIST_TAIL, "-magicked", 0, "define magicked status", false); 149 150 150 151 // -processedimfile … … 155 156 psMetadataAddStr(processedimfileArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 156 157 psMetadataAddStr(processedimfileArgs, PS_LIST_TAIL, "-label", 0, "search by chipRun label (LIKE comparison)", NULL); 158 psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-magicked", 0, "search by magicked status", false); 157 159 pxchipSetSearchArgs(processedimfileArgs); 158 160 psMetadataAddU64(processedimfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/difftool.c
r23352 r23594 41 41 static bool definepoprunMode(pxConfig *config); 42 42 static bool definebyqueryMode(pxConfig *config); 43 static bool definewarpwarpMode(pxConfig *config); 43 44 static bool pendingcleanuprunMode(pxConfig *config); 44 45 static bool pendingcleanupskyfileMode(pxConfig *config); … … 48 49 static bool importrunMode(pxConfig *config); 49 50 50 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state );51 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, bool magicked); 51 52 static bool diffRunComplete(pxConfig *config); 52 53 … … 79 80 MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunMode); 80 81 MODECASE(DIFFTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 82 MODECASE(DIFFTOOL_MODE_DEFINEWARPWARP, definewarpwarpMode); 81 83 MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 82 84 MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode); … … 131 133 registered, 132 134 tess_id, 133 exp_id 135 exp_id, 136 false 134 137 ); 135 138 if (!run) { … … 168 171 if (state) { 169 172 // set detRun.state to state 170 return setdiffRunState(config, diff_id, state );173 return setdiffRunState(config, diff_id, state, false); 171 174 } 172 175 … … 282 285 283 286 if (count == 2) { 284 if (!setdiffRunState(config, diff_id, "new" )) {287 if (!setdiffRunState(config, diff_id, "new", false)) { 285 288 if (!psDBRollback(config->dbh)) { 286 289 psError(PS_ERR_UNKNOWN, false, "database error"); … … 506 509 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false); 507 510 PXOPT_LOOKUP_F32(good_frac, config->args, "-good_frac", false, false); 511 PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false); 508 512 509 513 if (!psDBTransaction(config->dbh)) { … … 537 541 good_frac, 538 542 code, 539 0 // magic_ds_id543 magicked 540 544 )) { 541 545 if (!psDBRollback(config->dbh)) { … … 730 734 731 735 732 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state )736 static bool setdiffRunState(pxConfig *config, psS64 diff_id, const char *state, bool magicked) 733 737 { 734 738 PS_ASSERT_PTR_NON_NULL(state, false); … … 740 744 } 741 745 742 char *query = "UPDATE diffRun SET state = '%s' WHERE diff_id = %"PRId64; 743 if (!p_psDBRunQueryF(config->dbh, query, state, diff_id)) { 746 char *query = "UPDATE diffRun SET state = '%s', magicked = %d WHERE diff_id = %"PRId64; 747 748 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, diff_id)) { 744 749 psError(PS_ERR_UNKNOWN, false, 745 750 "failed to change state for diff_id %"PRId64, diff_id); … … 792 797 registered, 793 798 tess_id, 794 exp_id 799 exp_id, 800 false // magicked 795 801 ); 796 802 … … 1002 1008 psTrace("difftool", 1, query, warpQuery, diffQuery, expQuery, stackQuery); 1003 1009 1010 if (!psDBTransaction(config->dbh)) { 1011 psError(PS_ERR_UNKNOWN, false, "database error"); 1012 return false; 1013 } 1004 1014 1005 1015 if (!p_psDBRunQueryF(config->dbh, query, warpQuery, expQuery, diffQuery)) { 1006 1016 psError(PS_ERR_UNKNOWN, false, "database error"); 1007 1017 psFree(query); 1018 if (!psDBRollback(config->dbh)) { 1019 psError(PS_ERR_UNKNOWN, false, "database error"); 1020 } 1008 1021 return false; 1009 1022 } … … 1014 1027 psErrorCode err = psErrorCodeLast(); 1015 1028 switch (err) { 1016 case PS_ERR_DB_CLIENT: 1017 psError(PXTOOLS_ERR_SYS, false, "database error"); 1018 case PS_ERR_DB_SERVER: 1019 psError(PXTOOLS_ERR_PROG, false, "database error"); 1020 default: 1021 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1022 } 1023 1029 case PS_ERR_DB_CLIENT: 1030 psError(PXTOOLS_ERR_SYS, false, "database error"); 1031 break; 1032 case PS_ERR_DB_SERVER: 1033 psError(PXTOOLS_ERR_PROG, false, "database error"); 1034 break; 1035 default: 1036 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1037 break; 1038 } 1039 if (!psDBRollback(config->dbh)) { 1040 psError(PS_ERR_UNKNOWN, false, "database error"); 1041 } 1024 1042 return false; 1025 1043 } … … 1027 1045 psTrace("difftool", PS_LOG_INFO, "no rows found"); 1028 1046 psFree(output); 1047 if (!psDBCommit(config->dbh)) { 1048 psError(PS_ERR_UNKNOWN, false, "database error"); 1049 return false; 1050 } 1029 1051 return true; 1030 1052 } … … 1035 1057 psError(PS_ERR_UNKNOWN, false, "database error"); 1036 1058 psFree(query); 1059 if (!psDBRollback(config->dbh)) { 1060 psError(PS_ERR_UNKNOWN, false, "database error"); 1061 } 1037 1062 return false; 1038 1063 } … … 1055 1080 if (!mdok) { 1056 1081 psError(PXTOOLS_ERR_PROG, false, "exp_id not found"); 1082 if (!psDBRollback(config->dbh)) { 1083 psError(PS_ERR_UNKNOWN, false, "database error"); 1084 } 1057 1085 return false; 1058 1086 } … … 1068 1096 psFree(stackQuery); 1069 1097 psFree(skycell_query); 1098 if (!psDBRollback(config->dbh)) { 1099 psError(PS_ERR_UNKNOWN, false, "database error"); 1100 } 1070 1101 return false; 1071 1102 } … … 1076 1107 psFree(stackQuery); 1077 1108 psFree(skycell_query); 1109 if (!psDBRollback(config->dbh)) { 1110 psError(PS_ERR_UNKNOWN, false, "database error"); 1111 } 1078 1112 return false; 1079 1113 } … … 1084 1118 psFree(stackQuery); 1085 1119 psFree(skycell_query); 1120 if (!psDBRollback(config->dbh)) { 1121 psError(PS_ERR_UNKNOWN, false, "database error"); 1122 } 1086 1123 return false; 1087 1124 } … … 1092 1129 psFree(stackQuery); 1093 1130 psFree(skycell_query); 1131 if (!psDBRollback(config->dbh)) { 1132 psError(PS_ERR_UNKNOWN, false, "database error"); 1133 } 1094 1134 return false; 1095 1135 } … … 1100 1140 psFree(stackQuery); 1101 1141 psFree(skycell_query); 1142 if (!psDBRollback(config->dbh)) { 1143 psError(PS_ERR_UNKNOWN, false, "database error"); 1144 } 1102 1145 return false; 1103 1146 } … … 1107 1150 psFree(stackQuery); 1108 1151 psFree(skycell_query); 1152 if (!psDBRollback(config->dbh)) { 1153 psError(PS_ERR_UNKNOWN, false, "database error"); 1154 } 1109 1155 return false; 1110 1156 } … … 1132 1178 registered, 1133 1179 tess_id, 1134 exp_id 1180 exp_id, 1181 false // magicked 1135 1182 ); 1136 1183 … … 1138 1185 psError(PS_ERR_UNKNOWN, false, "database error"); 1139 1186 psFree(run); 1140 return true; 1187 if (!psDBRollback(config->dbh)) { 1188 psError(PS_ERR_UNKNOWN, false, "database error"); 1189 } 1190 return false; 1141 1191 } 1142 1192 run->diff_id = psDBLastInsertID(config->dbh); … … 1149 1199 psFree(skycell_query); 1150 1200 psFree(query); 1201 if (!psDBRollback(config->dbh)) { 1202 psError(PS_ERR_UNKNOWN, false, "database error"); 1203 } 1151 1204 return false; 1152 1205 } … … 1160 1213 psFree(skycell_query); 1161 1214 psFree(query); 1215 if (!psDBRollback(config->dbh)) { 1216 psError(PS_ERR_UNKNOWN, false, "database error"); 1217 } 1162 1218 return false; 1163 1219 } … … 1165 1221 query = NULL; 1166 1222 1167 if (!setdiffRunState(config, run->diff_id, "new" )) {1223 if (!setdiffRunState(config, run->diff_id, "new", false)) { 1168 1224 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1169 1225 run->diff_id); … … 1172 1228 psFree(skycell_query); 1173 1229 psFree(query); 1230 if (!psDBRollback(config->dbh)) { 1231 psError(PS_ERR_UNKNOWN, false, "database error"); 1232 } 1174 1233 return false; 1175 1234 } … … 1183 1242 psFree(skycell_query); 1184 1243 1244 if (!psDBCommit(config->dbh)) { 1245 psError(PS_ERR_UNKNOWN, false, "database error"); 1246 psFree(list); 1247 return false; 1248 } 1249 1185 1250 if (!diffRunPrintObjects(stdout, list, !simple)) { 1186 1251 psError(PS_ERR_UNKNOWN, false, "failed to print object"); … … 1192 1257 return true; 1193 1258 } 1259 1260 static bool definewarpwarpMode(pxConfig *config) 1261 { 1262 PS_ASSERT_PTR_NON_NULL(config, false); 1263 1264 psMetadata *selectWhere = psMetadataAlloc(); 1265 psMetadata *insertWhere = psMetadataAlloc(); 1266 1267 // Restrictions for selecting warps 1268 PXOPT_COPY_S64(config->args, selectWhere, "-warp_id", "inputWarpRun.warp_id", "=="); 1269 PXOPT_COPY_S64(config->args, selectWhere, "-exp_id", "inputRawExp.exp_id", "=="); 1270 PXOPT_COPY_STR(config->args, selectWhere, "-filter", "inputRawExp.filter", "=="); 1271 PXOPT_COPY_STR(config->args, selectWhere, "-input_label", "inputWarpRun.label", "=="); 1272 PXOPT_COPY_STR(config->args, selectWhere, "-template_label", "templateWarpRun.label", "=="); 1273 PXOPT_COPY_F32(config->args, selectWhere, "-timediff", 1274 "ABS(TIME_TO_SEC(TIMEDIFF(inputRawExp.dateobs, templateRawExp.dateobs)))", "<="); 1275 PXOPT_COPY_F32(config->args, selectWhere, "-rotdiff", "ABS(inputRawExp.posang - templateRawExp.posang)", "<="); 1276 1277 // Restrictions for inserting skycells 1278 PXOPT_COPY_F32(config->args, insertWhere, "-good_frac", "inputWarpSkyfile.good_frac", ">="); 1279 PXOPT_COPY_F32(config->args, insertWhere, "-good_frac", "templateWarpSkyfile.good_frac", ">="); 1280 1281 // Additional controls 1282 PXOPT_LOOKUP_BOOL(rerun, config->args, "-rerun", false); 1283 PXOPT_LOOKUP_BOOL(available, config->args, "-available", false); 1284 1285 // Settings to apply to defined run 1286 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); // required options 1287 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); // option 1288 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); // option 1289 PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false); 1290 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1291 1292 1293 psString select = pxDataGet("difftool_definewarpwarp_select.sql"); 1294 if (!select) { 1295 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1296 return false; 1297 } 1298 1299 psString whereClause = NULL; // The WHERE part of the query 1300 1301 if (psListLength(selectWhere->list)) { 1302 psString new = psDBGenerateWhereConditionSQL(selectWhere, NULL); 1303 psStringAppend(&whereClause, "\n%s %s", whereClause ? "AND" : "WHERE", new); 1304 psFree(new); 1305 } 1306 psFree(selectWhere); 1307 1308 if (!rerun) { 1309 psStringAppend(&whereClause, "\n%s diffRun.diff_id IS NULL", whereClause ? "AND" : "WHERE"); 1310 } 1311 1312 if (!available) { 1313 psStringAppend(&whereClause, "\n%s inputWarpRun.state = 'full'", whereClause ? "AND" : "WHERE"); 1314 } 1315 1316 if (!psDBTransaction(config->dbh)) { 1317 psError(PS_ERR_UNKNOWN, false, "database error"); 1318 psFree(select); 1319 psFree(whereClause); 1320 psFree(insertWhere); 1321 return false; 1322 } 1323 1324 if (!p_psDBRunQueryF(config->dbh, select, 1325 !rerun ? "\n" : "", // Activate LEFT JOIN against diffRun? 1326 whereClause)) { 1327 psError(PS_ERR_UNKNOWN, false, "Unable to run query: %s [WITH] %s", select, whereClause); 1328 psFree(select); 1329 psFree(whereClause); 1330 psFree(insertWhere); 1331 if (!psDBRollback(config->dbh)) { 1332 psError(PS_ERR_UNKNOWN, false, "database error"); 1333 } 1334 return false; 1335 } 1336 psFree(select); 1337 psFree(whereClause); 1338 1339 psArray *results = p_psDBFetchResult(config->dbh); // Results of query 1340 if (!results) { 1341 psErrorCode err = psErrorCodeLast(); // Code for error 1342 switch (err) { 1343 case PS_ERR_DB_CLIENT: 1344 psError(PXTOOLS_ERR_SYS, false, "database error"); 1345 break; 1346 case PS_ERR_DB_SERVER: 1347 psError(PXTOOLS_ERR_PROG, false, "database error"); 1348 break; 1349 default: 1350 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 1351 break; 1352 } 1353 if (!psDBRollback(config->dbh)) { 1354 psError(PS_ERR_UNKNOWN, false, "database error"); 1355 } 1356 psFree(insertWhere); 1357 return false; 1358 } 1359 if (!psArrayLength(results)) { 1360 psTrace("difftool", 1, "no rows found"); 1361 psFree(results); 1362 psFree(insertWhere); 1363 if (!psDBCommit(config->dbh)) { 1364 psError(PS_ERR_UNKNOWN, false, "database error"); 1365 return false; 1366 } 1367 return true; 1368 } 1369 1370 psString insert = pxDataGet("difftool_definewarpwarp_insert.sql"); // Insertion for each new run 1371 1372 if (psListLength(insertWhere->list)) { 1373 psString whereClause = psDBGenerateWhereConditionSQL(insertWhere, NULL); 1374 psStringAppend(&insert, "\n%s", whereClause); 1375 psFree(whereClause); 1376 } 1377 psFree(insertWhere); 1378 1379 psArray *list = psArrayAllocEmpty(16); // List of runs defined, to print 1380 long numGood = 0; // Number of good rows added 1381 for (long i = 0; i < results->n; i++) { 1382 psMetadata *row = results->data[i]; // Result row from query 1383 1384 psS64 exp_id = psMetadataLookupS64(NULL, row, "input_exp_id"); 1385 psS64 input_id = psMetadataLookupS64(NULL, row, "input_warp_id"); 1386 psS64 template_id = psMetadataLookupS64(NULL, row, "template_warp_id"); 1387 const char *tess_id = psMetadataLookupStr(NULL, row, "tess_id"); 1388 if (!exp_id || !input_id || !template_id || !tess_id) { 1389 psError(PXTOOLS_ERR_PROG, false, "Identifiers not found"); 1390 psFree(list); 1391 psFree(insert); 1392 psFree(results); 1393 if (!psDBRollback(config->dbh)) { 1394 psError(PS_ERR_UNKNOWN, false, "database error"); 1395 } 1396 return false; 1397 } 1398 1399 diffRunRow *run = diffRunRowAlloc(0, "reg", workdir, label, reduction, NULL, registered, 1400 tess_id, exp_id, false); // Run to insert 1401 if (!diffRunInsertObject(config->dbh, run)) { 1402 psError(PS_ERR_UNKNOWN, false, "database error"); 1403 psFree(run); 1404 psFree(list); 1405 psFree(insert); 1406 psFree(results); 1407 if (!psDBRollback(config->dbh)) { 1408 psError(PS_ERR_UNKNOWN, false, "database error"); 1409 } 1410 return false; 1411 } 1412 run->diff_id = psDBLastInsertID(config->dbh); // Difference run identifier 1413 1414 // Convert identifiers to string, for insertion into query 1415 psString diff = NULL, input = NULL, template = NULL; // String versions of identifiers 1416 psStringAppend(&diff, "%" PRId64, run->diff_id); 1417 psStringAppend(&input, "%" PRId64, input_id); 1418 psStringAppend(&template, "%" PRId64, template_id); 1419 1420 if (!p_psDBRunQueryF(config->dbh, insert, diff, input, template, input, template)) { 1421 psError(PS_ERR_UNKNOWN, false, "database error"); 1422 psFree(input); 1423 psFree(template); 1424 psFree(diff); 1425 psFree(run); 1426 psFree(list); 1427 psFree(insert); 1428 psFree(results); 1429 if (!psDBRollback(config->dbh)) { 1430 psError(PS_ERR_UNKNOWN, false, "database error"); 1431 } 1432 return false; 1433 } 1434 psFree(input); 1435 psFree(template); 1436 psFree(diff); 1437 1438 if (!setdiffRunState(config, run->diff_id, "new", false)) { 1439 psError(PS_ERR_UNKNOWN, false, "Failed to change diffRun.state for diff_id: %" PRId64, 1440 run->diff_id); 1441 psFree(run); 1442 psFree(list); 1443 psFree(insert); 1444 psFree(results); 1445 if (!psDBRollback(config->dbh)) { 1446 psError(PS_ERR_UNKNOWN, false, "database error"); 1447 } 1448 return false; 1449 } 1450 1451 psArrayAdd(list, list->n, run); 1452 psFree(run); // Drop reference 1453 1454 numGood++; 1455 } 1456 psFree(insert); 1457 psFree(results); 1458 1459 if (!psDBCommit(config->dbh)) { 1460 psError(PS_ERR_UNKNOWN, false, "database error"); 1461 psFree(list); 1462 return false; 1463 } 1464 1465 if (!diffRunPrintObjects(stdout, list, !simple)) { 1466 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 1467 psFree(list); 1468 return false; 1469 } 1470 psFree(list); 1471 1472 return true; 1473 } 1474 1194 1475 1195 1476 static bool pendingcleanuprunMode(pxConfig *config) … … 1428 1709 1429 1710 psS64 diff_id = psMetadataLookupS64(NULL, row, "diff_id"); 1711 bool magicked = psMetadataLookupBool(NULL, row, "magicked"); 1430 1712 1431 1713 // set diffRun.state to 'stop' 1432 if (!setdiffRunState(config, diff_id, "full" )) {1714 if (!setdiffRunState(config, diff_id, "full", magicked)) { 1433 1715 psError(PS_ERR_UNKNOWN, false, "failed to change diffRun.state for diff_id: %" PRId64, 1434 1716 diff_id); … … 1447 1729 char sqlFilename[80]; 1448 1730 } ExportTable; 1449 1731 1450 1732 int numExportFiles = 3; 1451 1733 … … 1526 1808 { 1527 1809 unsigned int nFail; 1528 1810 1529 1811 int numImportTables = 2; 1530 1812 1531 1813 char tables[2] [80] = {"diffInputSkyfile", "diffSkyfile"}; 1532 1814 1533 1815 PS_ASSERT_PTR_NON_NULL(config, NULL); 1534 1816 1535 1817 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false); 1536 1818 … … 1557 1839 psAssert (item, "entry not in input?"); 1558 1840 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1559 1841 1560 1842 switch (i) { 1561 1843 case 0: … … 1571 1853 } 1572 1854 break; 1573 1855 1574 1856 case 1: 1575 1857 for (int i = 0; i < item->data.list->n; i++) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/difftool.h
r23352 r23594 35 35 DIFFTOOL_MODE_DEFINEPOPRUN, 36 36 DIFFTOOL_MODE_DEFINEBYQUERY, 37 DIFFTOOL_MODE_DEFINEWARPWARP, 37 38 DIFFTOOL_MODE_PENDINGCLEANUPRUN, 38 39 DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/difftoolConfig.c
r23352 r23594 107 107 psMetadataAddF32(adddiffskyfileArgs, PS_LIST_TAIL, "-kernel_xy", 0, "define kernel xy moment", NAN); 108 108 psMetadataAddF32(adddiffskyfileArgs, PS_LIST_TAIL, "-kernel_yy", 0, "define kernel yy moment", NAN); 109 psMetadataAddS32(adddiffskyfileArgs, PS_LIST_TAIL, "-sources", 0, "define number of sources", 0); 110 psMetadataAddStr(adddiffskyfileArgs, PS_LIST_TAIL, "-hostname", 0, "define hostname", 0); 111 psMetadataAddF32(adddiffskyfileArgs, PS_LIST_TAIL, "-good_frac", 0, "define %% of good pixels", NAN); 109 psMetadataAddS32(adddiffskyfileArgs, PS_LIST_TAIL, "-sources", 0, "define number of sources", 0); 110 psMetadataAddStr(adddiffskyfileArgs, PS_LIST_TAIL, "-hostname", 0, "define hostname", 0); 111 psMetadataAddF32(adddiffskyfileArgs, PS_LIST_TAIL, "-good_frac", 0, "define %% of good pixels", NAN); 112 psMetadataAddBool(adddiffskyfileArgs, PS_LIST_TAIL, "-magicked", 0, "define magicked state", false); 112 113 113 114 // -diffskyfile … … 164 165 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 165 166 167 // -definewarpwarp 168 psMetadata *definewarpwarpArgs = psMetadataAlloc(); 169 psMetadataAddS64(definewarpwarpArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID", 0); 170 psMetadataAddS64(definewarpwarpArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID", 0); 171 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-filter", 0, "search by filter", NULL); 172 psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-timediff", 0, "limit time difference between input and template", NAN); 173 psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-rotdiff", 0, "limit rotator difference between input and template", NAN); 174 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-input_label", 0, "search by warp label for input", NULL); 175 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-template_label", 0, "search by warp label for template", NULL); 176 psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-good_frac", 0, "minimum good fraction of skycell", NAN); 177 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 178 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 179 psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-reduction", 0, "define reduction class", NULL); 180 psMetadataAddTime(definewarpwarpArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 181 psMetadataAddBool(definewarpwarpArgs, PS_LIST_TAIL, "-rerun", 0, "define new run even if one exists", false); 182 psMetadataAddBool(definewarpwarpArgs, PS_LIST_TAIL, "-available", 0, "define new run even if warpRun has some faults", false); 183 psMetadataAddBool(definewarpwarpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 184 166 185 // -pendingcleanuprun 167 186 psMetadata *pendingcleanuprunArgs = psMetadataAlloc(); … … 214 233 PXOPT_ADD_MODE("-definepoprun", "", DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunArgs); 215 234 PXOPT_ADD_MODE("-definebyquery", "", DIFFTOOL_MODE_DEFINEBYQUERY, definebyqueryArgs); 235 PXOPT_ADD_MODE("-definewarpwarp", "", DIFFTOOL_MODE_DEFINEWARPWARP, definewarpwarpArgs); 216 236 PXOPT_ADD_MODE("-pendingcleanuprun", "show runs that need to be cleaned up", DIFFTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunArgs); 217 237 PXOPT_ADD_MODE("-pendingcleanupskyfile", "show runs that need to be cleaned up", DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileArgs); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/disttool.c
r23352 r23594 98 98 PXOPT_LOOKUP_STR(set_label, config->args, "-set_label", false, false); 99 99 100 bool require_chip_id = false;101 if (!strcmp(stage, "raw")) {102 // need to know the chip id for raw stage so that we can find the masks103 require_chip_id = true;104 }105 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", require_chip_id, false);106 107 100 // TODO: check that stage has an expected value 101 // XXX: all of the following concerns will be managed properly by definebyquery 102 108 103 // TODO: check that stage_id actually exists for stage 109 104 // in magicdstool we queue off of a magic_id so the stage_id, exp_id, and cam_id get looked up … … 113 108 // change between the time that it is queued. 114 109 115 if (!distRunInsert(config->dbh, 0, stage, stage_id, chip_id, set_label, outroot, clean, "new", 0)) {110 if (!distRunInsert(config->dbh, 0, stage, stage_id, set_label, outroot, clean, "new", NULL, 0)) { 116 111 psError(PS_ERR_UNKNOWN, false, "database error"); 117 112 return false; … … 151 146 } 152 147 153 psString query = psStringCopy("UPDATE distRun ");148 psString query = psStringCopy("UPDATE distRun SET time_stamp = UTC_TIMESTAMP()"); 154 149 155 150 if (state) { 156 psStringAppend(&query, " SETstate = '%s'", state);151 psStringAppend(&query, " , state = '%s'", state); 157 152 } 158 153 159 154 if (label) { 160 psStringAppend(&query, " SETlabel = '%s'", label);155 psStringAppend(&query, " , label = '%s'", label); 161 156 } 162 157 163 158 if (code) { 164 psStringAppend(&query, " SETfault = %d", code);159 psStringAppend(&query, " , fault = %d", code); 165 160 } 166 161 … … 301 296 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 302 297 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 298 PXOPT_LOOKUP_BOOL(need_magic, config->args, "-need_magic", false); 303 299 304 300 // look for "inputs" that need to processed … … 323 319 } 324 320 325 if (!p_psDBRunQuery(config->dbh, query)) { 321 psString chip_magic = ""; 322 psString raw_where = ""; 323 psString chip_where = ""; 324 psString camera_where = ""; 325 psString fake_where = ""; 326 psString warp_where = ""; 327 psString diff_where = ""; 328 psString stack_where = ""; 329 330 if (need_magic) { 331 chip_magic = psStringCopy("\nAND chipRun.magicked"); 332 raw_where = psStringCopy("\nAND rawExp.magicked"); 333 chip_where = psStringCopy("\nAND (distRun.clean OR chipRun.magicked)"); 334 // chipRun must be magicked to allow release camera level masks 335 camera_where = psStringCopy("\nAND (distRun.clean OR chipRun.magicked)"); 336 warp_where = psStringCopy("\nAND (distRun.clean OR warpRun.magicked)"); 337 diff_where = psStringCopy("\nAND (distRun.clean OR diffRun.magicked)"); 338 } 339 340 if (!p_psDBRunQueryF(config->dbh, 341 query, 342 chip_magic, 343 raw_where, 344 chip_where, 345 camera_where, 346 fake_where, 347 warp_where, 348 diff_where, 349 stack_where)) { 326 350 psError(PS_ERR_UNKNOWN, false, "database error"); 327 351 psFree(query); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/disttoolConfig.c
r23352 r23594 47 47 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-stage", 0, "define stage for bundle (required)", NULL); 48 48 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage_id (required)", 0); 49 psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-chip_id", 0, "define chip_id (required for raw stage", 0);50 49 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-outroot", 0, "define output destination (required)", NULL); 51 50 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-clean", 0, "build clean distribution bundle", false); … … 76 75 psMetadataAddS64(pendingcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0); 77 76 psMetadataAddStr(pendingcomponentArgs, PS_LIST_TAIL, "-stage", 0, "limit results to runs for stage", NULL); 77 psMetadataAddBool(pendingcomponentArgs, PS_LIST_TAIL, "-need_magic", 0, "magic is needed", false); 78 78 psMetadataAddStr(pendingcomponentArgs, PS_LIST_TAIL, "-label", 0, "limit results to label", NULL); 79 79 psMetadataAddU64(pendingcomponentArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/magicdstool.c
r21433 r23594 40 40 41 41 static bool setmagicDSRunState(pxConfig *config, psS64 magic_id, const char *state); 42 static bool magicDSRunComplete(pxConfig *config );42 static bool magicDSRunComplete(pxConfig *config, bool setmagicked); 43 43 static bool magicDSGetIDs(pxConfig *config, psString stage, psS64 magic_id, psS64 *stage_id, psS64 *cam_id); 44 44 … … 242 242 243 243 // create a new magicRun for this group 244 magicRunRow *run = magicRunRowAlloc(0, exp_id, " run", workdir, "dirty", label, dvodb, registered, 0);244 magicRunRow *run = magicRunRowAlloc(0, exp_id, "new", workdir, "dirty", label, dvodb, registered, 0); 245 245 if (!run) { 246 246 psAbort("failed to alloc magicRun object"); … … 320 320 PXOPT_LOOKUP_STR(stage, config->args, "-stage", true, false); 321 321 PXOPT_LOOKUP_STR(outroot, config->args, "-outroot", true, false); 322 323 // optional 322 324 PXOPT_LOOKUP_STR(recoveryroot, config->args, "-recoveryroot", false, false); 323 325 PXOPT_LOOKUP_BOOL(re_place, config->args, "-replace", false); 324 326 PXOPT_LOOKUP_BOOL(remove, config->args, "-remove", false); 325 326 // optional327 327 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 328 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 328 329 329 330 psS64 stage_id = 0, cam_id = 0; … … 337 338 0, // ID 338 339 magic_id, 339 " run", // state340 "new", // state 340 341 stage, 341 342 stage_id, 342 343 cam_id, 344 label, 343 345 outroot, 344 346 recoveryroot, … … 396 398 PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "=="); 397 399 PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "=="); 398 // PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");400 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 399 401 400 402 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 526 528 } 527 529 530 static bool 531 setRunMagicked(pxConfig *config, psS64 magic_ds_id) 532 { 533 // first query the magicDSRun to find the stage and the stage_id 534 psString query = "SELECT stage, stage_id from magicDSRun where magic_ds_id = %" PRId64; 535 536 if (!p_psDBRunQueryF(config->dbh, query, magic_ds_id)) { 537 psError(PS_ERR_UNKNOWN, false, "database error"); 538 return false; 539 } 540 541 psArray *output = p_psDBFetchResult(config->dbh); 542 if (!output) { 543 psError(PS_ERR_UNKNOWN, false, "database error"); 544 return false; 545 } 546 if (!psArrayLength(output)) { 547 psError(PS_ERR_UNKNOWN, true, "magicDSRun not found for magic_ds_id %" PRId64, magic_ds_id); 548 psFree(output); 549 return false; 550 } 551 if (psArrayLength(output) > 1) { 552 psError(PS_ERR_UNKNOWN, true, "unexpected number of rows found %ld for magic_ds_id %" PRId64, 553 psArrayLength(output), magic_ds_id); 554 psFree(output); 555 return false; 556 } 557 psMetadata *row = output->data[0]; 558 559 psString stage = psMetadataLookupStr(NULL, row, "stage"); 560 psS64 stage_id = psMetadataLookupS64(NULL, row, "stage_id"); 561 562 563 // chose the appropriate query based on the stage 564 if (!strcmp(stage, "raw")) { 565 query = "UPDATE rawExp SET magicked = 1 where exp_id = %" PRId64; 566 } else if (!strcmp(stage, "chip")) { 567 query = "UPDATE chipRun SET magicked = 1 where chip_id = %" PRId64; 568 } else if (!strcmp(stage, "warp")) { 569 query = "UPDATE warpRun SET magicked = 1 where warp_id = %" PRId64; 570 } else if (!strcmp(stage, "diff")) { 571 query = "UPDATE diffRun SET magicked = 1 where diff_id = %" PRId64; 572 } else { 573 psError(PS_ERR_UNKNOWN, true, "unexpected value for stage: %s found", stage); 574 psFree(output); 575 return false; 576 } 577 if (!p_psDBRunQueryF(config->dbh, query, stage_id)) { 578 psError(PS_ERR_UNKNOWN, false, "database error"); 579 return false; 580 } 581 psFree(output); 582 583 psU64 affected = psDBAffectedRows(config->dbh); 584 if (affected != 1) { 585 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row"); 586 return false; 587 } 588 589 return true; 590 } 591 528 592 static bool adddestreakedfileMode(pxConfig *config) 529 593 { … … 551 615 552 616 if (setmagicked) { 617 // set the image file's magicked flag 553 618 if (!setMagicked(config, magic_ds_id, component)) { 554 619 psError(PS_ERR_UNKNOWN, false, "setMagicked failed"); 620 if (!psDBRollback(config->dbh)) { 621 psError(PS_ERR_UNKNOWN, false, "database error"); 622 } 555 623 return false; 556 624 } … … 566 634 } 567 635 568 if (!magicDSRunComplete(config )) {636 if (!magicDSRunComplete(config, setmagicked)) { 569 637 // rollback 570 638 if (!psDBRollback(config->dbh)) { … … 591 659 592 660 if (!strcmp(stage, "diff")) { 593 // don't need these ids for diff stage 661 // don't need these ids for diff stage because diff_id is in the magicRun 594 662 *stage_id = 0; 595 663 *cam_id = 0; … … 652 720 } 653 721 654 static bool magicDSRunComplete(pxConfig *config )722 static bool magicDSRunComplete(pxConfig *config, bool setmagicked) 655 723 { 656 724 PS_ASSERT_PTR_NON_NULL(config, false); … … 685 753 psS64 magic_ds_id = psMetadataLookupS64(NULL, row, "magic_ds_id"); 686 754 687 // set magicDSRun.state to 'stop' 688 if (!setmagicDSRunState(config, magic_ds_id, "stop")) { 755 // if requested, set stageRun.magicked 756 if (setmagicked && !setRunMagicked(config, magic_ds_id)) { 757 psError(PS_ERR_UNKNOWN, false, "failed to change stageRun.magicked for magic_ds_id: %" PRId64, 758 magic_ds_id); 759 return false; 760 } 761 762 // set magicDSRun.state to 'full' 763 if (!setmagicDSRunState(config, magic_ds_id, "full")) { 689 764 psError(PS_ERR_UNKNOWN, false, "failed to change magicDSRun.state for magic_ds_id: %" PRId64, 690 765 magic_ds_id); … … 795 870 // check that state is a valid string value 796 871 if (!( 797 (strncmp(state, " run", 4) == 0)798 || (strncmp(state, " stop", 5) == 0)872 (strncmp(state, "new", 4) == 0) 873 || (strncmp(state, "full", 5) == 0) 799 874 ) 800 875 ) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/magicdstoolConfig.c
r21433 r23594 70 70 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-replace", 0, "use the simple output format", false); 71 71 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-remove", 0, "use the simple output format", false); 72 //psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL);72 psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 73 73 psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 74 74 … … 88 88 psMetadataAddS64(todestreakArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magic Destreak ID", 0); 89 89 psMetadataAddS64(todestreakArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magic ID", 0); 90 // psMetadataAddS64(todestreakArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID", 0);90 psMetadataAddStr(todestreakArgs, PS_LIST_TAIL, "-label", 0, "define label", NULL); 91 91 psMetadataAddU64(todestreakArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 92 92 psMetadataAddBool(todestreakArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/magictool.c
r21402 r23594 217 217 218 218 // create a new magicRun for this group 219 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, " run", workdir, "dirty", label, dvodb, registered, 0);219 magicRunRow *run = magicRunRowAlloc(0, exp_id, diff_id, "new", workdir, "dirty", label, dvodb, registered, 0); 220 220 if (!run) { 221 221 psAbort("failed to alloc magicRun object"); … … 538 538 539 539 if (code > 0) { 540 char *query = "UPDATE magicRun SET fault = %d, state = ' stop' WHERE magic_id = %" PRId64;540 char *query = "UPDATE magicRun SET fault = %d, state = 'full' WHERE magic_id = %" PRId64; 541 541 if (!p_psDBRunQueryF(config->dbh, query, code, magic_id)) { 542 542 psError(PS_ERR_UNKNOWN, false, … … 1088 1088 } 1089 1089 1090 // Set to " run"1090 // Set to "new" 1091 1091 { 1092 1092 psString query = psStringCopy("UPDATE magicRun JOIN magicMask USING(magic_id) " 1093 "SET magicRun.state = ' run' WHERE magicMask.fault != 0");1093 "SET magicRun.state = 'new' WHERE magicMask.fault != 0"); 1094 1094 1095 1095 if (psListLength(where->list)) { … … 1481 1481 // check that state is a valid string value 1482 1482 if (!( 1483 (strncmp(state, " run", 4) == 0)1484 || (strncmp(state, " stop", 5) == 0)1483 (strncmp(state, "new", 4) == 0) 1484 || (strncmp(state, "full", 5) == 0) 1485 1485 || (strncmp(state, "reg", 4) == 0) 1486 1486 ) -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxcam.c
r21402 r23594 42 42 psMetadataAddStr(md, PS_LIST_TAIL, "-comment", 0, "search by comment", NULL); 43 43 psMetadataAddStr(md, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 44 psMetadataAddStr(md, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL);45 44 psMetadataAddStr(md, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 46 45 psMetadataAddF64(md, PS_LIST_TAIL, "-airmass_min", 0, "define min airmass", NAN); … … 77 76 bool pxcamGetSearchArgs (pxConfig *config, psMetadata *where) { 78 77 79 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 80 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 81 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 82 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 83 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 84 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 85 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 86 PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "=="); 87 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 88 PXOPT_COPY_STR(config->args, where, "-comment", "rawExp.comment", "LIKE"); 89 PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "=="); 90 PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "=="); 91 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 92 PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">="); 93 PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<"); 94 PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">="); 95 PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<"); 96 PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">="); 97 PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<"); 98 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">="); 99 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<"); 100 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">="); 101 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<"); 102 PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">="); 103 PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<"); 104 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">="); 105 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<"); 106 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">="); 107 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<"); 108 PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">="); 109 PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<"); 110 PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">="); 111 PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<"); 112 PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">="); 113 PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<"); 114 PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">="); 115 PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<"); 116 PXOPT_COPY_STR(config->args, where, "-object", "object", "=="); 117 PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">="); 118 PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<"); 78 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 79 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 80 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 81 PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.camera", "=="); 82 PXOPT_COPY_STR(config->args, where, "-telescope", "rawExp.telescope", "=="); 83 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">="); 84 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); 85 PXOPT_COPY_STR(config->args, where, "-exp_tag", "rawExp.exp_tag", "=="); 86 PXOPT_COPY_STR(config->args, where, "-exp_type", "rawExp.exp_type", "=="); 87 PXOPT_COPY_STR(config->args, where, "-comment", "rawExp.comment", "LIKE"); 88 PXOPT_COPY_STR(config->args, where, "-filelevel", "rawExp.filelevel", "=="); 89 PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "=="); 90 PXOPT_COPY_F64(config->args, where, "-airmass_min", "rawExp.airmass", ">="); 91 PXOPT_COPY_F64(config->args, where, "-airmass_max", "rawExp.airmass", "<"); 92 PXOPT_COPY_F64(config->args, where, "-ra_min", "rawExp.ra", ">="); 93 PXOPT_COPY_F64(config->args, where, "-ra_max", "rawExp.ra", "<"); 94 PXOPT_COPY_F64(config->args, where, "-decl_min", "rawExp.decl", ">="); 95 PXOPT_COPY_F64(config->args, where, "-decl_max", "rawExp.decl", "<"); 96 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "rawExp.exp_time", ">="); 97 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "rawExp.exp_time", "<"); 98 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">="); 99 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<"); 100 PXOPT_COPY_F64(config->args, where, "-bg_min", "rawExp.bg", ">="); 101 PXOPT_COPY_F64(config->args, where, "-bg_max", "rawExp.bg", "<"); 102 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "rawExp.bg_stdev", ">="); 103 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "rawExp.bg_stdev", "<"); 104 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "rawExp.bg_mean_stdev", ">="); 105 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "rawExp.bg_mean_stdev", "<"); 106 PXOPT_COPY_F64(config->args, where, "-alt_min", "rawExp.alt", ">="); 107 PXOPT_COPY_F64(config->args, where, "-alt_max", "rawExp.alt", "<"); 108 PXOPT_COPY_F64(config->args, where, "-az_min", "rawExp.az", ">="); 109 PXOPT_COPY_F64(config->args, where, "-az_max", "rawExp.az", "<"); 110 PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "rawExp.ccd_temp", ">="); 111 PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "rawExp.ccd_temp", "<"); 112 PXOPT_COPY_F64(config->args, where, "-posang_min", "rawExp.posang", ">="); 113 PXOPT_COPY_F64(config->args, where, "-posang_max", "rawExp.posang", "<"); 114 PXOPT_COPY_STR(config->args, where, "-object", "rawExp.object", "=="); 115 PXOPT_COPY_F32(config->args, where, "-solang_min", "rawExp.solang", ">="); 116 PXOPT_COPY_F32(config->args, where, "-solang_max", "rawExp.solang", "<"); 119 117 120 118 return true; -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxchip.c
r21402 r23594 31 31 bool pxchipSetSearchArgs (psMetadata *md) { 32 32 33 // psMetadataAddStr(md, PS_LIST_TAIL, "-class_id", 0, "search by class ID", NULL); 34 // psMetadataAddStr(md, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 35 33 36 // XXX need to allow multiple exp_ids 34 37 psMetadataAddS64(md, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 35 38 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 36 // psMetadataAddStr(md, PS_LIST_TAIL, "-class_id", 0, "search by class ID", NULL);37 39 psMetadataAddStr(md, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 38 40 psMetadataAddStr(md, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); … … 42 44 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 43 45 psMetadataAddStr(md, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 44 // psMetadataAddStr(md, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL);45 46 psMetadataAddStr(md, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 46 47 psMetadataAddF32(md, PS_LIST_TAIL, "-airmass_min", 0, "search by min airmass", NAN); … … 128 129 } 129 130 130 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state )131 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state, const bool magicked) 131 132 { 132 133 PS_ASSERT_PTR_NON_NULL(config, false); … … 139 140 } 140 141 141 char *query = "UPDATE chipRun SET state = '%s' WHERE chip_id = %" PRId64;142 if (!p_psDBRunQueryF(config->dbh, query, state, chip_id)) {142 char *query = "UPDATE chipRun SET state = '%s', magicked = %d WHERE chip_id = %" PRId64; 143 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, chip_id)) { 143 144 psError(PS_ERR_UNKNOWN, false, 144 145 "failed to change state for chip_id %" PRId64, chip_id); … … 158 159 if (!pxIsValidState(state)) { 159 160 psError(PS_ERR_UNKNOWN, false, "invalid chipRun state: %s", state); 161 return false; 162 } 163 164 if (!strcmp(state, "full")) { 165 // There are states that need to be met for a run to be set to full that we don't 166 // check here. 167 // for example all of the run's Imfiles must have chipProcessedImfile.data_state == "full" 168 // chipRun.magicked = (SUM(!chipProcessedImfile.magicked) = 0) 169 // so don't do allow setting the state to full 170 psError(PS_ERR_UNKNOWN, true, "cannot use -updaterun so set chipRun state to full"); 160 171 return false; 161 172 } … … 253 264 dvodb, 254 265 tess_id, 255 end_stage) 266 end_stage, 267 0 // magicked 268 ) 256 269 ) { 257 270 if (!psDBRollback(config->dbh)) { -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxchip.h
r19324 r23594 25 25 #include "pxtools.h" 26 26 27 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state );27 bool pxchipRunSetState(pxConfig *config, psS64 chip_id, const char *state, const bool magicked); 28 28 bool pxchipRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); 29 29 bool pxchipRunSetLabel(pxConfig *config, psS64 chip_id, const char *label); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxerrors.c
r17611 r23594 24 24 #include "pxtools.h" 25 25 26 psExit pxerrorGetExitStatus () {26 psExit pxerrorGetExitStatus(void) { 27 27 28 28 psErrorCode err = psErrorCodeLast (); … … 38 38 default: 39 39 return PS_EXIT_UNKNOWN_ERROR; 40 } 40 } 41 41 return PS_EXIT_UNKNOWN_ERROR; 42 42 } -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxtools.h
r18561 r23594 53 53 bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS16 code); 54 54 55 psExit pxerrorGetExitStatus ();55 psExit pxerrorGetExitStatus(void); 56 56 57 57 void pxUsage(FILE *stream, int argc, char **argv, const char *modeName, psMetadata *argSet); … … 303 303 #define PXOPT_ADD_WHERE_BOOL(name) \ 304 304 { \ 305 bool value = false; \305 bool value = false; \ 306 306 bool status = false; \ 307 307 if ((value = psMetadataLookupBool(&status, config->args, "-" #name))) { \ … … 370 370 } 371 371 372 #define PXOPT_ADD_WHERE_BOOL_ALIAS(flag,name) \372 #define PXOPT_ADD_WHERE_BOOL_ALIAS(flag,name) \ 373 373 { \ 374 374 bool value = 0; \ 375 375 bool status = false; \ 376 if ((value = psMetadataLookupBool(&status, config->args, flag))) { \376 if ((value = psMetadataLookupBool(&status, config->args, flag))) { \ 377 377 if (!psMetadataAddBOOL(config->where, PS_LIST_TAIL, name, 0, "==", value)) { \ 378 378 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", flag); \ … … 383 383 } 384 384 385 #define PXOPT_ADD_WHERE_S16_ALIAS(flag,name) \385 #define PXOPT_ADD_WHERE_S16_ALIAS(flag,name) \ 386 386 { \ 387 387 psS16 s16 = 0; \ 388 388 bool status = false; \ 389 if ((s16= psMetadataLookupS16(&status, config->args, flag))) { \389 if ((s16= psMetadataLookupS16(&status, config->args, flag))) { \ 390 390 if (!psMetadataAddS16(config->where, PS_LIST_TAIL, name, 0, "==", s16)) { \ 391 391 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", flag); \ … … 396 396 } 397 397 398 #define PXOPT_ADD_WHERE_S32_ALIAS(flag,name) \398 #define PXOPT_ADD_WHERE_S32_ALIAS(flag,name) \ 399 399 { \ 400 400 psS32 s32 = 0; \ 401 401 bool status = false; \ 402 if ((s32= psMetadataLookupS32(&status, config->args, flag))) { \402 if ((s32= psMetadataLookupS32(&status, config->args, flag))) { \ 403 403 if (!psMetadataAddS32(config->where, PS_LIST_TAIL, name, 0, "==", s32)) { \ 404 404 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", flag); \ … … 409 409 } 410 410 411 #define PXOPT_ADD_WHERE_S64_ALIAS(flag,name) \411 #define PXOPT_ADD_WHERE_S64_ALIAS(flag,name) \ 412 412 { \ 413 413 psS64 s64 = 0; \ 414 414 bool status = false; \ 415 if ((s64= psMetadataLookupS64(&status, config->args, flag))) { \415 if ((s64= psMetadataLookupS64(&status, config->args, flag))) { \ 416 416 if (!psMetadataAddS64(config->where, PS_LIST_TAIL, name, 0, "==", s64)) { \ 417 417 psError(PS_ERR_UNKNOWN, false, "failed to add item %s", flag); \ … … 422 422 } 423 423 424 #define PXOPT_ADD_WHERE_F32_ALIAS(flag,name) \424 #define PXOPT_ADD_WHERE_F32_ALIAS(flag,name) \ 425 425 { \ 426 426 psF32 var = 0; \ 427 427 bool status = false; \ 428 if ((var = psMetadataLookupF32(&status, config->args, flag))) { \428 if ((var = psMetadataLookupF32(&status, config->args, flag))) { \ 429 429 if (!isnan(var)) { \ 430 430 if (!psMetadataAddF32(config->where, PS_LIST_TAIL, name, 0, "==", var)) { \ … … 437 437 } 438 438 439 #define PXOPT_ADD_WHERE_F64_ALIAS(flag,name) \439 #define PXOPT_ADD_WHERE_F64_ALIAS(flag,name) \ 440 440 { \ 441 441 psF64 var = 0; \ 442 442 bool status = false; \ 443 if ((var = psMetadataLookupF64(&status, config->args, flag))) { \443 if ((var = psMetadataLookupF64(&status, config->args, flag))) { \ 444 444 if (!isnan(var)) { \ 445 445 if (!psMetadataAddF64(config->where, PS_LIST_TAIL, name, 0, "==", var)) { \ -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxwarp.c
r23352 r23594 28 28 #include "pxtools.h" 29 29 #include "pxwarp.h" 30 31 bool pxwarpSetSearchArgs (psMetadata *md) { 32 psMetadataAddS64(md, PS_LIST_TAIL, "-fake_id", 0, "search by fake_id", 0); 33 psMetadataAddS64(md, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 34 psMetadataAddS64(md, PS_LIST_TAIL, "-chip_id", 0, "search by chip_id", 0); 35 psMetadataAddS64(md, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 36 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 37 psMetadataAddStr(md, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 38 psMetadataAddStr(md, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); 39 psMetadataAddTime(md, PS_LIST_TAIL, "-dateobs_begin", 0, "search for exposures by time (>=)", NULL); 40 psMetadataAddTime(md, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<)", NULL); 41 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_tag", 0, "search by exp_tag", NULL); 42 psMetadataAddStr(md, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 43 psMetadataAddStr(md, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 44 psMetadataAddStr(md, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 45 psMetadataAddF64(md, PS_LIST_TAIL, "-airmass_min", 0, "search by min airmass", NAN); 46 psMetadataAddF64(md, PS_LIST_TAIL, "-airmass_max", 0, "search by max airmass", NAN); 47 psMetadataAddF64(md, PS_LIST_TAIL, "-ra_min", 0, "search by min", NAN); 48 psMetadataAddF64(md, PS_LIST_TAIL, "-ra_max", 0, "search by max", NAN); 49 psMetadataAddF64(md, PS_LIST_TAIL, "-decl_min", 0, "search by min", NAN); 50 psMetadataAddF64(md, PS_LIST_TAIL, "-decl_max", 0, "search by max", NAN); 51 psMetadataAddF32(md, PS_LIST_TAIL, "-exp_time_min", 0, "search by min", NAN); 52 psMetadataAddF32(md, PS_LIST_TAIL, "-exp_time_max", 0, "search by max", NAN); 53 psMetadataAddF32(md, PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "search by max fraction of saturated pixels", NAN); 54 psMetadataAddF32(md, PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "search by min fraction of saturated pixels", NAN); 55 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_min", 0, "search by max", NAN); 56 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_max", 0, "search by max", NAN); 57 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_stdev_min", 0, "search by max", NAN); 58 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_stdev_max", 0, "search by max", NAN); 59 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_mean_stdev_min", 0, "search by max", NAN); 60 psMetadataAddF64(md, PS_LIST_TAIL, "-bg_mean_stdev_max", 0, "search by max", NAN); 61 psMetadataAddF64(md, PS_LIST_TAIL, "-alt_min", 0, "search by min", NAN); 62 psMetadataAddF64(md, PS_LIST_TAIL, "-alt_max", 0, "search by max", NAN); 63 psMetadataAddF64(md, PS_LIST_TAIL, "-az_min", 0, "search by min", NAN); 64 psMetadataAddF64(md, PS_LIST_TAIL, "-az_max", 0, "search by max", NAN); 65 psMetadataAddF32(md, PS_LIST_TAIL, "-ccd_temp_min", 0, "search by min ccd tempature", NAN); 66 psMetadataAddF32(md, PS_LIST_TAIL, "-ccd_temp_max", 0, "search by max ccd tempature", NAN); 67 psMetadataAddF64(md, PS_LIST_TAIL, "-posang_min", 0, "search by min rotator position angle", NAN); 68 psMetadataAddF64(md, PS_LIST_TAIL, "-posang_max", 0, "search by max rotator position angle", NAN); 69 psMetadataAddStr(md, PS_LIST_TAIL, "-object", 0, "search by exposure object", NULL); 70 psMetadataAddF32(md, PS_LIST_TAIL, "-solang_min", 0, "search by min solar angle", NAN); 71 psMetadataAddF32(md, PS_LIST_TAIL, "-solang_max", 0, "search by max solar angle", NAN); 72 return true; 73 } 74 75 bool pxwarpGetSearchArgs (pxConfig *config, psMetadata *where) { 76 PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "=="); 77 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 78 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 79 PXOPT_COPY_S64(config->args, where, "-exp_id", "newExp.exp_id", "=="); 80 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 81 PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.camera", "=="); 82 PXOPT_COPY_STR(config->args, where, "-telescope", "rawExp.telescope", "=="); 83 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">="); 84 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); 85 PXOPT_COPY_STR(config->args, where, "-exp_tag", "rawExp.exp_tag", "=="); 86 PXOPT_COPY_STR(config->args, where, "-exp_type", "rawExp.exp_type", "=="); 87 PXOPT_COPY_STR(config->args, where, "-filelevel", "rawExp.filelevel", "=="); 88 PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "=="); 89 PXOPT_COPY_F64(config->args, where, "-airmass_min", "rawExp.airmass", ">="); 90 PXOPT_COPY_F64(config->args, where, "-airmass_max", "rawExp.airmass", "<"); 91 PXOPT_COPY_F64(config->args, where, "-ra_min", "rawExp.ra", ">="); 92 PXOPT_COPY_F64(config->args, where, "-ra_max", "rawExp.ra", "<"); 93 PXOPT_COPY_F64(config->args, where, "-decl_min", "rawExp.decl", ">="); 94 PXOPT_COPY_F64(config->args, where, "-decl_max", "rawExp.decl", "<"); 95 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "rawExp.exp_time", ">="); 96 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "rawExp.exp_time", "<"); 97 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">="); 98 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<"); 99 PXOPT_COPY_F64(config->args, where, "-bg_min", "rawExp.bg", ">="); 100 PXOPT_COPY_F64(config->args, where, "-bg_max", "rawExp.bg", "<"); 101 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "rawExp.bg_stdev", ">="); 102 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "rawExp.bg_stdev", "<"); 103 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "rawExp.bg_mean_stdev", ">="); 104 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "rawExp.bg_mean_stdev", "<"); 105 PXOPT_COPY_F64(config->args, where, "-alt_min", "rawExp.alt", ">="); 106 PXOPT_COPY_F64(config->args, where, "-alt_max", "rawExp.alt", "<"); 107 PXOPT_COPY_F64(config->args, where, "-az_min", "rawExp.az", ">="); 108 PXOPT_COPY_F64(config->args, where, "-az_max", "rawExp.az", "<"); 109 PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "rawExp.ccd_temp", ">="); 110 PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "rawExp.ccd_temp", "<"); 111 PXOPT_COPY_F64(config->args, where, "-posang_min", "rawExp.posang", ">="); 112 PXOPT_COPY_F64(config->args, where, "-posang_max", "rawExp.posang", "<"); 113 PXOPT_COPY_STR(config->args, where, "-object", "rawExp.object", "=="); 114 PXOPT_COPY_F32(config->args, where, "-solang_min", "rawExp.solang", ">="); 115 PXOPT_COPY_F32(config->args, where, "-solang_max", "rawExp.solang", "<"); 116 return true; 117 } 30 118 31 119 bool pxwarpRunSetState(pxConfig *config, psS64 warp_id, const char *state) … … 147 235 tess_id, 148 236 end_stage, 149 NULL // registered 237 NULL, // registered 238 0 // magicked zero when created will get updated when warpRun goes to 'full' 150 239 )) { 151 240 psError(PS_ERR_UNKNOWN, false, "database error"); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pxwarp.h
r18029 r23594 25 25 #include "pxtools.h" 26 26 27 bool pxwarpGetSearchArgs (pxConfig *config, psMetadata *where); 28 bool pxwarpSetSearchArgs (psMetadata *md); 29 27 30 bool pxwarpRunSetState(pxConfig *config, psS64 warp_id, const char *state); 28 31 bool pxwarpRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pztool.c
r21479 r23594 44 44 45 45 static bool clearcommonfaultsMode(pxConfig *config); 46 static bool toadvanceMode(pxConfig *config); 46 47 static bool advanceMode(pxConfig *config); 47 48 48 static bool copydoneCompleteExp(pxConfig *config);49 // static bool copydoneCompleteExp(pxConfig *config); 49 50 static psArray *pzGetPendingCameras(pxConfig *config); 50 51 static psArray *pzArrayZip(psArray *arraySet, psS64 limit); … … 80 81 MODECASE(PZTOOL_MODE_REVERTCOPIED, revertcopiedMode); 81 82 MODECASE(PZTOOL_MODE_CLEARCOMMONFAULTS, clearcommonfaultsMode); 83 MODECASE(PZTOOL_MODE_TOADVANCE, toadvanceMode); 82 84 MODECASE(PZTOOL_MODE_ADVANCE, advanceMode); 83 85 default: … … 403 405 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 404 406 405 // NOTE : the rest of the command-line args are parsed in copydoneCompleteExp406 407 407 // start a transaction early so it will contain any row level locks 408 408 if (!psDBTransaction(config->dbh)) { … … 463 463 } 464 464 465 #ifdef notdef466 // we've changed to use -advance instead467 if (!copydoneCompleteExp(config)) {468 // rollback469 if (!psDBRollback(config->dbh)) {470 psError(PS_ERR_UNKNOWN, false, "database error");471 }472 psError(PS_ERR_UNKNOWN, false, "copydoneCompleteExp() failed");473 return false;474 }475 #endif476 465 // point of no return 477 466 if (!psDBCommit(config->dbh)) { … … 487 476 } 488 477 489 static bool copydoneCompleteExp(pxConfig *config) 490 { 491 // THIS FUNCTION MUST BE INVOKED FROM INSIDE A TRANSACTION!!! 492 493 PS_ASSERT_PTR_NON_NULL(config, false); 494 495 // XXX this is an ugly hack! 496 // we are passing exp level info to a imfile level mode (-copydone) 497 // these options are thrown away unless we just -copydone'd the last imfile 498 // in an exp. 499 500 // optional 501 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false); 502 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 503 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", false, false); 504 PXOPT_LOOKUP_STR(end_stage, config->args, "-end_stage", false, false); 505 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 478 static bool toadvanceMode(pxConfig *config) 479 { 480 PS_ASSERT_PTR_NON_NULL(config, false); 481 482 // optional args 483 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 506 484 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 507 485 … … 517 495 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 518 496 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 519 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 497 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 498 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 520 499 521 500 if (psListLength(where->list)) { … … 525 504 } 526 505 psFree(where); 506 527 507 528 508 // treat limit == 0 as "no limit" … … 552 532 } 553 533 554 for (long i = 0; i < psArrayLength(output); i++) { 555 psMetadata *row = output->data[i]; 556 557 pzDownloadExpRow *doneExp = pzDownloadExpObjectFromMetadata(row); 558 if (!doneExp) { 559 psError(PS_ERR_UNKNOWN, false, "pzDownloadExpObjectFromMetadata() failed"); 560 psFree(doneExp); 561 psFree(output); 562 return false; 563 } 564 565 if (!newExpInsert(config->dbh, 566 0x0, // exp_id 567 doneExp->exp_name, // tmp_exp_name 568 doneExp->camera, // tmp_camera 569 doneExp->telescope, // tmp_telescope 570 "run", // state 571 workdir, // workdir 572 "dirty", // workdir state 573 NULL, // reduction class 574 dvodb, // dvodb 575 tess_id, // tess_id 576 end_stage, // end_stage 577 label, 578 NULL // epoch 579 ) 534 if (!ippdbPrintMetadatas(stdout, output, "toadvance", !simple)) { 535 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 536 psFree(output); 537 return false; 538 } 539 540 psFree(output); 541 542 return true; 543 } 544 545 static bool advanceMode(pxConfig *config) 546 { 547 PS_ASSERT_PTR_NON_NULL(config, false); 548 549 // required 550 PXOPT_LOOKUP_STR(exp_name, config->args, "-exp_name", true, false); 551 PXOPT_LOOKUP_STR(inst, config->args, "-inst", true, false); 552 PXOPT_LOOKUP_STR(telescope, config->args, "-telescope", true, false); 553 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 554 555 // optional 556 PXOPT_LOOKUP_STR(dvodb, config->args, "-dvodb", false, false); 557 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", false, false); 558 PXOPT_LOOKUP_STR(end_stage, config->args, "-end_stage", false, false); 559 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 560 561 // start a transaction so it's all rows or nothing 562 if (!psDBTransaction(config->dbh)) { 563 psError(PS_ERR_UNKNOWN, false, "database error"); 564 return false; 565 } 566 567 if (!newExpInsert(config->dbh, 568 0x0, // exp_id 569 exp_name, // tmp_exp_name 570 inst, // tmp_camera 571 telescope, // tmp_telescope 572 "run", // state 573 workdir, // workdir 574 "dirty", // workdir state 575 NULL, // reduction class 576 dvodb, // dvodb 577 tess_id, // tess_id 578 end_stage, // end_stage 579 label, // label 580 NULL // epoch 581 ) 580 582 ) { 581 583 psError(PS_ERR_UNKNOWN, false, "database error"); 582 psFree(doneExp);583 psFree(output);584 584 return false; 585 585 } … … 592 592 "INSERT INTO newImfile" 593 593 " SElECT" 594 " %" PRId64 "," // exp_id594 " %" PRId64 "," // exp_id 595 595 " pzDownloadImfile.class_id," // tmp_class_id 596 " pzDownloadImfile.uri," // uri597 " NULL" // epoch596 " pzDownloadImfile.uri," // uri 597 " NULL" // epoch 598 598 " FROM pzDownloadImfile" 599 599 " WHERE" … … 602 602 " AND pzDownloadImfile.telescope = '%s'"; 603 603 604 if (!p_psDBRunQueryF(config->dbh, query, exp_id, doneExp->exp_name, doneExp->camera, doneExp->telescope)) { 605 psError(PS_ERR_UNKNOWN, false, "database error"); 606 psFree(doneExp); 607 psFree(output); 608 return false; 609 } 610 611 // sanity check: we should have inserted at least one row 612 psU64 affected = psDBAffectedRows(config->dbh); 613 if (psDBAffectedRows(config->dbh) < 1) { 614 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row but %" PRIu64 " rows were modified", affected); 615 psFree(doneExp); 616 psFree(output); 617 return false; 618 } 619 } 620 621 // set pzDownloadExp.state to 'stop' 622 if (!pzDownloadExpSetState(config, doneExp->exp_name, doneExp->camera, doneExp->telescope, "stop")) { 623 psError(PS_ERR_UNKNOWN, false, "failed to change pzDownloadExp.state for %s:%s:%s", doneExp->exp_name, doneExp->camera, doneExp->telescope); 624 psFree(doneExp); 625 psFree(output); 604 if (!p_psDBRunQueryF(config->dbh, query, exp_id, exp_name, inst, telescope)) { 605 psError(PS_ERR_UNKNOWN, false, "database error"); 626 606 return false; 627 } 628 629 psFree(doneExp); 630 } 631 632 psFree(output); 607 } 608 609 // sanity check: we should have inserted at least one row 610 psU64 affected = psDBAffectedRows(config->dbh); 611 if (psDBAffectedRows(config->dbh) < 1) { 612 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row but %" PRIu64 " rows were modified", affected); 613 return false; 614 } 615 } 616 617 // set pzDownloadExp.state to 'stop' 618 if (!pzDownloadExpSetState(config, exp_name, inst, telescope, "stop")) { 619 psError(PS_ERR_UNKNOWN, false, "failed to change pzDownloadExp.state for %s:%s:%s", exp_name, inst, telescope); 620 return false; 621 } 622 623 // point of no return 624 if (!psDBCommit(config->dbh)) { 625 // rollback 626 if (!psDBRollback(config->dbh)) { 627 psError(PS_ERR_UNKNOWN, false, "database error"); 628 } 629 psError(PS_ERR_UNKNOWN, false, "database error"); 630 return false; 631 } 632 633 633 634 634 return true; … … 872 872 } 873 873 874 static bool advanceMode(pxConfig *config)875 {876 PS_ASSERT_PTR_NON_NULL(config, false);877 878 // NOTE : the command-line args are parsed in copydoneCompleteExp879 880 // start a transaction so it's all rows or nothing881 if (!psDBTransaction(config->dbh)) {882 psError(PS_ERR_UNKNOWN, false, "database error");883 return false;884 }885 886 if (!copydoneCompleteExp(config)) {887 // rollback888 if (!psDBRollback(config->dbh)) {889 psError(PS_ERR_UNKNOWN, false, "database error");890 }891 psError(PS_ERR_UNKNOWN, false, "copydoneCompleteExp() failed");892 return false;893 }894 895 // point of no return896 if (!psDBCommit(config->dbh)) {897 // rollback898 if (!psDBRollback(config->dbh)) {899 psError(PS_ERR_UNKNOWN, false, "database error");900 }901 psError(PS_ERR_UNKNOWN, false, "database error");902 return false;903 }904 905 906 return true;907 }908 909 874 910 875 static bool pzDownloadExpSetState(pxConfig *config, const char *exp_name, const char *camera, const char *telescope, const char *state) -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pztool.h
r18314 r23594 35 35 PZTOOL_MODE_REVERTCOPIED, 36 36 PZTOOL_MODE_CLEARCOMMONFAULTS, 37 PZTOOL_MODE_TOADVANCE, 37 38 PZTOOL_MODE_ADVANCE 38 39 } pztoolMode; -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/pztoolConfig.c
r21479 r23594 97 97 psMetadataAddS16(copydoneArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0); 98 98 psMetadataAddBool(copydoneArgs, PS_LIST_TAIL, "-row_lock", 0, "lock pzDownImfile rows while advancing an exposure", false); 99 // XXX: remove this once advance is fixed 100 psMetadataAddU64(copydoneArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 99 101 100 102 // -copied … … 129 131 // -clearcommonfaults 130 132 psMetadata *clearcommonfaultsArgs = psMetadataAlloc(); 133 // 134 // -toadvance 135 psMetadata *toadvanceArgs = psMetadataAlloc(); 136 psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure ID", NULL); 137 psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-inst", 0, "define camera ID", NULL); 138 psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-telescope", 0, "define telescope ID", NULL); 139 psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-label", 0, "define the label for the chip stage", NULL); 140 psMetadataAddBool(toadvanceArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 141 psMetadataAddU64(toadvanceArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 131 142 132 143 // -advance 133 144 psMetadata *advanceArgs = psMetadataAlloc(); 134 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure ID", NULL); 135 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-inst", 0, "define camera ID", NULL); 136 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-telescope", 0, "define telescope ID", NULL); 137 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-workdir", 0, "define the \"default\" workdir for this exposure", NULL); 138 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-dvodb", 0, "define the dvodb for the next processing step", NULL); 139 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-tess_id", 0, "define the tess_id for the next processing step", NULL); 140 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-end_stage", 0, "define the end goal processing step", NULL); 141 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-label", 0, "define the label for the chip stage", NULL); 142 psMetadataAddU64(advanceArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 145 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-exp_name", 0, "define exposure ID (required)", NULL); 146 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-inst", 0, "define camera ID (required)", NULL); 147 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-telescope", 0, "define telescope ID (required)", NULL); 148 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-workdir", 0, "define the \"default\" workdir for this exposure (required)", NULL); 149 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-dvodb", 0, "define the dvodb for the next processing step", NULL); 150 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-tess_id", 0, "define the tess_id for the next processing step", NULL); 151 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-end_stage", 0, "define the end goal processing step", NULL); 152 psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-label", 0, "define the label for the chip stage", NULL); 143 153 144 154 psMetadata *argSets = psMetadataAlloc(); … … 155 165 PXOPT_ADD_MODE("-revertcopied", "", PZTOOL_MODE_REVERTCOPIED,revertcopiedArgs); 156 166 PXOPT_ADD_MODE("-clearcommonfaults","", PZTOOL_MODE_CLEARCOMMONFAULTS,clearcommonfaultsArgs); 167 PXOPT_ADD_MODE("-toadvance", "", PZTOOL_MODE_TOADVANCE, toadvanceArgs); 157 168 PXOPT_ADD_MODE("-advance", "", PZTOOL_MODE_ADVANCE, advanceArgs); 158 169 -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/regtool.c
r23352 r23594 319 319 320 320 psMetadata *where = psMetadataAlloc(); 321 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 322 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 323 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 321 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 322 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 323 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 324 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 325 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 324 326 325 327 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); … … 407 409 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 408 410 PXOPT_COPY_S16(config->args, where, "-code", "fault", "=="); 411 PXOPT_COPY_S64(config->args, where, "-exp_id_begin", "exp_id", ">="); 412 PXOPT_COPY_S64(config->args, where, "-exp_id_end", "exp_id", "<="); 409 413 410 414 psString query = pxDataGet("regtool_revertprocessedimfile.sql"); … … 419 423 psStringAppend(&query, " AND %s", whereClause); 420 424 psFree(whereClause); 425 } else { 426 psFree(where); 427 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 428 return false; 421 429 } 422 430 psFree(where); … … 429 437 psFree(query); 430 438 431 if (psDBAffectedRows(config->dbh) < 1) { 432 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 433 return false; 434 } 439 int numUpdated = psDBAffectedRows(config->dbh); 440 441 psLogMsg("regtool", PS_LOG_INFO, "Updated %d rawImfile", numUpdated); 435 442 436 443 return true; … … 441 448 { 442 449 PS_ASSERT_PTR_NON_NULL(config, false); 450 451 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); 452 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); 453 454 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 455 PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false); 456 457 if ((code == INT16_MAX) && !isfinite(user_1)) { 458 psError(PS_ERR_UNKNOWN, false, "one of -code or -user_1 must be selected"); 459 return false; 460 } 461 if ((code != INT16_MAX) && isfinite(user_1)) { 462 psError(PS_ERR_UNKNOWN, false, "only one of -code or -user_1 must be selected"); 463 return false; 464 } 443 465 444 466 psMetadata *where = psMetadataAlloc(); … … 446 468 PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); 447 469 448 PXOPT_LOOKUP_S16(code, config->args, "-code", true, false); 449 450 if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) { 451 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 452 psFree (where); 453 return false; 470 if (code != INT16_MAX) { 471 // this is fairly dangerous : can set all if the where is not set... 472 if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) { 473 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 474 psFree (where); 475 return false; 476 } 477 } 478 479 if (isfinite(user_1)) { 480 psString query = pxDataGet("regtool_updateprocessedimfile.sql"); 481 if (!query) { 482 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 483 return false; 484 } 485 486 if (!p_psDBRunQueryF(config->dbh, query, user_1, exp_id, class_id)) { 487 psError(PS_ERR_UNKNOWN, false, "database error"); 488 psFree(query); 489 return false; 490 } 491 psFree(query); 454 492 } 455 493 psFree (where); … … 764 802 hostname, 765 803 code, 766 NULL 804 NULL, 805 0 767 806 )) { 768 807 // rollback … … 806 845 exp_id, 807 846 workdir, 808 label,847 label, 809 848 reduction, 810 849 NULL, // expgroup … … 957 996 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 958 997 PXOPT_COPY_S16(config->args, where, "-code", "fault", "=="); 998 PXOPT_COPY_S64(config->args, where, "-exp_id_begin", "exp_id", ">="); 999 PXOPT_COPY_S64(config->args, where, "-exp_id_end", "exp_id", "<="); 959 1000 960 1001 psString query = pxDataGet("regtool_revertprocessedexp.sql"); … … 968 1009 psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp"); 969 1010 psStringAppend(&query, " AND %s", whereClause); 1011 psFree(whereClause); 1012 } else { 970 1013 psFree(where); 971 psFree(whereClause); 1014 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 1015 return false; 972 1016 } 973 1017 psFree(where); … … 980 1024 psFree(query); 981 1025 982 if (psDBAffectedRows(config->dbh) < 1) { 983 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 984 return false; 985 } 1026 int numUpdated = psDBAffectedRows(config->dbh); 1027 1028 psLogMsg("regtool", PS_LOG_INFO, "Updated %d rawExp", numUpdated); 986 1029 987 1030 return true; -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/regtoolConfig.c
r23352 r23594 129 129 ADD_OPT(Str, processedimfileArgs, "-exp_name", "search by exposure name", NULL); 130 130 ADD_OPT(Str, processedimfileArgs, "-class_id", "search by class ID", NULL); 131 ADD_OPT(Time, processedimfileArgs, "-dateobs_begin", "search for exposures by time (>=)", NULL); 132 ADD_OPT(Time, processedimfileArgs, "-dateobs_end", "search for exposures by time (<)", NULL); 131 133 ADD_OPT(U64, processedimfileArgs, "-limit", "limit result set to N items", 0); 132 134 ADD_OPT(Bool, processedimfileArgs, "-faulted", "only return imfiles with a fault status set", false); … … 135 137 // -revertprocessedimfile 136 138 psMetadata *revertprocessedimfileArgs = psMetadataAlloc(); 137 ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id", "search by exposure ID (required)", 0);139 ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id", "search by exposure ID", 0); 138 140 ADD_OPT(Str, revertprocessedimfileArgs, "-tmp_class_id", "searcy by temp. class ID", NULL); 139 141 ADD_OPT(Str, revertprocessedimfileArgs, "-class_id", "search by class ID", NULL); 140 142 ADD_OPT(S16, revertprocessedimfileArgs, "-code", "search by fault code", 0); 143 ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id_begin", "search by exposure ID", 0); 144 ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id_end", "search by exposure ID", 0); 141 145 142 146 // -updateprocessedimfile … … 144 148 ADD_OPT(S64, updateprocessedimfileArgs, "-exp_id", "search by exposure ID", 0); 145 149 ADD_OPT(Str, updateprocessedimfileArgs, "-class_id", "search by class ID", NULL); 146 ADD_OPT(S16, updateprocessedimfileArgs, "-code", "set fault code (required)", INT16_MAX); 150 ADD_OPT(F64, updateprocessedimfileArgs, "-user_1", "set user stat (1)", NAN); 151 ADD_OPT(S16, updateprocessedimfileArgs, "-code", "set fault code", INT16_MAX); 147 152 148 153 // -pendingexp … … 270 275 // -revertprocessedexp 271 276 psMetadata *revertprocessedexpArgs = psMetadataAlloc(); 272 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID (required)", 0);277 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exposure ID", 0); 273 278 psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0); 279 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id_begin", 0, "search by exposure ID", 0); 280 psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id_end", 0, "search by exposure ID", 0); 274 281 275 282 // -updatedprocessedexp -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/warptool.c
r23352 r23594 157 157 tess_id, 158 158 end_stage, 159 registered 159 registered, 160 false // magicked 160 161 ); 161 162 if (!warpRun) { … … 190 191 191 192 psMetadata *where = psMetadataAlloc(); 192 PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "=="); 193 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 194 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 195 PXOPT_COPY_S64(config->args, where, "-exp_id", "newExp.exp_id", "=="); 196 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 197 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 198 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 199 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 200 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 201 PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "=="); 202 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 203 PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "=="); 204 PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "=="); 205 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 206 PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">="); 207 PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<"); 208 PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">="); 209 PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<"); 210 PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">="); 211 PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<"); 212 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">="); 213 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<"); 214 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">="); 215 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<"); 216 PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">="); 217 PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<"); 218 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">="); 219 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<"); 220 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">="); 221 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<"); 222 PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">="); 223 PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<"); 224 PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">="); 225 PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<"); 226 PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">="); 227 PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<"); 228 PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">="); 229 PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<"); 230 PXOPT_COPY_STR(config->args, where, "-object", "object", "=="); 231 PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">="); 232 PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<"); 233 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 193 pxwarpGetSearchArgs (config, where); 194 PXOPT_COPY_STR(config->args, where, "-reduction", "fakeRun.reduction", "=="); 195 PXOPT_COPY_STR(config->args, where, "-label", "fakeRun.label", "=="); 234 196 235 197 if (!psListLength(where->list) && … … 337 299 338 300 psMetadata *where = psMetadataAlloc(); 339 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 340 PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "=="); 341 PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "=="); 342 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 343 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 344 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 345 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 346 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 347 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 348 PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "=="); 349 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 350 PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "=="); 351 PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "=="); 352 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 353 PXOPT_COPY_F32(config->args, where, "-airmass_min", "airmass", ">="); 354 PXOPT_COPY_F32(config->args, where, "-airmass_max", "airmass", "<"); 355 PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">="); 356 PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<"); 357 PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">="); 358 PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<"); 359 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">="); 360 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<"); 361 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">="); 362 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<"); 363 PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">="); 364 PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<"); 365 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">="); 366 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<"); 367 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">="); 368 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<"); 369 PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">="); 370 PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<"); 371 PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">="); 372 PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<"); 373 PXOPT_COPY_F64(config->args, where, "-ccd_temp_min", "ccd_temp", ">="); 374 PXOPT_COPY_F64(config->args, where, "-ccd_temp_max", "ccd_temp", "<"); 375 PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">="); 376 PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<"); 377 PXOPT_COPY_STR(config->args, where, "-object", "object", "=="); 378 PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">="); 379 PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<"); 301 pxwarpGetSearchArgs (config, where); 302 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpRun.warp_id", "=="); 303 PXOPT_COPY_STR(config->args, where, "-reduction", "warpRun.reduction", "=="); 304 PXOPT_COPY_STR(config->args, where, "-label", "warpRun.label", "=="); 305 PXOPT_COPY_STR(config->args, where, "-state", "warpRun.state", "=="); 380 306 381 307 if (!psListLength(where->list) … … 387 313 } 388 314 389 PXOPT_LOOKUP_STR(state, config->args, "-s tate", false, false);390 PXOPT_LOOKUP_STR(label, config->args, "- label", false, false);315 PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false); 316 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 391 317 392 318 if ((!state) && (!label)) { … … 934 860 PXOPT_LOOKUP_F32(good_frac, config->args, "-good_frac", false, false); 935 861 PXOPT_LOOKUP_BOOL(accept, config->args, "-accept", false); 862 PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false); 936 863 937 864 // default values … … 965 892 !accept, 966 893 code, 967 0 // magic_ds_id894 magicked 968 895 )) { 969 896 if (!psDBRollback(config->dbh)) { … … 995 922 PS_ASSERT_PTR_NON_NULL(config, false); 996 923 997 // XXX this SQL has not been broken out to into seperate files as the MYSQL 998 // < 5 & MYSQL 5 versions need to be kept in sync 999 1000 #undef MYSQL5 1001 #if MYSQL5 1002 // XXX at MySQL 4.1.21 (probably all of 4.1.x) chokes and dies on this 1003 // statement as it thinks it is trying to select from the table being 1004 // updated. The 4.1 manual says that nested sub-queries are explicited 1005 // allowed to do this with update statements as a temporary table is 1006 // created so that you are not actually selecting from the table you are 1007 // modifying. 1008 char *query = 1009 "UPDATE warpRun\n" 1010 " SET warpRun.state = 'stop'\n" 1011 " WHERE\n" 1012 " warpRun.warp_id =\n" 1013 " (SELECT DISTINCT\n" 1014 " warp_id\n" 1015 " FROM\n" 1016 " (SELECT DISTINCT\n" 1017 " warpRun.warp_id,\n" 1018 " warpSkyCellMap.warp_id as foo,\n" 1019 " warpSkyfile.warp_id as bar\n" 1020 " FROM warpRun\n" 1021 " JOIN warpSkyCellMap\n" 1022 " USING(warp_id)\n" 1023 " LEFT JOIN warpSkyfile\n" 1024 " USING(warp_id, skycell_id, tess_id)\n" 1025 " WHERE\n" 1026 " warpRun.state = 'new'\n" 1027 " GROUP BY\n" 1028 " warpRun.warp_id\n" 1029 " HAVING\n" 1030 " COUNT(warpSkyCellMap.warp_id) = COUNT(warpSkyfile.warp_id)\n" 1031 " ) as Foo\n" 1032 " )\n"; 924 psString query = pxDataGet("warptool_finished_run_select.sql"); 925 if (!query) { 926 psError(PXTOOLS_ERR_DATA, false, "failed to retrieve SQL statement"); 927 return false; 928 } 1033 929 1034 930 if (!p_psDBRunQuery(config->dbh, query)) { 1035 931 psError(PS_ERR_UNKNOWN, false, "database error"); 1036 return false; 1037 } 1038 #else // if MYSQL5 1039 { 1040 char *query = 1041 "CREATE TEMPORARY TABLE finished\n" 1042 " (warp_id INT, PRIMARY KEY(warp_id)) ENGINE=MEMORY\n"; 1043 1044 if (!p_psDBRunQuery(config->dbh, query)) { 1045 psError(PS_ERR_UNKNOWN, false, "database error"); 1046 return false; 1047 } 1048 } 1049 1050 { 1051 char *query = 1052 "INSERT INTO finished\n" 1053 " SELECT\n" 1054 " warp_id\n" 1055 " FROM\n" 1056 " (SELECT DISTINCT\n" 1057 " warpRun.warp_id,\n" 1058 " warpSkyCellMap.warp_id as foo,\n" 1059 " warpSkyfile.warp_id as bar\n" 1060 " FROM warpRun\n" 1061 " JOIN warpSkyCellMap\n" 1062 " USING(warp_id)\n" 1063 " LEFT JOIN warpSkyfile\n" 1064 " USING(warp_id, skycell_id)\n" 1065 " WHERE\n" 1066 " warpRun.state = 'new'\n" 1067 " GROUP BY\n" 1068 " warpRun.warp_id\n" 1069 " HAVING\n" 1070 " COUNT(warpSkyCellMap.warp_id) = COUNT(warpSkyfile.warp_id)\n" 1071 " ) as Foo \n"; 1072 1073 if (!p_psDBRunQuery(config->dbh, query)) { 1074 psError(PS_ERR_UNKNOWN, false, "database error"); 1075 return false; 1076 } 1077 } 1078 1079 { 1080 char *query = 1081 "UPDATE warpRun\n" 1082 " SET warpRun.state = 'full'\n" 1083 " WHERE\n" 1084 " warpRun.warp_id =\n" 1085 " (SELECT DISTINCT\n" 1086 " warp_id\n" 1087 " FROM finished\n" 1088 " )\n"; 1089 1090 if (!p_psDBRunQuery(config->dbh, query)) { 1091 psError(PS_ERR_UNKNOWN, false, "database error"); 1092 return false; 1093 } 1094 } 1095 #endif // if MYSQL5 932 psFree(query); 933 return false; 934 } 935 psFree(query); 936 937 psArray *output = p_psDBFetchResult(config->dbh); 938 if (!output) { 939 psError(PS_ERR_UNKNOWN, false, "database error"); 940 return false; 941 } 942 if (!psArrayLength(output)) { 943 psTrace("warptool", PS_LOG_INFO, "no rows found"); 944 psFree(output); 945 return true; 946 } 947 948 query = pxDataGet("warptool_finish_run.sql"); 949 for (long i = 0; i < psArrayLength(output); i++) { 950 psMetadata *row = output->data[i]; 951 952 bool status; 953 psS64 warp_id = psMetadataLookupS64(&status, row, "warp_id"); 954 if (!status) { 955 psError(PS_ERR_UNKNOWN, false, "failed to look up value for warp_id"); 956 psFree(output); 957 psFree(query); 958 return false; 959 } 960 psS32 magicked = psMetadataLookupS64(&status, row, "magicked"); 961 if (!status) { 962 psError(PS_ERR_UNKNOWN, false, "failed to look up value for magicked"); 963 psFree(output); 964 psFree(query); 965 return false; 966 } 967 if (!p_psDBRunQueryF(config->dbh, query, magicked, warp_id)) { 968 psError(PS_ERR_UNKNOWN, false, "database error"); 969 psFree(output); 970 psFree(query); 971 return false; 972 } 973 974 psS64 numUpdated = psDBAffectedRows(config->dbh); 975 976 if (numUpdated != 1) { 977 psError(PS_ERR_UNKNOWN, false, "should have affected 1 row"); 978 psFree(query); 979 psFree(output); 980 return false; 981 } 982 } 983 psFree(output); 984 psFree(query); 1096 985 1097 986 return true; … … 1181 1070 1182 1071 psMetadata *where = psMetadataAlloc(); 1183 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpSkyfile.warp_id", "=="); 1072 pxwarpGetSearchArgs (config, where); 1073 PXOPT_COPY_S64(config->args, where, "-warp_id", "warpSkyfile.warp_id", "=="); 1184 1074 PXOPT_COPY_STR(config->args, where, "-skycell_id", "warpSkyfile.skycell_id", "=="); 1185 PXOPT_COPY_STR(config->args, where, "-tess_id", "warpSkyfile.tess_id", "=="); 1186 PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "=="); 1187 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 1188 PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "=="); 1189 1190 PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "=="); 1191 PXOPT_COPY_STR(config->args, where, "-label", "warpRun.label", "=="); 1192 PXOPT_COPY_STR(config->args, where, "-inst", "rawExp.camera", "=="); 1193 PXOPT_COPY_STR(config->args, where, "-telescope", "rawExp.telescope", "=="); 1194 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs", ">="); 1195 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "rawExp.dateobs", "<="); 1196 PXOPT_COPY_STR(config->args, where, "-exp_tag", "rawExp.exp_tag", "=="); 1197 PXOPT_COPY_STR(config->args, where, "-exp_type", "rawExp.exp_type", "=="); 1198 PXOPT_COPY_STR(config->args, where, "-filelevel", "rawExp.filelevel", "=="); 1199 PXOPT_COPY_STR(config->args, where, "-reduction", "rawExp.reduction", "=="); 1200 PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "=="); 1201 1202 PXOPT_COPY_F32(config->args, where, "-airmass_min", "rawExp.airmass", ">="); 1203 PXOPT_COPY_F32(config->args, where, "-airmass_max", "rawExp.airmass", "<"); 1204 PXOPT_COPY_F64(config->args, where, "-ra_min", "rawExp.ra", ">="); 1205 PXOPT_COPY_F64(config->args, where, "-ra_max", "rawExp.ra", "<"); 1206 PXOPT_COPY_F64(config->args, where, "-decl_min", "rawExp.decl", ">="); 1207 PXOPT_COPY_F64(config->args, where, "-decl_max", "rawExp.decl", "<"); 1208 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "rawExp.exp_time", ">="); 1209 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "rawExp.exp_time", "<"); 1210 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">="); 1211 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<"); 1212 PXOPT_COPY_F64(config->args, where, "-bg_min", "rawExp.bg", ">="); 1213 PXOPT_COPY_F64(config->args, where, "-bg_max", "rawExp.bg", "<"); 1214 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "rawExp.bg_stdev", ">="); 1215 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "rawExp.bg_stdev", "<"); 1216 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "rawExp.bg_mean_stdev", ">="); 1217 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "rawExp.bg_mean_stdev", "<"); 1218 PXOPT_COPY_F64(config->args, where, "-alt_min", "rawExp.alt", ">="); 1219 PXOPT_COPY_F64(config->args, where, "-alt_max", "rawExp.alt", "<"); 1220 PXOPT_COPY_F64(config->args, where, "-az_min", "rawExp.az", ">="); 1221 PXOPT_COPY_F64(config->args, where, "-az_max", "rawExp.az", "<"); 1222 PXOPT_COPY_F64(config->args, where, "-ccd_temp_min", "rawExp.ccd_temp", ">="); 1223 PXOPT_COPY_F64(config->args, where, "-ccd_temp_max", "rawExp.ccd_temp", "<"); 1224 PXOPT_COPY_F64(config->args, where, "-posang_min", "rawExp.posang", ">="); 1225 PXOPT_COPY_F64(config->args, where, "-posang_max", "rawExp.posang", "<"); 1226 PXOPT_COPY_STR(config->args, where, "-object", "rawExp.object", "=="); 1227 PXOPT_COPY_F32(config->args, where, "-solang_min", "rawExp.solang", ">="); 1228 PXOPT_COPY_F32(config->args, where, "-solang_max", "rawExp.solang", "<"); 1229 PXOPT_COPY_S16(config->args, where, "-code", "warpSkyfile.fault", "=="); 1075 PXOPT_COPY_STR(config->args, where, "-tess_id", "warpSkyfile.tess_id", "=="); 1076 PXOPT_COPY_STR(config->args, where, "-reduction", "rawExp.reduction", "=="); 1077 PXOPT_COPY_STR(config->args, where, "-label", "warpRun.label", "=="); 1078 PXOPT_COPY_S16(config->args, where, "-code", "warpSkyfile.fault", "=="); 1230 1079 1231 1080 if (!psListLength(where->list) … … 1246 1095 int numUpdated; // Number updated 1247 1096 { 1097 // This query is no longer necessary because we do not set warpRun's to full statte 1098 // if they have faulted skyfiles. 1099 // We do have runs in the DB that follow the old convention so we leave this in for 1100 // now 1248 1101 psString query = pxDataGet("warptool_revertwarped_update.sql"); 1249 1102 if (!query) { … … 1273 1126 numUpdated = psDBAffectedRows(config->dbh); 1274 1127 1128 #ifdef notdef 1129 // new warpRuns won't get changed (they're already new) so don't require an update 1275 1130 if (numUpdated < 1) { 1276 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row");1131 psError(PS_ERR_UNKNOWN, false, "should have affected at least 1 row"); 1277 1132 if (!psDBRollback(config->dbh)) { 1278 1133 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1280 1135 return false; 1281 1136 } 1137 #endif 1282 1138 } 1283 1139 … … 1462 1318 PS_ASSERT_PTR_NON_NULL(config, NULL); 1463 1319 1464 PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", false, false);1320 PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false); 1465 1321 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1466 1322 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1467 1323 1468 1324 psMetadata *where = psMetadataAlloc(); 1469 if (warp_id) { 1470 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 1471 } 1325 PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "=="); 1472 1326 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1473 1327 … … 1624 1478 1625 1479 // note only updates if warpRun.state = run_state 1626 if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id, run_state)) { 1480 // XXX note that we have removed this constraint for now 1481 if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id)) { 1627 1482 psError(PS_ERR_UNKNOWN, false, "database error"); 1628 1483 // rollback -
branches/cnb_branches/cnb_branch_20090301/ippTools/src/warptoolConfig.c
r23352 r23594 51 51 // XXX need to allow multiple exp_ids 52 52 psMetadata *definebyqueryArgs = psMetadataAlloc(); 53 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-fake_id", 0, "search by fake_id", 0); 54 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-cam_id", 0, "search by cam_id", 0); 55 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip_id", 0); 56 psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 57 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 58 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 59 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); 60 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-dateobs_begin", 0, "search for exposures by time (>=)", NULL); 61 psMetadataAddTime(definebyqueryArgs, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<)", NULL); 62 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-exp_tag", 0, "search by exp_tag", NULL); 63 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 64 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 65 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 66 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 67 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-airmass_min", 0, "define min airmass", NAN); 68 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-airmass_max", 0, "define max airmass", NAN); 69 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-ra_min", 0, "define min", NAN); 70 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-ra_max", 0, "define max", NAN); 71 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-decl_min", 0, "define min", NAN); 72 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-decl_max", 0, "define max", NAN); 73 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-exp_time_min", 0, "define min", NAN); 74 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-exp_time_max", 0, "define max", NAN); 75 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "define max fraction of saturated pixels", NAN); 76 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "define min fraction of saturated pixels", NAN); 77 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_min", 0, "define max", NAN); 78 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_max", 0, "define max", NAN); 79 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_stdev_min", 0, "define max", NAN); 80 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_stdev_max", 0, "define max", NAN); 81 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_mean_stdev_min", 0, "define max", NAN); 82 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-bg_mean_stdev_max", 0, "define max", NAN); 83 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-alt_min", 0, "define min", NAN); 84 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-alt_max", 0, "define max", NAN); 85 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-az_min", 0, "define min", NAN); 86 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-az_max", 0, "define max", NAN); 87 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-ccd_temp_min", 0, "define min ccd tempature", NAN); 88 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-ccd_temp_max", 0, "define max ccd tempature", NAN); 89 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-posang_min", 0, "define min rotator position angle", NAN); 90 psMetadataAddF64(definebyqueryArgs, PS_LIST_TAIL, "-posang_max", 0, "define max rotator position angle", NAN); 91 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-object", 0, "search by exposure object", NULL); 92 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-solang_min", 0, "define min solar angle", NAN); 93 psMetadataAddF32(definebyqueryArgs, PS_LIST_TAIL, "-solang_max", 0, "define max solar angle", NAN); 94 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "search on fakeRun label", NULL); 95 53 pxwarpSetSearchArgs (definebyqueryArgs); 54 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction", 0, "search by fakeRun reduction class", NULL); 55 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", 0, "search on fakeRun label", NULL); 96 56 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_mode", 0, "define mode (warp, diff, stack, magic)", NULL); 97 57 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir", 0, "define workdir", NULL); … … 123 83 // XXX need to allow multiple exp_ids 124 84 psMetadata *updaterunArgs = psMetadataAlloc(); 125 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warptool ID", 0); 126 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-fake_id", 0, "search by fake_id", 0); 127 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip_id", 0); 128 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 129 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 130 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 131 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); 132 psMetadataAddTime(updaterunArgs, PS_LIST_TAIL, "-dateobs_begin", 0, "search for exposures by time (>=)", NULL); 133 psMetadataAddTime(updaterunArgs, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<)", NULL); 134 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-exp_tag", 0, "search by exp_tag", NULL); 135 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 136 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 137 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 138 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 139 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-airmass_min", 0, "define min airmass", NAN); 140 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-airmass_max", 0, "define max airmass", NAN); 141 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-ra_min", 0, "define min", NAN); 142 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-ra_max", 0, "define max", NAN); 143 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-decl_min", 0, "define min", NAN); 144 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-decl_max", 0, "define max", NAN); 145 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-exp_time_min", 0, "define min", NAN); 146 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-exp_time_max", 0, "define max", NAN); 147 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "define max fraction of saturated pixels", NAN); 148 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "define min fraction of saturated pixels", NAN); 149 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_min", 0, "define max", NAN); 150 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_max", 0, "define max", NAN); 151 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_stdev_min", 0, "define max", NAN); 152 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_stdev_max", 0, "define max", NAN); 153 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_mean_stdev_min", 0, "define max", NAN); 154 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-bg_mean_stdev_max", 0, "define max", NAN); 155 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-alt_min", 0, "define min", NAN); 156 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-alt_max", 0, "define max", NAN); 157 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-az_min", 0, "define min", NAN); 158 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-az_max", 0, "define max", NAN); 159 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-ccd_temp_min", 0, "define min ccd tempature", NAN); 160 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-ccd_temp_max", 0, "define max ccd tempature", NAN); 161 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-posang_min", 0, "define min rotator position angle", NAN); 162 psMetadataAddF64(updaterunArgs, PS_LIST_TAIL, "-posang_max", 0, "define max rotator position angle", NAN); 163 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-object", 0, "search by exposure object", NULL); 164 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-solang_min", 0, "define min solar angle", NAN); 165 psMetadataAddF32(updaterunArgs, PS_LIST_TAIL, "-solang_max", 0, "define max solar angle", NAN); 166 167 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 168 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "set state", NULL); 169 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "set label", NULL); 170 171 #if 0 172 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-workdir", 0, "define workdir (required)", NULL); 173 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-registered", 0, "time detrend run was registered", now); 174 #endif 85 pxwarpSetSearchArgs (updaterunArgs); 86 psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warptool ID", 0); 87 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction", 0, "search by warpRun reduction class", NULL); 88 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 0, "search by warpRun state", NULL); 89 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 0, "search by warpRun label", NULL); 90 psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 91 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "set state", NULL); 92 psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "set label", NULL); 175 93 176 94 // -exp … … 235 153 psMetadataAddF32(addwarpedArgs, PS_LIST_TAIL, "-good_frac", 0, "define %% of good pixels", NAN); 236 154 psMetadataAddBool(addwarpedArgs, PS_LIST_TAIL, "-accept", 0, "define if this skycell should be accepted", false); 155 psMetadataAddBool(addwarpedArgs, PS_LIST_TAIL, "-magicked", 0, "define if this skycell has been magicked", false); 237 156 psMetadataAddS16(addwarpedArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0); 238 157 … … 254 173 // XXX need to allow multiple exp_ids 255 174 psMetadata *revertwarpedArgs = psMetadataAlloc(); 175 pxwarpSetSearchArgs(revertwarpedArgs); // XXX does this work here? 256 176 psMetadataAddS64(revertwarpedArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warptool ID", 0); 257 177 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-skycell_id", 0, "search by skycell ID", NULL); 258 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-tess_id", 0, "searcy by tessellation ID", NULL); 259 psMetadataAddS64(revertwarpedArgs, PS_LIST_TAIL, "-fake_id", 0, "search by fake_id", 0); 260 psMetadataAddS64(revertwarpedArgs, PS_LIST_TAIL, "-chip_id", 0, "search by chip_id", 0); 261 psMetadataAddS64(revertwarpedArgs, PS_LIST_TAIL, "-exp_id", 0, "search by exp_id", 0); 262 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-exp_name", 0, "search by exp_name", NULL); 263 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL); 264 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-inst", 0, "search for camera", NULL); 265 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-telescope", 0, "search for telescope", NULL); 266 psMetadataAddTime(revertwarpedArgs, PS_LIST_TAIL, "-dateobs_begin", 0, "search for exposures by time (>=)", NULL); 267 psMetadataAddTime(revertwarpedArgs, PS_LIST_TAIL, "-dateobs_end", 0, "search for exposures by time (<)", NULL); 268 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-exp_tag", 0, "search by exp_tag", NULL); 269 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-exp_type", 0, "search by exp_type", NULL); 270 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-filelevel", 0, "search by filelevel", NULL); 271 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-reduction", 0, "search by reduction class", NULL); 272 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-filter", 0, "search for filter", NULL); 273 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-airmass_min", 0, "define min airmass", NAN); 274 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-airmass_max", 0, "define max airmass", NAN); 275 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-ra_min", 0, "define min", NAN); 276 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-ra_max", 0, "define max", NAN); 277 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-decl_min", 0, "define min", NAN); 278 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-decl_max", 0, "define max", NAN); 279 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-exp_time_min", 0, "define min", NAN); 280 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-exp_time_max", 0, "define max", NAN); 281 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "define max fraction of saturated pixels", NAN); 282 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "define min fraction of saturated pixels", NAN); 283 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_min", 0, "define max", NAN); 284 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_max", 0, "define max", NAN); 285 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_stdev_min", 0, "define max", NAN); 286 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_stdev_max", 0, "define max", NAN); 287 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_mean_stdev_min", 0, "define max", NAN); 288 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-bg_mean_stdev_max", 0, "define max", NAN); 289 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-alt_min", 0, "define min", NAN); 290 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-alt_max", 0, "define max", NAN); 291 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-az_min", 0, "define min", NAN); 292 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-az_max", 0, "define max", NAN); 293 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-ccd_temp_min", 0, "define min ccd tempature", NAN); 294 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-ccd_temp_max", 0, "define max ccd tempature", NAN); 295 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-posang_min", 0, "define min rotator position angle", NAN); 296 psMetadataAddF64(revertwarpedArgs, PS_LIST_TAIL, "-posang_max", 0, "define max rotator position angle", NAN); 297 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-object", 0, "search by exposure object", NULL); 298 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-solang_min", 0, "define min solar angle", NAN); 299 psMetadataAddF32(revertwarpedArgs, PS_LIST_TAIL, "-solang_max", 0, "define max solar angle", NAN); 300 178 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-tess_id", 0, "search by tessellation ID", NULL); 179 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-reduction", 0, "search by warpRun reduction class", NULL); 180 psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-label", 0, "search by warpRun label", NULL); 301 181 psMetadataAddS16(revertwarpedArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0); 302 182 psMetadataAddBool(revertwarpedArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); … … 323 203 psMetadata *pendingcleanupskyfileArgs = psMetadataAlloc(); 324 204 psMetadataAddStr(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-label", 0, "list blocks for specified label", NULL); 325 psMetadataAddS64(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID ", 0);205 psMetadataAddS64(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-warp_id", 0, "search by warp ID (required)", 0); 326 206 psMetadataAddBool(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 327 207 psMetadataAddU64(pendingcleanupskyfileArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);
Note:
See TracChangeset
for help on using the changeset viewer.
