Changeset 30967 for trunk/ippToPsps/src/DetectionBatch.c
- Timestamp:
- Mar 18, 2011, 11:33:22 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/src/DetectionBatch.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/DetectionBatch.c
r30193 r30967 15 15 free (this->expName); 16 16 free (this); 17 } 18 19 /** 20 Writes results to XML file 21 */ 22 static bool writeResults(DetectionBatch* this, long minObjID, long maxObjID, long totalDetectionsOut) { 23 24 if (!this->base.resultsXmlDoc) return false; 25 26 xmlNodePtr rootNode = xmlDocGetRootElement(this->base.resultsXmlDoc); 27 char tmp[100]; 28 sprintf(tmp, "%ld", minObjID); 29 xmlNewChild(rootNode, NULL, BAD_CAST "minObjID", BAD_CAST tmp); 30 sprintf(tmp, "%ld", maxObjID); 31 xmlNewChild(rootNode, NULL, BAD_CAST "maxObjID", BAD_CAST tmp); 32 sprintf(tmp, "%ld", totalDetectionsOut); 33 xmlNewChild(rootNode, NULL, BAD_CAST "totalDetections", BAD_CAST tmp); 34 35 return true; 17 36 } 18 37 … … 119 138 filterIDs[s] = filterID; 120 139 surveyIDs[s] = this->base.surveyID; 121 strcpy(assocDate[s], this->base.todaysDate); 140 141 // if running in test mode, don't use today's date 142 if (this->base.testMode) strcpy(assocDate[s], "2010-01-01"); 143 else strcpy(assocDate[s], this->base.todaysDate); 122 144 } 123 145 … … 133 155 int ippIDetNum, instMagNum, instMagErrNum, peakMagNum; 134 156 bool error = false; 135 136 // loop round all 60 chips 137 for (int x=0; x<8; x++) { 138 for (int y=0; y<8; y++) { 157 int startX, stopX, startY, stopY; 158 159 // in test mode, only run for chip 33 160 if (this->base.testMode) { 161 162 startX = 3; 163 stopX = 4; 164 startY = 3; 165 stopY = 4; 166 } 167 // in 'normal' mode, run for all chips 168 else { 169 170 startX = 0; 171 stopX = 8; 172 startY = 0; 173 stopY = 8; 174 } 175 176 // loop round chips 177 for (int x=startX; x<stopX; x++) { 178 for (int y=startY; y<stopY; y++) { 139 179 140 180 // dodge the corners … … 148 188 // check we can move to detections table in smf 149 189 sprintf(extensionName, "XY%s.psf", ccdNumber); 150 status=0; 151 if (fits_movnam_hdu(fitsIn, BINARY_TBL, extensionName, 0, &status)) { 152 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping this chip\n", extensionName); 153 continue; 154 } 190 if (!ippToPspsConfig_moveToExtensionTable(fitsIn, extensionName)) continue; 155 191 156 192 // move to header extension 157 193 sprintf(extensionName, "XY%s.hdr", ccdNumber); 158 status=0; 159 if (fits_movnam_hdu(fitsIn, IMAGE_HDU, extensionName, 0, &status)) { 160 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping this chip\n", extensionName); 161 continue; 162 } 194 if (!ippToPspsConfig_moveToExtensionHeader(fitsIn, extensionName)) continue; 163 195 164 196 // stuff to save from psf.hdr … … 214 246 // now move BACK to detections table in smf 215 247 sprintf(extensionName, "XY%s.psf", ccdNumber); 216 status=0; 217 if (fits_movnam_hdu(fitsIn, BINARY_TBL, extensionName, 0, &status)) { 218 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping\n", extensionName); 219 continue; 220 } 248 if (!ippToPspsConfig_moveToExtensionTable(fitsIn, extensionName)) continue; 221 249 222 250 // keep a running count of 'images' we find in order to write total to FrameMeta at the end … … 312 340 313 341 // check for invalid flux values, and skip them 314 if ( !peakFluxOk || !instFluxOk) {342 if (!peakFluxOk || !instFluxOk) { 315 343 removeList[numOfDuplicates+numInvalidFlux+numOfInvalidIppIDet] = s+1; 316 344 numInvalidFlux++; … … 408 436 409 437 // write number of images we have found into FrameMeta table 410 status=0; 411 if (fits_movnam_hdu(this->base.fitsOut, BINARY_TBL, "FrameMeta", 0, &status)) 412 psError(PS_ERR_IO, false, "Can't move back to FrameMeta extension to write number of OTAs\n"); 413 else { 438 if (ippToPspsConfig_moveToExtensionTable(this->base.fitsOut, "FrameMeta")) { 439 414 440 fits_write_col(this->base.fitsOut, TSHORT, FRAMEMETA_NOTA, 1, 1, 1, &nOta, &status); 415 441 fits_write_col(this->base.fitsOut, TSHORT, FRAMEMETA_NUMPHOTOREF, 1, 1, 1, &totalNumPhotoRef, &status); 416 442 } 443 417 444 status=0; 418 445 if (fits_close_file(fitsIn, &status)) fits_report_error(stderr, status); 419 // write results 420 if (this->base.resultsXmlDoc) { 421 422 xmlNodePtr rootNode = xmlDocGetRootElement(this->base.resultsXmlDoc); 423 char tmp[100]; 424 sprintf(tmp, "%ld", minObjID); 425 xmlNewChild(rootNode, NULL, BAD_CAST "minObjID", BAD_CAST tmp); 426 sprintf(tmp, "%ld", maxObjID); 427 xmlNewChild(rootNode, NULL, BAD_CAST "maxObjID", BAD_CAST tmp); 428 sprintf(tmp, "%ld", totalDetectionsOut); 429 xmlNewChild(rootNode, NULL, BAD_CAST "totalDetections", BAD_CAST tmp); 430 } 446 447 writeResults(this, minObjID, maxObjID, totalDetectionsOut); 431 448 432 449 psLogMsg("ippToPsps", PS_LOG_INFO, "Data written for a total of %d chips/OTAs", nOta); … … 437 454 return this->base.exitCode; 438 455 } 439 440 456 441 457 /**
Note:
See TracChangeset
for help on using the changeset viewer.
