Changeset 14465
- Timestamp:
- Aug 10, 2007, 3:03:30 PM (19 years ago)
- Location:
- trunk/psModules/src/concepts
- Files:
-
- 2 edited
-
pmConceptsAverage.c (modified) (2 diffs)
-
pmConceptsAverage.h (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 -
trunk/psModules/src/concepts/pmConceptsAverage.h
r12696 r14465 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 7$ $Name: not supported by cvs2svn $7 * @date $Date: 2007-0 3-30 21:12:56$6 * @version $Revision: 1.8 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-08-11 01:03:30 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 14 14 /// @addtogroup Concepts Data Abstraction Concepts 15 15 /// @{ 16 17 /// Set a variety of concepts in an FPA by averaging over several 18 /// 19 /// This function averages the values of the following concepts: 20 /// FPA.TIME 21 /// FPA.EXPOSURE 22 /// And ensure the following concepts are consistent: 23 /// FPA.FILTER 24 /// FPA.TIMESYS 25 bool pmConceptsAverageFPAs(pmFPA *target,///< Target FPA 26 psList *sources ///< List of source FPAs 27 ); 16 28 17 29 /// Set a variety of concepts in a cell by averaging over several
Note:
See TracChangeset
for help on using the changeset viewer.
