Changeset 14465 for trunk/psModules/src/concepts/pmConceptsAverage.c
- Timestamp:
- Aug 10, 2007, 3:03:30 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/concepts/pmConceptsAverage.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConceptsAverage.c
r12696 r14465 5 5 #include <stdio.h> 6 6 #include <pslib.h> 7 #include <string.h> 7 8 8 9 #include "pmHDU.h" … … 17 18 psMetadataItem *item = psMetadataLookup(MD, NAME); \ 18 19 item->data.TYPE = VALUE; \ 20 } 21 22 bool pmConceptsAverageFPAs(pmFPA *target, psList *sources) 23 { 24 PS_ASSERT_PTR_NON_NULL(target, false); 25 PS_ASSERT_PTR_NON_NULL(sources, false); 26 PS_ASSERT_INT_POSITIVE(sources->n, false); 27 bool success = true; // Result of setting everything 28 29 float exposure = 0.0; // Exposure time 30 double time = 0.0; // Time of observation 31 psTimeType timeSys = 0; // Time system 32 char *filter = NULL; // Filter 33 34 int num = 0; // Number of FPAs 35 psListIterator *sourcesIter = psListIteratorAlloc(sources, PS_LIST_HEAD, false); // Iterator for sources 36 pmFPA *fpa = NULL; // Source FPA from iteration 37 while ((fpa = psListGetAndIncrement(sourcesIter))) { 38 if (!fpa) { 39 continue; 40 } 41 42 num++; 43 exposure += psMetadataLookupF32(NULL, fpa->concepts, "FPA.EXPOSURE"); 44 45 psTime *fpaTime = psMetadataLookupPtr(NULL, fpa->concepts, "FPA.TIME"); 46 time += psTimeToMJD(fpaTime); 47 if (num == 1) { 48 timeSys = psMetadataLookupS32(NULL, fpa->concepts, "FPA.TIMESYS"); 49 filter = psMetadataLookupStr(NULL, fpa->concepts, "FPA.FILTER"); 50 } else { 51 if (timeSys != psMetadataLookupS32(NULL, fpa->concepts, "FPA.TIMESYS")) { 52 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Differing FPA.TIMESYS in use: %d vs %d\n", 53 timeSys, psMetadataLookupS32(NULL, fpa->concepts, "FPA.TIMESYS")); 54 success = false; 55 } 56 if (strcmp(filter, psMetadataLookupStr(NULL, fpa->concepts, "FPA.FILTER")) != 0) { 57 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Differing FPA.FILTER in use: %s vs %s\n", 58 filter, psMetadataLookupStr(NULL, fpa->concepts, "FPA.FILTER")); 59 success = false; 60 } 61 } 62 } 63 psFree(sourcesIter); 64 65 exposure /= (float)num; 66 time /= (double)num; 67 68 MD_UPDATE(target->concepts, "FPA.EXPOSURE", F32, exposure); 69 MD_UPDATE(target->concepts, "FPA.TIMESYS", S32, timeSys); 70 MD_UPDATE(target->concepts, "FPA.FILTER", str, filter); 71 72 // FPA.TIME needs special care 73 { 74 psMetadataItem *timeItem = psMetadataLookup(target->concepts, "FPA.TIME"); 75 psFree(timeItem->data.V); 76 timeItem->data.V = psTimeFromMJD(time); 77 } 78 79 return success; 19 80 } 20 81
Note:
See TracChangeset
for help on using the changeset viewer.
