[814] | 1 | // |
---|
| 2 | // C++ Interface: RowAccumulator |
---|
| 3 | // |
---|
| 4 | // Description: |
---|
| 5 | // |
---|
| 6 | // |
---|
| 7 | // Author: Malte Marquarding <Malte.Marquarding@csiro.au>, (C) 2005 |
---|
| 8 | // |
---|
| 9 | // Copyright: See COPYING file that comes with this distribution |
---|
| 10 | // |
---|
| 11 | // |
---|
| 12 | |
---|
| 13 | #include <casa/aips.h> |
---|
| 14 | #include <casa/Arrays/Vector.h> |
---|
| 15 | #include <casa/Arrays/MaskedArray.h> |
---|
[831] | 16 | #include "STDefs.h" |
---|
[814] | 17 | |
---|
| 18 | namespace asap { |
---|
[1104] | 19 | /** |
---|
| 20 | * This class accumulates spectra and weights and returns the averaged data |
---|
| 21 | * @brief Class for averaging of spectra |
---|
| 22 | * @author Malte Marquarding |
---|
| 23 | * @date $Date:$ |
---|
| 24 | * @version |
---|
| 25 | */ |
---|
[814] | 26 | class RowAccumulator { |
---|
| 27 | |
---|
| 28 | public: |
---|
| 29 | |
---|
[1104] | 30 | /** |
---|
| 31 | * Constructor taking a weight type as defined in @ref STDefs |
---|
| 32 | */ |
---|
[814] | 33 | RowAccumulator(WeightType wt = asap::NONE); |
---|
| 34 | |
---|
| 35 | ~RowAccumulator(); |
---|
| 36 | |
---|
[1104] | 37 | /** |
---|
| 38 | * add a new "row" to the accumulator |
---|
| 39 | * @param v the spectrum |
---|
| 40 | * @param m the mask for the spectrum |
---|
| 41 | * @param tsys the Tsys corresponing to the spectrum |
---|
| 42 | * @param interval the intergration time |
---|
| 43 | * @param the time of the observation |
---|
| 44 | */ |
---|
[814] | 45 | void add(const casa::Vector<casa::Float>& v, |
---|
| 46 | const casa::Vector<casa::Bool>& m, |
---|
| 47 | const casa::Vector<casa::Float>& tsys, |
---|
| 48 | casa::Double interval, |
---|
| 49 | casa::Double time); |
---|
[1104] | 50 | /** |
---|
| 51 | * Also set a user mask which get combined with the individual masks |
---|
| 52 | * from the spectra |
---|
| 53 | * @param m a boolean mask of teh same length as the spectrum |
---|
| 54 | */ |
---|
[814] | 55 | void setUserMask(const casa::Vector<casa::Bool>& m); |
---|
[1104] | 56 | /** |
---|
| 57 | * Get the spectrum. Applies the normalisation (averaging) |
---|
| 58 | * @return the spectrum vector |
---|
| 59 | */ |
---|
[814] | 60 | casa::Vector<casa::Float> getSpectrum() const; |
---|
[1104] | 61 | /** |
---|
| 62 | * Get the Tsys. Applies the normalisation (averaging) |
---|
| 63 | * @return the Tsys vector |
---|
| 64 | */ |
---|
[814] | 65 | casa::Vector<casa::Float> getTsys() const; |
---|
[1104] | 66 | /** |
---|
| 67 | * Get the spectrum's mask. Applies the normalisation (averaging) |
---|
| 68 | * @return the mask vector |
---|
| 69 | */ |
---|
[814] | 70 | casa::Vector<casa::Bool> getMask() const; |
---|
[1104] | 71 | /** |
---|
| 72 | * Get the total interval. |
---|
| 73 | * @return the integration time |
---|
| 74 | */ |
---|
[814] | 75 | casa::Double getInterval() const; |
---|
[1104] | 76 | /** |
---|
| 77 | * Get the time of the observation. Retrieves the "mean" time. |
---|
| 78 | * @return the integration time |
---|
| 79 | */ |
---|
[814] | 80 | casa::Double getTime() const; |
---|
[1104] | 81 | /** |
---|
| 82 | * Reset the acummulator to the state at construction. |
---|
| 83 | */ |
---|
[814] | 84 | void reset(); |
---|
| 85 | |
---|
| 86 | private: |
---|
| 87 | void addSpectrum( const casa::Vector<casa::Float>& v, |
---|
| 88 | const casa::Vector<casa::Bool>& m, |
---|
| 89 | casa::Float weight); |
---|
| 90 | |
---|
| 91 | casa::Float addTsys(const casa::Vector<casa::Float>& v); |
---|
| 92 | casa::Float addInterval(casa::Double inter); |
---|
| 93 | void addTime(casa::Double t); |
---|
| 94 | |
---|
| 95 | WeightType weightType_; |
---|
| 96 | casa::Bool initialized_; |
---|
[1104] | 97 | //these are Vectors |
---|
[814] | 98 | casa::MaskedArray<casa::Float> spectrum_; |
---|
| 99 | casa::MaskedArray<casa::Float> n_, weightSum_; |
---|
| 100 | |
---|
| 101 | casa::Vector<casa::Bool> userMask_; |
---|
| 102 | |
---|
| 103 | casa::Vector<casa::Float> tsysSum_; |
---|
| 104 | casa::Double timeSum_; |
---|
| 105 | casa::Double intervalSum_; |
---|
| 106 | }; |
---|
| 107 | |
---|
| 108 | } |
---|