- Timestamp:
- Jun 23, 2010, 2:29:49 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/ippToPsps/src/ippToPspsBatchDetection.c
r28305 r28439 13 13 #include "fitsio.h" 14 14 15 // Gets flux from magnitude15 // Gets uncalibrated instrumental flux from magnitude 16 16 static __inline bool ippToPsps_getFlux(const float zeroPoint, const float exposureTime, const float magnitude, float* flux) { 17 17 18 // use uncalibrated instrumental flux19 18 *flux = powf(10.0, -0.4*magnitude) / exposureTime; 20 21 // use calibrated flux in Janskys, where 3631 Jy is the zero point flux for the filter: constant over all filters because we're using AB magnitudes22 //float flux = 3631 * powf(10.0, -0.4*(magnitude + zeroPoint)) / exposureTime;23 24 // printf("mag=%f\texpTime=%f\tzeroPoint=%f\tflux=%f\n", magnitude, exposureTime, zeroPoint, flux);25 19 return (!isfinite(*flux) || *flux < 0.000001) ? false : true; 26 20 } … … 104 98 int maxDvoDetId = -1; 105 99 int numDvoDetections = -1; 106 Image * pImage = NULL;100 Image *image = NULL; 107 101 108 102 // stuff for detections table … … 157 151 long maxObjID = LONG_MIN; 158 152 long minObjID = LONG_MAX; 153 uint64_t imageFlags; 159 154 short nOta = 0; 160 155 long i; … … 163 158 uint32_t numInvalidFlux; 164 159 long numDetectionsOut; 160 long totalDetectionsOut = 0; 165 161 long removeList[MAXDETECT]; 166 162 long thisObjId; … … 203 199 204 200 // access DVO database 205 skylist = dvoSkyListByExternID(this->dvoConfig, sourceId, imageId, & pImage);201 skylist = dvoSkyListByExternID(this->dvoConfig, sourceId, imageId, &image); 206 202 if (skylist == NULL) { 207 203 psError(PS_ERR_IO, false, … … 212 208 213 209 // create unique int from 'frameID' (aka exposure ID) and ccd number 214 pspsImageId = (this->expId*100) + pImage->ccdnum;210 pspsImageId = (this->expId*100) + image->ccdnum; 215 211 216 212 // now get DVO detections 217 213 dvoDetections = NULL; 218 numDvoDetections = dvoGetDetections(skylist, pImage->imageID, &dvoDetections, &maxDvoDetId);214 numDvoDetections = dvoGetDetections(skylist, image->imageID, &dvoDetections, &maxDvoDetId); 219 215 220 216 // TODO check nDet < MAXDETECT … … 224 220 psfFwhm = (fwhmMaj+fwhmMin)/2; 225 221 momentFwhm = (momentMaj+momentMin)/2; 222 imageFlags = (uint64_t)image->flags; 226 223 fits_write_col(this->fitsOut, TLONGLONG, IMAGEMETA_IMAGEID, 1, 1, 1, &pspsImageId, &status); 227 224 fits_write_col(this->fitsOut, TLONG, IMAGEMETA_FRAMEID, 1, 1, 1, &this->expId, &status); 228 fits_write_col(this->fitsOut, TSHORT, IMAGEMETA_CCDID, 1, 1, 1, & pImage->ccdnum, &status);229 fits_write_col(this->fitsOut, TLONG, IMAGEMETA_PHOTOCALID, 1, 1, 1, & pImage->photcode, &status);225 fits_write_col(this->fitsOut, TSHORT, IMAGEMETA_CCDID, 1, 1, 1, &image->ccdnum, &status); 226 fits_write_col(this->fitsOut, TLONG, IMAGEMETA_PHOTOCALID, 1, 1, 1, &image->photcode, &status); 230 227 fits_write_col(this->fitsOut, TBYTE, IMAGEMETA_FILTERID, 1, 1, 1, &filterID, &status); 231 228 fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOSCAT, 1, 1, 1, &zptObs, &status); … … 233 230 fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_MOMENTFWHM, 1, 1, 1, &momentFwhm, &status); 234 231 fits_write_col(this->fitsOut, TFLOAT, IMAGEMETA_PHOTOZERO, 1, 1, 1, &zptObs, &status); 232 fits_write_col(this->fitsOut, TLONGLONG, IMAGEMETA_QAFLAGS, 1, 1, 1, &imageFlags, &status); 235 233 236 234 // now move BACK to detections table in smf … … 365 363 extensionName, nDet, numDetectionsOut, unmatched, numOfDuplicates, numInvalidFlux); 366 364 365 totalDetectionsOut += numDetectionsOut; 366 367 367 if (dvoDetections!= NULL) dvoFree(dvoDetections); 368 368 SkyListFree(skylist); 369 369 } 370 370 } 371 372 psLogMsg("ippToPsps", PS_LOG_INFO, "Total detections for this exposure = %ld\n", totalDetectionsOut); 371 373 372 374 for (uint32_t i=0; i<MAXDETECT;i++) free(assocDate[i]); … … 390 392 if (fprintf(this->resultsFile, "%ld\n", maxObjID) < 1 ) 391 393 psError(PS_ERR_IO, false, "Unable to write max Object ID to'%s'\n", this->resultsPath); 394 if (fprintf(this->resultsFile, "%ld\n", totalDetectionsOut) < 1 ) 395 psError(PS_ERR_IO, false, "Unable to write totalDetectionsOut to'%s'\n", this->resultsPath); 392 396 } 393 397
Note:
See TracChangeset
for help on using the changeset viewer.
