casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Reweighter.h
Go to the documentation of this file.
1 //# Reweighter.h: this defines Reweighter which reweights a selected part of an
2 //# casacore::MS based on the properties of a (possibly different) selection of it.
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 //# $Id$
32 //#include <msvis/MSVis/VisIterator.h>
33 #include <msvis/MSVis/SubMS.h>
35 #include <casa/aips.h>
36 #include <casa/Arrays/Array.h>
37 #include <casa/Arrays/Vector.h>
38 //#include <casa/Utilities/CountedPtr.h>
39 #include <map>
40 #include <set>
41 #include <vector>
42 
43 
44 #ifndef MSVIS_REWEIGHTER_H
45 namespace casacore{
46 
47 class MSSelection; // #include <ms/MSSel/MSSelection.h>
48 template<class T> class ArrayColumn;
49 }
50 
51 namespace casa { //# NAMESPACE CASA - BEGIN
52 
53 #define MSVIS_REWEIGHTER_H
54 
55 // <summary>
56 // Reweighter reweights a selected part of an casacore::MS based on the properties of a
57 // (possibly different) selection of it.
58 // </summary>
59 
60 // <visibility=export>
61 
62 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
63 // </reviewed>
64 
65 // <prerequisite>
66 // <li> MeasurementSet
67 // </prerequisite>
68 //
69 // <etymology>
70 // Reweighter ...it reweights.
71 // </etymology>
72 //
73 // <synopsis>
74 // The order of operations (as in ms::split()) is:
75 // ctor
76 // setmsselect
77 // selectTime
78 // makeReweighter
79 // </synopsis>
80 
81 // These forward declarations are so the corresponding .h files don't have to
82 // be included in this .h file, but it's only worth it if a lot of other files
83 // include this file.
84 
85 
87 {
88 public:
89  Reweighter(const casacore::String& theMS,
90  const casacore::Bool dorms=false, // Reweight by rms or stddev?
91  const casacore::uInt minsamp=1); // Minimum # of visibilities for measuring a scatter.
92 
93  virtual ~Reweighter();
94 
95  // Select spw and channels for each spw in spwstr.
96  // Returns true on success and false on failure.
97  casacore::Bool selectSpw(std::set<casacore::Int>& spwset, casacore::Vector<casacore::Int>& chanStartv,
99  const casacore::String& spwstr);
100 
101  // Setup polarization selection (for now, only from available correlations -
102  // no casacore::Stokes transformations.)
104 
105  //select stuff using msselection syntax ...time is left out
106  // call it separately with timebin
107  // Returns a success value.
108  casacore::Bool setmsselect(const casacore::String& fitspw="", const casacore::String& outspw="",
109  const casacore::String& field="", const casacore::String& baseline="",
110  const casacore::String& scan="",
111  const casacore::String& subarray="", const casacore::String& correlation="",
112  const casacore::String& intent="", const casacore::String& obs="");
113 
114  // Select source or field
116 
118  const casacore::Vector<casacore::String>& antennaSel)
119  {
121  antennaids, antennaSel);
122  }
123 
124  // Select array IDs to use.
125  void selectArray(const casacore::String& subarray) {arrayExpr_p = subarray;}
126 
127  //select time parameters
128  void selectTime(casacore::Double timeBin=-1.0, casacore::String timerng="");
129 
130  //void selectSource(casacore::Vector<casacore::String> sourceid);
131 
132  // Set the selection string for line-free channels.
133  void setFitSpw(const casacore::String& fitspw) {fitspw_p = fitspw;}
134  // Set the selection string for output spws (not channels!).
135  void setOutSpw(const casacore::String& outspw) {outspw_p = outspw;}
136 
137  // Do the reweighting!
138  casacore::Bool reweight(casacore::String& colname, const casacore::String& combine);
139 
140  //void verifyColumns(const casacore::MeasurementSet& ms, const casacore::Vector<casacore::MS::PredefinedColumns>& colNames);
141 
142  // Fills polIDs with a map from DDID to polID, and corrTypes with a map from
143  // polID to corrTypes.
144  // The return value is meaningless for now.
147  const casacore::MSColumns& msc);
148 
149  protected:
150 
151  //method that returns the selected ms (?! - but it's Boolean - RR)
153 
154  // *** Private member functions ***
155 
156  // Picks a reference to DATA, MODEL_DATA, CORRECTED_DATA, or LAG_DATA out
157  // of ms_p. FLOAT_DATA is not included because it is not natively complex.
159  const casacore::MS::PredefinedColumns datacol);
160 
161  // Sets sort to a casacore::Block of columns that a VisibilityIterator should sort by,
162  // according to combine_p. Columns that should never be combined in the
163  // calling function, i.e. spw for time averaging, should be listed in
164  // uncombinable.
165  //
166  // verbose: log a message on error.
167  //
168  // Returns whether or not there were any conflicts between combine_p and
169  // uncombinable.
171  const casacore::Bool verbose=true) const;
172 
173  // Returns whether col is (not in combine_p) || in uncombinable.
174  // Columns that should never be combined in the
175  // calling function, i.e. spw for time averaging, should be listed in
176  // uncombinable.
177  //
178  // verbose: log a message on error.
179  //
180  // conflict is set to true if there is a conflict between combine_p and
181  // uncombinable.
183  const casacore::String& uncombinable="",
184  const casacore::Bool verbose=true) const;
185 
186  void makeUnionSpw();
187 
188  // Defaults to DATA.
190 
191  // *** Member variables ***
192 
193  // Initialized* by ctors. (Maintain order both here and in ctors.)
194  // * not necessarily to anything useful.
196  casacore::Bool dorms_p; // Reweight by rms or stddev?
197  casacore::uInt minsamp_p; // Minimum # of visibilities for measuring a scatter.
199  casacore::Bool antennaSel_p; // Selecting by antenna?
201  casacore::String scanString_p, // Selects scans by #number#. Historically named.
202  intentString_p, // Selects scans by string. scanString_p was taken.
203  obsString_p; // casacore::String for observationID selection.
205  casacore::String combine_p; // Should time averaging not split bins by
206  // scan #, observation, and/or state ID?
207  // Must be lowercase at all times.
208  casacore::String fitspw_p; // Selection string for line-free channels.
209  casacore::String outspw_p; // Selection string for ddids to reweight.
210  casacore::Vector<casacore::Int> unionspw_p; // All the spws in fitspw_p or outspw_p.
211 
212  // Uninitialized by ctors.
215 
217 
218  // casacore::Map from DDID to polID, filled in getCorrTypes().
220 
221  // casacore::Map from polID to corrTypes, filled in getCorrTypes().
223 
224  casacore::Vector<casacore::Vector<casacore::Slice> > chanSlices_p; // Used by VisIterator::selectChannel()
226  casacore::Vector<casacore::Vector<casacore::Slice> > corrSlices_p; // Used by VisIterator::selectCorrelation()
228 
229  std::set<casacore::Int> fitspwset_p, outspwset_p;
231 };
232 
233 } //# NAMESPACE CASA - END
234 
235 #endif
236 
casacore::Bool selectSource(const casacore::Vector< casacore::Int > &fieldid)
Select source or field.
casacore::Vector< casacore::Int > fieldId_p
Definition: Reweighter.h:216
Reweighter(const casacore::String &theMS, const casacore::Bool dorms=false, const casacore::uInt minsamp=1)
casacore::Bool setmsselect(const casacore::String &fitspw="", const casacore::String &outspw="", const casacore::String &field="", const casacore::String &baseline="", const casacore::String &scan="", const casacore::String &subarray="", const casacore::String &correlation="", const casacore::String &intent="", const casacore::String &obs="")
select stuff using msselection syntax...time is left out call it separately with timebin Returns a su...
Reweighter reweights a selected part of an casacore::MS based on the properties of a (possibly differ...
Definition: Reweighter.h:86
casacore::MeasurementSet mssel_p
Definition: Reweighter.h:195
casacore::Vector< casacore::String > antennaSelStr_p
Uninitialized by ctors.
Definition: Reweighter.h:213
casacore::Vector< casacore::Int > fitStep_p
Definition: Reweighter.h:230
casacore::Matrix< casacore::Double > selTimeRanges_p
Definition: Reweighter.h:227
casacore::String obsString_p
Definition: Reweighter.h:201
static casacore::Bool pickAntennas(casacore::Vector< casacore::Int > &selected_antennaids, casacore::Vector< casacore::String > &selected_antenna_strs, const casacore::Vector< casacore::Int > &antennaids, const casacore::Vector< casacore::String > &antennaSel)
casacore::Bool selectCorrelations(const casacore::String &corrstr)
Setup polarization selection (for now, only from available correlations - no casacore::Stokes transfo...
casacore::Bool reweight(casacore::String &colname, const casacore::String &combine)
Do the reweighting!
static casacore::Bool getCorrTypes(casacore::Vector< casacore::Int > &polIDs, casacore::Vector< casacore::Vector< casacore::Int > > &corrTypes, const casacore::MSColumns &msc)
void verifyColumns(const casacore::MeasurementSet&amp; ms, const casacore::Vector&lt;casacore::MS::Predefine...
casacore::String arrayExpr_p
Definition: Reweighter.h:204
casacore::Vector< casacore::Vector< casacore::Int > > corrTypes_p
casacore::Map from polID to corrTypes, filled in getCorrTypes().
Definition: Reweighter.h:222
casacore::Double timeBin_p
Definition: Reweighter.h:200
casacore::Bool shouldWatch(casacore::Bool &conflict, const casacore::String &col, const casacore::String &uncombinable="", const casacore::Bool verbose=true) const
Returns whether col is (not in combine_p) || in uncombinable.
casacore::MS::PredefinedColumns dataColStrToEnum(const casacore::String &col)
Defaults to DATA.
void setOutSpw(const casacore::String &outspw)
Set the selection string for output spws (not channels!).
Definition: Reweighter.h:135
PredefinedColumns
The Main table colums with predefined meaning.
Definition: MSMainEnums.h:65
casacore::Vector< casacore::Vector< casacore::Slice > > corrSlices_p
Definition: Reweighter.h:226
casacore::MeasurementSet ms_p
*** Member variables ***
Definition: Reweighter.h:195
casacore::Vector< casacore::Int > polIDs_p
casacore::Map from DDID to polID, filled in getCorrTypes().
Definition: Reweighter.h:219
casacore::Vector< casacore::Int > antennaId_p
Definition: Reweighter.h:214
void selectTime(casacore::Double timeBin=-1.0, casacore::String timerng="")
select time parameters
casacore::String scanString_p
Definition: Reweighter.h:201
casacore::String fitspw_p
scan #, observation, and/or state ID? Must be lowercase at all times.
Definition: Reweighter.h:208
void setFitSpw(const casacore::String &fitspw)
void selectSource(casacore::Vector&lt;casacore::String&gt; sourceid);
Definition: Reweighter.h:133
casacore::Bool makeSelection()
method that returns the selected ms (?! - but it&#39;s Boolean - RR)
const casacore::ArrayColumn< casacore::Complex > & right_column(const casacore::ROMSColumns *ms_p, const casacore::MS::PredefinedColumns datacol)
*** Private member functions ***
double Double
Definition: aipstype.h:55
A class to provide easy read-only access to MeasurementSet columns.
Definition: MSColumns.h:111
MSSelection: Class to represent a selection on an MS.
Definition: MSSelection.h:118
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Vector< casacore::Int > fitStart_p
Definition: Reweighter.h:230
casacore::Vector< casacore::Int > fitEnd_p
Definition: Reweighter.h:230
Read and write access to an array table column with arbitrary data type.
Definition: Reweighter.h:48
casacore::Bool antennaSel_p
Definition: Reweighter.h:199
casacore::String combine_p
Definition: Reweighter.h:205
casacore::String corrString_p
Definition: Reweighter.h:204
A Table intended to hold astronomical data (a set of Measurements).
std::set< casacore::Int > outspwset_p
Definition: Reweighter.h:229
virtual ~Reweighter()
casacore::MSColumns * msc_p
Definition: Reweighter.h:198
void selectAntenna(const casacore::Vector< casacore::Int > &antennaids, const casacore::Vector< casacore::String > &antennaSel)
Definition: Reweighter.h:117
casacore::Bool selectSpw(std::set< casacore::Int > &spwset, casacore::Vector< casacore::Int > &chanStartv, casacore::Vector< casacore::Int > &chanEndv, casacore::Vector< casacore::Int > &chanStepv, const casacore::String &spwstr)
Select spw and channels for each spw in spwstr.
casacore::String intentString_p
Definition: Reweighter.h:201
A class to provide easy read-write access to MeasurementSet columns.
Definition: MSColumns.h:221
casacore::Bool dorms_p
Definition: Reweighter.h:196
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Vector< casacore::Int > unionspw_p
Definition: Reweighter.h:210
casacore::Vector< casacore::Slice > corrSlice_p
Definition: Reweighter.h:225
casacore::uInt minsamp_p
Definition: Reweighter.h:197
casacore::String timeRange_p
Definition: Reweighter.h:204
std::set< casacore::Int > fitspwset_p
Definition: Reweighter.h:229
casacore::Bool setSortOrder(casacore::Block< casacore::Int > &sort, const casacore::String &uncombinable="", const casacore::Bool verbose=true) const
Sets sort to a casacore::Block of columns that a VisibilityIterator should sort by, according to combine_p.
casacore::Vector< casacore::Vector< casacore::Slice > > chanSlices_p
Definition: Reweighter.h:224
void selectArray(const casacore::String &subarray)
Select array IDs to use.
Definition: Reweighter.h:125
casacore::String outspw_p
Definition: Reweighter.h:209
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42