casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSLister.h
Go to the documentation of this file.
1 //# MSLister.h: Helper class for applications listing records from an MS
2 //# Copyright (C) 1998,1999,2000
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 //#
28 #ifndef MS_MSLISTER_H
29 #define MS_MSLISTER_H
30 
31 
32 #include <casacore/casa/aips.h>
34 //#include <casacore/casa/Logging/LogSink.h>
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 class MeasurementSet;
42 
43 // <summary> List visibility records from a Measurement Set </summary>
44 // <use visibility=export>
45 //
46 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
47 // </reviewed>
48 //
49 // <prerequisite>
50 // <li> <linkto class=MSSelector>MSSelector</linkto>
51 // <li> <linkto class=MSSummary>MSSummary</linkto>
52 // </prerequisite>
53 //
54 // <etymology>
55 // The name comes from being a Lister for a MS.
56 // </etymology>
57 //
58 // <synopsis>
59 // MSs containing (u,v) data consist of amplitudes and phases for each
60 // baseline and sample time, typically sorted in TB order. These
61 // visibilities sometimes need to be examined one record at a time in
62 // a text-based format, giving the user access to their raw data.
63 // This class provides that access in a choice of several formats.
64 // </synopsis>
65 //
66 // <example>
67 // <srcBlock>
68 // // Define an MS
69 // MeasurementSet myMS(fileName);
70 // // Define an output stream
71 // LogIO myLog;
72 // // Construct the Lister object
73 // MSLister myList(myMS,myLog);
74 // // List all data
75 // myList.list();
76 //
77 // // Send the next output to a new location
78 // LogIO newLog;
79 // setNewOS(newLog);
80 // // List all the data, with default output options
81 // myList.list();
82 // // List only selected data, with specified output options
83 // datacolumn = 'corrected'; spw = '3:5~10'; timerange = '<13:34:25.1';
84 // scan = '5'; pagerows = 10; listfile = 'myList.list.out';
85 // // ... define any other parameters, then call function ...
86 // myList.list(options, datacolumn, field, spw, antenna, timerange,
87 // correlation, scan, feed, array, uvrange, average,
88 // showflags, msselect, pagerows, listfile);
89 // </srcBlock>
90 // An <src>MSLister</src> object is constructed from a <src>MS</src>
91 // object, and then logged to the supplied <src>LogIO</src> object.
92 // A new <src>LogIO</src> object is defined for a more restricted
93 // listing.
94 // </example>
95 //
96 // <note role=caution>
97 // Note that if the <src>MS</src> goes out of scope, this class will
98 // retrieve rubbish (probably giving runtime errors) as it just
99 // maintains a pointer to the image.
100 // </note>
101 //
102 // <motivation>
103 // The viewing of the raw data is a basic capability that is
104 // commonly required.
105 // </motivation>
106 //
107 // <todo asof="2008/02/08">
108 // <li> Several of the input parameters to <src>MSLister::list</src> are not
109 // funcational presently.
110 // <li> The (pointer to the) MS is declared and used as non-const throughout
111 // MSLister, because MSSelector requires it. MSSelector should be
112 // changed to require a const MS since it claims not to change the MS
113 // anyway. Then the pointer/MS should be made const here too.
114 // <li> Add more sanity checks.
115 // <li> Actually do something with the nDecimal_p number.
116 // <li> There are more formatting options planned.
117 // </todo>
118 
119 
120 class MSLister
121 {
122 public:
123  // Null constructor
124  MSLister();
125 
126  // Construct from a MeasurementSet (set pointer), set formatting string,
127  // and initialise listing with os.
128  // <todo> os is currently not used as the primary steam for log messages.
129  // This should be corrected, or os removed completely from the class.
130  // </todo>
131  MSLister (const MeasurementSet& ms, LogIO& os);
132 
133  // Copy constructor, this will initialise the MSLister's MS with other's MS
134  MSLister (MSLister& other);
135 
136  // Assignment, this will initialise the MSLister's MS with other's MS
137  MSLister& operator=(MSLister& other);
138 
139  // Destructor
140  ~MSLister();
141 
142  // Change or set the OS this MSLister uses. Do this before setMS()
143  // if doing both. This method avoids having to reconstruct the MSLister
144  // object if you change your mind about the output destination.
145  // <todo> os is currently not used as the primary steam for log messages.
146  // This should be corrected, or os removed completely from the class.
147  // </todo>
148  Bool setNewOS (LogIO& os);
149 
150  // Change or set the MS this MSLister refers to, and reinitialise the
151  // MSLister object. Do this after setNewOS() if doing both.
152  Bool setMS (MeasurementSet& ms);
153 
154  // Page size for various formats, output devices (default for landscape
155  // printing).
156  void setPage (const uInt width=120, const uInt height=20);
157 
158  // Format for output, ie data display precision.
159  void setFormat (const uInt ndec=2);
160 
161  // User choices for list precision (sensible defaults):
162  // (time precision for user interface is fraction of sec)
163  void setPrecision ( const Int precTime=1, const Int precUVDist=0,
164  const Int precAmpl=3, const int precPhase=1,
165  const Int precWeight=0 );
166 
167  // List the visibilities, with optional data selection and output
168  // specification.
169  void list (const String& options="",
170  const String& datacolumn="",
171  const String& field="",
172  const String& spw="",
173  const String& antenna="",
174  const String& timerange="",
175  const String& correlation="",
176  const String& scan="",
177  const String& feed="",
178  const String& array="",
179  const String& observation="",
180  const String& uvrange="",
181  const String& average="",
182  const bool showflags=False,
183  const String& msSelect="",
184  const long pagerows=50,
185  const String& listfile="");
186 
187  // Set uv-data selection via MSSelection
188  void selectvis(const String& timerange="",
189  const String& spw="",
190  const String& scan="",
191  const String& field="",
192  const String& baseline="",
193  const String& uvrange="",
194  const String& chanmode="none",
195  const Int& nchan=1,
196  const Int& start=0,
197  const Int& step=1,
198  const MRadialVelocity& mStart=MRadialVelocity(),
199  const MRadialVelocity& mStep=MRadialVelocity(),
200  const String& correlation="",
201  const String& array="",
202  const String& observation="",
203  const String& msSelect="");
204 
205 private:
206 
207  // Initialise the listing. initList() does things that need to be done
208  // once per MS: declares and initialises the private MSSelector object,
209  // and gets all the attribute ranges up front.
210  void initList();
211 
212  // A preamble of abbreviated MSSummary information.
213  void listHeader();
214 
215  // Get the ranges of a fixed set of MS key attributes.
216  void getRanges(const MeasurementSet &ms);
217 
218  // Most of the heavy lifting is in here. Get the data records and list
219  // them.
220  void listData(const int pageRows=50, const String listfile="");
221 
222  // Column header line for pagination of output.
223  void listColumnHeader(ostream& myout);
224 
225  // Setup class polarization information for specified MS.
226  // pols_p holds the polarization names contained in the MS
227  // in the same order that the polarization data are listed in the
228  // main table.
229  void _polarizationSetup(const uInt selPolID);
230 
231  // Parse the correlation parameter value; fill indexPols_p to output
232  // selected polarizations. If correlation is empty, all polarizations
233  // are selected.
234  void polarizationParse(String correlation);
235 
236  // Calculate column width for a Vector<String>
237  Int columnWidth(const Vector<String> antNames);
238 
239  // Pointer to the MS
242 
243  // Output stream
245 
246  // A formatting string for convenience
248 
249  // The MSSelector object used in list() etc.
251 
252  // List of channels
254  // True if listing multiple channels.
256 
257  // Pol counters
259 
260  // SpW/Pol info from subtables
263 
264  // SpWId map from DDIs:
266  // True if listing multiple spws
268 
269  // Polarization indexing variables; for polarization (correlation) selection.
272 
273  // Field width variables
278 
279  // Order of magnitude control (digits to left of decimal, including sign)
283 
284  // Precision control (digits to right of decimal point)
285  // (precTime_p includes hhmmss, so 7 yields hh:mm:ss.s)
289 
290  // Page params
293 
294  // for assigning desired columns from the ms
296 
297  // Bools for column showing and to identify FLOAT_DATA column of single dish
299 
300  // Data selections
301  // data --> "amplitude", "phase"
302  // corrected --> "corrected_amplitude", "corrected_phase"
303  // model --> "model_amplitude", "model_phase"
304  // residual --> "residual_amplitude", "residual_phase"
306 
307  // The Record object containing the MSSelector ranges
309 
310  // The conversion of the above to a regular Record object
312 
313  // Clear the formatting flags
314  void clearFlags();
315 };
316 
317 
318 } //# NAMESPACE CASACORE - END
319 
320 #endif
Vector< Int > spwins_p
SpWId map from DDIs:
Definition: MSLister.h:265
A 1-D Specialization of the Array class.
Definition: ArrayFwd.h:9
int Int
Definition: aipstype.h:50
void clearFlags()
Clear the formatting flags.
List visibility records from a Measurement Set.
Definition: MSLister.h:120
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1929
void listData(const int pageRows=50, const String listfile="")
Most of the heavy lifting is in here.
void getRanges(const MeasurementSet &ms)
Get the ranges of a fixed set of MS key attributes.
Int pageWidth_p
Page params.
Definition: MSLister.h:291
ostream-like interface to creating log messages.
Definition: LogIO.h:167
A Measure: radial velocity.
void setPage(const uInt width=120, const uInt height=20)
Page size for various formats, output devices (default for landscape printing).
Bool multiSpw_p
True if listing multiple spws.
Definition: MSLister.h:267
MSSelector mss_p
The MSSelector object used in list() etc.
Definition: MSLister.h:250
Vector< Double > freqs_p
Definition: MSLister.h:262
MeasurementSet * pMSSel_p
Definition: MSLister.h:241
Int columnWidth(const Vector< String > antNames)
Calculate column width for a Vector&lt;String&gt;
void listHeader()
A preamble of abbreviated MSSummary information.
Vector< String > items_p
for assigning desired columns from the ms
Definition: MSLister.h:295
void selectvis(const String &timerange="", const String &spw="", const String &scan="", const String &field="", const String &baseline="", const String &uvrange="", const String &chanmode="none", const Int &nchan=1, const Int &start=0, const Int &step=1, const MRadialVelocity &mStart=MRadialVelocity(), const MRadialVelocity &mStep=MRadialVelocity(), const String &correlation="", const String &array="", const String &observation="", const String &msSelect="")
Set uv-data selection via MSSelection.
Int precTime_p
Precision control (digits to right of decimal point) (precTime_p includes hhmmss, so 7 yields hh:mm:s...
Definition: MSLister.h:286
uInt npols_p
Pol counters.
Definition: MSLister.h:258
MSLister()
Null constructor.
Vector< Int > indexPols_p
Polarization indexing variables; for polarization (correlation) selection.
Definition: MSLister.h:270
uInt wTime_p
Field width variables.
Definition: MSLister.h:274
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
LogIO logStream_p
Output stream.
Definition: MSLister.h:244
void initList()
Initialise the listing.
void setPrecision(const Int precTime=1, const Int precUVDist=0, const Int precAmpl=3, const int precPhase=1, const Int precWeight=0)
User choices for list precision (sensible defaults): (time precision for user interface is fraction o...
const Bool False
Definition: aipstype.h:44
void listColumnHeader(ostream &myout)
Column header line for pagination of output.
Bool setNewOS(LogIO &os)
Change or set the OS this MSLister uses.
A Table intended to hold astronomical data (a set of Measurements).
void list(const String &options="", const String &datacolumn="", const String &field="", const String &spw="", const String &antenna="", const String &timerange="", const String &correlation="", const String &scan="", const String &feed="", const String &array="", const String &observation="", const String &uvrange="", const String &average="", const bool showflags=False, const String &msSelect="", const long pagerows=50, const String &listfile="")
List the visibilities, with optional data selection and output specification.
Record dataRecords_p
The conversion of the above to a regular Record object.
Definition: MSLister.h:311
uInt oTime_p
Order of magnitude control (digits to left of decimal, including sign)
Definition: MSLister.h:280
MSLister & operator=(MSLister &other)
Assignment, this will initialise the MSLister&#39;s MS with other&#39;s MS.
const String dashline_p
A formatting string for convenience.
Definition: MSLister.h:247
Record ranges_p
The Record object containing the MSSelector ranges.
Definition: MSLister.h:308
void _polarizationSetup(const uInt selPolID)
Setup class polarization information for specified MS.
Matrix< Int > chanList_p
List of channels.
Definition: MSLister.h:253
Vector< String > pols_p
SpW/Pol info from subtables.
Definition: MSLister.h:261
Bool doFld_p
Bools for column showing and to identify FLOAT_DATA column of single dish.
Definition: MSLister.h:298
Bool setMS(MeasurementSet &ms)
Change or set the MS this MSLister refers to, and reinitialise the MSLister object.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
MeasurementSet * pMS_p
Pointer to the MS.
Definition: MSLister.h:240
MSSelector specifies selections on a MeasurementSet.
Definition: MSSelector.h:113
void setFormat(const uInt ndec=2)
Format for output, ie data display precision.
Bool multiChan_p
True if listing multiple channels.
Definition: MSLister.h:255
~MSLister()
Destructor.
Vector< String > dataColSel
Data selections data –&gt; &quot;amplitude&quot;, &quot;phase&quot; corrected –&gt; &quot;corrected_amplitude&quot;, &quot;corrected_phase&quot; mo...
Definition: MSLister.h:305
unsigned int uInt
Definition: aipstype.h:51
void polarizationParse(String correlation)
Parse the correlation parameter value; fill indexPols_p to output selected polarizations.