casa
$Rev:20696$
|
00001 //# MSLister.h: Helper class for applications listing records from an MS 00002 //# Copyright (C) 1998,1999,2000 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 addressed 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 //# $Id: MSLister.h 20749 2009-09-30 14:24:05Z gervandiepen $ 00027 //# 00028 #ifndef MS_MSLISTER_H 00029 #define MS_MSLISTER_H 00030 00031 00032 #include <casa/aips.h> 00033 #include <casa/Logging/LogIO.h> 00034 //#include <casa/Logging/LogSink.h> 00035 #include <casa/BasicSL/String.h> 00036 #include <casa/Arrays/Vector.h> 00037 #include <casa/Containers/Record.h> 00038 #include <ms/MeasurementSets/MSSelector.h> 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 00041 class MeasurementSet; 00042 00043 // <summary> List visibility records from a Measurement Set </summary> 00044 // <use visibility=export> 00045 // 00046 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00047 // </reviewed> 00048 // 00049 // <prerequisite> 00050 // <li> <linkto class=MSSelector>MSSelector</linkto> 00051 // <li> <linkto class=MSSummary>MSSummary</linkto> 00052 // </prerequisite> 00053 // 00054 // <etymology> 00055 // The name comes from being a Lister for a MS. 00056 // </etymology> 00057 // 00058 // <synopsis> 00059 // MSs containing (u,v) data consist of amplitudes and phases for each 00060 // baseline and sample time, typically sorted in TB order. These 00061 // visibilities sometimes need to be examined one record at a time in 00062 // a text-based format, giving the user access to their raw data. 00063 // This class provides that access in a choice of several formats. 00064 // </synopsis> 00065 // 00066 // <example> 00067 // <srcBlock> 00068 // // Define an MS 00069 // MeasurementSet myMS(fileName); 00070 // // Define an output stream 00071 // LogIO myLog; 00072 // // Construct the Lister object 00073 // MSLister myList(myMS,myLog); 00074 // // List all data 00075 // myList.list(); 00076 // 00077 // // Send the next output to a new location 00078 // LogIO newLog; 00079 // setNewOS(newLog); 00080 // // List all the data, with default output options 00081 // myList.list(); 00082 // // List only selected data, with specified output options 00083 // datacolumn = 'corrected'; spw = '3:5~10'; timerange = '<13:34:25.1'; 00084 // scan = '5'; pagerows = 10; listfile = 'myList.list.out'; 00085 // // ... define any other parameters, then call function ... 00086 // myList.list(options, datacolumn, field, spw, antenna, timerange, 00087 // correlation, scan, feed, array, uvrange, average, 00088 // showflags, msselect, pagerows, listfile); 00089 // </srcBlock> 00090 // An <src>MSLister</src> object is constructed from a <src>MS</src> 00091 // object, and then logged to the supplied <src>LogIO</src> object. 00092 // A new <src>LogIO</src> object is defined for a more restricted 00093 // listing. 00094 // </example> 00095 // 00096 // <note role=caution> 00097 // Note that if the <src>MS</src> goes out of scope, this class will 00098 // retrieve rubbish (probably giving runtime errors) as it just 00099 // maintains a pointer to the image. 00100 // </note> 00101 // 00102 // <motivation> 00103 // The viewing of the raw data is a basic capability that is 00104 // commonly required. 00105 // </motivation> 00106 // 00107 // <todo asof="2008/02/08"> 00108 // <li> Several of the input parameters to <src>MSLister::list</src> are not 00109 // funcational presently. 00110 // <li> The (pointer to the) MS is declared and used as non-const throughout 00111 // MSLister, because MSSelector requires it. MSSelector should be 00112 // changed to require a const MS since it claims not to change the MS 00113 // anyway. Then the pointer/MS should be made const here too. 00114 // <li> Add more sanity checks. 00115 // <li> Actually do something with the nDecimal_p number. 00116 // <li> There are more formatting options planned. 00117 // </todo> 00118 00119 00120 class MSLister 00121 { 00122 public: 00123 // Null constructor 00124 MSLister(); 00125 00126 // Construct from a MeasurementSet (set pointer), set formatting string, 00127 // and initialise listing with os. 00128 // <todo> os is currently not used as the primary steam for log messages. 00129 // This should be corrected, or os removed completely from the class. 00130 // </todo> 00131 MSLister (const MeasurementSet& ms, LogIO& os); 00132 00133 // Copy constructor, this will initialise the MSLister's MS with other's MS 00134 MSLister (MSLister& other); 00135 00136 // Assignment, this will initialise the MSLister's MS with other's MS 00137 MSLister& operator=(MSLister& other); 00138 00139 // Destructor 00140 ~MSLister(); 00141 00142 // Change or set the OS this MSLister uses. Do this before setMS() 00143 // if doing both. This method avoids having to reconstruct the MSLister 00144 // object if you change your mind about the output destination. 00145 // <todo> os is currently not used as the primary steam for log messages. 00146 // This should be corrected, or os removed completely from the class. 00147 // </todo> 00148 Bool setNewOS (LogIO& os); 00149 00150 // Change or set the MS this MSLister refers to, and reinitialise the 00151 // MSLister object. Do this after setNewOS() if doing both. 00152 Bool setMS (MeasurementSet& ms); 00153 00154 // Page size for various formats, output devices (default for landscape 00155 // printing). 00156 void setPage (const uInt width=120, const uInt height=20); 00157 00158 // Format for output, ie data display precision. 00159 void setFormat (const uInt ndec=2); 00160 00161 // User choices for list precision (sensible defaults): 00162 // (time precision for user interface is fraction of sec) 00163 void setPrecision ( const Int precTime=1, const Int precUVDist=0, 00164 const Int precAmpl=3, const int precPhase=1, 00165 const Int precWeight=0 ); 00166 00167 // List the visibilities, with optional data selection and output 00168 // specification. 00169 void list (const String& options="", 00170 const String& datacolumn="", 00171 const String& field="", 00172 const String& spw="", 00173 const String& antenna="", 00174 const String& timerange="", 00175 const String& correlation="", 00176 const String& scan="", 00177 const String& feed="", 00178 const String& array="", 00179 const String& observation="", 00180 const String& uvrange="", 00181 const String& average="", 00182 const bool showflags=False, 00183 const String& msSelect="", 00184 const long pagerows=50, 00185 const String& listfile=""); 00186 00187 // Set uv-data selection via MSSelection 00188 void selectvis(const String& timerange="", 00189 const String& spw="", 00190 const String& scan="", 00191 const String& field="", 00192 const String& baseline="", 00193 const String& uvrange="", 00194 const String& chanmode="none", 00195 const Int& nchan=1, 00196 const Int& start=0, 00197 const Int& step=1, 00198 const MRadialVelocity& mStart=MRadialVelocity(), 00199 const MRadialVelocity& mStep=MRadialVelocity(), 00200 const String& correlation="", 00201 const String& array="", 00202 const String& observation="", 00203 const String& msSelect=""); 00204 00205 private: 00206 00207 // Initialise the listing. initList() does things that need to be done 00208 // once per MS: declares and initialises the private MSSelector object, 00209 // and gets all the attribute ranges up front. 00210 void initList(); 00211 00212 // A preamble of abbreviated MSSummary information. 00213 void listHeader(); 00214 00215 // Get the ranges of a fixed set of MS key attributes. 00216 void getRanges(const MeasurementSet &ms); 00217 00218 // Most of the heavy lifting is in here. Get the data records and list 00219 // them. 00220 void listData(const int pageRows=50, const String listfile=""); 00221 00222 // Column header line for pagination of output. 00223 void listColumnHeader(ostream& myout); 00224 00225 // Setup class polarization information for specified MS. 00226 // pols_p holds the polarization names contained in the MS 00227 // in the same order that the polarization data are listed in the 00228 // main table. 00229 void _polarizationSetup(const uInt selPolID); 00230 00231 // Parse the correlation parameter value; fill indexPols_p to output 00232 // selected polarizations. If correlation is empty, all polarizations 00233 // are selected. 00234 void polarizationParse(String correlation); 00235 00236 // Calculate column width for a Vector<String> 00237 Int columnWidth(const Vector<String> antNames); 00238 00239 // Pointer to the MS 00240 MeasurementSet* pMS_p; 00241 MeasurementSet* pMSSel_p; 00242 00243 // Output stream 00244 LogIO logStream_p; 00245 00246 // A formatting string for convenience 00247 const String dashline_p; 00248 00249 // The MSSelector object used in list() etc. 00250 MSSelector mss_p; 00251 00252 // List of channels 00253 Matrix<Int> chanList_p; 00254 // True if listing multiple channels. 00255 Bool multiChan_p; 00256 00257 // Pol counters 00258 uInt npols_p; 00259 00260 // SpW/Pol info from subtables 00261 Vector<String> pols_p; 00262 Vector<Double> freqs_p; 00263 00264 // SpWId map from DDIs: 00265 Vector<Int> spwins_p; 00266 // True if listing multiple spws 00267 Bool multiSpw_p; 00268 00269 // Polarization indexing variables; for polarization (correlation) selection. 00270 Vector<Int> indexPols_p; 00271 uInt nIndexPols_p; 00272 00273 // Field width variables 00274 uInt wTime_p, wAnt1_p, wAnt2_p, wIntrf_p, wUVDist_p, wUVW_p; 00275 uInt wFld_p, wSpW_p, wChn_p; 00276 uInt wAmpl_p, wPhase_p, wWeight_p, wVis_p, wFlag_p; 00277 uInt wTotal_p; 00278 00279 // Order of magnitude control (digits to left of decimal, including sign) 00280 uInt oTime_p, oUVDist_p, oUVW_p; 00281 uInt oAmpl_p, oPhase_p; 00282 uInt oWeight_p; 00283 00284 // Precision control (digits to right of decimal point) 00285 // (precTime_p includes hhmmss, so 7 yields hh:mm:ss.s) 00286 Int precTime_p, precUVDist_p, precUVW_p; 00287 Int precAmpl_p, precPhase_p; 00288 Int precWeight_p; 00289 00290 // Page params 00291 Int pageWidth_p, pageHeight_p, nDecimal_p; 00292 String date_p, lastdate_p; 00293 00294 // for assigning desired columns from the ms 00295 Vector <String> items_p; 00296 00297 // Bools for column showing and to identify FLOAT_DATA column of single dish 00298 Bool doFld_p, doSpW_p, doChn_p, is_float; 00299 00300 // Data selections 00301 // data --> "amplitude", "phase" 00302 // corrected --> "corrected_amplitude", "corrected_phase" 00303 // model --> "model_amplitude", "model_phase" 00304 // residual --> "residual_amplitude", "residual_phase" 00305 Vector <String> dataColSel; 00306 00307 // The Record object containing the MSSelector ranges 00308 Record ranges_p; 00309 00310 // The conversion of the above to a regular Record object 00311 Record dataRecords_p; 00312 00313 // Clear the formatting flags 00314 void clearFlags(); 00315 }; 00316 00317 00318 } //# NAMESPACE CASA - END 00319 00320 #endif