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