- Timestamp:
- Oct 21, 2010, 2:45:13 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100823/ippToPsps/src/ippToPspsBatchDetection.c
r29124 r29515 11 11 #include "ippToPspsConfig.h" 12 12 #include "ippToPspsDetEnums.h" 13 #include "fitsio.h"14 15 // Gets uncalibrated instrumental flux from magnitude16 static __inline bool ippToPsps_getFlux(const float exposureTime, const float magnitude, float* flux, const float magnitudeErr, float* fluxErr) {17 18 *flux = powf(10.0, -0.4*magnitude) / exposureTime;19 if (!isfinite(*flux) || *flux < 0.000001) return false;20 if (fluxErr) *fluxErr = fabsf((magnitudeErr * *flux)/1.085736);21 // if (fluxErr) printf("Mag = %03.03f, Flux = %03.03f, Mag err = %03.03f, Flux Err = %03.03f\n", magnitude, *flux, magnitudeErr, *fluxErr);22 23 return true;24 }25 13 26 14 /** … … 35 23 int ippToPsps_batchDetection(IppToPsps *this) { 36 24 37 if (this->numOfInputFiles < 1) return PS_EXIT_DATA_ERROR;38 39 25 int status = 0; 40 26 fitsfile *fitsIn; 41 int nKeys;42 27 43 28 if (fits_open_file(&fitsIn, this->inputFiles[0], READONLY, &status)) { … … 48 33 49 34 // get primary header and pull stuff out for later 35 int nKeys; 50 36 fits_get_hdrspace(fitsIn, &nKeys, NULL, &status); 51 37 … … 65 51 66 52 // FrameMeta values 67 fits_write_col(this->fitsOut, TLONG, FRAMEMETA_FRAMEID, 1, 1, 1, &this-> expId, &status);53 fits_write_col(this->fitsOut, TLONG, FRAMEMETA_FRAMEID, 1, 1, 1, &this->id, &status); 68 54 fits_write_col(this->fitsOut, TSTRING, FRAMEMETA_FRAMENAME, 1, 1, 1, &this->expName, &status); 69 55 70 int8_t surveyID = -1; 71 if (!ippToPspsConfig_getSurveyId(this->config, this->surveyType, &surveyID)) {return PS_EXIT_DATA_ERROR;} 72 fits_write_col(this->fitsOut, TBYTE, FRAMEMETA_SURVEYID, 1, 1, 1, &surveyID, &status); 56 fits_write_col(this->fitsOut, TBYTE, FRAMEMETA_SURVEYID, 1, 1, 1, &this->surveyID, &status); 73 57 74 58 int8_t filterID = -1; … … 97 81 98 82 // stuff for detections table 99 time_t now;100 struct tm *ts;101 char timeStr[12];102 now = time(NULL);103 ts = gmtime(&now); // TODO should be UTC104 strftime(timeStr, sizeof(timeStr), "%Y-%m-%d", ts);105 106 83 uint32_t s,d, invalidDvoRows, smfJumps, unmatched, totalDetections = 0; 107 84 … … 128 105 129 106 filterIDs[s] = filterID; 130 surveyIDs[s] = surveyID;131 strcpy(assocDate[s], t imeStr);107 surveyIDs[s] = this->surveyID; 108 strcpy(assocDate[s], this->todaysDate); 132 109 } 133 110 … … 192 169 193 170 // create unique int from 'frameID' (aka exposure ID) and ccd number 194 pspsImageId = (this-> expId*100) + image->ccdnum;171 pspsImageId = (this->id*100) + image->ccdnum; 195 172 196 173 // now get DVO detections … … 206 183 imageFlags = (uint64_t)image->flags; 207 184 fits_write_col(this->fitsOut, TLONGLONG, IMAGEMETA_IMAGEID, 1, 1, 1, &pspsImageId, &status); 208 fits_write_col(this->fitsOut, TLONG, IMAGEMETA_FRAMEID, 1, 1, 1, &this-> expId, &status);185 fits_write_col(this->fitsOut, TLONG, IMAGEMETA_FRAMEID, 1, 1, 1, &this->id, &status); 209 186 fits_write_col(this->fitsOut, TSHORT, IMAGEMETA_CCDID, 1, 1, 1, &image->ccdnum, &status); 210 187 fits_write_col(this->fitsOut, TLONG, IMAGEMETA_PHOTOCALID, 1, 1, 1, &image->photcode, &status);
Note:
See TracChangeset
for help on using the changeset viewer.
