source: trunk/src/RowAccumulator.h@ 2188

Last change on this file since 2188 was 2141, checked in by WataruKawasaki, 14 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s):

Description: bugfix in RowAccumulator::add()


File size: 4.1 KB
RevLine 
[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
21namespace 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]29class RowAccumulator {
30
31public:
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 */
[814]48 void add(const casa::Vector<casa::Float>& v,
49 const casa::Vector<casa::Bool>& m,
50 const casa::Vector<casa::Float>& tsys,
[2125]51 const casa::Double interval,
52 const casa::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 */
[814]58 void setUserMask(const casa::Vector<casa::Bool>& m);
[1114]59 /**
60 * Get the spectrum. Applies the normalisation (averaging)
61 * @return the spectrum vector
62 */
[814]63 casa::Vector<casa::Float> getSpectrum() const;
[1114]64 /**
65 * Get the Tsys. Applies the normalisation (averaging)
66 * @return the Tsys vector
67 */
[814]68 casa::Vector<casa::Float> getTsys() const;
[1114]69 /**
70 * Get the spectrum's mask. Applies the normalisation (averaging)
71 * @return the mask vector
72 */
[814]73 casa::Vector<casa::Bool> getMask() const;
[1114]74 /**
75 * Get the total interval.
76 * @return the integration time
77 */
[814]78 casa::Double getInterval() const;
[1114]79 /**
80 * Get the time of the observation. Retrieves the "mean" time.
81 * @return the integration time
82 */
[814]83 casa::Double getTime() const;
[1114]84 /**
85 * Reset the acummulator to the state at construction.
86 */
[2125]87 void reset(const casa::uInt size=0, const casa::uInt tsysSize=0);
88 void initialize(const casa::uInt size, const casa::uInt tsysSize);
[1819]89 /**
90 * check the initialization state
91 */
92 casa::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
99private:
[2125]100 void addSpectrum(const casa::Vector<casa::Float>& v,
101 const casa::Vector<casa::Bool>& m,
102 const casa::Vector<casa::Float>& tsys,
103 const casa::Double interval,
104 const casa::Double time);
105 void doAddSpectrum(const casa::Vector<casa::Float>& v,
106 const casa::Vector<casa::Bool>& m,
107 const casa::Vector<casa::Float>& tsys,
108 const casa::Double interval,
109 const casa::Double time,
[2141]110 const casa::Bool inverseMask);
[2125]111 casa::Float getTotalWeight(const casa::MaskedArray<casa::Float>& data,
112 const casa::Vector<casa::Float>& tsys,
113 const casa::Double interval,
114 const casa::Double time,
[2141]115 const casa::Bool inverseMask);
116 casa::Float addTsys(const casa::Vector<casa::Float>& v, casa::Bool inverseMask);
117 casa::Float addInterval(casa::Double inter, casa::Bool inverseMask);
118 void addTime(casa::Double t, casa::Bool inverseMask);
[814]119
120 WeightType weightType_;
121 casa::Bool initialized_;
[1104]122 //these are Vectors
[814]123 casa::MaskedArray<casa::Float> spectrum_;
[1398]124 casa::MaskedArray<casa::Float> weightSum_;
125 casa::MaskedArray<casa::uInt> n_;
[814]126
[2125]127 //these three are used for normalise() (CAS-2776; 2011/04/07 by WK)
128 casa::MaskedArray<casa::Float> spectrumNoMask_;
129 casa::MaskedArray<casa::Float> weightSumNoMask_;
130 casa::MaskedArray<casa::uInt> nNoMask_;
131
[814]132 casa::Vector<casa::Bool> userMask_;
133
[2125]134 casa::Vector<casa::Float> tsysSum_, tsysSumNoMask_;
135 casa::Double timeSum_, timeSumNoMask_;
136 casa::Double intervalSum_, intervalSumNoMask_;
[814]137};
138
139}
[1114]140#endif
Note: See TracBrowser for help on using the repository browser.