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: casa-feedback@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#ifndef MS_MSLISTER_H
27#define MS_MSLISTER_H
28
29
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Logging/LogIO.h>
32//#include <casacore/casa/Logging/LogSink.h>
33#include <casacore/casa/BasicSL/String.h>
34#include <casacore/casa/Arrays/Vector.h>
35#include <casacore/casa/Containers/Record.h>
36#include <casacore/ms/MSSel/MSSelector.h>
37namespace casacore { //# NAMESPACE CASACORE - BEGIN
38
39class MeasurementSet;
40
41// <summary> List visibility records from a Measurement Set </summary>
42// <use visibility=export>
43//
44// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
45// </reviewed>
46//
47// <prerequisite>
48// <li> <linkto class=MSSelector>MSSelector</linkto>
49// <li> <linkto class=MSSummary>MSSummary</linkto>
50// </prerequisite>
51//
52// <etymology>
53// The name comes from being a Lister for a MS.
54// </etymology>
55//
56// <synopsis>
57// MSs containing (u,v) data consist of amplitudes and phases for each
58// baseline and sample time, typically sorted in TB order. These
59// visibilities sometimes need to be examined one record at a time in
60// a text-based format, giving the user access to their raw data.
61// This class provides that access in a choice of several formats.
62// </synopsis>
63//
64// <example>
65// <srcBlock>
66// // Define an MS
67// MeasurementSet myMS(fileName);
68// // Define an output stream
69// LogIO myLog;
70// // Construct the Lister object
71// MSLister myList(myMS,myLog);
72// // List all data
73// myList.list();
74//
75// // Send the next output to a new location
76// LogIO newLog;
77// setNewOS(newLog);
78// // List all the data, with default output options
79// myList.list();
80// // List only selected data, with specified output options
81// datacolumn = 'corrected'; spw = '3:5~10'; timerange = '<13:34:25.1';
82// scan = '5'; pagerows = 10; listfile = 'myList.list.out';
83// // ... define any other parameters, then call function ...
84// myList.list(options, datacolumn, field, spw, antenna, timerange,
85// correlation, scan, feed, array, uvrange, average,
86// showflags, msselect, pagerows, listfile);
87// </srcBlock>
88// An <src>MSLister</src> object is constructed from a <src>MS</src>
89// object, and then logged to the supplied <src>LogIO</src> object.
90// A new <src>LogIO</src> object is defined for a more restricted
91// listing.
92// </example>
93//
94// <note role=caution>
95// Note that if the <src>MS</src> goes out of scope, this class will
96// retrieve rubbish (probably giving runtime errors) as it just
97// maintains a pointer to the image.
98// </note>
99//
100// <motivation>
101// The viewing of the raw data is a basic capability that is
102// commonly required.
103// </motivation>
104//
105// <todo asof="2008/02/08">
106// <li> Several of the input parameters to <src>MSLister::list</src> are not
107// funcational presently.
108// <li> The (pointer to the) MS is declared and used as non-const throughout
109// MSLister, because MSSelector requires it. MSSelector should be
110// changed to require a const MS since it claims not to change the MS
111// anyway. Then the pointer/MS should be made const here too.
112// <li> Add more sanity checks.
113// <li> Actually do something with the nDecimal_p number.
114// <li> There are more formatting options planned.
115// </todo>
116
117
119{
120public:
121 // Null constructor
123
124 // Construct from a MeasurementSet (set pointer), set formatting string,
125 // and initialise listing with os.
126 // <todo> os is currently not used as the primary steam for log messages.
127 // This should be corrected, or os removed completely from the class.
128 // </todo>
129 MSLister (const MeasurementSet& ms, LogIO& os);
130
131 // Copy constructor, this will initialise the MSLister's MS with other's MS
133
134 // Assignment, this will initialise the MSLister's MS with other's MS
136
137 // Destructor
139
140 // Change or set the OS this MSLister uses. Do this before setMS()
141 // if doing both. This method avoids having to reconstruct the MSLister
142 // object if you change your mind about the output destination.
143 // <todo> os is currently not used as the primary steam for log messages.
144 // This should be corrected, or os removed completely from the class.
145 // </todo>
147
148 // Change or set the MS this MSLister refers to, and reinitialise the
149 // MSLister object. Do this after setNewOS() if doing both.
151
152 // Page size for various formats, output devices (default for landscape
153 // printing).
154 void setPage (const uInt width=120, const uInt height=20);
155
156 // Format for output, ie data display precision.
157 void setFormat (const uInt ndec=2);
158
159 // User choices for list precision (sensible defaults):
160 // (time precision for user interface is fraction of sec)
161 void setPrecision ( const Int precTime=1, const Int precUVDist=0,
162 const Int precAmpl=3, const int precPhase=1,
163 const Int precWeight=0 );
164
165 // List the visibilities, with optional data selection and output
166 // specification.
167 void list (const String& options="",
168 const String& datacolumn="",
169 const String& field="",
170 const String& spw="",
171 const String& antenna="",
172 const String& timerange="",
173 const String& correlation="",
174 const String& scan="",
175 const String& feed="",
176 const String& array="",
177 const String& observation="",
178 const String& uvrange="",
179 const String& average="",
180 const bool showflags=False,
181 const String& msSelect="",
182 const long pagerows=50,
183 const String& listfile="");
184
185 // Set uv-data selection via MSSelection
186 void selectvis(const String& timerange="",
187 const String& spw="",
188 const String& scan="",
189 const String& field="",
190 const String& baseline="",
191 const String& uvrange="",
192 const String& chanmode="none",
193 const Int& nchan=1,
194 const Int& start=0,
195 const Int& step=1,
196 const MRadialVelocity& mStart=MRadialVelocity(),
197 const MRadialVelocity& mStep=MRadialVelocity(),
198 const String& correlation="",
199 const String& array="",
200 const String& observation="",
201 const String& msSelect="");
202
203private:
204
205 // Initialise the listing. initList() does things that need to be done
206 // once per MS: declares and initialises the private MSSelector object,
207 // and gets all the attribute ranges up front.
208 void initList();
209
210 // A preamble of abbreviated MSSummary information.
212
213 // Get the ranges of a fixed set of MS key attributes.
214 void getRanges(const MeasurementSet &ms);
215
216 // Most of the heavy lifting is in here. Get the data records and list
217 // them.
218 void listData(const int pageRows=50, const String listfile="");
219
220 // Column header line for pagination of output.
221 void listColumnHeader(ostream& myout);
222
223 // Setup class polarization information for specified MS.
224 // pols_p holds the polarization names contained in the MS
225 // in the same order that the polarization data are listed in the
226 // main table.
227 void _polarizationSetup(const uInt selPolID);
228
229 // Parse the correlation parameter value; fill indexPols_p to output
230 // selected polarizations. If correlation is empty, all polarizations
231 // are selected.
232 void polarizationParse(String correlation);
233
234 // Calculate column width for a Vector<String>
236
237 // Pointer to the MS
240
241 // Output stream
243
244 // A formatting string for convenience
246
247 // The MSSelector object used in list() etc.
249
250 // List of channels
252 // True if listing multiple channels.
254
255 // Pol counters
257
258 // SpW/Pol info from subtables
261
262 // SpWId map from DDIs:
264 // True if listing multiple spws
266
267 // Polarization indexing variables; for polarization (correlation) selection.
270
271 // Field width variables
276
277 // Order of magnitude control (digits to left of decimal, including sign)
281
282 // Precision control (digits to right of decimal point)
283 // (precTime_p includes hhmmss, so 7 yields hh:mm:ss.s)
287
288 // Page params
291
292 // for assigning desired columns from the ms
293 Vector <String> items_p;
294
295 // Bools for column showing and to identify FLOAT_DATA column of single dish
297
298 // Data selections
299 // data --> "amplitude", "phase"
300 // corrected --> "corrected_amplitude", "corrected_phase"
301 // model --> "model_amplitude", "model_phase"
302 // residual --> "residual_amplitude", "residual_phase"
303 Vector <String> dataColSel;
304
305 // The Record object containing the MSSelector ranges
307
308 // The conversion of the above to a regular Record object
310
311 // Clear the formatting flags
313};
314
315
316} //# NAMESPACE CASACORE - END
317
318#endif
Bool multiSpw_p
True if listing multiple spws.
Definition MSLister.h:265
uInt oTime_p
Order of magnitude control (digits to left of decimal, including sign)
Definition MSLister.h:278
Vector< String > pols_p
SpW/Pol info from subtables.
Definition MSLister.h:259
void listColumnHeader(ostream &myout)
Column header line for pagination of output.
const String dashline_p
A formatting string for convenience.
Definition MSLister.h:245
Bool multiChan_p
True if listing multiple channels.
Definition MSLister.h:253
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:242
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:293
Vector< Int > spwins_p
SpWId map from DDIs:
Definition MSLister.h:263
void setFormat(const uInt ndec=2)
Format for output, ie data display precision.
Matrix< Int > chanList_p
List of channels.
Definition MSLister.h:251
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:248
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:309
Int precTime_p
Precision control (digits to right of decimal point) (precTime_p includes hhmmss, so 7 yields hh:mm:s...
Definition MSLister.h:284
void listHeader()
A preamble of abbreviated MSSummary information.
void clearFlags()
Clear the formatting flags.
uInt wTime_p
Field width variables.
Definition MSLister.h:272
uInt npols_p
Pol counters.
Definition MSLister.h:256
Vector< Int > indexPols_p
Polarization indexing variables; for polarization (correlation) selection.
Definition MSLister.h:268
~MSLister()
Destructor.
Vector< String > dataColSel
Data selections data --> "amplitude", "phase" corrected --> "corrected_amplitude",...
Definition MSLister.h:303
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:289
Bool doFld_p
Bools for column showing and to identify FLOAT_DATA column of single dish.
Definition MSLister.h:296
MeasurementSet * pMSSel_p
Definition MSLister.h:239
Record ranges_p
The Record object containing the MSSelector ranges.
Definition MSLister.h:306
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:260
MeasurementSet * pMS_p
Pointer to the MS.
Definition MSLister.h:238
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:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition ExprNode.h:1933
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40