casa
$Rev:20696$
|
00001 //# CTIter.h: Iterating interfaces for modern CalTables 00002 //# Copyright (C) 2011 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be adressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 00028 #ifndef CALIBRATION_CALTABITER_H 00029 #define CALIBRATION_CALTABITER_H 00030 00031 #include <casa/aips.h> 00032 #include <tables/Tables/TableIter.h> 00033 #include <synthesis/CalTables/NewCalTable.h> 00034 #include <synthesis/CalTables/CTMainColumns.h> 00035 #include <synthesis/CalTables/CTColumns.h> 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 // <summary> 00040 // ROCTIter: Read-only iterating interface to New Calibration tables 00041 // </summary> 00042 00043 // <reviewed reviewer="" date="" tests="" demos=""> 00044 00045 // <prerequisite> 00046 // <li> <linkto class="CalTableDesc">NewCalTable</linkto> module 00047 // </prerequisite> 00048 // 00049 // <etymology> 00050 // From "calibration", "table", and "iteration". 00051 // </etymology> 00052 // 00053 // <synopsis> 00054 // The ROCTIter class provide basic iterated access to the contents 00055 // of a NewCalTable. The iteration is initialized according to sort 00056 // columns specified in the constructor, and access to the contents 00057 // of each iteration is provided via a NewCalTable object (referencing 00058 // the iterated subset of the original NewCalTable) or methods that return 00059 // Vectors or Arrays of the contents of specific columns. For the latter, 00060 // the Vectors/Arrays are generated only on-demand. 00061 // </synopsis> 00062 // 00063 // <example> 00064 // <srcblock> 00065 // </srcblock> 00066 // </example> 00067 // 00068 // <motivation> 00069 // This class is used by calibration table clients to access calibration tables 00070 // in a piecemeal fashion, e.g., for plotting, interpolation, etc. 00071 // </motivation> 00072 // 00073 // <todo asof="11/06/10"> 00074 // </todo> 00075 00076 class ROCTIter 00077 { 00078 public: 00079 // Constructor/Destructor 00080 ROCTIter(NewCalTable tab,const Block<String>& sortcol); 00081 virtual ~ROCTIter(); 00082 00083 // Iteration operators 00084 inline void reset() { ti_->reset(); this->attach(); }; 00085 inline Bool pastEnd() { return ti_->pastEnd(); }; 00086 void next(); 00087 void next0(); 00088 00089 // Return the current table iteration 00090 NewCalTable table() const { return NewCalTable(ti_->table()); }; 00091 00092 Int nrow() const { return ti_->table().nrow(); }; 00093 00094 // Column accessors 00095 // Those methods that return scalars for data coordinates 00096 // (e.g., thisTime(), thisField(), etc.) return the first element 00097 // of the corresponding vector of values in the current 00098 // iteration. This makes the most sense when the corresponding 00099 // column is a sort column in the iteration, such that the contents 00100 // of the vector is in fact a unique value. (TBD: return -1 from 00101 // scalar methods when column is not unique?) 00102 00103 Double thisTime() const; 00104 Vector<Double> time() const; 00105 void time(Vector<Double>& v) const; 00106 00107 Int thisField() const; 00108 Vector<Int> field() const; 00109 void field(Vector<Int>& v) const; 00110 00111 Int thisSpw() const; 00112 Vector<Int> spw() const; 00113 void spw(Vector<Int>& v) const; 00114 00115 Int thisScan() const; 00116 Vector<Int> scan() const; 00117 void scan(Vector<Int>& v) const; 00118 00119 Int thisObs() const; 00120 Vector<Int> obs() const; 00121 void obs(Vector<Int>& v) const; 00122 00123 Int thisAntenna1() const; 00124 Vector<Int> antenna1() const; 00125 void antenna1(Vector<Int>& v) const; 00126 Int thisAntenna2() const; 00127 Vector<Int> antenna2() const; 00128 void antenna2(Vector<Int>& v) const; 00129 00130 Cube<Complex> cparam() const; 00131 void cparam(Cube<Complex>& c) const; 00132 00133 Cube<Float> fparam() const; 00134 void fparam(Cube<Float>& c) const; 00135 00136 Cube<Float> casfparam(String what="") const; 00137 void casfparam(Cube<Float>& casf, String what="") const; 00138 00139 00140 Cube<Float> paramErr() const; 00141 void paramErr(Cube<Float>& c) const; 00142 00143 Cube<Float> snr() const; 00144 void snr(Cube<Float>& c) const; 00145 00146 Cube<Float> wt() const; 00147 void wt(Cube<Float>& c) const; 00148 00149 Cube<Bool> flag() const; 00150 void flag(Cube<Bool>& c) const; 00151 00152 Int nchan() const; 00153 Vector<Int> chan() const; 00154 void chan(Vector<Int>& v) const; 00155 Vector<Double> freq() const; 00156 void freq(Vector<Double>& v) const; 00157 00158 protected: 00159 00160 // Attach accessors 00161 virtual void attach(); 00162 00163 private: 00164 00165 // Prohibit public use of copy, assignment 00166 ROCTIter (const ROCTIter& other); 00167 ROCTIter& operator= (const ROCTIter& other); 00168 00169 // Data: 00170 00171 // Remember the sort columns... 00172 Vector<String> sortCols_; 00173 00174 // If true, spw is unique per iteration, and it is 00175 // safe to access channel axis info 00176 Bool singleSpw_; 00177 00178 // The parent NewCalTable (Table) object 00179 // (stays in scope for the life of the CTIter) 00180 NewCalTable parentNCT_; 00181 00182 // Access to subtables (e.g., for frequencies) 00183 ROCTColumns calCol_; 00184 00185 // The underlying TableIterator 00186 TableIterator *ti_; 00187 00188 // Per-iteration table 00189 NewCalTable *inct_; 00190 00191 // Per-iteration columns 00192 ROCTMainColumns *iROCTMainCols_; 00193 00194 00195 }; 00196 00197 // Writable version (limited to certain 'columns') 00198 class CTIter : public ROCTIter 00199 { 00200 public: 00201 // Constructor/Destructor 00202 CTIter(NewCalTable tab,const Block<String>& sortcol); 00203 virtual ~CTIter(); 00204 00205 // Set fieldid 00206 void setfield(Int fieldid); 00207 00208 // Set scan number 00209 void setscan(Int scan); 00210 00211 // Set obsid 00212 void setobs(Int obs); 00213 00214 // Set antenna2 (e.g., used for setting refant) 00215 void setantenna2(const Vector<Int>& a2); 00216 00217 // Set the flags 00218 void setflag(const Cube<Bool>& flag); 00219 00220 // Set the parameters 00221 void setfparam(const Cube<Float>& f); 00222 void setcparam(const Cube<Complex>& c); 00223 00224 protected: 00225 00226 // Attach writable column access 00227 virtual void attach(); 00228 00229 private: 00230 00231 // Prohibit public use of copy, assignment 00232 CTIter (const CTIter& other); 00233 CTIter& operator= (const CTIter& other); 00234 00235 // Per-iteration table 00236 NewCalTable *irwnct_; 00237 00238 // Writable column access 00239 CTMainColumns *iRWCTMainCols_; 00240 00241 }; 00242 00243 00244 } //# NAMESPACE CASA - END 00245 00246 #endif