casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VBGContinuumSubtractor.h
Go to the documentation of this file.
1 //# VBGContinuumSubtractor.h: Estimates the continuum of VisBuffGroups and
2 //# writes the difference to a new MS.
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_VBGCONTINUUMSUBTRACTOR_H
29 #define MSVIS_VBGCONTINUUMSUBTRACTOR_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>VBGContinuumSubtractors subtract the continuum out of VisBuffGroups</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="VisBuffGroup">VisibilityIterator</linkto>
53 // <li> <linkto class="GroupProcessor">GroupProcessor</linkto>
54 // <li> <linkto class="GroupWriteToNewMS">GroupWriteToNewMS</linkto>
55 // </prerequisite>
56 //
57 // <etymology>
58 // VBGContinuumSubtractors subtract the continuum out of VisBuffGroups.
59 // </etymology>
60 //
61 //<synopsis>
62 // This estimates the continuum by fitting a low order polynomial in frequency
63 // for each baseline in a VisBuffGroup, and then writes those visibilities,
64 // with the continuum subtracted, to a different MS. The VisBuffers in the
65 // VisBuffGroup do not all have to have the same spw, set of baselines, or even
66 // set of correlations, but output visibilities for which the continuum cannot
67 // be estimated will be flagged.
68 //</synopsis>
69 //
70 //<todo>
71 // <li>
72 //</todo>
74 {
75 public:
76  // Construct an object that will write to outms after subtracting a continuum
77  // estimated by fitting a polynomial of order fitorder. It will always
78  // _write_ to DATA if datacols.nelements() == 1, and write to all 3
79  // otherwise. Thus datacols.nelements() should be either 1 or 3. Anything
80  // else will result in an AipsError. 4 and 2 are right out, and FLOAT_DATA
81  // isn't handled by this yet.
82  //
83  // invi is the input VisibilityIterator, only used directly here to get the
84  // sort columns and whether or not WEIGHT_SPECTRUM and/or FLAG_CATEGORY are
85  // present.
86  //
89  const VBRemapper& remapper,
90  const ROVisibilityIterator& invi,
91  const casacore::uInt fitorder=1,
93  const casacore::String& fitspw="*",
94  const casacore::String& outspw="*");
95 
97  //VBGContinuumSubtractor(const VBGContinuumSubtractor& other) {}
98 
99  // Destructor
100  virtual ~VBGContinuumSubtractor();
101 
103  //virtual VBGContinuumSubtractor& operator=(const VBGContinuumSubtractor& gw) {}
104 
105  // // Returns which columns need to be prefetched for process to work.
106  // virtual asyncio::PrefetchColumns *prefetchColumns() const;
107 
108  // This is where all the work gets done!
109  virtual casacore::Bool process(VisBuffGroup& vbg);
110 
112  void setWantCont(bool want_cont) {want_cont_p = want_cont;}
113 
114 private:
115  // Disable null c'tor.
117 
118  // Initialized by c'tor:
119 
120  // Order of the fit polynomials.
122 
123  // Which of DATA, MODEL_DATA, or CORRECTED_DATA to fit.
124  // It will always _write_ to DATA if datacols_p.nelements() == 1, and write
125  // to all 3 otherwise. Thus datacols_p.nelements() should be either 1 or 3.
126  // 4 and 2 are right out, and FLOAT_DATA isn't handled by this yet.
128 
129  casacore::String fitspw_p; // Line-free channels used for the fit. Can include ;
130  casacore::String outspw_p; // Channels to write out. Does not yet support ;.
131  casacore::uInt rowsdone_p; // How many rows have been written so far.
132  std::set<casacore::Int> outspws_p; // Spws to write out.
133 
134  casacore::Bool doWS_p; // Is WEIGHT_SPECTRUM present?
135  casacore::Bool doFC_p; // Is FLAG_CATEGORY present?
136 
137  // Not initialized by c'tor:
138 
139  // These cubes could be made local to process(), but I want to avoid repeated
140  // c'ting and d'ting.
141  casacore::Cube<casacore::Complex> coeffs_p; // casacore::Polynomial coefficients for the continuum, indexed by (corr,
142  // order, hash(ant1, ant2).
143  casacore::Cube<casacore::Bool> coeffsOK_p; // Flags on the sol'ns, indexed by (corr,
144  // order, hash(ant1, ant2).
145 
146  std::set<casacore::Int> appliedSpWs_p;
147 
148  std::map<casacore::Int, casacore::Vector<casacore::Bool>*> fitmask_p; // spw -> a list of flags by chan
149 
150  bool tvi_debug;
152 };
153 
154 } //# NAMESPACE CASA - END
155 
156 #endif
157 
casacore::uInt fitorder_p
Initialized by c&#39;tor:
std::set< casacore::Int > appliedSpWs_p
order, hash(ant1, ant2).
VBRemappers remap VisBuffers.
Definition: VBRemapper.h:67
VBGContinuumSubtractor()
Disable null c&#39;tor.
VBGContinuumSubtractors subtract the continuum out of VisBuffGroups.
PredefinedColumns
The Main table colums with predefined meaning.
Definition: MSMainEnums.h:65
A class to store a group of VisBuffers.
Definition: VisBuffGroup.h:83
std::map< casacore::Int, casacore::Vector< casacore::Bool > * > fitmask_p
Destructor *virtual ~VBGContinuumSubtractor()
This is where all the work gets done *virtual casacore::Bool process(VisBuffGroup &vbg)
This is where all the work gets done!
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A Table intended to hold astronomical data (a set of Measurements).
bool debug
A base class for ROGroupWorkers that write to a new MS.
Definition: GroupWorker.h:193
casacore::MS::PredefinedColumns datacol_p
Which of DATA, MODEL_DATA, or CORRECTED_DATA to fit.
A class to provide easy read-write access to MeasurementSet columns.
Definition: MSColumns.h:221
String: the storage and methods of handling collections of characters.
Definition: String.h:223
ROVisibilityIterator iterates through one or more readonly MeasurementSets.
std::set< casacore::Int > outspws_p
Complex visibility matrix.
Definition: MSMainEnums.h:183
unsigned int uInt
Definition: aipstype.h:51
casacore::Cube< casacore::Bool > coeffsOK_p
order, hash(ant1, ant2).
casacore::Cube< casacore::Complex > coeffs_p
Not initialized by c&#39;tor: