- 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/ippToPsps.c
r28529 r29515 24 24 extern int ippToPsps_batchDifference(IppToPsps *data); 25 25 26 // Gets uncalibrated instrumental flux from magnitude 27 __inline bool ippToPsps_getFlux(const float exposureTime, const float magnitude, float* flux, const float magnitudeErr, float* fluxErr) { 28 29 *flux = powf(10.0, -0.4*magnitude) / exposureTime; 30 if (!isfinite(*flux) || *flux < 0.000001) return false; 31 if (fluxErr) *fluxErr = fabsf((magnitudeErr * *flux)/1.085736); 32 // if (fluxErr) printf("Mag = %03.03f, Flux = %03.03f, Mag err = %03.03f, Flux Err = %03.03f\n", magnitude, *flux, magnitudeErr, *fluxErr); 33 34 return true; 35 } 36 26 37 // Destructor 27 38 static void ippToPsps_Destructor(IppToPsps* this) { … … 55 66 // save XML document for results 56 67 if (this->resultsXmlDoc) { 57 68 58 69 xmlSaveFormatFileEnc(this->resultsPath, this->resultsXmlDoc, "UTF-8", 1); 59 70 … … 151 162 152 163 psMetadata *arguments = psMetadataAlloc(); 153 psMetadataAddStr(arguments, PS_LIST_TAIL, "- expid", 0, "ExposureID", NULL);164 psMetadataAddStr(arguments, PS_LIST_TAIL, "-id", 0, "ID", NULL); 154 165 psMetadataAddStr(arguments, PS_LIST_TAIL, "-expname", 0, "Exposure name", NULL); 155 166 psMetadataAddStr(arguments, PS_LIST_TAIL, "-survey", 0, "Survey type", NULL); … … 158 169 psMetadataAddStr(arguments, PS_LIST_TAIL, "-results", 0, "Path to results output", NULL); 159 170 psMetadataAddStr(arguments, PS_LIST_TAIL, "-config", 0, "Path to config dir", NULL); 160 psMetadataAddStr(arguments, PS_LIST_TAIL, "-batch", 0, "Product type: [ det|stack|diff]", NULL);171 psMetadataAddStr(arguments, PS_LIST_TAIL, "-batch", 0, "Product type: [IN|P2|ST|TODO]", NULL); 161 172 162 173 bool ret = true; … … 168 179 else { 169 180 170 char *tmp = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "- expid"));171 if (tmp) this-> expId = atoi(tmp);181 char *tmp = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-id")); 182 if (tmp) this->id = atoi(tmp); 172 183 //free(tmp); tmp = NULL; 173 184 this->expName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-expname")); … … 181 192 if (!tmp) this->batchType = BATCH_UNDEFINED; 182 193 else if (strcmp(tmp, "test") == 0) this->batchType = BATCH_TEST; 183 else if (strcmp(tmp, " init") == 0) this->batchType = BATCH_INIT;184 else if (strcmp(tmp, " det") == 0) this->batchType = BATCH_DETECTION;185 else if (strcmp(tmp, " stack") == 0) this->batchType = BATCH_STACK;186 else if (strcmp(tmp, " diff") == 0) this->batchType = BATCH_DIFFERENCE;194 else if (strcmp(tmp, "IN") == 0) this->batchType = BATCH_INIT; 195 else if (strcmp(tmp, "P2") == 0) this->batchType = BATCH_DETECTION; 196 else if (strcmp(tmp, "ST") == 0) this->batchType = BATCH_STACK; 197 else if (strcmp(tmp, "TODO") == 0) this->batchType = BATCH_DIFFERENCE; 187 198 else this->batchType = BATCH_UNDEFINED; 188 199 … … 192 203 (this->batchType != BATCH_INIT && !this->fitsInPath) || 193 204 (this->batchType != BATCH_INIT && !this->resultsPath) || 194 (this->batchType != BATCH_INIT && this-> expId == -1) ||205 (this->batchType != BATCH_INIT && this->id == -1) || 195 206 !this->fitsOutPath || 196 207 !this->configsDir || … … 211 222 static int ippToPsps_run(IppToPsps *this) { 212 223 224 // any files? 225 if (this->batchType == BATCH_DETECTION || 226 this->batchType == BATCH_STACK || 227 this->batchType == BATCH_DIFFERENCE ) { 228 229 if (this->numOfInputFiles < 1) { 230 231 this->exitCode = PS_EXIT_DATA_ERROR; 232 psError(PS_ERR_UNKNOWN, false, "No input files for this batch"); 233 } 234 235 } 236 213 237 if(this->exitCode == PS_EXIT_SUCCESS) { 214 238 … … 250 274 psMemSetDeallocator(this, (psFreeFunc)ippToPsps_Destructor); 251 275 252 this->expId = -1; 276 // deal with DVO database 277 bool haveDvo = false; 278 for (int i=0;i<*argc; i++) { 279 280 if (strcmp(argv[i], "CATDIR") == 0) {haveDvo = true; break;} 281 } 282 if (haveDvo) this->dvoConfig = dvoConfigRead(argc, argv); 283 else this->dvoConfig = NULL; 284 285 // remaining args 286 this->id = -1; 253 287 this->expName = NULL; 254 288 this->surveyType = NULL; 289 this->surveyID = -1; 255 290 this->fitsInPath = NULL; 256 291 this->resultsPath = NULL; … … 261 296 this->fitsOut = NULL; 262 297 this->configsDir = NULL; 263 this->dvoConfig = NULL;264 298 this->config = NULL; 265 this->dvoConfig = dvoConfigRead(argc, argv);266 299 this->pmconfig = pmConfigRead(argc, argv, NULL); 267 300 this->exitCode = PS_EXIT_SUCCESS; 268 301 this->run = ippToPsps_run; 302 303 // sort out current time 304 time_t now = time(NULL);; 305 struct tm *ts = gmtime(&now); // TODO should be UTC 306 strftime(this->todaysDate, sizeof(this->todaysDate), "%Y-%m-%d", ts); 269 307 270 308 if (!this->pmconfig) { … … 299 337 psStringAppend(&this->configsDir, "/stack"); 300 338 301 339 // create filename 302 340 char outputName[100]; 303 sprintf(outputName, "%08d.FITS", this-> expId);341 sprintf(outputName, "%08d.FITS", this->id); 304 342 psStringAppend(&this->fitsOutPath, "/%s", outputName); 305 343 … … 321 359 } 322 360 361 // get survey ID using config object 362 if (this->batchType != BATCH_INIT && 363 !ippToPspsConfig_getSurveyId(this->config, this->surveyType, &this->surveyID)) { 364 365 this->exitCode = PS_EXIT_CONFIG_ERROR; 366 return this; 367 } 368 323 369 // create XML document for results 324 370 if (this->resultsPath) {
Note:
See TracChangeset
for help on using the changeset viewer.
