Changeset 11047 for trunk/ippTools/src
- Timestamp:
- Jan 11, 2007, 3:38:56 PM (19 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 9 edited
-
Makefile.am (modified) (1 diff)
-
dettool.c (modified) (46 diffs)
-
pxframes.c (modified) (3 diffs)
-
pxinject.c (modified) (2 diffs)
-
pxtables.c (modified) (2 diffs)
-
pxtools.h (modified) (1 diff)
-
regtool.c (modified) (26 diffs)
-
regtool.h (modified) (1 diff)
-
regtoolConfig.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/Makefile.am
r11037 r11047 39 39 pxconfig.c \ 40 40 pxfault.c \ 41 pxframes.c \42 41 pxtables.c \ 43 42 pxtag.c -
trunk/ippTools/src/dettool.c
r10741 r11047 77 77 //static psArray *validDetInputClassIds(pxConfig *config, const char *det_id); 78 78 //static psArray *searchInputImfiles(pxConfig *config, const char *det_id); 79 static detInputExpRow *rawDetrenTodetInputExpRow(raw DetrendExpRow *rawExp, psS32 det_id, psS32 iteration);79 static detInputExpRow *rawDetrenTodetInputExpRow(rawExpRow *rawExp, psS32 det_id, psS32 iteration); 80 80 static psArray *searchRawImfiles(pxConfig *config, psMetadata *where); 81 81 static psS32 incrementIteration(pxConfig *config, const char *det_id); … … 161 161 psString query = psStringCopy( 162 162 "SELECT" 163 " raw DetrendExp.*"164 " FROM raw DetrendExp"163 " rawExp.*" 164 " FROM rawExp" 165 165 " LEFT JOIN detInputExp" 166 " ON raw DetrendExp.exp_tag = detInputExp.exp_tag"166 " ON rawExp.exp_tag = detInputExp.exp_tag" 167 167 " WHERE" 168 168 " detInputExp.exp_tag IS NULL" … … 170 170 171 171 if (config->where) { 172 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "raw DetrendExp");172 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawExp"); 173 173 psStringAppend(&query, " AND %s", whereClause); 174 174 psFree(whereClause); … … 189 189 if (!psArrayLength(output)) { 190 190 // XXX check psError here 191 psError(PS_ERR_UNKNOWN, false, "no pending raw DetrendExp rows found");191 psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found"); 192 192 psFree(output); 193 193 return true; … … 205 205 206 206 // negative simple so the default is true 207 if (!ippdbPrintMetadatas(stdout, output, "raw DetrendExp", !simple)) {207 if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) { 208 208 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 209 209 psFree(output); … … 390 390 391 391 // check that the specified exp_tags actually exist 392 psArray *detrendExps = raw DetrendExpSelectRowObjects(config->dbh, where, 0);392 psArray *detrendExps = rawExpSelectRowObjects(config->dbh, where, 0); 393 393 psFree(where); 394 394 if (!detrendExps) { 395 psError(PS_ERR_UNKNOWN, false, "no raw DetrendExp rows found");396 return false; 397 } 398 399 // we should have one raw DetrendExp row per exp_tag specified395 psError(PS_ERR_UNKNOWN, false, "no rawExp rows found"); 396 return false; 397 } 398 399 // we should have one rawExp row per exp_tag specified 400 400 if (psListLength(item->data.list) != psArrayLength(detrendExps)) { 401 401 psAbort(config->argv[0], 402 "an -exp_tag matched more then one raw DetrendExp (this should not happen");402 "an -exp_tag matched more then one rawExp (this should not happen"); 403 403 404 404 } … … 433 433 long det_id = psDBLastInsertID(config->dbh); 434 434 435 // create new detInputExp row(s) from the raw DetrendExp row(s)435 // create new detInputExp row(s) from the rawExp row(s) 436 436 psArray *inputExps = psArrayAllocEmpty(psArrayLength(detrendExps)); 437 437 for (long i = 0; i < psArrayLength(detrendExps); i++) { … … 803 803 } 804 804 805 // search for raw DetrendExps with the specified options806 psArray *detrendExps = raw DetrendExpSelectRowObjects(config->dbh, where, 0);805 // search for rawExps with the specified options 806 psArray *detrendExps = rawExpSelectRowObjects(config->dbh, where, 0); 807 807 psFree(where); 808 // make sure that we found at least one raw DetrendExp808 // make sure that we found at least one rawExp 809 809 if (!detrendExps) { 810 810 psError(PS_ERR_UNKNOWN, false, "database error"); … … 815 815 } 816 816 if (!psArrayLength(detrendExps)) { 817 psError(PS_ERR_UNKNOWN, true, "no raw DetrendExp rows found");817 psError(PS_ERR_UNKNOWN, true, "no rawExp rows found"); 818 818 psFree(detrendExps); 819 819 psFree(registered); … … 825 825 if (pretend) { 826 826 // negative simple so the default is true 827 if (!raw DetrendExpPrintObjects(stdout, detrendExps, !simple)) {827 if (!rawExpPrintObjects(stdout, detrendExps, !simple)) { 828 828 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 829 829 psFree(detrendExps); … … 874 874 long det_id = psDBLastInsertID(config->dbh); 875 875 876 // create new detInputExp row(s) from the raw DetrendExp row(s)876 // create new detInputExp row(s) from the rawExp row(s) 877 877 psArray *inputExps = psArrayAllocEmpty(psArrayLength(detrendExps)); 878 878 for (long i = 0; i < psArrayLength(detrendExps); i++) { … … 1208 1208 " detResidExp.accept" 1209 1209 " FROM detResidExp" 1210 " JOIN raw DetrendExp"1210 " JOIN rawExp" 1211 1211 " USING(exp_tag)" 1212 1212 " WHERE det_id = %d" … … 1214 1214 1215 1215 if (time_filter->list->n) { 1216 psString whereClause = psDBGenerateWhereConditionSQL(time_filter, "raw DetrendExp");1216 psString whereClause = psDBGenerateWhereConditionSQL(time_filter, "rawExp"); 1217 1217 psStringAppend(&query, " AND %s", whereClause); 1218 1218 psFree(whereClause); … … 1325 1325 } 1326 1326 1327 static detInputExpRow *rawDetrenTodetInputExpRow(raw DetrendExpRow *rawExp, psS32 det_id, psS32 iteration)1327 static detInputExpRow *rawDetrenTodetInputExpRow(rawExpRow *rawExp, psS32 det_id, psS32 iteration) 1328 1328 { 1329 1329 PS_ASSERT_PTR_NON_NULL(rawExp, NULL); … … 1342 1342 1343 1343 // select detInputExp.* 1344 // select raw DetrendExp.*1344 // select rawExp.* 1345 1345 // by: 1346 1346 // exp_tag … … 1349 1349 "SELECT DISTINCT *" 1350 1350 " FROM detInputExp" 1351 " JOIN raw DetrendExp"1351 " JOIN rawExp" 1352 1352 " USING(exp_tag)" 1353 1353 ); … … 1373 1373 if (!psArrayLength(output)) { 1374 1374 // XXX check psError here 1375 psError(PS_ERR_UNKNOWN, false, "no pending raw DetrendExp rows found");1375 psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found"); 1376 1376 psFree(output); 1377 1377 return true; … … 1409 1409 " detRun.det_type," 1410 1410 " rawImfile.*," 1411 " raw DetrendExp.camera"1411 " rawExp.camera" 1412 1412 " FROM rawImfile" 1413 1413 " JOIN detInputExp" 1414 1414 " USING(exp_tag) " 1415 " JOIN raw DetrendExp"1415 " JOIN rawExp" 1416 1416 " USING(exp_tag) " 1417 1417 " JOIN detRun" … … 1494 1494 " detRun.det_type," 1495 1495 " rawImfile.*," 1496 " raw DetrendExp.camera"1496 " rawExp.camera" 1497 1497 " FROM detRun" 1498 1498 " JOIN detInputExp" 1499 1499 " USING(det_id, iteration)" 1500 " JOIN raw DetrendExp"1501 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"1500 " JOIN rawExp" 1501 " ON detInputExp.exp_tag = rawExp.exp_tag" 1502 1502 " JOIN rawImfile" 1503 1503 " ON detInputExp.exp_tag = rawImfile.exp_tag" … … 1582 1582 detInputExpSelectRowObjects(config->dbh, where, 0); 1583 1583 if (!detInputExp) { 1584 psError(PS_ERR_UNKNOWN, false, "no raw DetrendExp rows found");1584 psError(PS_ERR_UNKNOWN, false, "no rawExp rows found"); 1585 1585 return NULL; 1586 1586 } … … 1789 1789 " detRun.det_type," 1790 1790 " detProcessedImfile.exp_tag," 1791 " raw DetrendExp.camera,"1791 " rawExp.camera," 1792 1792 " detProcessedImfile.class_id," 1793 " raw DetrendExp.imfiles"1793 " rawExp.imfiles" 1794 1794 " FROM detRun" 1795 1795 " JOIN detInputExp" 1796 1796 " USING(det_id, iteration)" 1797 " JOIN raw DetrendExp"1798 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"1797 " JOIN rawExp" 1798 " ON detInputExp.exp_tag = rawExp.exp_tag" 1799 1799 " JOIN rawImfile" 1800 " ON raw DetrendExp.exp_tag = rawImfile.exp_tag"1800 " ON rawExp.exp_tag = rawImfile.exp_tag" 1801 1801 " LEFT JOIN detProcessedImfile" 1802 1802 " ON detRun.det_id = detProcessedImfile.det_id" … … 1813 1813 " AND detInputExp.include = 1" 1814 1814 " GROUP BY" 1815 " raw DetrendExp.exp_tag,"1815 " rawExp.exp_tag," 1816 1816 " detRun.det_id" 1817 1817 " HAVING" 1818 " COUNT(detProcessedImfile.class_id) = raw DetrendExp.imfiles"1818 " COUNT(detProcessedImfile.class_id) = rawExp.imfiles" 1819 1819 " ) AS detProcessedExp" 1820 1820 ); … … 1850 1850 if (!psArrayLength(output)) { 1851 1851 // XXX check psError here 1852 psError(PS_ERR_UNKNOWN, false, "no pending raw DetrendExp rows found");1852 psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found"); 1853 1853 psFree(output); 1854 1854 return true; … … 1960 1960 " ON detRun.det_id = detInputExp.det_id" 1961 1961 " AND detRun.iteration = detInputExp.iteration" 1962 " JOIN raw DetrendExp"1963 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"1962 " JOIN rawExp" 1963 " ON detInputExp.exp_tag = rawExp.exp_tag" 1964 1964 " JOIN detProcessedImfile" 1965 1965 " ON detInputExp.det_id = detProcessedImfile.det_id" … … 2001 2001 if (!psArrayLength(output)) { 2002 2002 // XXX check psError here 2003 psError(PS_ERR_UNKNOWN, false, "no pending raw DetrendExp rows found");2003 psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found"); 2004 2004 return true; 2005 2005 } … … 2114 2114 " detRun.det_type," 2115 2115 " detProcessedImfile.class_id," 2116 " raw DetrendExp.camera"2116 " rawExp.camera" 2117 2117 " FROM detRun" 2118 2118 " JOIN detInputExp" 2119 2119 " ON detRun.det_id = detInputExp.det_id" 2120 2120 " AND detRun.iteration = detInputExp.iteration" 2121 " JOIN raw DetrendExp"2122 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"2121 " JOIN rawExp" 2122 " ON detInputExp.exp_tag = rawExp.exp_tag" 2123 2123 " JOIN rawImfile" 2124 2124 " ON detInputExp.exp_tag = rawImfile.exp_tag" … … 2271 2271 2272 2272 // negative simple so the default is true 2273 if (!ippdbPrintMetadatas(stdout, output, "raw DetrendImfile", !simple)) {2273 if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) { 2274 2274 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 2275 2275 psFree(output); … … 2471 2471 2472 2472 // negative simple so the default is true 2473 if (!ippdbPrintMetadatas(stdout, output, "raw DetrendImfile", !simple)) {2473 if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) { 2474 2474 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 2475 2475 psFree(output); … … 2517 2517 " detRun.det_type," 2518 2518 " detRun.iteration," 2519 " raw DetrendExp.camera,"2520 " raw DetrendExp.imfiles,"2519 " rawExp.camera," 2520 " rawExp.imfiles," 2521 2521 " detStackedImfile.class_id" 2522 2522 " FROM detRun" … … 2524 2524 " ON detRun.det_id = detInputExp.det_id" 2525 2525 " AND detRun.iteration = detInputExp.iteration" 2526 " JOIN raw DetrendExp"2527 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"2526 " JOIN rawExp" 2527 " ON detInputExp.exp_tag = rawExp.exp_tag" 2528 2528 " JOIN detStackedImfile" 2529 2529 " ON detInputExp.det_id = detStackedImfile.det_id" … … 2540 2540 " AND detNormalizedStatImfile.class_id IS NULL" 2541 2541 " GROUP BY" 2542 " raw DetrendExp.exp_tag,"2542 " rawExp.exp_tag," 2543 2543 " detRun.iteration," 2544 2544 " detRun.det_id" 2545 " HAVING MAX(raw DetrendExp.imfiles) = COUNT(detStackedImfile.class_id)"2545 " HAVING MAX(rawExp.imfiles) = COUNT(detStackedImfile.class_id)" 2546 2546 ") as tonormalizedstat" 2547 2547 ); … … 2734 2734 "SELECT DISTINCT" 2735 2735 " detRun.det_type," 2736 " raw DetrendExp.camera,"2736 " rawExp.camera," 2737 2737 " detStackedImfile.uri," 2738 2738 " detNormalizedStatImfile.*" … … 2742 2742 " JOIN detInputExp" 2743 2743 " USING(det_id, iteration)" 2744 " JOIN raw DetrendExp"2745 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"2744 " JOIN rawExp" 2745 " ON detInputExp.exp_tag = rawExp.exp_tag" 2746 2746 " JOIN detNormalizedStatImfile" 2747 2747 " ON detStackedImfile.det_id = detNormalizedStatImfile.det_id" … … 2805 2805 2806 2806 // negative simple so the default is true 2807 if (!ippdbPrintMetadatas(stdout, output, "raw DetrendImfile", !simple)) {2807 if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) { 2808 2808 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 2809 2809 psFree(output); … … 3064 3064 " detRun.iteration," 3065 3065 " detRun.det_type," 3066 " raw DetrendExp.camera,"3067 " raw DetrendExp.telescope,"3068 " raw DetrendExp.exp_type,"3069 " raw DetrendExp.imfiles"3066 " rawExp.camera," 3067 " rawExp.telescope," 3068 " rawExp.exp_type," 3069 " rawExp.imfiles" 3070 3070 " FROM detRun" 3071 3071 " JOIN detInputExp" 3072 3072 " ON detRun.det_id = detInputExp.det_id" 3073 3073 " AND detRun.iteration = detInputExp.iteration" 3074 " JOIN raw DetrendExp"3075 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"3074 " JOIN rawExp" 3075 " ON detInputExp.exp_tag = rawExp.exp_tag" 3076 3076 " JOIN detNormalizedImfile" 3077 3077 " ON detInputExp.det_id = detNormalizedImfile.det_id" … … 3227 3227 " detRun.iteration," 3228 3228 " detRun.det_type," 3229 " raw DetrendExp.camera,"3230 " raw DetrendExp.telescope,"3231 " raw DetrendExp.exp_type,"3232 " raw DetrendExp.imfiles"3229 " rawExp.camera," 3230 " rawExp.telescope," 3231 " rawExp.exp_type," 3232 " rawExp.imfiles" 3233 3233 " FROM detRun" 3234 3234 " JOIN detInputExp" 3235 3235 " ON detRun.det_id = detInputExp.det_id" 3236 3236 " AND detRun.iteration = detInputExp.iteration" 3237 " JOIN raw DetrendExp"3238 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"3237 " JOIN rawExp" 3238 " ON detInputExp.exp_tag = rawExp.exp_tag" 3239 3239 " JOIN detNormalizedImfile" 3240 3240 " ON detInputExp.det_id = detNormalizedImfile.det_id" … … 3462 3462 " detProcessedImfile.uri,\n" 3463 3463 " detNormalizedImfile.uri AS det_uri,\n" 3464 " raw DetrendExp.camera\n"3464 " rawExp.camera\n" 3465 3465 " FROM detRun\n" 3466 3466 " JOIN detInputExp\n" 3467 3467 " USING(det_id, iteration)\n" 3468 " JOIN raw DetrendExp\n"3469 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag\n"3468 " JOIN rawExp\n" 3469 " ON detInputExp.exp_tag = rawExp.exp_tag\n" 3470 3470 " JOIN detProcessedImfile\n" 3471 3471 " ON detRun.det_id = detProcessedImfile.det_id\n" … … 3497 3497 " rawImfile.uri,\n" 3498 3498 " 'NULL' AS det_uri,\n" 3499 " raw DetrendExp.camera\n"3499 " rawExp.camera\n" 3500 3500 " FROM detRun\n" 3501 3501 " JOIN detInputExp\n" 3502 3502 " USING(det_id, iteration)\n" 3503 " JOIN raw DetrendExp\n"3504 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag\n"3503 " JOIN rawExp\n" 3504 " ON detInputExp.exp_tag = rawExp.exp_tag\n" 3505 3505 " JOIN rawImfile\n" 3506 3506 " ON detInputExp.exp_tag = rawImfile.exp_tag\n" … … 3689 3689 " JOIN detInputExp\n" 3690 3690 " USING(det_id, iteration)\n" 3691 " JOIN raw DetrendExp\n"3692 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag\n"3691 " JOIN rawExp\n" 3692 " ON detInputExp.exp_tag = rawExp.exp_tag\n" 3693 3693 " JOIN rawImfile\n" 3694 3694 " ON detInputExp.exp_tag = rawImfile.exp_tag\n" … … 4047 4047 " detInputExp.exp_tag,\n" 4048 4048 " detInputExp.include,\n" 4049 " raw DetrendExp.imfiles,\n"4050 " raw DetrendExp.camera,\n"4049 " rawExp.imfiles,\n" 4050 " rawExp.camera,\n" 4051 4051 " detResidImfile.class_id\n" 4052 4052 " FROM detRun\n" 4053 4053 " JOIN detInputExp\n" 4054 4054 " USING(det_id, iteration)\n" 4055 " JOIN raw DetrendExp\n"4056 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag\n"4055 " JOIN rawExp\n" 4056 " ON detInputExp.exp_tag = rawExp.exp_tag\n" 4057 4057 " JOIN detResidImfile\n" 4058 4058 " ON detRun.det_id = detResidImfile.det_id\n" … … 4073 4073 " detRun.det_id\n" 4074 4074 " HAVING\n" 4075 " raw DetrendExp.imfiles = COUNT(detResidImfile.class_id)\n"4075 " rawExp.imfiles = COUNT(detResidImfile.class_id)\n" 4076 4076 " ) AS toresidexp\n" 4077 4077 ); … … 4171 4171 " detInputExp.exp_tag," 4172 4172 " detInputExp.include," 4173 " raw DetrendExp.imfiles"4173 " rawExp.imfiles" 4174 4174 " FROM detRun" 4175 4175 " JOIN detInputExp" 4176 4176 " USING(det_id, iteration)" 4177 " JOIN raw DetrendExp"4178 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag"4177 " JOIN rawExp" 4178 " ON detInputExp.exp_tag = rawExp.exp_tag" 4179 4179 " JOIN detResidImfile" 4180 4180 " ON detRun.det_id = detResidImfile.det_id" … … 4195 4195 " detRun.det_id" 4196 4196 " HAVING" 4197 " raw DetrendExp.imfiles = COUNT(detResidImfile.class_id)"4197 " rawExp.imfiles = COUNT(detResidImfile.class_id)" 4198 4198 " ) AS toresidexp" 4199 4199 ); … … 4528 4528 " detRun.mode,\n" 4529 4529 " detInputExp.exp_tag,\n" 4530 " raw DetrendExp.camera\n"4530 " rawExp.camera\n" 4531 4531 " FROM detRun\n" 4532 4532 " JOIN detInputExp\n" 4533 4533 " USING(det_id, iteration)\n" 4534 " JOIN raw DetrendExp\n"4535 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag\n"4534 " JOIN rawExp\n" 4535 " ON detInputExp.exp_tag = rawExp.exp_tag\n" 4536 4536 " LEFT JOIN detResidExp\n" 4537 4537 " ON detRun.det_id = detResidExp.det_id\n" … … 4802 4802 " ON detRun.det_id = detInputExp.det_id\n" 4803 4803 " AND detRun.iteration = detInputExp.iteration\n" 4804 " LEFT JOIN raw DetrendExp\n"4805 " ON detInputExp.exp_tag = raw DetrendExp.exp_tag\n"4804 " LEFT JOIN rawExp\n" 4805 " ON detInputExp.exp_tag = rawExp.exp_tag\n" 4806 4806 " LEFT JOIN detResidExp\n" 4807 4807 " ON detRun.det_id = detResidExp.det_id\n" … … 5305 5305 psFree(where); 5306 5306 if (!detrendExps) { 5307 psError(PS_ERR_UNKNOWN, false, "no raw DetrendExp rows found");5307 psError(PS_ERR_UNKNOWN, false, "no rawExp rows found"); 5308 5308 psFree(where); 5309 5309 return false; -
trunk/ippTools/src/pxframes.c
r10230 r11047 57 57 //PX_FRAME_ALLOC(newFrame, newExp); 58 58 //PX_FRAME_ALLOC(rawDetrendFrame, rawDetrendExp); 59 PX_FRAME_ALLOC(rawScienceFrame, rawScienceExp);59 //PX_FRAME_ALLOC(rawScienceFrame, rawScienceExp); 60 60 //PX_FRAME_ALLOC(p2PendingFrame, p2PendingExp); 61 61 … … 92 92 93 93 //PX_FRAME_PRINT(newFrame, newImfile); 94 PX_FRAME_PRINT(rawScienceFrame, rawImfile);94 //PX_FRAME_PRINT(rawScienceFrame, rawImfile); 95 95 //PX_FRAME_PRINT(rawDetrendFrame, rawImfile); 96 96 //PX_FRAME_PRINT(p2PendingFrame, p2PendingImfile); … … 145 145 //PX_FRAME_SEARCH(newFrame, newExp, newImfile); 146 146 //PX_FRAME_SEARCH(rawDetrendFrame, rawDetrendExp, rawImfile, exp_tag); 147 PX_FRAME_SEARCH(rawScienceFrame, rawScienceExp, rawImfile, exp_tag);147 //PX_FRAME_SEARCH(rawScienceFrame, rawScienceExp, rawImfile, exp_tag); 148 148 //PX_FRAME_SEARCH(p2PendingFrame, p2PendingExp, p2PendingImfile, exp_tag); 149 149 -
trunk/ippTools/src/pxinject.c
r10971 r11047 148 148 dateobs, 149 149 exp_type, 150 imfiles, 151 0 // error flags 150 imfiles 152 151 ) 153 152 ) { … … 232 231 233 232 // insert with error flag state set to 0 (no errors) 234 if (!newImfileInsert(config->dbh, exp_tag, class, class_id, uri , 0)) {233 if (!newImfileInsert(config->dbh, exp_tag, class, class_id, uri)) { 235 234 psError(PS_ERR_UNKNOWN, false, "database error"); 236 235 return false; -
trunk/ippTools/src/pxtables.c
r10755 r11047 57 57 CREATE_TABLE(newExpCreateTable); 58 58 CREATE_TABLE(newImfileCreateTable); 59 CREATE_TABLE(raw ScienceExpCreateTable);59 CREATE_TABLE(rawExpCreateTable); 60 60 CREATE_TABLE(rawImfileCreateTable); 61 CREATE_TABLE(rawDetrendExpCreateTable);62 61 CREATE_TABLE(p1PendingExpCreateTable); 63 62 CREATE_TABLE(p2PendingExpCreateTable); … … 130 129 DROP_TABLE(newExpDropTable); 131 130 DROP_TABLE(newImfileDropTable); 132 DROP_TABLE(raw ScienceExpDropTable);131 DROP_TABLE(rawExpDropTable); 133 132 DROP_TABLE(rawImfileDropTable); 134 DROP_TABLE(rawDetrendExpDropTable);135 133 DROP_TABLE(p1PendingExpDropTable); 136 134 DROP_TABLE(p2PendingExpDropTable); -
trunk/ippTools/src/pxtools.h
r11037 r11047 49 49 bool pxDeleteTables (pxConfig *config); 50 50 51 typedef struct {52 rawScienceExpRow *exposure;53 psArray *images;54 } rawScienceFrame;55 56 rawScienceFrame *rawScienceFrameAlloc(57 rawScienceExpRow *exposure,58 psArray *images59 );60 61 bool rawScienceFramePrint(FILE *stream, pxConfig *config, psArray *frames);62 psArray *rawScienceFrameSearch(pxConfig *config);63 bool rawScienceFrameInsert(pxConfig *config, rawScienceFrame *frame);64 65 51 bool pxSetFaultCode(psDB *dbh, const char *tableName, psMetadata *where, psS8 code); 66 52 -
trunk/ippTools/src/regtool.c
r11037 r11047 27 27 #include "p0tool.h" 28 28 29 static bool pendingimfileMode(pxConfig *config); 30 static bool addprocessedimfileMode(pxConfig *config); 31 static bool processedimfileMode(pxConfig *config); 32 static bool updateprocessedimfileMode(pxConfig *config); 33 29 34 static bool pendingexpMode(pxConfig *config); 30 static bool pendingimfileMode(pxConfig *config); 31 static bool updateexpMode(pxConfig *config); 32 static bool updateimfileMode(pxConfig *config); 33 static bool faultexpMode(pxConfig *config); 34 static bool faultimfileMode(pxConfig *config); 35 static bool rawimfileMode(pxConfig *config); 35 static bool addprocessedexpMode(pxConfig *config); 36 static bool processedexpMode(pxConfig *config); 37 static bool updateprocessedexpMode(pxConfig *config); 38 39 36 40 // static p1PendingExpRow *newToP1PendingExp(newExpRow *newExp); 37 41 static p2PendingExpRow *newToP2PendingExp(pxConfig *config, newExpRow *newExp); 38 42 static p2PendingImfileRow *rawImfileToP2PendingImfile(pxConfig *config, rawImfileRow *rawImfile); 39 static rawScienceExpRow *newToRawScienceExp(pxConfig *config, newExpRow *exp); 40 static raw DetrendExpRow *newToRawDetrendExp(pxConfig *config, newExpRow *exp);43 44 static rawExpRow *newToRawExp(pxConfig *config, newExpRow *exp); 41 45 static rawImfileRow *newToRawImfile(pxConfig *config, newImfileRow *exp); 42 46 //static psU32 mapCodeStrToInt(const char *codeStr); … … 59 63 60 64 switch (config->mode) { 61 MODECASE(P0TOOL_MODE_PENDINGEXP, pendingexpMode); 62 MODECASE(P0TOOL_MODE_PENDINGIMFILE, pendingimfileMode); 63 MODECASE(P0TOOL_MODE_UPDATEEXP, updateexpMode); 64 MODECASE(P0TOOL_MODE_FAULTEXP, faultexpMode); 65 MODECASE(P0TOOL_MODE_UPDATEIMFILE, updateimfileMode); 66 MODECASE(P0TOOL_MODE_FAULTIMFILE, faultimfileMode); 67 MODECASE(P0TOOL_MODE_RAWIMFILE, rawimfileMode); 65 MODECASE(P0TOOL_MODE_PENDINGIMFILE, pendingimfileMode); 66 MODECASE(P0TOOL_MODE_ADDPROCESSEDIMFILE, addprocessedimfileMode); 67 MODECASE(P0TOOL_MODE_PROCESSEDIMFILE, processedimfileMode); 68 MODECASE(P0TOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileMode); 69 MODECASE(P0TOOL_MODE_PENDINGEXP, pendingexpMode); 70 MODECASE(P0TOOL_MODE_ADDPROCESSEDEXP, addprocessedexpMode); 71 MODECASE(P0TOOL_MODE_PROCESSEDEXP, processedexpMode); 72 MODECASE(P0TOOL_MODE_UPDATEPROCESSEDEXP, updateprocessedexpMode); 68 73 default: 69 74 psAbort(argv[0], "invalid option (this should not happen)"); … … 88 93 } 89 94 90 static bool pendingexpMode(pxConfig *config) 95 96 static bool pendingimfileMode(pxConfig *config) 91 97 { 92 98 PS_ASSERT_PTR_NON_NULL(config, false); … … 99 105 } 100 106 107 // select newImfiles that: 108 // exp_tag is in newExp 109 // don't have their exp_tag in rawExp 110 // XXX having the same exp_tag in newExp and raw*Exp is probably an error 111 // that should be checked for 112 113 psString query = psStringCopy( 114 "SELECT\n" 115 " newImfile.*\n" 116 " FROM newImfile\n" 117 " LEFT JOIN newExp\n" 118 " USING(exp_tag)\n" 119 " LEFT JOIN rawExp\n" 120 " USING(exp_tag)\n" 121 " WHERE\n" 122 " newExp.exp_tag is NOT NULL\n" 123 " AND rawExp.exp_tag IS NULL\n" 124 ); 125 126 // treat limit == 0 as "no limit" 127 if (limit) { 128 psString limitString = psDBGenerateLimitSQL(limit); 129 psStringAppend(&query, " %s", limitString); 130 psFree(limitString); 131 } 132 133 if (!p_psDBRunQuery(config->dbh, query)) { 134 // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms) 135 psError(PXTOOLS_ERR_PROG, false, "database error"); 136 psFree(query); 137 return false; 138 } 139 psFree(query); 140 141 psArray *output = p_psDBFetchResult(config->dbh); 142 if (!output) { 143 // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms) 144 psError(PXTOOLS_ERR_PROG, false, "database error"); 145 return false; 146 } 147 if (!psArrayLength(output)) { 148 psFree(output); 149 return true; 150 } 151 152 bool simple = false; 153 simple = psMetadataLookupBool(&status, config->args, "-simple"); 154 if (!status) { 155 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -simple"); 156 return false; 157 } 158 159 // negate simple so the default is true 160 if (!ippdbPrintMetadatas(stdout, output, "p0PendingImfile", !simple)) { 161 psError(PXTOOLS_ERR_PROG, false, "failed to print array"); 162 psFree(output); 163 return false; 164 } 165 166 psFree(output); 167 168 return true; 169 } 170 171 172 static bool addprocessedimfileMode(pxConfig *config) 173 { 174 PS_ASSERT_PTR_NON_NULL(config, false); 175 176 // XXX search by the whole frame some imfiles without a newExp don't get 177 // processed -- this may not be the correct thing to do 178 psString query = psStringCopy( 179 "SELECT\n" 180 " *\n" 181 " FROM\n" 182 " (SELECT newImfile.* FROM newImfile\n" 183 " LEFT JOIN newExp USING(exp_tag)\n" 184 " LEFT JOIN rawExp USING(exp_tag)\n" 185 " WHERE newExp.exp_tag IS NOT NULL\n" 186 " AND rawExp.exp_tag IS NULL) as Foo\n" 187 ); // WHERE class is generated from exp_tag, class, & class_id 188 189 { 190 // build a query to search by exp_tag, class, class_id 191 psMetadata *where = psMetadataAlloc(); 192 bool status = false; 193 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag"); 194 if (!status) { 195 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag"); 196 psFree(query); 197 return false; 198 } 199 if (exp_tag) { 200 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) { 201 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 202 psFree(where); 203 psFree(query); 204 return false; 205 } 206 } 207 psString class = psMetadataLookupStr(&status, config->args, "-class"); 208 if (!status) { 209 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class"); 210 psFree(query); 211 return false; 212 } 213 if (class) { 214 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==", class)) { 215 psError(PS_ERR_UNKNOWN, false, "failed to add item class"); 216 psFree(where); 217 psFree(query); 218 return false; 219 } 220 } 221 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 222 if (!status) { 223 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 224 psFree(query); 225 return false; 226 } 227 if (class_id) { 228 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) { 229 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 230 psFree(where); 231 psFree(query); 232 return false; 233 } 234 } 235 236 // there's not 237 psString whereClaus = psDBGenerateWhereSQL(where, NULL); 238 psFree(where); 239 if (whereClaus) { 240 psStringAppend(&query, " %s", whereClaus); 241 psFree(whereClaus); 242 } 243 } 244 245 if (!p_psDBRunQuery(config->dbh, query)) { 246 psError(PS_ERR_UNKNOWN, false, "database error"); 247 psFree(query); 248 return false; 249 } 250 psFree(query); 251 252 psArray *output = p_psDBFetchResult(config->dbh); 253 if (!output) { 254 psError(PS_ERR_UNKNOWN, false, "database error"); 255 return false; 256 } 257 if (!psArrayLength(output)) { 258 // XXX check psError here 259 psError(PS_ERR_UNKNOWN, false, "no pending newImfile rows found"); 260 psFree(output); 261 return false; 262 } 263 264 // insert 'newImfile's into rawImfile 265 if (psArrayLength(output) > 0) { 266 // start a transaction so we don't end up half of the imfiles we were 267 // trying to update uninserted 268 if (!psDBTransaction(config->dbh)) { 269 psError(PS_ERR_UNKNOWN, false, "database error"); 270 psFree(output); 271 return false; 272 } 273 274 for (long i = 0; i < psArrayLength(output); i++) { 275 // convert newImfile metadata -> newImfile object 276 newImfileRow *object = newImfileObjectFromMetadata(output->data[i]); 277 // convert newImfile object -> rawImfile object 278 rawImfileRow *imfile = newToRawImfile(config, object); 279 if (!imfile) { 280 // rollback 281 if (!psDBRollback(config->dbh)) { 282 psError(PS_ERR_UNKNOWN, false, "database error"); 283 } 284 psError(PS_ERR_UNKNOWN, false, "failed to create a new rawImfile row"); 285 psFree(object); 286 psFree(output); 287 return false; 288 } 289 // insert the rawImfile object into the database 290 if (!rawImfileInsertObject(config->dbh, imfile)) { 291 // rollback 292 if (!psDBRollback(config->dbh)) { 293 psError(PS_ERR_UNKNOWN, false, "database error"); 294 } 295 psError(PS_ERR_UNKNOWN, false, "failed to insert row into the database"); 296 psFree(imfile); 297 psFree(object); 298 psFree(output); 299 return false; 300 } 301 psFree(imfile); 302 // remove the neImfile object from the database 303 if (!newImfileDeleteObject(config->dbh, object)) { 304 // rollback 305 if (!psDBRollback(config->dbh)) { 306 psError(PS_ERR_UNKNOWN, false, "database error"); 307 } 308 psError(PS_ERR_UNKNOWN, false, "failed to delete row from the database"); 309 psFree(object); 310 psFree(output); 311 return false; 312 } 313 psFree(object); 314 } 315 316 // point of no return for rawImfile 317 if (!psDBCommit(config->dbh)) { 318 psError(PS_ERR_UNKNOWN, false, "database error"); 319 psFree(output); 320 return false; 321 } 322 } 323 324 psFree(output); 325 326 return true; 327 } 328 329 330 static bool processedimfileMode(pxConfig *config) 331 { 332 PS_ASSERT_PTR_NON_NULL(config, false); 333 334 bool status = false; 335 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 336 if (!status) { 337 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 338 return false; 339 } 340 101 341 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 102 342 if (!status) { … … 105 345 } 106 346 347 // find all rawImfiles matching the default query 348 psString query = psStringCopy( 349 "SELECT\n" 350 " *\n" 351 " FROM rawImfile\n" 352 " WHERE rawImfile.exp_tag is NOT NULL\n" //bogus conditional so there is a where clause to append to 353 ); 354 355 if (config->where) { 356 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawImfile"); 357 psStringAppend(&query, " AND %s", whereClause); 358 psFree(whereClause); 359 } 360 361 if (faulted) { 362 // list only faulted rows 363 psStringAppend(&query, " %s", "AND rawImfile.fault != 0"); 364 } else { 365 // don't list faulted rows 366 psStringAppend(&query, " %s", "AND rawImfile.fault = 0"); 367 } 368 369 // treat limit == 0 as "no limit" 370 if (limit) { 371 psString limitString = psDBGenerateLimitSQL(limit); 372 psStringAppend(&query, " %s", limitString); 373 psFree(limitString); 374 } 375 376 if (!p_psDBRunQuery(config->dbh, query)) { 377 psError(PS_ERR_UNKNOWN, false, "database error"); 378 psFree(query); 379 return false; 380 } 381 psFree(query); 382 383 psArray *output = p_psDBFetchResult(config->dbh); 384 if (!output) { 385 psError(PS_ERR_UNKNOWN, false, "database error"); 386 return false; 387 } 388 if (!psArrayLength(output)) { 389 psError(PS_ERR_UNKNOWN, false, "no pending rawImfile rows found"); 390 psFree(output); 391 return true; 392 } 393 394 bool simple = false; 395 { 396 bool status = false; 397 simple = psMetadataLookupBool(&status, config->args, "-simple"); 398 if (!status) { 399 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 400 return false; 401 } 402 } 403 404 if (psArrayLength(output)) { 405 // negative simple so the default is true 406 if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) { 407 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 408 psFree(output); 409 return false; 410 } 411 } 412 413 psFree(output); 414 415 return true; 416 } 417 418 419 static bool updateprocessedimfileMode(pxConfig *config) 420 { 421 PS_ASSERT_PTR_NON_NULL(config, false); 422 423 bool status = false; 424 psS8 code = psMetadataLookupS8(&status, config->args, "-code"); 425 if (!status) { 426 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 427 return false; 428 } 429 430 if (!pxSetFaultCode(config->dbh, "rawImfile", config->where, code)) { 431 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 432 return false; 433 } 434 435 return true; 436 } 437 438 439 static bool pendingexpMode(pxConfig *config) 440 { 441 PS_ASSERT_PTR_NON_NULL(config, false); 442 443 bool status = false; 444 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 445 if (!status) { 446 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 447 return false; 448 } 449 107 450 // return only exps that: 108 // are not in rawScienceExp 109 // are not in rawDetrendExp 451 // are not in rawExp 110 452 // have ALL of their imfiles in rawImfile (by count) 111 453 // and have no associated imfiles left in newImfile … … 117 459 " LEFT JOIN newImfile" 118 460 " USING(exp_tag)" 119 " LEFT JOIN rawScienceExp" 120 " USING(exp_tag)" 121 " LEFT JOIN rawDetrendExp" 461 " LEFT JOIN rawExp" 122 462 " USING(exp_tag)" 123 463 " WHERE" 124 464 " newImfile.exp_tag IS NULL" 125 " AND rawScienceExp.exp_tag IS NULL" 126 " AND rawDetrendExp.exp_tag IS NULL" 465 " AND rawExp.exp_tag IS NULL" 127 466 " AND newExp.imfiles =" 128 467 " (SELECT COUNT(exp_tag) FROM rawImfile" 129 468 " WHERE rawImfile.exp_tag = newExp.exp_tag)" 130 469 ); 131 132 if (faulted) {133 // list only faulted rows134 psStringAppend(&query, " %s", "AND newExp.fault != 0");135 } else {136 // don't list faulted rows137 psStringAppend(&query, " %s", "AND newExp.fault = 0");138 }139 470 140 471 // treat limit == 0 as "no limit" … … 183 514 } 184 515 185 static bool pendingimfileMode(pxConfig *config) 516 517 static bool addprocessedexpMode(pxConfig *config) 186 518 { 187 519 PS_ASSERT_PTR_NON_NULL(config, false); 188 520 189 bool status = false;190 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit");191 if (!status) {192 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit");193 return false;194 }195 196 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted");197 if (!status) {198 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -faulted");199 return false;200 }201 202 // select newImfiles that:203 // exp_tag is in newExp204 // don't have their exp_tag in rawScienceExp205 // don't have their exp_tag in rawDetrendExp206 // XXX having the same exp_tag in newExp and raw*Exp is probably an error207 // that should be checked for208 209 psString query = psStringCopy(210 "SELECT newImfile.* FROM newImfile"211 " LEFT JOIN newExp USING(exp_tag)"212 " LEFT JOIN rawScienceExp USING(exp_tag)"213 " LEFT JOIN rawDetrendExp USING (exp_tag)"214 " WHERE newExp.exp_tag is NOT NULL"215 " AND rawScienceExp.exp_tag IS NULL"216 " AND rawDetrendExp.exp_tag IS NULL"217 );218 219 if (faulted) {220 // list only faulted rows221 psStringAppend(&query, " %s", "AND newImfile.fault != 0");222 } else {223 // don't list faulted rows224 psStringAppend(&query, " %s", "AND newImfile.fault = 0");225 }226 227 // treat limit == 0 as "no limit"228 if (limit) {229 psString limitString = psDBGenerateLimitSQL(limit);230 psStringAppend(&query, " %s", limitString);231 psFree(limitString);232 }233 234 if (!p_psDBRunQuery(config->dbh, query)) {235 // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms)236 psError(PXTOOLS_ERR_PROG, false, "database error");237 psFree(query);238 return false;239 }240 psFree(query);241 242 psArray *output = p_psDBFetchResult(config->dbh);243 if (!output) {244 // XXX PS_EXIT_PROG_ERROR (incorrect SQL) or SYS_ERROR (database comms)245 psError(PXTOOLS_ERR_PROG, false, "database error");246 return false;247 }248 if (!psArrayLength(output)) {249 psFree(output);250 return true;251 }252 253 bool simple = false;254 simple = psMetadataLookupBool(&status, config->args, "-simple");255 if (!status) {256 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -simple");257 return false;258 }259 260 // negate simple so the default is true261 if (!ippdbPrintMetadatas(stdout, output, "newImfile", !simple)) {262 psError(PXTOOLS_ERR_PROG, false, "failed to print array");263 psFree(output);264 return false;265 }266 267 psFree(output);268 269 return true;270 }271 272 static bool faultexpMode(pxConfig *config)273 {274 bool status = false;275 psS8 code = psMetadataLookupS8(&status, config->args, "-code");276 if (!status) {277 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");278 return false;279 }280 281 if (!pxSetFaultCode(config->dbh, "newExp", config->where, code)) {282 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");283 return false;284 }285 286 return true;287 }288 289 static bool faultimfileMode(pxConfig *config)290 {291 PS_ASSERT_PTR_NON_NULL(config, false);292 293 bool status = false;294 psS8 code = psMetadataLookupS8(&status, config->args, "-code");295 if (!status) {296 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code");297 return false;298 }299 300 if (!pxSetFaultCode(config->dbh, "newImfile", config->where, code)) {301 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");302 return false;303 }304 305 return true;306 }307 308 309 static bool updateexpMode(pxConfig *config)310 {311 PS_ASSERT_PTR_NON_NULL(config, false);312 313 521 // make sure that the exp_tag(s) are ready to be updated based on: 314 // exp_tag is not in rawScienceExp 315 // exp_tag is not in rawDetrendExp 522 // exp_tag is not in rawExp 316 523 // exp_tag is not in newImfile 317 524 // that the correct count of imfiles is in rawImfile … … 340 547 " LEFT JOIN newImfile" 341 548 " USING(exp_tag)" 342 " LEFT JOIN rawScienceExp" 343 " USING(exp_tag)" 344 " LEFT JOIN rawDetrendExp" 549 " LEFT JOIN rawExp" 345 550 " USING(exp_tag)" 346 551 " WHERE" 347 552 " newExp.exp_tag IS NOT NULL" 348 553 " AND newImfile.exp_tag IS NULL" 349 " AND raw ScienceExp.exp_tag IS NULL"554 " AND rawExp.exp_tag IS NULL" 350 555 " AND newExp.imfiles =" 351 556 " (SELECT COUNT(exp_tag) FROM rawImfile" … … 369 574 } 370 575 371 372 // start a transaction so we don't end up with an exp in 373 // rawScience/DetrendExp and in newExp 576 // start a transaction so we don't end up with an exp in both rawExp & 577 // newExp 374 578 if (!psDBTransaction(config->dbh)) { 375 579 psError(PS_ERR_UNKNOWN, false, "database error"); … … 378 582 } 379 583 380 // if it's a detrend exp 381 if (detrend) { 382 for (long i = 0; psArrayLength(output) > i; i++) { 383 psMetadata *row = output->data[i]; 384 // convert metadata into a newExp object 385 newExpRow *newExp = newExpObjectFromMetadata(row); 386 // convert newExp object into a rawDetrendExp object 387 rawDetrendExpRow *rawExp = newToRawDetrendExp(config, newExp); 388 if (!rawExp) { 389 // rollback 390 if (!psDBRollback(config->dbh)) { 391 psError(PS_ERR_UNKNOWN, false, "database error"); 392 } 393 psError(PS_ERR_UNKNOWN, false, "failed to convert newExp to rawDetrendExp"); 394 psFree(newExp); 395 psFree(output); 396 return false; 397 } 398 // insert the rawDetrendExp object into the database 399 if (!rawDetrendExpInsertObject(config->dbh, rawExp)) { 400 // rollback 401 if (!psDBRollback(config->dbh)) { 402 psError(PS_ERR_UNKNOWN, false, "database error"); 403 } 404 psError(PS_ERR_UNKNOWN, false, "database error"); 405 psFree(rawExp); 406 psFree(newExp); 407 psFree(output); 408 return false; 409 } 410 psFree(rawExp); 411 // delete the newExp object from the database 412 if (!newExpDeleteObject(config->dbh, newExp)) { 413 // rollback 414 if (!psDBRollback(config->dbh)) { 415 psError(PS_ERR_UNKNOWN, false, "database error"); 416 } 417 psError(PS_ERR_UNKNOWN, false, "database error"); 418 psFree(newExp); 419 psFree(output); 420 return false; 421 } 422 psFree(newExp); 423 } 424 425 psFree(output); 426 427 if (!psDBCommit(config->dbh)) { 428 psError(PS_ERR_UNKNOWN, false, "database error"); 429 return false; 430 } 431 432 return true; 433 } 434 435 // else 436 // it's a science exp 584 // insert the exp into rawExp 437 585 for (long i = 0; psArrayLength(output) > i; i++) { 438 586 psMetadata *row = output->data[i]; 439 587 // convert metadata into a newExp object 440 588 newExpRow *newExp = newExpObjectFromMetadata(row); 441 // convert newExp object into a raw DetrendExp object442 raw ScienceExpRow *rawExp = newToRawScienceExp(config, newExp);589 // convert newExp object into a rawExp object 590 rawExpRow *rawExp = newToRawExp(config, newExp); 443 591 if (!rawExp) { 444 592 // rollback … … 446 594 psError(PS_ERR_UNKNOWN, false, "database error"); 447 595 } 448 psError(PS_ERR_UNKNOWN, false, "failed to convert newExp to raw ScienceExp");596 psError(PS_ERR_UNKNOWN, false, "failed to convert newExp to rawExp"); 449 597 psFree(newExp); 450 598 psFree(output); 451 599 return false; 452 600 } 453 // insert the rawDetrendExp object into the database 454 if (!rawScienceExpInsertObject(config->dbh, rawExp)) { 601 602 // insert the rawExp object into the database 603 if (!rawExpInsertObject(config->dbh, rawExp)) { 455 604 // rollback 456 605 if (!psDBRollback(config->dbh)) { … … 464 613 } 465 614 psFree(rawExp); 615 466 616 // delete the newExp object from the database 467 617 if (!newExpDeleteObject(config->dbh, newExp)) { … … 475 625 return false; 476 626 } 627 628 // if this is a detrend image don't put it in the p2 queue (and we're 629 // done) 630 if (detrend) { 631 psFree(newExp); 632 continue; 633 } 634 477 635 // insert an entry into the p2PendingExp table 478 636 p2PendingExpRow *p2PendingExp = newToP2PendingExp(config, newExp); … … 483 641 return false; 484 642 } 643 485 644 // insert the p2PendingExp object into the database 486 645 if (!p2PendingExpInsertObject(config->dbh, p2PendingExp)) { … … 496 655 } 497 656 psFree(p2PendingExp); 657 498 658 // find all of the rawImfiles associated with the p2PendingExp object 499 659 psArray *rawImfiles = NULL; … … 570 730 } 571 731 572 static bool updateimfileMode(pxConfig *config) 732 733 static bool processedexpMode(pxConfig *config) 573 734 { 574 735 PS_ASSERT_PTR_NON_NULL(config, false); 575 736 576 // XXX search by the whole frame some imfiles without a newExp don't get 577 // processed -- this may not be the correct thing to do 578 psString query = psStringCopy( 579 "SELECT * FROM" 580 " (SELECT newImfile.* FROM newImfile" 581 " LEFT JOIN newExp USING(exp_tag)" 582 " LEFT JOIN rawScienceExp USING(exp_tag)" 583 " LEFT JOIN rawDetrendExp USING (exp_tag)" 584 " WHERE newExp.exp_tag IS NOT NULL" 585 " AND rawScienceExp.exp_tag IS NULL" 586 " AND rawDetrendExp.exp_tag IS NULL) AS foo" 587 ); // WHERE class is generated from exp_tag, class, & class_id 588 589 { 590 // build a query to search by exp_tag, class, class_id 591 psMetadata *where = psMetadataAlloc(); 592 bool status = false; 593 psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag"); 594 if (!status) { 595 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag"); 596 psFree(query); 597 return false; 598 } 599 if (exp_tag) { 600 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) { 601 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag"); 602 psFree(where); 603 psFree(query); 604 return false; 605 } 606 } 607 psString class = psMetadataLookupStr(&status, config->args, "-class"); 608 if (!status) { 609 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class"); 610 psFree(query); 611 return false; 612 } 613 if (class) { 614 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==", class)) { 615 psError(PS_ERR_UNKNOWN, false, "failed to add item class"); 616 psFree(where); 617 psFree(query); 618 return false; 619 } 620 } 621 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 622 if (!status) { 623 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 624 psFree(query); 625 return false; 626 } 627 if (class_id) { 628 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) { 629 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 630 psFree(where); 631 psFree(query); 632 return false; 633 } 634 } 635 636 // there's not 637 psString whereClaus = psDBGenerateWhereSQL(where, NULL); 638 psFree(where); 639 if (whereClaus) { 640 psStringAppend(&query, " %s", whereClaus); 641 psFree(whereClaus); 642 } 737 bool status = false; 738 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 739 if (!status) { 740 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 741 return false; 742 } 743 744 bool faulted = psMetadataLookupU64(&status, config->args, "-faulted"); 745 if (!status) { 746 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -faulted"); 747 return false; 748 } 749 750 // find all rawImfiles matching the default query 751 psString query = psStringCopy( 752 "SELECT\n" 753 " *\n" 754 " FROM rawExp\n" 755 " WHERE\n" 756 " rawExp.exp_tag IS NOT NULL\n" // bogus where clause 757 ); 758 759 if (config->where) { 760 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawExp"); 761 psStringAppend(&query, " AND %s", whereClause); 762 psFree(whereClause); 763 } 764 765 if (faulted) { 766 // list only faulted rows 767 psStringAppend(&query, " %s", "AND rawExp.fault != 0"); 768 } else { 769 // don't list faulted rows 770 psStringAppend(&query, " %s", "AND rawExp.fault = 0"); 771 } 772 773 // treat limit == 0 as "no limit" 774 if (limit) { 775 psString limitString = psDBGenerateLimitSQL(limit); 776 psStringAppend(&query, " %s", limitString); 777 psFree(limitString); 643 778 } 644 779 645 780 if (!p_psDBRunQuery(config->dbh, query)) { 646 781 psError(PS_ERR_UNKNOWN, false, "database error"); 647 psFree(query);648 782 return false; 649 783 } … … 656 790 } 657 791 if (!psArrayLength(output)) { 658 // XXX check psError here 659 psError(PS_ERR_UNKNOWN, false, "no pending newImfile rows found"); 792 psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found"); 660 793 psFree(output); 661 return false; 662 } 663 664 // insert 'newImfile's into rawImfile 665 if (psArrayLength(output) > 0) { 666 // start a transaction so we don't end up half of the imfiles we were 667 // trying to update uninserted 668 if (!psDBTransaction(config->dbh)) { 669 psError(PS_ERR_UNKNOWN, false, "database error"); 670 psFree(output); 671 return false; 672 } 673 674 for (long i = 0; i < psArrayLength(output); i++) { 675 // convert newImfile metadata -> newImfile object 676 newImfileRow *object = newImfileObjectFromMetadata(output->data[i]); 677 // convert newImfile object -> rawImfile object 678 rawImfileRow *imfile = newToRawImfile(config, object); 679 if (!imfile) { 680 // rollback 681 if (!psDBRollback(config->dbh)) { 682 psError(PS_ERR_UNKNOWN, false, "database error"); 683 } 684 psError(PS_ERR_UNKNOWN, false, "failed to create a new rawImfile row"); 685 psFree(object); 686 psFree(output); 687 return false; 688 } 689 // insert the rawImfile object into the database 690 if (!rawImfileInsertObject(config->dbh, imfile)) { 691 // rollback 692 if (!psDBRollback(config->dbh)) { 693 psError(PS_ERR_UNKNOWN, false, "database error"); 694 } 695 psError(PS_ERR_UNKNOWN, false, "failed to insert row into the database"); 696 psFree(imfile); 697 psFree(object); 698 psFree(output); 699 return false; 700 } 701 psFree(imfile); 702 // remove the neImfile object from the database 703 if (!newImfileDeleteObject(config->dbh, object)) { 704 // rollback 705 if (!psDBRollback(config->dbh)) { 706 psError(PS_ERR_UNKNOWN, false, "database error"); 707 } 708 psError(PS_ERR_UNKNOWN, false, "failed to delete row from the database"); 709 psFree(object); 710 psFree(output); 711 return false; 712 } 713 psFree(object); 714 } 715 716 // point of no return for rawImfile 717 if (!psDBCommit(config->dbh)) { 718 psError(PS_ERR_UNKNOWN, false, "database error"); 719 psFree(output); 720 return false; 721 } 722 } 723 724 psFree(output); 725 726 return true; 727 } 728 729 static bool rawimfileMode(pxConfig *config) 730 { 731 PS_ASSERT_PTR_NON_NULL(config, false); 732 733 // find all rawImfiles matching the default query 734 psArray *rawImfiles = rawImfileSelectRowObjects(config->dbh, config->where, 0); 735 if (!rawImfiles) { 736 psError(PS_ERR_UNKNOWN, false, "no rawImfile rows found"); 737 return false; 738 } 794 return true; 795 } 796 739 797 bool simple = false; 740 798 { … … 747 805 } 748 806 749 if (psArrayLength( rawImfiles)) {807 if (psArrayLength(output)) { 750 808 // negative simple so the default is true 751 if (! rawImfilePrintObjects(stdout, rawImfiles, !simple)) {809 if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) { 752 810 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 753 psFree( rawImfiles);754 return false; 755 } 756 } 757 758 psFree( rawImfiles);811 psFree(output); 812 return false; 813 } 814 } 815 816 psFree(output); 759 817 760 818 return true; 761 819 } 820 821 822 static bool updateprocessedexpMode(pxConfig *config) 823 { 824 bool status = false; 825 psS8 code = psMetadataLookupS8(&status, config->args, "-code"); 826 if (!status) { 827 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 828 return false; 829 } 830 831 if (!pxSetFaultCode(config->dbh, "rawExp", config->where, code)) { 832 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 833 return false; 834 } 835 836 return true; 837 } 838 839 762 840 # if 0 763 841 static p1PendingExpRow *newToP1PendingExp(newExpRow *newExp) … … 781 859 #endif 782 860 861 783 862 static p2PendingExpRow *newToP2PendingExp(pxConfig *config, newExpRow *exp) 784 863 { … … 804 883 return p2Exp; 805 884 } 885 806 886 807 887 static p2PendingImfileRow *rawImfileToP2PendingImfile(pxConfig *config, rawImfileRow *rawImfile) … … 817 897 } 818 898 819 static rawScienceExpRow *newToRawScienceExp(pxConfig *config, newExpRow *exp) 820 { 821 PS_ASSERT_PTR_NON_NULL(config, NULL); 822 PS_ASSERT_PTR_NON_NULL(exp, NULL); 823 824 // XXX this is dangerous but we should be able to get away with this as 825 // long rawScienceExp & rawDetrendExp are idetnical 826 return (rawScienceExpRow *)newToRawDetrendExp(config, exp); 827 } 828 829 static rawDetrendExpRow *newToRawDetrendExp(pxConfig *config, newExpRow *exp) 899 900 static rawExpRow *newToRawExp(pxConfig *config, newExpRow *exp) 830 901 { 831 902 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 932 1003 } 933 1004 934 rawDetrendExpRow *raw = rawDetrendExpRowAlloc( 1005 // default 1006 psS8 code = psMetadataLookupS8(&status, config->args, "-code"); 1007 if (!status) { 1008 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 1009 return false; 1010 } 1011 1012 rawExpRow *raw = rawExpRowAlloc( 935 1013 exp->exp_tag, 936 1014 exp->camera, … … 951 1029 posang, 952 1030 object, 953 dateobs 1031 dateobs, 1032 code 954 1033 ); 955 1034 … … 960 1039 return raw; 961 1040 } 1041 962 1042 963 1043 static rawImfileRow *newToRawImfile(pxConfig *config, newImfileRow *imfile) … … 1065 1145 dateobs = NULL; 1066 1146 } 1147 } 1148 1149 psS8 code = psMetadataLookupS8(&status, config->args, "-code"); 1150 if (!status) { 1151 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -code"); 1152 return false; 1067 1153 } 1068 1154 … … 1086 1172 posang, 1087 1173 object, 1088 dateobs 1174 dateobs, 1175 code 1089 1176 ); 1090 1177 -
trunk/ippTools/src/regtool.h
r10976 r11047 25 25 typedef enum { 26 26 P0TOOL_MODE_NONE = 0x0, 27 P0TOOL_MODE_PENDINGIMFILE, 28 P0TOOL_MODE_ADDPROCESSEDIMFILE, 29 P0TOOL_MODE_PROCESSEDIMFILE, 30 P0TOOL_MODE_UPDATEPROCESSEDIMFILE, 27 31 P0TOOL_MODE_PENDINGEXP, 28 P0TOOL_MODE_PENDINGIMFILE, 29 P0TOOL_MODE_UPDATEEXP, 30 P0TOOL_MODE_FAULTEXP, 31 P0TOOL_MODE_UPDATEIMFILE, 32 P0TOOL_MODE_FAULTIMFILE, 33 P0TOOL_MODE_RAWIMFILE 32 P0TOOL_MODE_ADDPROCESSEDEXP, 33 P0TOOL_MODE_PROCESSEDEXP, 34 P0TOOL_MODE_UPDATEPROCESSEDEXP, 34 35 } p0toolMode; 35 36 -
trunk/ippTools/src/regtoolConfig.c
r10988 r11047 41 41 } 42 42 43 // -pendingimfile 44 psMetadata *pendingimfileArgs = psMetadataAlloc(); 45 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-exp_tag", 0, 46 "search by exposure ID", NULL); 47 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class", 0, 48 "search by class", NULL); 49 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class_id", 0, 50 "search by class ID", NULL); 51 psMetadataAddU64(pendingimfileArgs, PS_LIST_TAIL, "-limit", 0, 52 "limit result set to N items", 0); 53 psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-simple", 0, 54 "use the simple output format", false); 55 56 // -addprocessedimfile 57 psMetadata *addprocessedimfileArgs = psMetadataAlloc(); 58 psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-exp_tag", 0, 59 "search by exposure ID", NULL); 60 psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-class", 0, 61 "search by class", NULL); 62 psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-class_id", 0, 63 "search by class ID", NULL); 64 psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-exp_type", 0, 65 "define exposure type", NULL); 66 psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-filter", 0, 67 "define filter ", NULL); 68 psMetadataAddF32(addprocessedimfileArgs, PS_LIST_TAIL, "-airmass", 0, 69 "define airmass", NAN); 70 psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-ra", 0, 71 "define RA", NAN); 72 psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-decl", 0, 73 "define DEC", NAN); 74 psMetadataAddF32(addprocessedimfileArgs, PS_LIST_TAIL, "-exp_time", 0, 75 "define exposure time", NAN); 76 psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-bg", 0, 77 "define exposue background", NAN); 78 psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-bg_stdev", 0, 79 "define exposue background stdev", NAN); 80 psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-bg_mean_stdev", 0, 81 "define exposue background mean stdev", NAN); 82 psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-alt", 0, 83 "define altitute", NAN); 84 psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-az", 0, 85 "define azimuth", NAN); 86 psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-ccd_temp", 0, 87 "define ccd tempature", NAN); 88 psMetadataAddF64(addprocessedimfileArgs, PS_LIST_TAIL, "-posang", 0, 89 "define rotator position angle", NAN); 90 psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-object", 0, 91 "define exposure object", NULL); 92 psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-dateobs", 0, 93 "define observation time", NULL); 94 psMetadataAddS8(addprocessedimfileArgs, PS_LIST_TAIL, "-code", 0, 95 "set fault code (required)", 0); 96 97 // -processedimfile 98 psMetadata *processedimfileArgs = psMetadataAlloc(); 99 psMetadataAddStr(processedimfileArgs, PS_LIST_TAIL, "-exp_tag", 0, 100 "search by exposure ID", NULL); 101 psMetadataAddStr(processedimfileArgs, PS_LIST_TAIL, "-class", 0, 102 "search by class", NULL); 103 psMetadataAddStr(processedimfileArgs, PS_LIST_TAIL, "-class_id", 0, 104 "search by class ID", NULL); 105 psMetadataAddU64(processedimfileArgs, PS_LIST_TAIL, "-limit", 0, 106 "limit result set to N items", 0); 107 psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-faulted", 0, 108 "only return imfiles with a fault status set", false); 109 psMetadataAddBool(processedimfileArgs, PS_LIST_TAIL, "-simple", 0, 110 "use the simple output format", false); 111 112 // -updateprocessedimfile 113 psMetadata *updateprocessedimfileArgs = psMetadataAlloc(); 114 psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-exp_tag", 0, 115 "search by exposure ID", NULL); 116 psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-class", 0, 117 "search by class", NULL); 118 psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-class_id", 0, 119 "search by class ID", NULL); 120 psMetadataAddS8(updateprocessedimfileArgs, PS_LIST_TAIL, "-code", 0, 121 "set fault code (required)", 0); 122 123 43 124 // -pendingexp 44 125 psMetadata *pendingexpArgs = psMetadataAlloc(); … … 55 136 psMetadataAddU64(pendingexpArgs, PS_LIST_TAIL, "-limit", 0, 56 137 "limit result set to N items", 0); 57 psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-faulted", 0,58 "only return imfiles with a fault status set", false);59 138 psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple", 0, 60 139 "use the simple output format", false); 61 62 // -pendingimfile 63 psMetadata *pendingimfileArgs = psMetadataAlloc(); 64 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-exp_tag", 0, 65 "search by exposure ID", NULL); 66 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class", 0, 67 "search by class", NULL); 68 psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class_id", 0, 69 "search by class ID", NULL); 70 psMetadataAddU64(pendingimfileArgs, PS_LIST_TAIL, "-limit", 0, 71 "limit result set to N items", 0); 72 psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-faulted", 0, 73 "only return imfiles with a fault status set", false); 74 psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-simple", 0, 75 "use the simple output format", false); 76 77 78 // -updateexp 79 psMetadata *updateexpArgs = psMetadataAlloc(); 80 psMetadataAddStr(updateexpArgs, PS_LIST_TAIL, "-exp_tag", 0, 140 141 // -addprocessedexp 142 psMetadata *addprocessedexpArgs = psMetadataAlloc(); 143 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-exp_tag", 0, 81 144 "exp_tag to operate on (required)", NULL); 82 psMetadataAddStr( updateexpArgs, PS_LIST_TAIL, "-exp_type", 0,145 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-exp_type", 0, 83 146 "define exposure type", NULL); 84 psMetadataAddStr( updateexpArgs, PS_LIST_TAIL, "-filter", 0,147 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-filter", 0, 85 148 "define filter ", NULL); 86 psMetadataAddF32( updateexpArgs, PS_LIST_TAIL, "-airmass", 0,149 psMetadataAddF32(addprocessedexpArgs, PS_LIST_TAIL, "-airmass", 0, 87 150 "define airmass", NAN); 88 psMetadataAddF64( updateexpArgs, PS_LIST_TAIL, "-ra", 0,151 psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-ra", 0, 89 152 "define RA", NAN); 90 psMetadataAddF64( updateexpArgs, PS_LIST_TAIL, "-decl", 0,153 psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-decl", 0, 91 154 "define DEC", NAN); 92 psMetadataAddF32( updateexpArgs, PS_LIST_TAIL, "-exp_time", 0,155 psMetadataAddF32(addprocessedexpArgs, PS_LIST_TAIL, "-exp_time", 0, 93 156 "define exposure time", NAN); 94 psMetadataAddF64( updateexpArgs, PS_LIST_TAIL, "-bg", 0,157 psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-bg", 0, 95 158 "define exposue background", NAN); 96 psMetadataAddF64( updateexpArgs, PS_LIST_TAIL, "-bg_stdev", 0,159 psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-bg_stdev", 0, 97 160 "define exposue background stdev", NAN); 98 psMetadataAddF64( updateexpArgs, PS_LIST_TAIL, "-bg_mean_stdev", 0,161 psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-bg_mean_stdev", 0, 99 162 "define exposue background mean stdev", NAN); 100 psMetadataAddF64( updateexpArgs, PS_LIST_TAIL, "-alt", 0,163 psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-alt", 0, 101 164 "define altitute", NAN); 102 psMetadataAddF64( updateexpArgs, PS_LIST_TAIL, "-az", 0,165 psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-az", 0, 103 166 "define azimuth", NAN); 104 psMetadataAddF64( updateexpArgs, PS_LIST_TAIL, "-ccd_temp", 0,167 psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-ccd_temp", 0, 105 168 "define ccd tempature", NAN); 106 psMetadataAddF64( updateexpArgs, PS_LIST_TAIL, "-posang", 0,169 psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-posang", 0, 107 170 "define rotator position angle", NAN); 108 psMetadataAddStr( updateexpArgs, PS_LIST_TAIL, "-object", 0,171 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-object", 0, 109 172 "define exposure object", NULL); 110 psMetadataAddStr( updateexpArgs, PS_LIST_TAIL, "-dateobs", 0,173 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-dateobs", 0, 111 174 "define observation time", NULL); 112 psMetadataAddStr( updateexpArgs, PS_LIST_TAIL, "-label", 0,175 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-label", 0, 113 176 "define label for phase 2 processing (non-detrend data only)", NULL); 177 psMetadataAddS8(addprocessedexpArgs, PS_LIST_TAIL, "-code", 0, 178 "set fault code (required)", 0); 114 179 /* 115 180 psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-recip", 0, … … 118 183 "define URL", NULL); 119 184 */ 120 psMetadataAddBool( updateexpArgs, PS_LIST_TAIL, "-detrend", 0,185 psMetadataAddBool(addprocessedexpArgs, PS_LIST_TAIL, "-detrend", 0, 121 186 "declare this as detrend data", false); 122 187 123 // -faultexp 124 psMetadata *faultexpArgs = psMetadataAlloc(); 125 psMetadataAddStr(faultexpArgs, PS_LIST_TAIL, "-exp_tag", 0, 126 "search by exposure ID", NULL); 127 psMetadataAddS8(faultexpArgs, PS_LIST_TAIL, "-code", 0, 188 // -processedexp 189 psMetadata *processedexpArgs = psMetadataAlloc(); 190 psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-exp_tag", 0, 191 "search by exposure ID", NULL); 192 psMetadataAddU64(processedexpArgs, PS_LIST_TAIL, "-limit", 0, 193 "limit result set to N items", 0); 194 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-faulted", 0, 195 "only return imfiles with a fault status set", false); 196 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple", 0, 197 "use the simple output format", false); 198 199 // -updatedprocessedexp 200 psMetadata *updatedprocessedexpArgs = psMetadataAlloc(); 201 psMetadataAddStr(updatedprocessedexpArgs, PS_LIST_TAIL, "-exp_tag", 0, 202 "search by exposure ID", NULL); 203 psMetadataAddS8(updatedprocessedexpArgs, PS_LIST_TAIL, "-code", 0, 128 204 "set fault code (required)", 0); 129 205 130 // -updateimfile131 psMetadata *updateimfileArgs = psMetadataAlloc();132 psMetadataAddStr(updateimfileArgs, PS_LIST_TAIL, "-exp_tag", 0,133 "search by exposure ID", NULL);134 psMetadataAddStr(updateimfileArgs, PS_LIST_TAIL, "-class", 0,135 "search by class", NULL);136 psMetadataAddStr(updateimfileArgs, PS_LIST_TAIL, "-class_id", 0,137 "search by class ID", NULL);138 psMetadataAddStr(updateimfileArgs, PS_LIST_TAIL, "-exp_type", 0,139 "define exposure type", NULL);140 psMetadataAddStr(updateimfileArgs, PS_LIST_TAIL, "-filter", 0,141 "define filter ", NULL);142 psMetadataAddF32(updateimfileArgs, PS_LIST_TAIL, "-airmass", 0,143 "define airmass", NAN);144 psMetadataAddF64(updateimfileArgs, PS_LIST_TAIL, "-ra", 0,145 "define RA", NAN);146 psMetadataAddF64(updateimfileArgs, PS_LIST_TAIL, "-decl", 0,147 "define DEC", NAN);148 psMetadataAddF32(updateimfileArgs, PS_LIST_TAIL, "-exp_time", 0,149 "define exposure time", NAN);150 psMetadataAddF64(updateimfileArgs, PS_LIST_TAIL, "-bg", 0,151 "define exposue background", NAN);152 psMetadataAddF64(updateimfileArgs, PS_LIST_TAIL, "-bg_stdev", 0,153 "define exposue background stdev", NAN);154 psMetadataAddF64(updateimfileArgs, PS_LIST_TAIL, "-bg_mean_stdev", 0,155 "define exposue background mean stdev", NAN);156 psMetadataAddF64(updateimfileArgs, PS_LIST_TAIL, "-alt", 0,157 "define altitute", NAN);158 psMetadataAddF64(updateimfileArgs, PS_LIST_TAIL, "-az", 0,159 "define azimuth", NAN);160 psMetadataAddF64(updateimfileArgs, PS_LIST_TAIL, "-ccd_temp", 0,161 "define ccd tempature", NAN);162 psMetadataAddF64(updateimfileArgs, PS_LIST_TAIL, "-posang", 0,163 "define rotator position angle", NAN);164 psMetadataAddStr(updateimfileArgs, PS_LIST_TAIL, "-object", 0,165 "define exposure object", NULL);166 psMetadataAddStr(updateimfileArgs, PS_LIST_TAIL, "-dateobs", 0,167 "define observation time", NULL);168 169 // -faultimfile170 psMetadata *faultimfileArgs = psMetadataAlloc();171 psMetadataAddStr(faultimfileArgs, PS_LIST_TAIL, "-exp_tag", 0,172 "search by exposure ID", NULL);173 psMetadataAddStr(faultimfileArgs, PS_LIST_TAIL, "-class", 0,174 "search by class", NULL);175 psMetadataAddStr(faultimfileArgs, PS_LIST_TAIL, "-class_id", 0,176 "search by class ID", NULL);177 psMetadataAddS8(faultimfileArgs, PS_LIST_TAIL, "-code", 0,178 "set fault code (required)", 0);179 180 // -rawimfile181 psMetadata *rawimfileArgs = psMetadataAlloc();182 psMetadataAddStr(rawimfileArgs, PS_LIST_TAIL, "-exp_tag", 0,183 "search by exposure ID", NULL);184 psMetadataAddStr(rawimfileArgs, PS_LIST_TAIL, "-class_id", 0,185 "search by class ID", NULL);186 psMetadataAddBool(rawimfileArgs, PS_LIST_TAIL, "-simple", 0,187 "use the simple output format", false);188 206 189 207 #define PXTOOL_MODE(option, modeval, argset) \ … … 207 225 psMetadata *argSets = psMetadataAlloc(); 208 226 // find which mode we're running under 209 PXTOOL_MODE("-pendingexp", P0TOOL_MODE_PENDINGEXP, pendingexpArgs); 210 PXTOOL_MODE("-pendingimfile",P0TOOL_MODE_PENDINGIMFILE, pendingimfileArgs); 211 PXTOOL_MODE("-updateexp", P0TOOL_MODE_UPDATEEXP, updateexpArgs); 212 PXTOOL_MODE("-faultexp", P0TOOL_MODE_FAULTEXP, faultexpArgs); 213 PXTOOL_MODE("-updateimfile", P0TOOL_MODE_UPDATEIMFILE, updateimfileArgs); 214 PXTOOL_MODE("-faultimfile", P0TOOL_MODE_FAULTIMFILE, faultimfileArgs); 215 PXTOOL_MODE("-rawimfile", P0TOOL_MODE_RAWIMFILE, rawimfileArgs); 227 PXTOOL_MODE("-pendingimfile", P0TOOL_MODE_PENDINGIMFILE, pendingimfileArgs); 228 PXTOOL_MODE("-addprocessedimfile", P0TOOL_MODE_ADDPROCESSEDIMFILE, addprocessedimfileArgs); 229 PXTOOL_MODE("-processedimfile", P0TOOL_MODE_PROCESSEDIMFILE, processedimfileArgs); 230 PXTOOL_MODE("-updateprocessedimfile", P0TOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileArgs); 231 PXTOOL_MODE("-pendingexp", P0TOOL_MODE_PENDINGEXP,pendingexpArgs); 232 PXTOOL_MODE("-addprocessedexp", P0TOOL_MODE_ADDPROCESSEDEXP, addprocessedexpArgs); 233 PXTOOL_MODE("-processedexp", P0TOOL_MODE_PROCESSEDEXP, processedexpArgs); 234 PXTOOL_MODE("-updateprocessedexp", P0TOOL_MODE_UPDATEPROCESSEDEXP, updatedprocessedexpArgs); 216 235 217 236 bool argErr = false;
Note:
See TracChangeset
for help on using the changeset viewer.
