casa
$Rev:20696$
|
00001 //# VBGContinuumSubtractor.h: Estimates the continuum of VisBuffGroups and 00002 //# writes the difference to a new MS. 00003 //# Copyright (C) 2011 00004 //# Associated Universities, Inc. Washington DC, USA. 00005 //# 00006 //# This library is free software; you can redistribute it and/or modify it 00007 //# under the terms of the GNU Library General Public License as published by 00008 //# the Free Software Foundation; either version 2 of the License, or (at your 00009 //# option) any later version. 00010 //# 00011 //# This library is distributed in the hope that it will be useful, but WITHOUT 00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00014 //# License for more details. 00015 //# 00016 //# You should have received a copy of the GNU Library General Public License 00017 //# along with this library; if not, write to the Free Software Foundation, 00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00019 //# 00020 //# Correspondence concerning AIPS++ should be addressed as follows: 00021 //# Internet email: aips2-request@nrao.edu. 00022 //# Postal address: AIPS++ Project Office 00023 //# National Radio Astronomy Observatory 00024 //# 520 Edgemont Road 00025 //# Charlottesville, VA 22903-2475 USA 00026 //# 00027 00028 #ifndef MSVIS_VBGCONTINUUMSUBTRACTOR_H 00029 #define MSVIS_VBGCONTINUUMSUBTRACTOR_H 00030 00031 #include <casa/aips.h> 00032 #include <ms/MeasurementSets/MeasurementSet.h> 00033 #include <synthesis/MSVis/GroupWorker.h> 00034 #include <synthesis/MSVis/VisibilityIterator.h> 00035 #include <synthesis/MSVis/VisBufferComponents.h> 00036 #include <map> 00037 #include <set> 00038 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 00041 //# forward decl 00042 class VisBuffGroup; 00043 00044 //<summary>VBGContinuumSubtractors subtract the continuum out of VisBuffGroups</summary> 00045 // 00046 // <use visibility=export> 00047 // 00048 // <reviewed reviewer="" date="" tests="" demos=""> 00049 00050 // <prerequisite> 00051 // <li> <linkto class="VisBuffGroup">VisBuffGroup</linkto> 00052 // <li> <linkto class="VisBuffGroup">VisibilityIterator</linkto> 00053 // <li> <linkto class="GroupProcessor">GroupProcessor</linkto> 00054 // <li> <linkto class="GroupWriteToNewMS">GroupWriteToNewMS</linkto> 00055 // </prerequisite> 00056 // 00057 // <etymology> 00058 // VBGContinuumSubtractors subtract the continuum out of VisBuffGroups. 00059 // </etymology> 00060 // 00061 //<synopsis> 00062 // This estimates the continuum by fitting a low order polynomial in frequency 00063 // for each baseline in a VisBuffGroup, and then writes those visibilities, 00064 // with the continuum subtracted, to a different MS. The VisBuffers in the 00065 // VisBuffGroup do not all have to have the same spw, set of baselines, or even 00066 // set of correlations, but output visibilities for which the continuum cannot 00067 // be estimated will be flagged. 00068 //</synopsis> 00069 // 00070 //<todo> 00071 // <li> 00072 //</todo> 00073 class VBGContinuumSubtractor : public GroupWriteToNewMS 00074 { 00075 public: 00076 // Construct an object that will write to outms after subtracting a continuum 00077 // estimated by fitting a polynomial of order fitorder. It will always 00078 // _write_ to DATA if datacols.nelements() == 1, and write to all 3 00079 // otherwise. Thus datacols.nelements() should be either 1 or 3. Anything 00080 // else will result in an AipsError. 4 and 2 are right out, and FLOAT_DATA 00081 // isn't handled by this yet. 00082 // 00083 // invi is the input VisibilityIterator, only used directly here to get the 00084 // sort columns and whether or not WEIGHT_SPECTRUM and/or FLAG_CATEGORY are 00085 // present. 00086 // 00087 VBGContinuumSubtractor(MeasurementSet& outms, 00088 MSColumns *msc, 00089 const VBRemapper& remapper, 00090 const ROVisibilityIterator& invi, 00091 const uInt fitorder=1, 00092 const MS::PredefinedColumns datacols=MS::DATA, 00093 const String& fitspw="*", 00094 const String& outspw="*"); 00095 00097 //VBGContinuumSubtractor(const VBGContinuumSubtractor& other) {} 00098 00099 // Destructor 00100 virtual ~VBGContinuumSubtractor(); 00101 00103 //virtual VBGContinuumSubtractor& operator=(const VBGContinuumSubtractor& gw) {} 00104 00105 // // Returns which columns need to be prefetched for process to work. 00106 // virtual asyncio::PrefetchColumns *prefetchColumns() const; 00107 00108 // This is where all the work gets done! 00109 virtual Bool process(VisBuffGroup& vbg); 00110 00111 private: 00112 // Disable null c'tor. 00113 VBGContinuumSubtractor(); 00114 00115 // Initialized by c'tor: 00116 00117 // Order of the fit polynomials. 00118 uInt fitorder_p; 00119 00120 // Which of DATA, MODEL_DATA, or CORRECTED_DATA to fit. 00121 // It will always _write_ to DATA if datacols_p.nelements() == 1, and write 00122 // to all 3 otherwise. Thus datacols_p.nelements() should be either 1 or 3. 00123 // 4 and 2 are right out, and FLOAT_DATA isn't handled by this yet. 00124 MS::PredefinedColumns datacol_p; 00125 00126 String fitspw_p; // Line-free channels used for the fit. Can include ; 00127 String outspw_p; // Channels to write out. Does not yet support ;. 00128 uInt rowsdone_p; // How many rows have been written so far. 00129 std::set<Int> outspws_p; // Spws to write out. 00130 00131 Bool doWS_p; // Is WEIGHT_SPECTRUM present? 00132 Bool doFC_p; // Is FLAG_CATEGORY present? 00133 00134 // Not initialized by c'tor: 00135 00136 // These cubes could be made local to process(), but I want to avoid repeated 00137 // c'ting and d'ting. 00138 Cube<Complex> coeffs_p; // Polynomial coefficients for the continuum, indexed by (corr, 00139 // order, hash(ant1, ant2). 00140 Cube<Bool> coeffsOK_p; // Flags on the sol'ns, indexed by (corr, 00141 // order, hash(ant1, ant2). 00142 00143 std::set<Int> appliedSpWs_p; 00144 00145 std::map<Int, Vector<Bool>*> fitmask_p; // spw -> a list of flags by chan 00146 }; 00147 00148 } //# NAMESPACE CASA - END 00149 00150 #endif 00151