casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StatWT.h
Go to the documentation of this file.
1 //# StatWT.h: Sets WEIGHT and SIGMA for a VisBuffGroup according to the scatter
2 //# of its visibilities.
3 //# Copyright (C) 2011
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This library is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU Library General Public License as published by
8 //# the Free Software Foundation; either version 2 of the License, or (at your
9 //# option) any later version.
10 //#
11 //# This library is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 //# License for more details.
15 //#
16 //# You should have received a copy of the GNU Library General Public License
17 //# along with this library; if not, write to the Free Software Foundation,
18 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 //#
27 
28 #ifndef MSVIS_STATWT_H
29 #define MSVIS_STATWT_H
30 
31 #include <casa/aips.h>
36 #include <map>
37 #include <set>
38 
39 namespace casa { //# NAMESPACE CASA - BEGIN
40 
41 //# forward decl
42 class VisBuffGroup;
43 
44 //<summary>StatWT sets WEIGHT and SIGMA statistically</summary>
45 //
46 // <use visibility=export>
47 //
48 // <reviewed reviewer="" date="" tests="" demos="">
49 
50 // <prerequisite>
51 // <li> <linkto class="VisBuffGroup">VisBuffGroup</linkto>
52 // <li> <linkto class="VisibilityIterator">VisibilityIterator</linkto>
53 // <li> <linkto class="GroupProcessor">GroupProcessor</linkto>
54 // <li> <linkto class="GroupWorker">GroupWorker</linkto>
55 // </prerequisite>
56 //
57 // <etymology>
58 // StatWT sets WEIGHT and SIGMA statistically.
59 // </etymology>
60 //
61 //<synopsis>
62 // Set the weights and sigmas according to the scatter of the
63 // visibilities.
64 //</synopsis>
65 //
66 //<todo>
67 // <li>
68 //</todo>
69 class StatWT : public GroupWorker
70 {
71 public:
72  // Construct an object that will set the weights and sigmas of vi's
73  // casacore::MeasurementSet, as selected by outspw, according to the scatter of the
74  // visibilities selected by fitspw. If dorms is true, assume that the true
75  // mean is 0. Otherwise, use the standard sample variance.
76  //
77  // For each baseline and correlation, if fitspw does not select at least
78  // minsamp unflagged visibilities, it will be flagged and weight and sigma
79  // will not be calculated. minsamp is effectively at least 2.
80  //
81  StatWT(const ROVisibilityIterator& vi,
83  const casacore::String& fitspw="*",
84  const casacore::String& outspw="*",
85  const casacore::Bool dorms=false,
86  const casacore::uInt minsamp=2,
87  const std::vector<casacore::uInt> selcorrs=std::vector<casacore::uInt>());
88 
90  //StatWT(const StatWT& other) {}
91 
92  // Destructor
93  virtual ~StatWT();
94 
96  //virtual StatWT& operator=(const StatWT& gw) {}
97 
98  // // Returns which columns need to be prefetched for process to work.
99  // virtual asyncio::PrefetchColumns *prefetchColumns() const;
100 
101  // This is where all the work gets done!
102  virtual casacore::Bool process(VisBuffGroup& vbg);
103 
104 private:
105  // Disable null c'tor.
106  StatWT();
107 
111  const VisBuffer& vb,
112  const casacore::Cube<casacore::Bool>& chanmaskedflags, const casacore::uInt maxAnt);
113 
114  // ns and variances are effectively const here, but declaring them that way
115  // would take some gymnastics.
119  const casacore::uInt maxAnt);
120 
121  // Compute a baseline (row) index (ant1, ant2).
122  // It ASSUMES that ant1 and ant2 are both <= maxAnt.
124  {
125  return (maxAnt + 1) * ant1 - (ant1 * (ant1 - 1)) / 2 + ant2 - ant1;
126  }
127 
128  // Initialized by c'tor:
129 
130  // Which of DATA, MODEL_DATA, or CORRECTED_DATA to fit.
131  // It will always _write_ to DATA if datacols_p.nelements() == 1, and write
132  // to all 3 otherwise. Thus datacols_p.nelements() should be either 1 or 3.
133  // 4 and 2 are right out, and FLOAT_DATA isn't handled by this yet.
135 
136  casacore::String fitspw_p; // Line-free channels used for the fit. Can include ;
137  casacore::String outspw_p; // Channels to write out. Does not yet support ;.
138  casacore::Bool dorms_p; // If true, assume that the true mean is 0.
139  casacore::uInt rowsdone_p; // How many rows have been written so far.
140  std::set<casacore::Int> outspws_p; // Spws to reweight.
141  // Otherwise, use the standard sample variance.
142  casacore::uInt minsamp_p; // Minimum # of unflagged visibilities for calculating
143  // a variance.
144  std::vector<casacore::uInt> selcorrs_p;
145  // Not initialized by c'tor:
146  //std::set<casacore::Int> appliedSpWs_p;
147  std::map<casacore::Int, casacore::Vector<casacore::Bool>*> fitmask_p; // spw -> a list of flags by chan
148 };
149 
150 } //# NAMESPACE CASA - END
151 
152 #endif
153 
std::vector< casacore::uInt > selcorrs_p
a variance.
Definition: StatWT.h:144
This is where all the work gets done *virtual casacore::Bool process(VisBuffGroup &vbg)
This is where all the work gets done!
casacore::Bool apply_variances(VisBuffer &vb, std::map< casacore::uInt, casacore::Vector< casacore::uInt > > &ns, std::map< casacore::uInt, casacore::Vector< casacore::Double > > &variances, const casacore::uInt maxAnt)
ns and variances are effectively const here, but declaring them that way would take some gymnastics...
int Int
Definition: aipstype.h:50
TableExprNode means(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1699
casacore::uInt minsamp_p
Otherwise, use the standard sample variance.
Definition: StatWT.h:142
StatWT sets WEIGHT and SIGMA statistically.
Definition: StatWT.h:69
TableExprNode variances(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1705
std::set< casacore::Int > outspws_p
Definition: StatWT.h:140
PredefinedColumns
The Main table colums with predefined meaning.
Definition: MSMainEnums.h:65
StatWT()
Disable null c&#39;tor.
A class to store a group of VisBuffers.
Definition: VisBuffGroup.h:83
casacore::uInt rowsdone_p
Definition: StatWT.h:139
casacore::uInt hashFunction(const casacore::Int ant1, const casacore::Int ant2, const casacore::Int maxAnt)
Compute a baseline (row) index (ant1, ant2).
Definition: StatWT.h:123
A base class for GroupWorkers that can modify their input MS.
Definition: GroupWorker.h:150
std::map< casacore::Int, casacore::Vector< casacore::Bool > * > fitmask_p
Not initialized by c&#39;tor: std::set&lt;casacore::Int&gt; appliedSpWs_p;
Definition: StatWT.h:147
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool dorms_p
Definition: StatWT.h:138
String: the storage and methods of handling collections of characters.
Definition: String.h:223
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
casacore::String fitspw_p
Definition: StatWT.h:136
Destructor *virtual ~StatWT()
ROVisibilityIterator iterates through one or more readonly MeasurementSets.
casacore::Bool update_variances(std::map< casacore::uInt, casacore::Vector< casacore::uInt > > &ns, std::map< casacore::uInt, casacore::Vector< casacore::Complex > > &means, std::map< casacore::uInt, casacore::Vector< casacore::Double > > &variances, const VisBuffer &vb, const casacore::Cube< casacore::Bool > &chanmaskedflags, const casacore::uInt maxAnt)
Complex visibility matrix.
Definition: MSMainEnums.h:183
casacore::String outspw_p
Definition: StatWT.h:137
unsigned int uInt
Definition: aipstype.h:51
casacore::MS::PredefinedColumns datacol_p
Initialized by c&#39;tor:
Definition: StatWT.h:134