Changeset 27685
- Timestamp:
- Apr 14, 2010, 3:55:17 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/src/ippToPspsBatchDetection.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/ippToPspsBatchDetection.c
r27683 r27685 35 35 Loop loads the data from the input smf file(s), consults the DVO database, then prepares an output FITS format suitable for PSPS. 36 36 */ 37 boolippToPsps_batchDetection(IppToPsps *this) {38 39 if (this->numOfInputFiles < 1) return false;37 int ippToPsps_batchDetection(IppToPsps *this) { 38 39 if (this->numOfInputFiles < 1) return PS_EXIT_DATA_ERROR; 40 40 41 41 int status = 0; … … 46 46 47 47 fits_report_error(stderr, status); 48 return false;48 return PS_EXIT_SYS_ERROR; 49 49 } 50 50 … … 98 98 int numDvoDetections = -1; 99 99 Image *pImage = NULL; 100 101 bool ret = true;102 100 103 101 // stuff for detections table … … 171 169 sprintf(ccdNumber, "%d%d", x, y); 172 170 171 // check we can move to detections table in smf 172 sprintf(extensionName, "XY%s.psf", ccdNumber); 173 status=0; 174 if (fits_movnam_hdu(fitsIn, BINARY_TBL, extensionName, 0, &status)) { 175 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping this chip\n", extensionName); 176 continue; 177 } 178 179 // move to header extension 173 180 sprintf(extensionName, "XY%s.hdr", ccdNumber); 174 181 status=0; 175 182 if (fits_movnam_hdu(fitsIn, IMAGE_HDU, extensionName, 0, &status)) { 176 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping \n", extensionName);183 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping this chip\n", extensionName); 177 184 continue; 178 185 } … … 190 197 skylist = dvoSkyListByExternID(this->dvoConfig, sourceId, imageId, &pImage); 191 198 if (skylist == NULL) { 192 psError(PS_ERR_IO, false, " Can't find SkyList for sourceId='%d' imageId='%d' (CCD = XY%s): skipping\n", sourceId, imageId, ccdNumber);199 psError(PS_ERR_IO, false, "DVO: can't find SkyList for sourceId='%d' imageId='%d' (CCD = XY%s): skipping\n", sourceId, imageId, ccdNumber); 193 200 continue; 194 201 } … … 201 208 numDvoDetections = dvoGetDetections(skylist, pImage->imageID, &dvoDetections, &maxDvoDetId); 202 209 203 204 // keep a running count of 'images' we find in order to write total to FrameMeta at the end205 nOta++;206 207 210 // TODO check nDet < MAXDETECT 208 // move to detections table in smf209 sprintf(extensionName, "XY%s.psf", ccdNumber);210 status=0;211 if (fits_movnam_hdu(fitsIn, BINARY_TBL, extensionName, 0, &status)) {212 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping\n", extensionName);213 continue;214 }215 211 216 212 // create ImageMeta … … 222 218 fits_write_col(this->fitsOut, TSHORT, IMAGEMETA_CCDID, 1, 1, 1, &pImage->ccdnum, &status); 223 219 // fits_write_col(this->fitsOut, TLONG, IMAGEMETA_PHOTOCALID, 1, 1, 1, &pImage->photcode, &status); TODO 224 psLogMsg("ippToPsps", PS_LOG_INFO, "photocode %d", pImage->photcode);225 220 fits_write_col(this->fitsOut, TBYTE, IMAGEMETA_FILTERID, 1, 1, 1, &filterID, &status); 226 221 fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOSCAT, 1, 1, 1, &zptObs, &status); … … 228 223 fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_MOMENTFWHM, 1, 1, 1, &momentFwhm, &status); 229 224 fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOZERO, 1, 1, 1, &zptObs, &status); 225 226 // now move BACK to detections table in smf 227 sprintf(extensionName, "XY%s.psf", ccdNumber); 228 status=0; 229 if (fits_movnam_hdu(fitsIn, BINARY_TBL, extensionName, 0, &status)) { 230 psError(PS_ERR_IO, false, "Can't move to extension: %s skipping\n", extensionName); 231 continue; 232 } 233 234 // keep a running count of 'images' we find in order to write total to FrameMeta at the end 235 nOta++; 230 236 231 237 long nDet = 0; … … 346 352 347 353 // write number of images we have found into FrameMeta table 354 status=0; 348 355 if (fits_movnam_hdu(this->fitsOut, BINARY_TBL, "FrameMeta", 0, &status)) 349 fits_report_error(stderr, status);356 psError(PS_ERR_IO, false, "Can't move back to FrameMeta extension to write number of OTAs\n"); 350 357 else 351 358 fits_write_col(this->fitsOut, TSHORT, FRAMEMETA_NOTA, 1, 1, 1, &nOta, &status); 352 359 360 status=0; 353 361 if (fits_close_file(fitsIn, &status)) fits_report_error(stderr, status); 354 362 … … 362 370 } 363 371 364 return ret; 372 psLogMsg("ippToPsps", PS_LOG_INFO, "Data written for a total of %d chips/OTAs", nOta); 373 374 return PS_EXIT_SUCCESS; 365 375 } 366 376
Note:
See TracChangeset
for help on using the changeset viewer.
