casacore
Loading...
Searching...
No Matches
MSRange.h
Go to the documentation of this file.
1//# MSRange.h: this defines MSRange, which determines ranges of ms values
2//# Copyright (C) 1997,1998,1999,2000,2001
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_MSRANGE_H
27#define MS_MSRANGE_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/casa/Arrays/Vector.h>
31#include <casacore/ms/MeasurementSets/MeasurementSet.h>
32#include <casacore/ms/MSSel/MSSelectionKeywords.h>
33namespace casacore { //# NAMESPACE CASACORE - BEGIN
34
35template <class T> class ArrayColumn;
36template <class T> class ScalarColumn;
37class Record;
38class MSSelector;
39// <summary>
40// MSRange determines ranges of values in a MeasurementSet
41// </summary>
42
43// <use visibility=export>
44
45// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
46// </reviewed>
47
48// <prerequisite>
49// <li> MeasurementSet
50// <li> Record
51// </prerequisite>
52//
53// <etymology>
54// MSRange is a class that determines ranges of values in an MS
55// </etymology>
56//
57// <synopsis>
58// This class is used to determine the range of values present for
59// the various columns in a MeasurementSet.
60// This class is initialized from a MeasurementSet. If the MS contains more
61// than one DATA_DESC_ID, it can be preselected on this to allow
62// a consistent set of frequencies to be returned.
63// The ms DO provides access to this class from glish and GUIs.
64//
65// <example> <srcblock>
66// MSRange myRange(myMS);
67// Vector<String> items(3);
68// // fill in some fields
69// items(0)="field_id";
70// items(1)="time";
71// items(2)="data_desc_id";
72// // get the range of values for the items specified
73// cout << myRange.range(items)<<endl;
74// // sample output: range=[field_id=[0,1,2],time=[4.5e9, 4.51e9],
75// // data_desc_id=[0,1,2]];
76// // Now preselect on data_desc_id
77// MSSelector mss(myMS);
78// Vector<Int> dd(2); dd(0)=1; dd(1)=2;
79// mss.selectinit(0,dd); // select data desc ids 1 and 2
80// MSRange r2(mss);
81// items(2)="amplitude";
82// cout<< r2.range(items)<<endl;
83// // sample output: [field_id=[0,1,2],time=[4.5e9, 4.51e9],
84// // amplitude=[0.00132,1.543]]
85// </srcblock></example>
86// </synopsis>
87//
88// <motivation>
89// Finding out the range of values in a column is often needed before a
90// sensible selection of data can be made. This class, formerly part of
91// MSSelector, separates out this functionality.
92// </motivation>
93//
94// <thrown>
95// <li>
96// <li>
97// </thrown>
98//
99// <todo asof="1998/11/25">
100// <li> maybe add channel selection and polarization conversion
101// </todo>
102
104{
105public:
106 enum {
107 // spectral window selection and shapes have not been checked
109 // multiple spectral windows with varying shapes
111 // multiple spectral windows with same shape
112 ALL = -1
113 };
114
115 // Default constructor, only useful to assign to.
117
118 // Construct from an MS.
119 explicit MSRange(const MeasurementSet& ms);
120
121 // construct from an MSSelector, if this constructor is used, the data
122 // will be channel selected and polarization converted as specified in
123 // the MSSelector object, and the current selection is used in the range.
124 explicit MSRange(const MSSelector& msSel);
125
126 // Copy constructor
127 MSRange(const MSRange& other);
128
129 // Assignment
130 MSRange& operator=(const MSRange& other);
131
132 // Return the range of values for each of the items specified in
133 // the record. For index-like items a list of values is returned,
134 // for non-index items the minimum and maximum are returned.
135 // Items with varying array shape will not be returned by this function (i.e.
136 // you may need to preselect the MS passed to MSRange).
137 // See the enum description in MSSelector for the list of supported items.
138 // Use the data flags if useFlags is True.
139 // Correct for one-based indexing if oneBased is True.
141 Bool useFlags=True,
142 Bool OneBased=False);
143
144 // Same as previous function, with Vector of MSS::Field keys instead
145 // of Strings
146 Record range(const Vector<Int>& items,
147 Bool useFlags=True,
148 Bool OneBased=False);
149
150 // Similar to above, with a single enum, for convenience
152 Bool useFlags=True);
153
154 // Set the block size (in Mbytes) to use when reading the data column.
155 // The default is 10 MB. Actual memory used is higher due to
156 // temporaries and caching.
157 void setBlockSize(Int blockSize=10);
158
159protected:
160
161 // check the data description selection (one or more with same shape, or
162 // varying shape)
164
165 // get the range of a ScalarColumn<Int>, correct for 1-based
166 // indexing if oneBased is True, and add to out record.
167 void scalarRange(Record& out, const String& item,
168 const ScalarColumn<Int>& id, Bool oneBased);
169
170 // get the range of a ScalarColumn<Int>
172
173 // get the minimum and maximum of a Complex data column, after
174 // application of some function to convert to Float (e.g., real,
175 // amplitude,...). This function reads the data in blocks of
176 // size blockSize, as set by the setBlockSize function.
177 void minMax(Matrix<Float>& minmax,
178 const Vector<Bool>& funcSel,
179 const ArrayColumn<Complex>& data1,
180 const ArrayColumn<Complex>& data2,
181 const ArrayColumn<Bool>& flag,
182 Int dataType,
183 Bool useFlags);
184
185 // get the minimum and maximum of a Float data column
186 // This function reads the data in blocks of
187 // size blockSize, as set by the setBlockSize function.
188 void minMax(Float& mini, Float& maxi,
189 const ArrayColumn<Float>& data,
190 const ArrayColumn<Bool>& flag,
191 Bool useFlags);
192
193 // Get the range of interferometer numbers given the antenna1 and antenna2
194 // columns.
196 const ScalarColumn<Int>& ant2);
197
198private:
199 // The function types
201
202 // The data types
204
205 MeasurementSet ms_p; // the original ms
212};
213
214
215} //# NAMESPACE CASACORE - END
216
217#endif
218
219
MeasurementSet ms_p
Definition MSRange.h:205
Vector< Int > ifrNumbers(const ScalarColumn< Int > &ant1, const ScalarColumn< Int > &ant2)
Get the range of interferometer numbers given the antenna1 and antenna2 columns.
void scalarRange(Record &out, const String &item, const ScalarColumn< Int > &id, Bool oneBased)
get the range of a ScalarColumn<Int>, correct for 1-based indexing if oneBased is True,...
MSRange & operator=(const MSRange &other)
Assignment.
Vector< Int > scalarRange(const ScalarColumn< Int > &id)
get the range of a ScalarColumn<Int>
void minMax(Matrix< Float > &minmax, const Vector< Bool > &funcSel, const ArrayColumn< Complex > &data1, const ArrayColumn< Complex > &data2, const ArrayColumn< Bool > &flag, Int dataType, Bool useFlags)
get the minimum and maximum of a Complex data column, after application of some function to convert t...
MSRange(const MSSelector &msSel)
construct from an MSSelector, if this constructor is used, the data will be channel selected and pola...
Vector< Int > ddId_p
Definition MSRange.h:207
const MSSelector * sel_p
Definition MSRange.h:211
Vector< uInt > spwId_p
Definition MSRange.h:208
void minMax(Float &mini, Float &maxi, const ArrayColumn< Float > &data, const ArrayColumn< Bool > &flag, Bool useFlags)
get the minimum and maximum of a Float data column This function reads the data in blocks of size blo...
MSRange()
Default constructor, only useful to assign to.
Record range(const Vector< Int > &items, Bool useFlags=True, Bool OneBased=False)
Same as previous function, with Vector of MSS::Field keys instead of Strings.
Vector< uInt > polId_p
Definition MSRange.h:209
@ UNCHECKED
spectral window selection and shapes have not been checked
Definition MSRange.h:108
@ ALL
multiple spectral windows with same shape
Definition MSRange.h:112
@ UNSELECTED
multiple spectral windows with varying shapes
Definition MSRange.h:110
MSRange(const MeasurementSet &ms)
Construct from an MS.
Record range(const Vector< String > &items, Bool useFlags=True, Bool OneBased=False)
Return the range of values for each of the items specified in the record.
Record range(MSS::Field item, Bool useFlags=True)
Similar to above, with a single enum, for convenience.
void setBlockSize(Int blockSize=10)
Set the block size (in Mbytes) to use when reading the data column.
Bool checkShapes()
check the data description selection (one or more with same shape, or varying shape)
MSRange(const MSRange &other)
Copy constructor.
Field
The fields in the MS for which selection and range operations are defined.
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
float Float
Definition aipstype.h:52
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41