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