[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 | // |
---|
[1114] | 12 | #ifndef ASAPROWACCUMULATOR_H |
---|
| 13 | #define ASAPROWACCUMULATOR_H |
---|
[814] | 14 | |
---|
[2125] | 15 | #include <math.h> |
---|
[814] | 16 | #include <casa/aips.h> |
---|
| 17 | #include <casa/Arrays/Vector.h> |
---|
| 18 | #include <casa/Arrays/MaskedArray.h> |
---|
[831] | 19 | #include "STDefs.h" |
---|
[814] | 20 | |
---|
| 21 | namespace asap { |
---|
[1104] | 22 | /** |
---|
| 23 | * This class accumulates spectra and weights and returns the averaged data |
---|
| 24 | * @brief Class for averaging of spectra |
---|
| 25 | * @author Malte Marquarding |
---|
| 26 | * @date $Date:$ |
---|
| 27 | * @version |
---|
| 28 | */ |
---|
[814] | 29 | class RowAccumulator { |
---|
| 30 | |
---|
| 31 | public: |
---|
| 32 | |
---|
[1104] | 33 | /** |
---|
| 34 | * Constructor taking a weight type as defined in @ref STDefs |
---|
| 35 | */ |
---|
[1569] | 36 | explicit RowAccumulator(WeightType wt = asap::W_NONE); |
---|
[814] | 37 | |
---|
| 38 | ~RowAccumulator(); |
---|
| 39 | |
---|
[1114] | 40 | /** |
---|
| 41 | * add a new "row" to the accumulator |
---|
| 42 | * @param v the spectrum |
---|
| 43 | * @param m the mask for the spectrum |
---|
| 44 | * @param tsys the Tsys corresponing to the spectrum |
---|
| 45 | * @param interval the intergration time |
---|
[1295] | 46 | * @param time the time of the observation |
---|
[1114] | 47 | */ |
---|
[3106] | 48 | void add(const casacore::Vector<casacore::Float>& v, |
---|
| 49 | const casacore::Vector<casacore::Bool>& m, |
---|
| 50 | const casacore::Vector<casacore::Float>& tsys, |
---|
| 51 | const casacore::Double interval, |
---|
| 52 | const casacore::Double time); |
---|
[1114] | 53 | /** |
---|
| 54 | * Also set a user mask which get combined with the individual masks |
---|
| 55 | * from the spectra |
---|
| 56 | * @param m a boolean mask of teh same length as the spectrum |
---|
| 57 | */ |
---|
[3106] | 58 | void setUserMask(const casacore::Vector<casacore::Bool>& m); |
---|
[1114] | 59 | /** |
---|
| 60 | * Get the spectrum. Applies the normalisation (averaging) |
---|
| 61 | * @return the spectrum vector |
---|
| 62 | */ |
---|
[3106] | 63 | casacore::Vector<casacore::Float> getSpectrum() const; |
---|
[1114] | 64 | /** |
---|
| 65 | * Get the Tsys. Applies the normalisation (averaging) |
---|
| 66 | * @return the Tsys vector |
---|
| 67 | */ |
---|
[3106] | 68 | casacore::Vector<casacore::Float> getTsys() const; |
---|
[1114] | 69 | /** |
---|
| 70 | * Get the spectrum's mask. Applies the normalisation (averaging) |
---|
| 71 | * @return the mask vector |
---|
| 72 | */ |
---|
[3106] | 73 | casacore::Vector<casacore::Bool> getMask() const; |
---|
[1114] | 74 | /** |
---|
| 75 | * Get the total interval. |
---|
| 76 | * @return the integration time |
---|
| 77 | */ |
---|
[3106] | 78 | casacore::Double getInterval() const; |
---|
[1114] | 79 | /** |
---|
| 80 | * Get the time of the observation. Retrieves the "mean" time. |
---|
| 81 | * @return the integration time |
---|
| 82 | */ |
---|
[3106] | 83 | casacore::Double getTime() const; |
---|
[1114] | 84 | /** |
---|
| 85 | * Reset the acummulator to the state at construction. |
---|
| 86 | */ |
---|
[3106] | 87 | void reset(const casacore::uInt size=0, const casacore::uInt tsysSize=0); |
---|
| 88 | void initialize(const casacore::uInt size, const casacore::uInt tsysSize); |
---|
[1819] | 89 | /** |
---|
| 90 | * check the initialization state |
---|
| 91 | */ |
---|
[3106] | 92 | casacore::Bool state() const; |
---|
[2125] | 93 | /** |
---|
| 94 | * replace NaN values with (normal) values at the same channels in the given spetrum. |
---|
| 95 | * (CAS-2776; 2011/04/07 by Wataru Kawasaki) |
---|
| 96 | */ |
---|
| 97 | void replaceNaN(); |
---|
[814] | 98 | |
---|
| 99 | private: |
---|
[3106] | 100 | void addSpectrum(const casacore::Vector<casacore::Float>& v, |
---|
| 101 | const casacore::Vector<casacore::Bool>& m, |
---|
| 102 | const casacore::Vector<casacore::Float>& tsys, |
---|
| 103 | const casacore::Double interval, |
---|
| 104 | const casacore::Double time); |
---|
| 105 | void doAddSpectrum(const casacore::Vector<casacore::Float>& v, |
---|
| 106 | const casacore::Vector<casacore::Bool>& m, |
---|
| 107 | const casacore::Vector<casacore::Float>& tsys, |
---|
| 108 | const casacore::Double interval, |
---|
| 109 | const casacore::Double time, |
---|
| 110 | const casacore::Bool inverseMask); |
---|
| 111 | void doAddSpectrum2(const casacore::Vector<casacore::Float>& v, |
---|
| 112 | const casacore::Vector<casacore::Bool>& m, |
---|
| 113 | const casacore::Vector<casacore::Float>& tsys, |
---|
| 114 | const casacore::Double interval, |
---|
| 115 | const casacore::Double time); |
---|
| 116 | casacore::Float getTotalWeight(const casacore::MaskedArray<casacore::Float>& data, |
---|
| 117 | const casacore::Vector<casacore::Float>& tsys, |
---|
| 118 | const casacore::Double interval, |
---|
| 119 | const casacore::Double time, |
---|
| 120 | const casacore::Bool inverseMask); |
---|
| 121 | casacore::Float addTsys(const casacore::Vector<casacore::Float>& v, casacore::Bool inverseMask); |
---|
| 122 | casacore::Float addInterval(casacore::Double inter, casacore::Bool inverseMask); |
---|
| 123 | void addTime(casacore::Double t, casacore::Bool inverseMask); |
---|
[814] | 124 | |
---|
| 125 | WeightType weightType_; |
---|
[3106] | 126 | casacore::Bool initialized_; |
---|
[1104] | 127 | //these are Vectors |
---|
[3106] | 128 | casacore::MaskedArray<casacore::Float> spectrum_; |
---|
| 129 | casacore::MaskedArray<casacore::Float> weightSum_; |
---|
| 130 | casacore::MaskedArray<casacore::uInt> n_; |
---|
[814] | 131 | |
---|
[2125] | 132 | //these three are used for normalise() (CAS-2776; 2011/04/07 by WK) |
---|
[3106] | 133 | casacore::MaskedArray<casacore::Float> spectrumNoMask_; |
---|
| 134 | casacore::MaskedArray<casacore::Float> weightSumNoMask_; |
---|
| 135 | casacore::MaskedArray<casacore::uInt> nNoMask_; |
---|
[2125] | 136 | |
---|
[3106] | 137 | casacore::Vector<casacore::Bool> userMask_; |
---|
[814] | 138 | |
---|
[3106] | 139 | casacore::Vector<casacore::Float> tsysSum_, tsysSumNoMask_; |
---|
| 140 | casacore::Double timeSum_, timeSumNoMask_; |
---|
| 141 | casacore::Double intervalSum_, intervalSumNoMask_; |
---|
[814] | 142 | }; |
---|
| 143 | |
---|
| 144 | } |
---|
[1114] | 145 | #endif |
---|