Changeset 4977 for trunk/psphot/src/psModulesUtils.c
- Timestamp:
- Sep 7, 2005, 6:32:40 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psModulesUtils.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psModulesUtils.c
r4954 r4977 1 # include "psphot.h" 1 # include "psModulesUtils.h" 2 3 // extract config informatin from config data or from image header, if specified 4 psF32 pmConfigLookupF32 (bool *status, psMetadata *config, psMetadata *header, char *name) { 5 6 char *source; 7 char *keyword; 8 psF32 value; 9 psMetadataItem *item; 10 11 // look for the entry in the config collection 12 item = psMetadataLookup (config, name); 13 if (item == NULL) { 14 psLogMsg ("pmConfigLookupF32", 2, "no key %s in config data, trying as header keyword", name); 15 value = psMetadataLookupF32 (status, header, name); 16 if (*status == false) { 17 psAbort ("pmConfigLookupF32", "no key %s in header", name); 18 } 19 *status = true; 20 return (value); 21 } 22 23 // I'm either expecting a string, with the name "HD:keyword"... 24 if (item->type == PS_META_STR) { 25 source = item->data.V; 26 if (!strncasecmp (source, "HD:", 3)) { 27 keyword = &source[3]; 28 value = psMetadataLookupF32 (status, header, keyword); 29 if (*status == false) { 30 psAbort ("pmConfigLookupF32", "no key %s in config", name); 31 } 32 *status = true; 33 // psFree (item); 34 return (value); 35 } 36 } 37 38 // ... or a value (F32?) 39 if (item->type == PS_META_F32) { 40 value = item->data.F32; 41 // psFree (item); 42 return (value); 43 } 44 45 *status = false; 46 psError(PS_ERR_UNKNOWN, true, "invalid item"); 47 return (0); 48 } 2 49 3 50 // XXX EAM : these are my alternate implementations of psModule functions … … 321 368 return (status); 322 369 } 370 371 bool pmSourcePhotometry (float *fitMag, float *obsMag, pmModel *model, psImage *image, psImage *mask) { 372 373 float obsSum = 0; 374 float fitSum = 0; 375 float sky = model->params->data.F32[0]; 376 377 pmModelFlux modelFluxFunc = pmModelFlux_GetFunction (model->type); 378 fitSum = modelFluxFunc (model->params); 379 380 for (int ix = 0; ix < image->numCols; ix++) { 381 for (int iy = 0; iy < image->numRows; iy++) { 382 if (mask->data.U8[iy][ix]) continue; 383 obsSum += image->data.F32[iy][ix] - sky; 384 } 385 } 386 if (obsSum <= 0) return false; 387 if (fitSum <= 0) return false; 388 389 *fitMag = -2.5*log10(fitSum); 390 *obsMag = -2.5*log10(obsSum); 391 return (true); 392 } 393
Note:
See TracChangeset
for help on using the changeset viewer.
