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