Changeset 8120 for trunk/ippTools/src
- Timestamp:
- Aug 3, 2006, 6:18:57 PM (20 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 12 edited
-
chiptool.c (modified) (3 diffs)
-
dettool.c (modified) (16 diffs)
-
dettoolConfig.c (modified) (12 diffs)
-
guidetool.c (modified) (2 diffs)
-
guidetoolConfig.c (modified) (2 diffs)
-
p2insertPendingFrames.c (modified) (2 diffs)
-
p2pendingToDone.c (modified) (3 diffs)
-
p2rawToPending.c (modified) (2 diffs)
-
pxframes.c (modified) (8 diffs)
-
pxtools.h (modified) (1 diff)
-
regtool.c (modified) (12 diffs)
-
regtoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r8073 r8120 241 241 psFree(pendingImfiles); 242 242 243 // point of no return for p2PendingImfile -> p2DoneImfile 244 if (!psDBCommit(config->dbh)) { 245 psError(PS_ERR_UNKNOWN, false, "database error"); 246 return false; 247 } 248 249 // XXX make exposure state transition transactional 243 // XXX I've decided to make the transaction cover the Exp migration as 244 // well. Otherwise, if the last imfile in an exp is moved and the exp 245 // migration fails then the data base is left in a satuation where the exp 246 // migration can't happen. 250 247 251 248 // look for pending exposures 252 249 psArray *pendingExps = p2searchPendingExp(config); 253 250 if (!pendingExps) { 251 // rollback 252 if (!psDBRollback(config->dbh)) { 253 psError(PS_ERR_UNKNOWN, false, "database error"); 254 } 254 255 psError(PS_ERR_UNKNOWN, false, "no p2PendingExps found"); 255 256 return false; … … 265 266 if (!pendingImfiles) { 266 267 // exp has no coresponding imfiles 267 psArray *nukeMe = psArrayAlloc(1); 268 nukeMe->n = 0; 269 psArrayAdd(nukeMe, 0, pendingExp); 270 bool status = p2PendingExpDeleteRowObjects(config->dbh, nukeMe, MAX_ROWS); 271 psFree(nukeMe); 272 if (!status) { 268 psMetadata *where = psMetadataAlloc(); 269 psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", pendingExp->exp_id); 270 long long count = p2PendingExpDelete(config->dbh, where, MAX_ROWS); 271 psFree(where); 272 if (count != 0) { 273 // rollback 274 if (!psDBRollback(config->dbh)) { 275 psError(PS_ERR_UNKNOWN, false, "database error"); 276 } 273 277 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 278 psFree(pendingExps); 274 279 return false; 275 280 } 276 // XXX need a func to convert from p2PendingExp -> p2DoneExp277 281 278 282 p2DoneExpRow *doneExp = p2pendingToDoneExp(pendingExp); 279 283 if (!doneExp) { 284 // rollback 285 if (!psDBRollback(config->dbh)) { 286 psError(PS_ERR_UNKNOWN, false, "database error"); 287 } 280 288 psError(PS_ERR_UNKNOWN, false, "p2PendingExp -> p2DoneExp failed"); 289 psFree(pendingExps); 281 290 return false; 282 291 } 283 292 if (!p2DoneExpInsertObject(config->dbh, doneExp)) { 293 // rollback 294 if (!psDBRollback(config->dbh)) { 295 psError(PS_ERR_UNKNOWN, false, "database error"); 296 } 284 297 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 298 psFree(doneExp); 299 psFree(pendingExps); 285 300 return false; 286 301 } 287 } 288 // skip phase 3 for the time being 302 psFree(doneExp); 303 } 304 // XXX skip phase 3 for the time being 289 305 psFree(pendingImfiles); 290 306 } 291 307 308 psFree(pendingExps); 309 310 // point of no return for p2PendingImfile -> p2DoneImfile 311 // point of no return for p2PendingExp -> p2DoneExp 312 if (!psDBCommit(config->dbh)) { 313 psError(PS_ERR_UNKNOWN, false, "database error"); 314 return false; 315 } 292 316 /* 293 317 psArray *doneFrames = p2pendingToDone(config, pendingFrames); … … 328 352 uri, 329 353 "my recipe", // recipe 330 "my stats", // stats331 354 imfile->p1_version, 332 355 imfile->p2_version -
trunk/ippTools/src/dettool.c
r8076 r8120 422 422 rawExp->imfiles, 423 423 rawExp->filter, 424 rawExp->stats 424 rawExp->airmass, 425 rawExp->ra, 426 rawExp->decl, 427 rawExp->exp_time, 428 rawExp->background 425 429 ); 426 430 } … … 604 608 return false; 605 609 } 606 psString stats = psMetadataLookupStr(&status, config->args, "-stats");607 if (!status) {608 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stats");609 return false;610 }611 if (!stats) {612 psError(PS_ERR_UNKNOWN, true, "-stats is required");613 return false;614 }615 610 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 616 611 if (!status) { … … 645 640 // create a new detProcessedImfile object 646 641 detProcessedImfileRow *detRow = detProcessedImfileRowAlloc( 647 (psS32)atol(det_id), exp_id, class_id, uri, stats,recipe642 (psS32)atol(det_id), exp_id, class_id, uri, recipe 648 643 ); 649 644 psFree(rawImfiles); … … 921 916 PS_ASSERT_PTR_NON_NULL(config, false); 922 917 923 // det_id, class_id, uri, stats,& recipe are required918 // det_id, class_id, uri, & recipe are required 924 919 bool status = false; 925 920 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); … … 948 943 if (!uri) { 949 944 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 950 return false;951 }952 psString stats = psMetadataLookupStr(&status, config->args, "-stats");953 if (!status) {954 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stats");955 return false;956 }957 if (!stats) {958 psError(PS_ERR_UNKNOWN, true, "-stats is required");959 945 return false; 960 946 } … … 1010 996 // create a new detStackedImfile object 1011 997 detStackedImfileRow *stackedImfile = detStackedImfileRowAlloc( 1012 (psS32)atol(det_id), iteration, class_id, uri, stats,recipe998 (psS32)atol(det_id), iteration, class_id, uri, recipe 1013 999 ); 1014 1000 … … 1270 1256 PS_ASSERT_PTR_NON_NULL(config, false); 1271 1257 1272 // det_id, class_id, uri, stats,& recipe are required1258 // det_id, class_id, uri, & recipe are required 1273 1259 bool status = false; 1274 1260 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); … … 1297 1283 if (!uri) { 1298 1284 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 1299 return false;1300 }1301 psString stats = psMetadataLookupStr(&status, config->args, "-stats");1302 if (!status) {1303 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stats");1304 return false;1305 }1306 if (!stats) {1307 psError(PS_ERR_UNKNOWN, true, "-stats is required");1308 1285 return false; 1309 1286 } … … 1367 1344 // create a new detNormalizedImfile object 1368 1345 detNormalizedImfileRow *masterImfile = detNormalizedImfileRowAlloc( 1369 (psS32)atol(det_id), iteration, class_id, uri, stats,recipe1346 (psS32)atol(det_id), iteration, class_id, uri, recipe 1370 1347 ); 1371 1348 … … 1541 1518 PS_ASSERT_PTR_NON_NULL(config, false); 1542 1519 1543 // det_id, exp_id, class_id, stats,& recipe are required1520 // det_id, exp_id, class_id, & recipe are required 1544 1521 bool status = false; 1545 1522 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); … … 1568 1545 if (!class_id) { 1569 1546 psError(PS_ERR_UNKNOWN, true, "-class_id is required"); 1570 return false;1571 }1572 psString stats = psMetadataLookupStr(&status, config->args, "-stats");1573 if (!status) {1574 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stats");1575 return false;1576 }1577 if (!stats) {1578 psError(PS_ERR_UNKNOWN, true, "-stats is required");1579 1547 return false; 1580 1548 } … … 1649 1617 exp_id, 1650 1618 class_id, 1651 stats,1652 1619 recipe 1653 1620 ); … … 1704 1671 PS_ASSERT_PTR_NON_NULL(config, false); 1705 1672 1706 // det_id, exp_id, stats,& recipe are required1673 // det_id, exp_id, & recipe are required 1707 1674 bool status = false; 1708 1675 psString det_id = psMetadataLookupStr(&status, config->args, "-det_id"); … … 1722 1689 if (!exp_id) { 1723 1690 psError(PS_ERR_UNKNOWN, true, "-exp_id is required"); 1724 return false;1725 }1726 psString stats = psMetadataLookupStr(&status, config->args, "-stats");1727 if (!status) {1728 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -stats");1729 return false;1730 }1731 if (!stats) {1732 psError(PS_ERR_UNKNOWN, true, "-stats is required");1733 1691 return false; 1734 1692 } … … 1789 1747 iteration, 1790 1748 exp_id, 1791 stats,1792 1749 recipe, 1793 1750 accept … … 2099 2056 inputExp->imfiles, 2100 2057 inputExp->filter, 2101 inputExp->stats 2058 inputExp->airmass, 2059 inputExp->ra, 2060 inputExp->decl, 2061 inputExp->exp_time, 2062 inputExp->background 2102 2063 ); 2103 2064 psArrayAdd(newInputExps, 0, newInputExp); -
trunk/ippTools/src/dettoolConfig.c
r8041 r8120 79 79 psMetadataAddStr(addprocArgs, PS_LIST_TAIL, "-uri", 0, 80 80 "define URI (required)", NULL); 81 psMetadataAddStr(addprocArgs, PS_LIST_TAIL, "-stats", 0,82 "define stat (required)", NULL);83 81 psMetadataAddStr(addprocArgs, PS_LIST_TAIL, "-recip", 0, 84 82 "define recipe (required)", NULL); … … 111 109 psMetadataAddStr(addstacArgs, PS_LIST_TAIL, "-uri", 0, 112 110 "define URI (required)", NULL); 113 psMetadataAddStr(addstacArgs, PS_LIST_TAIL, "-stats", 0,114 "define stat (required)", NULL);115 111 psMetadataAddStr(addstacArgs, PS_LIST_TAIL, "-recip", 0, 116 112 "define recipe (required)", NULL); … … 124 120 psMetadataAddStr(stacArgs, PS_LIST_TAIL, "-class_id", 0, 125 121 "search for class ID", NULL); 126 psMetadataAddStr(stacArgs, PS_LIST_TAIL, "-stats", 0,127 "search for stats", NULL);128 122 psMetadataAddStr(stacArgs, PS_LIST_TAIL, "-recip", 0, 129 123 "search for recipe", NULL); … … 137 131 psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-class_id", 0, 138 132 "search for class ID", NULL); 139 psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-stats", 0,140 "search for stats", NULL);141 133 psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-recip", 0, 142 134 "search for recipe", NULL); … … 152 144 psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-uri", 0, 153 145 "define URI (required)", NULL); 154 psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-stats", 0,155 "define stat (required)", NULL);156 146 psMetadataAddStr(addnormalizedArgs, PS_LIST_TAIL, "-recip", 0, 157 147 "define recipe (required)", NULL); … … 165 155 psMetadataAddStr(normalizedArgs, PS_LIST_TAIL, "-class_id", 0, 166 156 "search for class ID", NULL); 167 psMetadataAddStr(normalizedArgs, PS_LIST_TAIL, "-stats", 0,168 "search for stats", NULL);169 157 psMetadataAddStr(normalizedArgs, PS_LIST_TAIL, "-recip", 0, 170 158 "search for recipe", NULL); … … 178 166 psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-class_id", 0, 179 167 "search for class ID", NULL); 180 psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-stats", 0,181 "search for stats", NULL);182 168 psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-recip", 0, 183 169 "search for recipe", NULL); … … 193 179 psMetadataAddStr(addresidArgs, PS_LIST_TAIL, "-class_id", 0, 194 180 "define class ID (required)", NULL); 195 psMetadataAddStr(addresidArgs, PS_LIST_TAIL, "-stats", 0,196 "define stats (required)", NULL);197 181 psMetadataAddStr(addresidArgs, PS_LIST_TAIL, "-recip", 0, 198 182 "define recipe (required)", NULL); … … 208 192 psMetadataAddStr(residArgs, PS_LIST_TAIL, "-class_id", 0, 209 193 "search for class ID", NULL); 210 psMetadataAddStr(residArgs, PS_LIST_TAIL, "-stats", 0,211 "search for stats", NULL);212 194 psMetadataAddStr(residArgs, PS_LIST_TAIL, "-recip", 0, 213 195 "search for recipe", NULL); … … 221 203 psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-exp_id", 0, 222 204 "define detrend ID (required)", NULL); 223 psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-stats", 0,224 "define stats (required)", NULL);225 205 psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-recip", 0, 226 206 "define recipe (required)", NULL); … … 236 216 psMetadataAddStr(residexpArgs, PS_LIST_TAIL, "-exp_id", 0, 237 217 "search for exp ID", NULL); 238 psMetadataAddStr(residexpArgs, PS_LIST_TAIL, "-stats", 0,239 "search for stats", NULL);240 218 psMetadataAddStr(residexpArgs, PS_LIST_TAIL, "-recip", 0, 241 219 "search for recipe", NULL); … … 468 446 } 469 447 addWhereStr(filter); 470 addWhereStr(stats);471 448 addWhereStr(recipe); 472 449 { -
trunk/ippTools/src/guidetool.c
r7038 r8120 10 10 static bool pendingMode(pxConfig *config); 11 11 static bool defineMode(pxConfig *config); 12 static p1PendingExpRow *rawScienceTop1PendingExp(pxConfig *config, rawScienceExpRow * raw);12 static p1PendingExpRow *rawScienceTop1PendingExp(pxConfig *config, rawScienceExpRow *exp); 13 13 14 14 int main(int argc, char **argv) … … 104 104 } 105 105 106 static p1PendingExpRow *rawScienceTop1PendingExp(pxConfig *config, rawScienceExpRow * raw)106 static p1PendingExpRow *rawScienceTop1PendingExp(pxConfig *config, rawScienceExpRow *exp) 107 107 { 108 PS_ASSERT_PTR_NON_NULL(config, NULL); 109 PS_ASSERT_PTR_NON_NULL(exp, NULL); 110 111 bool status = false; 112 psString filter = psMetadataLookupStr(&status, config->args, "-filter"); 113 if (!status) { 114 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter"); 115 return false; 116 } 117 if (!filter) { 118 psError(PS_ERR_UNKNOWN, true, "-filter is required"); 119 return false; 120 } 121 psF32 airmass = psMetadataLookupF32(&status, config->args, "-airmass"); 122 if (!status) { 123 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass"); 124 return false; 125 } 126 if (!airmass) { 127 psError(PS_ERR_UNKNOWN, true, "-airmass is required"); 128 return false; 129 } 130 psF64 ra = psMetadataLookupF64(&status, config->args, "-ra"); 131 if (!status) { 132 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ra"); 133 return false; 134 } 135 if (!ra) { 136 psError(PS_ERR_UNKNOWN, true, "-airmass is required"); 137 return false; 138 } 139 psF64 dec = psMetadataLookupF64(&status, config->args, "-dec"); 140 if (!status) { 141 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -dec"); 142 return false; 143 } 144 if (!dec) { 145 psError(PS_ERR_UNKNOWN, true, "-dec is required"); 146 return false; 147 } 148 psF32 exp_time = psMetadataLookupF32(&status, config->args, "-exp_time"); 149 if (!status) { 150 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time"); 151 return false; 152 } 153 if (!exp_time) { 154 psError(PS_ERR_UNKNOWN, true, "-exp_time is required"); 155 return false; 156 } 157 psF64 background = psMetadataLookupF64(&status, config->args, "-background"); 158 if (!status) { 159 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -background"); 160 return false; 161 } 162 if (!exp_time) { 163 psError(PS_ERR_UNKNOWN, true, "-background is required"); 164 return false; 165 } 166 108 167 return p1PendingExpRowAlloc( 109 raw->exp_id, 110 raw->camera, 111 raw->telescope, 112 raw->exp_type, 113 // newExp->class, 114 raw->imfiles, 115 raw->filter, 116 raw->stats, 117 "my recipe", //recipe 118 0xff // XXX calc version number 168 exp->exp_id, 169 exp->camera, 170 exp->telescope, 171 exp->exp_type, 172 exp->imfiles, 173 filter, 174 airmass, 175 ra, 176 dec, 177 exp_time, 178 background, 179 "my recipe", 180 0xff // XXX calc version number 119 181 ); 120 182 } -
trunk/ippTools/src/guidetoolConfig.c
r7063 r8120 43 43 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-filter", 0, 44 44 "define filter of interest", NULL); 45 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-stats", 0,46 "define stats of interest", NULL);47 45 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-recipe", 0, 48 46 "define recipe of interest", NULL); … … 64 62 psMetadataAddStr(defineArgs, PS_LIST_TAIL, "-filter", 0, 65 63 "define filter of interest", NULL); 66 psMetadataAddStr(defineArgs, PS_LIST_TAIL, "-stats", 0,67 "define stats of interest", NULL);68 64 // these two are inputs NOT search parameters 69 65 psMetadataAddStr(defineArgs, PS_LIST_TAIL, "-recipe", 0, -
trunk/ippTools/src/p2insertPendingFrames.c
r8062 r8120 44 44 rawFrame->exposure->telescope, 45 45 rawFrame->exposure->exp_type, 46 // rawFrame->exposure->class,47 46 rawFrame->exposure->imfiles, 48 47 rawFrame->exposure->filter, 49 rawFrame->exposure->stats, 48 rawFrame->exposure->airmass, 49 rawFrame->exposure->ra, 50 rawFrame->exposure->decl, 51 rawFrame->exposure->exp_time, 52 rawFrame->exposure->background, 50 53 "my recipe", 51 54 0xff, … … 62 65 rawImage->class_id, 63 66 rawImage->uri, 64 "my stats",65 67 "my recipe", 66 68 0xff, // p1 -
trunk/ippTools/src/p2pendingToDone.c
r8062 r8120 22 22 pendingFrame->exposure->telescope, 23 23 pendingFrame->exposure->exp_type, 24 // pendingFrame->exposure->class,25 24 pendingFrame->exposure->imfiles, 26 25 pendingFrame->exposure->filter, 27 pendingFrame->exposure->stats, 26 pendingFrame->exposure->airmass, 27 pendingFrame->exposure->ra, 28 pendingFrame->exposure->decl, 29 pendingFrame->exposure->exp_time, 30 pendingFrame->exposure->background, 28 31 "my recipe", 29 32 pendingFrame->exposure->p1_version, … … 46 49 pendingImage->class_id, 47 50 pendingImage->uri, 48 "my stats", // stats49 51 "my recipe", // recipe 50 52 pendingImage->p1_version, … … 73 75 pendingExp->telescope, 74 76 pendingExp->exp_type, 75 // pendingExp->class,76 77 pendingExp->imfiles, // XXX ndone is uneeded? 77 78 pendingExp->filter, 78 pendingExp->stats, 79 pendingExp->airmass, 80 pendingExp->ra, 81 pendingExp->decl, 82 pendingExp->exp_time, 83 pendingExp->background, 79 84 "my recipe", 80 85 pendingExp->p1_version, -
trunk/ippTools/src/p2rawToPending.c
r8062 r8120 21 21 rawFrame->exposure->telescope, 22 22 rawFrame->exposure->exp_type, 23 // rawFrame->exposure->class,24 23 rawFrame->exposure->imfiles, 25 24 rawFrame->exposure->filter, 26 rawFrame->exposure->stats, 25 rawFrame->exposure->airmass, 26 rawFrame->exposure->ra, 27 rawFrame->exposure->decl, 28 rawFrame->exposure->exp_time, 29 rawFrame->exposure->background, 27 30 "my recipe", 28 31 0xff, // p1 … … 38 41 rawImage->class_id, 39 42 rawImage->uri, 40 "my stats", // stats41 43 "my recipe", // recipe 42 44 0xff, // p1 -
trunk/ippTools/src/pxframes.c
r8062 r8120 6 6 7 7 #include "pxtools.h" 8 9 static rawDetrendExpRow *newToRawDetrendExp(pxConfig *config, newExpRow *exp); 8 10 9 11 #define PX_FRAME_ALLOC(frametype, exptype) \ … … 77 79 PX_FRAME_PRINT(p2PendingFrame, p2PendingImfile); 78 80 79 81 // XXX fix the exposure search so that it doesn't dump the entire table 80 82 #define PX_FRAME_SEARCH(frametype, exptype, imfiletype) \ 81 83 psArray *frametype##Search(pxConfig *config) \ … … 83 85 PS_ASSERT_PTR_NON_NULL(config, NULL); \ 84 86 \ 85 psArray *exposures = exptype##SelectRowObjects(config->dbh, \ 86 config->where, MAX_ROWS); \ 87 psArray *exposures = exptype##SelectRowObjects(config->dbh, NULL, MAX_ROWS); \ 87 88 if (!exposures) { \ 88 89 psError(PS_ERR_UNKNOWN, false, "no " #exptype " rows found"); \ … … 131 132 PX_FRAME_SEARCH(p2PendingFrame, p2PendingExp, p2PendingImfile); 132 133 133 rawScienceFrame *newToRawScienceFrame(newFrame *newFrame) 134 { 134 135 bool rawScienceFrameInsert(pxConfig *config, rawScienceFrame *frame) 136 { 137 PS_ASSERT_PTR_NON_NULL(config, false); 138 PS_ASSERT_PTR_NON_NULL(config->dbh, false); 139 PS_ASSERT_PTR_NON_NULL(frame, false); 140 141 psDB *dbh = config->dbh; 142 143 if (!rawScienceExpInsertObject(dbh, frame->exposure)) { 144 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 145 return false; 146 } 147 148 psArray *images = frame->images; 149 for (long i = 0; i < psArrayLength(images); i++) { 150 if (!rawImfileInsertObject(dbh, images->data[i])) { 151 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 152 return false; 153 } 154 } 155 156 return true; 157 } 158 159 rawDetrendFrame *newToRawDetrendFrame(pxConfig *config, newFrame *newFrame) 160 { 161 newExpRow *newExp = NULL; 162 135 163 PS_ASSERT_PTR_NON_NULL(newFrame, NULL); 136 164 137 newExpRow *newExp = newFrame->exposure; 138 rawScienceExpRow *rawScienceExp = rawScienceExpRowAlloc( 139 newExp->exp_id, 140 newExp->camera, 141 newExp->telescope, 142 newExp->exp_type, 143 // newExp->class, 144 newExp->imfiles, 145 "my filter", 146 "my stats" 147 ); 165 newExp = newFrame->exposure; 166 rawDetrendExpRow *rawDetrendExp = newToRawDetrendExp(config, newExp); 148 167 149 168 psArray *newImages = newFrame->images; … … 155 174 newImfile->class, 156 175 newImfile->class_id, 157 newImfile->uri, 158 "my stats" 176 newImfile->uri 159 177 ); 160 178 psArrayAdd(rawImages, 0, rawImfile); … … 162 180 } 163 181 164 raw ScienceFrame *rawScienceFrame = rawScienceFrameAlloc(rawScienceExp, rawImages);165 psFree(raw ScienceExp);182 rawDetrendFrame *rawDetrendFrame = rawDetrendFrameAlloc(rawDetrendExp, rawImages); 183 psFree(rawDetrendExp); 166 184 psFree(rawImages); 167 185 168 return raw ScienceFrame;169 } 170 171 bool raw ScienceFrameInsert(pxConfig *config, rawScienceFrame *frame)186 return rawDetrendFrame; 187 } 188 189 bool rawDetrendFrameInsert(pxConfig *config, rawDetrendFrame *frame) 172 190 { 173 191 PS_ASSERT_PTR_NON_NULL(config, false); … … 177 195 psDB *dbh = config->dbh; 178 196 179 if (!raw ScienceExpInsertObject(dbh, frame->exposure)) {197 if (!rawDetrendExpInsertObject(dbh, frame->exposure)) { 180 198 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 181 199 return false; … … 193 211 } 194 212 195 rawDetrendFrame *newToRawDetrendFrame(newFrame *newFrame) 196 { 197 newExpRow *newExp = NULL; 198 199 PS_ASSERT_PTR_NON_NULL(newFrame, NULL); 200 201 newExp = newFrame->exposure; 202 rawDetrendExpRow *rawDetrendExp = rawDetrendExpRowAlloc( 203 newExp->exp_id, 204 newExp->camera, 205 newExp->telescope, 206 newExp->exp_type, 207 // newExp->class, 208 newExp->imfiles, 209 "my filter", 210 "my stats" 213 static rawDetrendExpRow *newToRawDetrendExp(pxConfig *config, newExpRow *exp) 214 { 215 PS_ASSERT_PTR_NON_NULL(config, NULL); 216 PS_ASSERT_PTR_NON_NULL(exp, NULL); 217 218 bool status = false; 219 psString filter = psMetadataLookupStr(&status, config->args, "-filter"); 220 if (!status) { 221 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter"); 222 return false; 223 } 224 if (!filter) { 225 psError(PS_ERR_UNKNOWN, true, "-filter is required"); 226 return false; 227 } 228 psF32 airmass = psMetadataLookupF32(&status, config->args, "-airmass"); 229 if (!status) { 230 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass"); 231 return false; 232 } 233 if (isnan(airmass)) { 234 psError(PS_ERR_UNKNOWN, true, "-airmass is required"); 235 return false; 236 } 237 psF64 ra = psMetadataLookupF64(&status, config->args, "-ra"); 238 if (!status) { 239 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ra"); 240 return false; 241 } 242 if (isnan(ra)) { 243 psError(PS_ERR_UNKNOWN, true, "-airmass is required"); 244 return false; 245 } 246 psF64 decl = psMetadataLookupF64(&status, config->args, "-decl"); 247 if (!status) { 248 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -decl"); 249 return false; 250 } 251 if (isnan(decl)) { 252 psError(PS_ERR_UNKNOWN, true, "-decl is required"); 253 return false; 254 } 255 psF32 exp_time = psMetadataLookupF32(&status, config->args, "-exp_time"); 256 if (isnan(exp_time)) { 257 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time"); 258 return false; 259 } 260 if (!exp_time) { 261 psError(PS_ERR_UNKNOWN, true, "-exp_time is required"); 262 return false; 263 } 264 psF64 background = psMetadataLookupF64(&status, config->args, "-background"); 265 if (!status) { 266 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -background"); 267 return false; 268 } 269 if (!exp_time) { 270 psError(PS_ERR_UNKNOWN, true, "-background is required"); 271 return false; 272 } 273 274 return rawDetrendExpRowAlloc( 275 exp->exp_id, 276 exp->camera, 277 exp->telescope, 278 exp->exp_type, 279 exp->imfiles, 280 filter, 281 airmass, 282 ra, 283 decl, 284 exp_time, 285 background 211 286 ); 212 213 psArray *newImages = newFrame->images; 214 psArray *rawImages = psArrayAlloc(psArrayLength(newImages)); 215 for (long i = 0; i < psArrayLength(newImages); i++) { 216 newImfileRow *newImfile = newImages->data[i]; 217 rawImfileRow *rawImfile = rawImfileRowAlloc( 218 newImfile->exp_id, 219 newImfile->class, 220 newImfile->class_id, 221 newImfile->uri, 222 "my stats" 223 ); 224 psArrayAdd(rawImages, 0, rawImfile); 225 psFree(rawImfile); 226 } 227 228 rawDetrendFrame *rawDetrendFrame = rawDetrendFrameAlloc(rawDetrendExp, rawImages); 229 psFree(rawDetrendExp); 230 psFree(rawImages); 231 232 return rawDetrendFrame; 233 } 234 235 bool rawDetrendFrameInsert(pxConfig *config, rawDetrendFrame *frame) 236 { 237 PS_ASSERT_PTR_NON_NULL(config, false); 238 PS_ASSERT_PTR_NON_NULL(config->dbh, false); 239 PS_ASSERT_PTR_NON_NULL(frame, false); 240 241 psDB *dbh = config->dbh; 242 243 if (!rawDetrendExpInsertObject(dbh, frame->exposure)) { 244 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 245 return false; 246 } 247 248 psArray *images = frame->images; 249 for (long i = 0; i < psArrayLength(images); i++) { 250 if (!rawImfileInsertObject(dbh, images->data[i])) { 251 psError(PS_ERR_UNKNOWN, false, "dbh access failed"); 252 return false; 253 } 254 } 255 256 return true; 257 } 287 } -
trunk/ippTools/src/pxtools.h
r8061 r8120 131 131 psArray *newFrameSearch(pxConfig *config); 132 132 133 rawScienceFrame *newToRawScienceFrame(newFrame *newFrame);134 133 bool rawScienceFrameInsert(pxConfig *config, rawScienceFrame *frame); 135 rawDetrendFrame *newToRawDetrendFrame( newFrame *newFrame);134 rawDetrendFrame *newToRawDetrendFrame(pxConfig *config, newFrame *newFrame); 136 135 bool rawDetrendFrameInsert(pxConfig *config, rawDetrendFrame *frame); 137 136 -
trunk/ippTools/src/regtool.c
r8042 r8120 12 12 static psArray *newFrameSearchPending(pxConfig *config); 13 13 static p1PendingExpRow *newToP1PendingExp(newExpRow *newExp); 14 static p2PendingExpRow *newToP2PendingExp( newExpRow *newExp);14 static p2PendingExpRow *newToP2PendingExp(pxConfig *config, newExpRow *newExp); 15 15 static p2PendingImfileRow *newImfileToP2PendingImfile(newImfileRow *newImfile); 16 static rawScienceFrame *newToRawScienceFrame(pxConfig *config, newFrame *newFrame); 17 static rawScienceExpRow *newToRawScienceExp(pxConfig *config, newExpRow *exp); 18 16 19 17 20 # define MODECASE(caseName, func) \ … … 89 92 // insert 'new' rawScience & detrendframes 90 93 if (psArrayLength(new) > 0) { 94 // start a transaction so we don't end up file raw* frames but no 95 // p2Pending*, etc. 96 if (!psDBTransaction(config->dbh)) { 97 psError(PS_ERR_UNKNOWN, false, "database error"); 98 psFree(exp); 99 psFree(new); 100 return false; 101 } 102 91 103 for (long i = 0; i < psArrayLength(new); i++) { 92 104 newFrame *newFrame = new->data[i]; 93 105 if (detrend) { 94 106 // it's a detrend frame 95 rawDetrendFrame *frame = newToRawDetrendFrame( newFrame);107 rawDetrendFrame *frame = newToRawDetrendFrame(config, newFrame); 96 108 if (!frame) { 97 109 psError(PS_ERR_UNKNOWN, false, "failed to convert new frame into a detrend frame"); … … 100 112 } 101 113 if (!rawDetrendFrameInsert(config, frame)) { 114 // rollback 115 if (!psDBRollback(config->dbh)) { 116 psError(PS_ERR_UNKNOWN, false, "database error"); 117 } 102 118 psError(PS_ERR_UNKNOWN, false, "failed to insert frame into the database"); 103 119 psFree(frame); … … 112 128 // it's a science frame 113 129 // insert into into rawScienceExp 114 rawScienceFrame *frame = newToRawScienceFrame( newFrame);130 rawScienceFrame *frame = newToRawScienceFrame(config, newFrame); 115 131 if (!frame) { 132 // rollback 133 if (!psDBRollback(config->dbh)) { 134 psError(PS_ERR_UNKNOWN, false, "database error"); 135 } 116 136 psError(PS_ERR_UNKNOWN, false, "failed to convert new frame into a science frame"); 117 137 psFree(new); … … 119 139 } 120 140 if (!rawScienceFrameInsert(config, frame)) { 141 // rollback 142 if (!psDBRollback(config->dbh)) { 143 psError(PS_ERR_UNKNOWN, false, "database error"); 144 } 121 145 psError(PS_ERR_UNKNOWN, false, "failed to insert frame into the database"); 122 146 psFree(frame); … … 127 151 128 152 // insert into into p2PendingExp 129 p2PendingExpRow *exp = newToP2PendingExp(newFrame->exposure); 153 // XXX add a newToP2PendingFrame() 154 // XXX add a p2PendingFrameInsert() 155 p2PendingExpRow *exp = newToP2PendingExp(config, newFrame->exposure); 130 156 if (!exp) { 157 // rollback 158 if (!psDBRollback(config->dbh)) { 159 psError(PS_ERR_UNKNOWN, false, "database error"); 160 } 131 161 psError(PS_ERR_UNKNOWN, false, "failed to convert newExp into a p2PendingExp"); 132 162 psFree(new); 133 163 return false; 134 164 } 165 135 166 if (!p2PendingExpInsertObject(config->dbh, exp)) { 167 // rollback 168 if (!psDBRollback(config->dbh)) { 169 psError(PS_ERR_UNKNOWN, false, "database error"); 170 } 136 171 psError(PS_ERR_UNKNOWN, false, "failed to insert p2PendingExp into the database"); 137 172 psFree(exp); … … 145 180 p2PendingImfileRow *imfile = newImfileToP2PendingImfile(newFrame->images->data[i]); 146 181 if (!p2PendingImfileInsertObject(config->dbh, imfile)) { 147 psError(PS_ERR_UNKNOWN, false, "failed to insert p2PendingImfile into the database"); 182 // rollback 183 if (!psDBRollback(config->dbh)) { 184 psError(PS_ERR_UNKNOWN, false, "database error"); 185 } 186 psError(PS_ERR_UNKNOWN, false, "failed to insert p2PendingImfile into the database"); 148 187 psFree(imfile); 149 188 psFree(new); … … 152 191 psFree(imfile); 153 192 } 193 } 194 // point of no return for p2Pending[Exp|Imfile] 195 if (!psDBCommit(config->dbh)) { 196 psError(PS_ERR_UNKNOWN, false, "database error"); 197 return false; 154 198 } 155 199 } … … 231 275 newExp->telescope, 232 276 newExp->exp_type, 233 // newExp->class,234 277 newExp->imfiles, 235 278 "my filter", 236 "my stats", 279 0.1, // airmass 280 0.2, // ra 281 0.3, // dec 282 0.4, // exp time 283 0.5, // background 237 284 "my recipe", 238 285 0xff // XXX calc version number … … 240 287 } 241 288 242 static p2PendingExpRow *newToP2PendingExp(newExpRow *newExp) 243 { 289 static p2PendingExpRow *newToP2PendingExp(pxConfig *config, newExpRow *exp) 290 { 291 PS_ASSERT_PTR_NON_NULL(config, NULL); 292 PS_ASSERT_PTR_NON_NULL(exp, NULL); 293 294 bool status = false; 295 psString filter = psMetadataLookupStr(&status, config->args, "-filter"); 296 if (!status) { 297 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter"); 298 return false; 299 } 300 if (!filter) { 301 psError(PS_ERR_UNKNOWN, true, "-filter is required"); 302 return false; 303 } 304 psF32 airmass = psMetadataLookupF32(&status, config->args, "-airmass"); 305 if (!status) { 306 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass"); 307 return false; 308 } 309 if (isnan(airmass)) { 310 psError(PS_ERR_UNKNOWN, true, "-airmass is required"); 311 return false; 312 } 313 psF64 ra = psMetadataLookupF64(&status, config->args, "-ra"); 314 if (!status) { 315 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ra"); 316 return false; 317 } 318 if (isnan(ra)) { 319 psError(PS_ERR_UNKNOWN, true, "-ra is required"); 320 return false; 321 } 322 psF64 decl = psMetadataLookupF64(&status, config->args, "-decl"); 323 if (!status) { 324 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -decl"); 325 return false; 326 } 327 if (isnan(decl)) { 328 psError(PS_ERR_UNKNOWN, true, "-decl is required"); 329 return false; 330 } 331 psF32 exp_time = psMetadataLookupF32(&status, config->args, "-exp_time"); 332 if (!status) { 333 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time"); 334 return false; 335 } 336 if (isnan(exp_time)) { 337 psError(PS_ERR_UNKNOWN, true, "-exp_time is required"); 338 return false; 339 } 340 psF64 background = psMetadataLookupF64(&status, config->args, "-background"); 341 if (!status) { 342 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -background"); 343 return false; 344 } 345 if (isnan(background)) { 346 psError(PS_ERR_UNKNOWN, true, "-background is required"); 347 return false; 348 } 349 244 350 return p2PendingExpRowAlloc( 245 newExp->exp_id, 246 newExp->camera, 247 newExp->telescope, 248 newExp->exp_type, 249 // newExp->class, 250 newExp->imfiles, 251 "my filter", 252 "my stats", 351 exp->exp_id, 352 exp->camera, 353 exp->telescope, 354 exp->exp_type, 355 exp->imfiles, 356 filter, 357 airmass, 358 ra, 359 decl, 360 exp_time, 361 background, 253 362 "my recipe", 254 363 0xff, // XXX calc version number … … 263 372 newImfile->class_id, 264 373 newImfile->uri, 265 "my stats",266 374 "my recipe", 267 375 0xff, // XXX calc version number … … 269 377 ); 270 378 } 379 380 static rawScienceFrame *newToRawScienceFrame(pxConfig *config, newFrame *newFrame) 381 { 382 PS_ASSERT_PTR_NON_NULL(config, NULL); 383 PS_ASSERT_PTR_NON_NULL(newFrame, NULL); 384 385 newExpRow *newExp = newFrame->exposure; 386 rawScienceExpRow *rawScienceExp = newToRawScienceExp(config, newExp); 387 if (!rawScienceExp) { 388 psError(PS_ERR_UNKNOWN, false, "failed to convert newExp to rawScienceExp"); 389 return NULL; 390 } 391 392 psArray *newImages = newFrame->images; 393 psArray *rawImages = psArrayAlloc(psArrayLength(newImages)); 394 for (long i = 0; i < psArrayLength(newImages); i++) { 395 newImfileRow *newImfile = newImages->data[i]; 396 rawImfileRow *rawImfile = rawImfileRowAlloc( 397 newImfile->exp_id, 398 newImfile->class, 399 newImfile->class_id, 400 newImfile->uri 401 ); 402 psArrayAdd(rawImages, 0, rawImfile); 403 psFree(rawImfile); 404 } 405 406 rawScienceFrame *rawScienceFrame = rawScienceFrameAlloc(rawScienceExp, rawImages); 407 psFree(rawScienceExp); 408 psFree(rawImages); 409 410 return rawScienceFrame; 411 } 412 413 static rawScienceExpRow *newToRawScienceExp(pxConfig *config, newExpRow *exp) 414 { 415 PS_ASSERT_PTR_NON_NULL(config, NULL); 416 PS_ASSERT_PTR_NON_NULL(exp, NULL); 417 418 bool status = false; 419 psString filter = psMetadataLookupStr(&status, config->args, "-filter"); 420 if (!status) { 421 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -filter"); 422 return NULL; 423 } 424 if (!filter) { 425 psError(PS_ERR_UNKNOWN, true, "-filter is required"); 426 return NULL; 427 } 428 psF32 airmass = psMetadataLookupF32(&status, config->args, "-airmass"); 429 if (!status) { 430 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -airmass"); 431 return NULL; 432 } 433 if (isnan(airmass)) { 434 psError(PS_ERR_UNKNOWN, true, "-airmass is required"); 435 return NULL; 436 } 437 psF64 ra = psMetadataLookupF64(&status, config->args, "-ra"); 438 if (!status) { 439 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -ra"); 440 return NULL; 441 } 442 if (isnan(ra)) { 443 psError(PS_ERR_UNKNOWN, true, "-airmass is required"); 444 return NULL; 445 } 446 psF64 decl = psMetadataLookupF64(&status, config->args, "-decl"); 447 if (!status) { 448 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -decl"); 449 return NULL; 450 } 451 if (isnan(decl)) { 452 psError(PS_ERR_UNKNOWN, true, "-decl is required"); 453 return NULL; 454 } 455 psF32 exp_time = psMetadataLookupF32(&status, config->args, "-exp_time"); 456 if (!status) { 457 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_time"); 458 return NULL; 459 } 460 if (isnan(exp_time)) { 461 psError(PS_ERR_UNKNOWN, true, "-exp_time is required"); 462 return NULL; 463 } 464 psF64 background = psMetadataLookupF64(&status, config->args, "-background"); 465 if (!status) { 466 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -background"); 467 return NULL; 468 } 469 if (isnan(background)) { 470 psError(PS_ERR_UNKNOWN, true, "-background is required"); 471 return NULL; 472 } 473 474 return rawScienceExpRowAlloc( 475 exp->exp_id, 476 exp->camera, 477 exp->telescope, 478 exp->exp_type, 479 exp->imfiles, 480 filter, 481 airmass, 482 ra, 483 decl, 484 exp_time, 485 background 486 ); 487 } 488 489 -
trunk/ippTools/src/regtoolConfig.c
r8075 r8120 4 4 5 5 #include <pmConfig.h> 6 #include <math.h> 6 7 7 8 #include "pxtools.h" … … 38 39 psMetadata *updateArgs = psMetadataAlloc(); 39 40 psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-exp_id", 0, 40 "define class", NULL); 41 psMetadataAddBool(updateArgs, PS_LIST_TAIL, "-detrend", 0, 42 "declare this as detrend data", false); 41 "exp_id to operate on", NULL); 43 42 psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-filter", 0, 44 "define filter of interest", NULL); 45 psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-stat", 0, 46 "define URL", NULL); 43 "define filter ", NULL); 44 psMetadataAddF32(updateArgs, PS_LIST_TAIL, "-airmass", 0, 45 "define airmass", NAN); 46 psMetadataAddF64(updateArgs, PS_LIST_TAIL, "-ra", 0, 47 "define RA", NAN); 48 psMetadataAddF64(updateArgs, PS_LIST_TAIL, "-decl", 0, 49 "define DEC", NAN); 50 psMetadataAddF32(updateArgs, PS_LIST_TAIL, "-exp_time", 0, 51 "define exposure time", NAN); 52 psMetadataAddF64(updateArgs, PS_LIST_TAIL, "-background", 0, 53 "define exposue background", NAN); 54 /* 47 55 psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-recip", 0, 48 56 "define URL", NULL); 49 57 psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-mosiac", 0, 50 58 "define URL", NULL); 59 */ 60 psMetadataAddBool(updateArgs, PS_LIST_TAIL, "-detrend", 0, 61 "declare this as detrend data", false); 51 62 52 63 #define PXTOOL_MODE(option, modeval, argset) \
Note:
See TracChangeset
for help on using the changeset viewer.
