casacore
Loading...
Searching...
No Matches
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>
33#include <casacore/casa/Logging/LogIO.h>
34//#include <casacore/casa/Logging/LogSink.h>
35#include <casacore/casa/BasicSL/String.h>
36#include <casacore/casa/Arrays/Vector.h>
37#include <casacore/casa/Containers/Record.h>
38#include <casacore/ms/MSSel/MSSelector.h>
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41class 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
121{
122public:
123 // Null constructor
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
135
136 // Assignment, this will initialise the MSLister's MS with other's MS
138
139 // Destructor
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>
149
150 // Change or set the MS this MSLister refers to, and reinitialise the
151 // MSLister object. Do this after setNewOS() if doing both.
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
205private:
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.
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>
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
295 Vector <String> items_p;
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"
305 Vector <String> dataColSel;
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
315};
316
317
318} //# NAMESPACE CASACORE - END
319
320#endif
Bool multiSpw_p
True if listing multiple spws.
Definition MSLister.h:267
uInt oTime_p
Order of magnitude control (digits to left of decimal, including sign)
Definition MSLister.h:280
Vector< String > pols_p
SpW/Pol info from subtables.
Definition MSLister.h:261
void listColumnHeader(ostream &myout)
Column header line for pagination of output.
const String dashline_p
A formatting string for convenience.
Definition MSLister.h:247
Bool multiChan_p
True if listing multiple channels.
Definition MSLister.h:255
void listData(const int pageRows=50, const String listfile="")
Most of the heavy lifting is in here.
MSLister(MSLister &other)
Copy constructor, this will initialise the MSLister's MS with other's MS.
MSLister & operator=(MSLister &other)
Assignment, this will initialise the MSLister's MS with other's MS.
LogIO logStream_p
Output stream.
Definition MSLister.h:244
Bool setNewOS(LogIO &os)
Change or set the OS this MSLister uses.
Vector< String > items_p
for assigning desired columns from the ms
Definition MSLister.h:295
Vector< Int > spwins_p
SpWId map from DDIs:
Definition MSLister.h:265
void setFormat(const uInt ndec=2)
Format for output, ie data display precision.
Matrix< Int > chanList_p
List of channels.
Definition MSLister.h:253
Bool setMS(MeasurementSet &ms)
Change or set the MS this MSLister refers to, and reinitialise the MSLister object.
void setPage(const uInt width=120, const uInt height=20)
Page size for various formats, output devices (default for landscape printing).
MSLister()
Null constructor.
void getRanges(const MeasurementSet &ms)
Get the ranges of a fixed set of MS key attributes.
MSSelector mss_p
The MSSelector object used in list() etc.
Definition MSLister.h:250
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.
MSLister(const MeasurementSet &ms, LogIO &os)
Construct from a MeasurementSet (set pointer), set formatting string, and initialise listing with os.
Record dataRecords_p
The conversion of the above to a regular Record object.
Definition MSLister.h:311
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
void listHeader()
A preamble of abbreviated MSSummary information.
void clearFlags()
Clear the formatting flags.
uInt wTime_p
Field width variables.
Definition MSLister.h:274
uInt npols_p
Pol counters.
Definition MSLister.h:258
Vector< Int > indexPols_p
Polarization indexing variables; for polarization (correlation) selection.
Definition MSLister.h:270
~MSLister()
Destructor.
Vector< String > dataColSel
Data selections data --> "amplitude", "phase" corrected --> "corrected_amplitude",...
Definition MSLister.h:305
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...
Int pageWidth_p
Page params.
Definition MSLister.h:291
Bool doFld_p
Bools for column showing and to identify FLOAT_DATA column of single dish.
Definition MSLister.h:298
MeasurementSet * pMSSel_p
Definition MSLister.h:241
Record ranges_p
The Record object containing the MSSelector ranges.
Definition MSLister.h:308
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.
Int columnWidth(const Vector< String > antNames)
Calculate column width for a Vector<String>
Vector< Double > freqs_p
Definition MSLister.h:262
MeasurementSet * pMS_p
Pointer to the MS.
Definition MSLister.h:240
void _polarizationSetup(const uInt selPolID)
Setup class polarization information for specified MS.
void polarizationParse(String correlation)
Parse the correlation parameter value; fill indexPols_p to output selected polarizations.
void initList()
Initialise the listing.
String: the storage and methods of handling collections of characters.
Definition String.h:225
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:44
unsigned int uInt
Definition aipstype.h:51
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
int Int
Definition aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:42