Changeset 24120 for branches/pap_magic/ippTools/src/difftool.c
- Timestamp:
- May 8, 2009, 5:21:35 PM (17 years ago)
- Location:
- branches/pap_magic
- Files:
-
- 1 edited
- 1 copied
-
. (copied) (copied from trunk )
-
ippTools/src/difftool.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_magic/ippTools/src/difftool.c
r24059 r24120 40 40 static bool revertdiffskyfileMode(pxConfig *config); 41 41 static bool definepoprunMode(pxConfig *config); 42 static bool define byqueryMode(pxConfig *config);42 static bool definewarpstackMode(pxConfig *config); 43 43 static bool definewarpwarpMode(pxConfig *config); 44 44 static bool pendingcleanuprunMode(pxConfig *config); … … 79 79 MODECASE(DIFFTOOL_MODE_REVERTDIFFSKYFILE, revertdiffskyfileMode); 80 80 MODECASE(DIFFTOOL_MODE_DEFINEPOPRUN, definepoprunMode); 81 MODECASE(DIFFTOOL_MODE_DEFINE BYQUERY, definebyqueryMode);81 MODECASE(DIFFTOOL_MODE_DEFINEWARPSTACK, definewarpstackMode); 82 82 MODECASE(DIFFTOOL_MODE_DEFINEWARPWARP, definewarpwarpMode); 83 83 MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); … … 116 116 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false); 117 117 PXOPT_LOOKUP_STR(tess_id, config->args, "-tess_id", true, false); 118 PXOPT_LOOKUP_BOOL(bothways, config->args, "-bothways", false); 119 PXOPT_LOOKUP_BOOL(exposure, config->args, "-exposure", false); 118 120 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 119 121 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 120 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false);121 122 122 123 // default … … 133 134 registered, 134 135 tess_id, 135 exp_id, 136 bothways, 137 exposure, 136 138 false 137 139 ); … … 771 773 psS64 template_warp_id, // Warp identifier for template image, PS_MAX_S64 for none 772 774 psS64 template_stack_id, // Stack identifier for template image, PS_MAX_S64 for none 773 psS64 exp_id, // exposure id for input_warp_id (if defined)774 775 pxConfig *config // Configuration 775 776 ) … … 802 803 registered, 803 804 tess_id, 804 exp_id, 805 false, 806 false, 805 807 false // magicked 806 808 ); … … 882 884 PXOPT_LOOKUP_S64(input_warp_id, config->args, "-input_warp_id", false, false); 883 885 PXOPT_LOOKUP_S64(input_stack_id, config->args, "-input_stack_id", false, false); 884 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false);885 886 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 886 887 … … 902 903 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 903 904 "No input has been defined (-input_stack_id or -input_warp_id)"); 904 return false;905 }906 if (input_warp_id && !exp_id) {907 psError(PS_ERR_BAD_PARAMETER_VALUE, true,908 "-exp_id is required with -input_warp_id.");909 905 return false; 910 906 } … … 917 913 template_warp_id ? template_warp_id : PS_MAX_S64, 918 914 template_stack_id ? template_stack_id : PS_MAX_S64, 919 exp_id ? exp_id : PS_MAX_S64,920 915 config)) { 921 916 psError(PS_ERR_UNKNOWN, false, "failed to create populated diffRun"); … … 935 930 936 931 937 static bool define byqueryMode(pxConfig *config)932 static bool definewarpstackMode(pxConfig *config) 938 933 { 939 934 PS_ASSERT_PTR_NON_NULL(config, false); … … 962 957 963 958 // find all things to queue 964 psString query = pxDataGet("difftool_define byquery_part1.sql");959 psString query = pxDataGet("difftool_definewarpstack_part1.sql"); 965 960 if (!query) { 966 961 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 1058 1053 1059 1054 // create temporary table 1060 query = pxDataGet("difftool_define byquery_temp_create.sql");1055 query = pxDataGet("difftool_definewarpstack_temp_create.sql"); 1061 1056 if (!p_psDBRunQuery(config->dbh, query)) { 1062 1057 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1070 1065 query = NULL; 1071 1066 1072 psString skycell_query = pxDataGet("difftool_define byquery_part2.sql");1067 psString skycell_query = pxDataGet("difftool_definewarpstack_part2.sql"); 1073 1068 1074 1069 psArray *list = psArrayAllocEmpty(16); // List of runs, to print … … 1183 1178 registered, 1184 1179 tess_id, 1185 exp_id, 1180 true, 1181 false, 1186 1182 false // magicked 1187 1183 ); … … 1284 1280 // Haversine formula for great circle distance 1285 1281 PXOPT_COPY_F32(config->args, selectWhere, "-distance", 1286 "DEGREES(2*ASIN(SQRT(POW(SIN(inputRawExp.decl - templateRawExp.decl),2) + COS(inputRawExp.decl)*COS(templateRawExp.decl)*POW(SIN(inputRawExp.ra - templateRawExp.ra),2))))", "<="); 1282 "DEGREES(2*ASIN(SQRT(POW(SIN(inputRawExp.decl - templateRawExp.decl),2) + " 1283 "COS(inputRawExp.decl)*COS(templateRawExp.decl)*" 1284 "POW(SIN(inputRawExp.ra - templateRawExp.ra),2))))", "<="); 1287 1285 1288 1286 PXOPT_LOOKUP_BOOL(backwards, config->args, "-backwards", false); … … 1308 1306 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 1309 1307 1308 if (!psDBTransaction(config->dbh)) { 1309 psError(PS_ERR_UNKNOWN, false, "database error"); 1310 psFree(selectWhere); 1311 psFree(insertWhere); 1312 return false; 1313 } 1314 1315 if (!rerun) { 1316 // Need to build table of exposures with diffs 1317 psString tempCreate = pxDataGet("difftool_definewarpwarp_temp_create.sql"); // Create temp table SQL 1318 if (!tempCreate) { 1319 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1320 psFree(selectWhere); 1321 psFree(insertWhere); 1322 if (!psDBRollback(config->dbh)) { 1323 psError(PS_ERR_UNKNOWN, false, "database error"); 1324 } 1325 return false; 1326 } 1327 1328 if (!p_psDBRunQuery(config->dbh, tempCreate)) { 1329 psError(PS_ERR_UNKNOWN, false, "Unable to create temp table: %s", tempCreate); 1330 psFree(tempCreate); 1331 psFree(selectWhere); 1332 psFree(insertWhere); 1333 if (!psDBRollback(config->dbh)) { 1334 psError(PS_ERR_UNKNOWN, false, "database error"); 1335 } 1336 return false; 1337 } 1338 psFree(tempCreate); 1339 1340 psString tempInsert = pxDataGet("difftool_definewarpwarp_temp_insert.sql"); // Insert to temp table 1341 if (!tempInsert) { 1342 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1343 psFree(selectWhere); 1344 psFree(insertWhere); 1345 if (!psDBRollback(config->dbh)) { 1346 psError(PS_ERR_UNKNOWN, false, "database error"); 1347 } 1348 return false; 1349 } 1350 1351 psString where = psStringCopy(""); // WHERE for insertion 1352 if (label) { 1353 psStringAppend(&where, "\nAND diffRun.label = '%s'", label); 1354 } 1355 1356 if (!p_psDBRunQueryF(config->dbh, tempInsert, where, where)) { 1357 psError(PS_ERR_UNKNOWN, false, "Unable to insert into temp table: %s", tempInsert); 1358 psFree(tempInsert); 1359 psFree(where); 1360 psFree(selectWhere); 1361 psFree(insertWhere); 1362 if (!psDBRollback(config->dbh)) { 1363 psError(PS_ERR_UNKNOWN, false, "database error"); 1364 } 1365 return false; 1366 } 1367 psFree(where); 1368 psFree(tempInsert); 1369 } 1370 1371 // Get list of warps to diff 1310 1372 psString select = pxDataGet("difftool_definewarpwarp_select.sql"); 1311 1373 if (!select) { 1312 1374 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1375 psFree(selectWhere); 1376 psFree(insertWhere); 1377 if (!psDBRollback(config->dbh)) { 1378 psError(PS_ERR_UNKNOWN, false, "database error"); 1379 } 1313 1380 return false; 1314 1381 } … … 1323 1390 psFree(selectWhere); 1324 1391 1325 if (!rerun) {1326 psStringAppend(&whereClause, "\n%s (diffRun.diff_id IS NULL", whereClause ? "AND" : "WHERE");1327 if (label) {1328 psStringAppend(&whereClause, " OR diffRun.label != '%s'", label);1329 }1330 psStringAppend(&whereClause, ")");1331 }1332 1333 1392 if (!available) { 1334 1393 psStringAppend(&whereClause, "\n%s inputWarpRun.state = 'full'", whereClause ? "AND" : "WHERE"); 1335 1394 } 1336 1395 1337 if (!psDBTransaction(config->dbh)) { 1338 psError(PS_ERR_UNKNOWN, false, "database error"); 1339 psFree(select); 1340 psFree(whereClause); 1341 psFree(insertWhere); 1342 return false; 1396 if (!rerun) { 1397 psStringAppend(&whereClause, "\n%s diffs.diff_id IS NULL", whereClause ? "AND" : "WHERE"); 1343 1398 } 1344 1399 1345 1400 if (!p_psDBRunQueryF(config->dbh, select, 1346 !rerun ? "\n" : "", // Activate LEFT JOIN against diff Run?1401 !rerun ? "\n" : "", // Activate LEFT JOIN against diffs? 1347 1402 whereClause)) { 1348 1403 psError(PS_ERR_UNKNOWN, false, "Unable to run query: %s [WITH] %s", select, whereClause); … … 1414 1469 psMetadata *row = results->data[i]; // Result row from query 1415 1470 1416 psS64 exp_id = psMetadataLookupS64(NULL, row, "input_exp_id");1417 1471 psS64 input_id = psMetadataLookupS64(NULL, row, "input_warp_id"); 1418 1472 const char *template = psMetadataLookupStr(NULL, row, "template_warp_id"); 1419 1473 const char *tess_id = psMetadataLookupStr(NULL, row, "tess_id"); 1420 if (! exp_id || !input_id || !template || !tess_id) {1474 if (!input_id || !template || !tess_id) { 1421 1475 psError(PXTOOLS_ERR_PROG, false, "Identifiers not found"); 1422 1476 psFree(list); … … 1430 1484 1431 1485 diffRunRow *run = diffRunRowAlloc(0, "reg", workdir, label, reduction, NULL, registered, 1432 tess_id, exp_id, false); // Run to insert1486 tess_id, true, true, false); // Run to insert 1433 1487 if (!diffRunInsertObject(config->dbh, run)) { 1434 1488 psError(PS_ERR_UNKNOWN, false, "database error");
Note:
See TracChangeset
for help on using the changeset viewer.
