casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Partition.h
Go to the documentation of this file.
1 //# Partition.h: this defines Partition which creates an casacore::MS that is a subset of
2 //# an casacore::MS without any changes to the subtables.
3 //#
4 //# Copyright (C) 2011
5 //# Associated Universities, Inc. Washington DC, USA.
6 //#
7 //# This library is free software; you can redistribute it and/or modify it
8 //# under the terms of the GNU Library General Public License as published by
9 //# the Free Software Foundation; either version 2 of the License, or (at your
10 //# option) any later version.
11 //#
12 //# This library is distributed in the hope that it will be useful, but WITHOUT
13 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 //# License for more details.
16 //#
17 //# You should have received a copy of the GNU Library General Public License
18 //# along with this library; if not, write to the Free Software Foundation,
19 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20 //#
21 //# Correspondence concerning AIPS++ should be addressed as follows:
22 //# Internet email: aips2-request@nrao.edu.
23 //# Postal address: AIPS++ Project Office
24 //# National Radio Astronomy Observatory
25 //# 520 Edgemont Road
26 //# Charlottesville, VA 22903-2475 USA
27 //#
28 //#
29 //# $Id$
34 //#include <msvis/MSVis/VisIterator.h>
35 #include <casa/aips.h>
36 #include <casa/Arrays/Array.h>
37 #include <casa/Arrays/Vector.h>
38 //#include <casa/Utilities/CountedPtr.h>
39 #include <msvis/MSVis/SubMS.h>
40 
41 #ifndef MSVIS_PARTITION_H
42 namespace casacore{
43 
44 template<class T> class ArrayColumn;
45 }
46 
47 namespace casa { //# NAMESPACE CASA - BEGIN
48 
49 #define MSVIS_PARTITION_H
50 
51 // <summary>
52 // Partition makes a subset of an existing casacore::MS without remapping any indices
53 // or resizing any subtables (unlike SubMS).
54 // </summary>
55 
56 // <visibility=export>
57 
58 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
59 // </reviewed>
60 
61 // <prerequisite>
62 // <li> MeasurementSet
63 // <li> SubMS
64 // </prerequisite>
65 //
66 // <etymology>
67 // Partition an MS.
68 // </etymology>
69 //
70 // <synopsis>
71 // The order of operations (as in ms::partition()) is:
72 // ctor
73 // setmsselect
74 // selectTime
75 // makePartition
76 // </synopsis>
77 
78 //casacore::Bool isAllColumns(const casacore::Vector<casacore::MS::PredefinedColumns>& colNames);
79 
80 class Partition
81 {
82 public:
84 
85  // construct from an MS
87 
88  virtual ~Partition();
89 
90  // Change or Set the casacore::MS this casacore::MSSelector refers to.
92 
93  // Select spw and channels for each spw.
94  // It returns true on success and false on failure.
96 
97  //select casacore::Time and time averaging or regridding
98  //void selectTime();
99 
100  //select stuff using msselection syntax ...time is left out
101  // call it separately with timebin
102  casacore::Bool setmsselect(const casacore::String& spw="", const casacore::String& field="",
103  const casacore::String& baseline="", const casacore::String& scan="",
104  const casacore::String& uvrange="", const casacore::String& taql="",
105  const casacore::String& subarray="", const casacore::String& intent="",
106  const casacore::String& obs="");
107 
108  // Select source or field
110 
111  // Select Antennas to split out
113  {
115  antennaids, antennaSel);
116  }
117 
118  // Select array IDs to use.
119  void selectArray(const casacore::String& subarray);
120 
121  //select time parameters
122  void selectTime(casacore::Double timeBin=-1.0, casacore::String timerng="");
123 
124  //void selectSource(casacore::Vector<casacore::String> sourceid);
125 
126  //Method to set if a phase Center rotation is needed
127  //void setPhaseCenter(casacore::Int fieldid, casacore::MDirection& newPhaseCenter);
128 
129  //Method to make the partition.
130  //
131  //TileShape of size 1 can have 2 values [0], and [1] ...these are used in to
132  //determine the tileshape by using MSTileLayout. Otherwise it has to be a
133  //vector size 3 e.g [4, 15, 351] => a tile shape of 4 stokes, 15 channels 351
134  //rows.
135  //
136  // combine sets combine_p. (Columns to ignore while time averaging.)
137  //
140  const casacore::String& combine="");
141 
142  //Method to make a scratch partition and even in memory if posssible
143  //Useful if temporary subselection/averaging is necessary
144  // It'll be in memory if the basic output ms is less than half of
145  // memory reported by casacore::HostInfo unless forced to by user...
147  const casacore::Bool forceInMemory=false);
148  // In this form whichDataCol gets passed to parseColumnNames().
149  virtual casacore::MeasurementSet* makeScratchPartition(const casacore::String& whichDataCol,
150  const casacore::Bool forceInMemory=false);
151 
152  // This sets up a default new ms
153  // Declared static as it can be called directly outside of Partition.
154  // Therefore it is not dependent on any member variable.
156  const casacore::Int nchan, const casacore::Int npol, const casacore::String& telescop,
158  const casacore::Int obstype=0);
159 
160  // Same as above except allowing manual tileshapes
162  const casacore::Int nchan, const casacore::Int npol,
165 
167 private:
168  //method that returns the selected ms (?! - but it's Boolean - RR)
170 
171  // (Sub)table fillers.
174 
175  // casacore::Bool writeDiffSpwShape(const casacore::Vector<casacore::MS::PredefinedColumns>& colNames);
177 
178  // *** Private member functions ***
180  const casacore::MS::PredefinedColumns colName);
182  const casacore::MS::PredefinedColumns colName);
184  const casacore::MS::PredefinedColumns datacol,
185  const casacore::Bool writeToDataCol=false);
187  const casacore::MS::PredefinedColumns datacol,
188  const casacore::Bool writeToDataCol=false);
189 
190  // This method uses VisIter for efficient copy mode data transfer
192  const casacore::Bool writeToDataCol);
193 
194  // Used in a couple of places to estimate how much memory to grab.
196  sizeof(casacore::Complex);}
197 
198  // Read the input, time average it to timeBin_p, and write the output.
200 
201  // Fills mapper[ntok] with a map from dataColumn indices to ArrayColumns in
202  // the output. mapper must have ntok slots!
204  casacore::uInt ntok,
206 
207  // *** Member variables ***
208 
209  // Initialized* by ctors. (Maintain order both here and in ctors.)
210  // * not necessarily to anything useful.
212  casacore::MSMainColumns * msc_p; // columns of msOut_p
214  casacore::Bool antennaSel_p; // Selecting by antenna?
216  casacore::String scanString_p, // Selects scans by #number#. Historically named.
217  intentString_p, // Selects scans by string. scanString_p was taken.
218  obsString_p, // casacore::String for observationID selection.
221  casacore::String combine_p; // Should time averaging not split bins by
222  // scan #, observation, and/or state ID?
223  // Must be lowercase at all times.
224  casacore::Int maxnchan_p, // The maximum # of channels and correlations for each
225  maxncorr_p; // selected DDID. (casacore::Int because NUM_CHAN and NUM_CORR
226  // are casacore::Int instead of uInt.)
227 
228  // Uninitialized by ctors.
230  casacore::Vector<casacore::Int> spw_p; // Selected spw numbers
236 };
237 
238 } //# NAMESPACE CASA - END
239 
240 #endif
241 
casacore::Double timeBin_p
Definition: Partition.h:215
casacore::Bool putDataColumn(casacore::MSColumns &msc, casacore::ArrayColumn< casacore::Complex > &data, const casacore::MS::PredefinedColumns datacol, const casacore::Bool writeToDataCol=false)
casacore::Vector< casacore::Int > fieldid_p
Definition: Partition.h:231
casacore::Bool makePartition(casacore::String &outname, casacore::String &whichDataCol, const casacore::Vector< casacore::Int > &tileShape=casacore::Vector< casacore::Int >(1, 0), const casacore::String &combine="")
void selectSource(casacore::Vector&lt;casacore::String&gt; sourceid);
virtual casacore::MeasurementSet * makeScratchPartition(const casacore::Vector< casacore::MS::PredefinedColumns > &whichDataCols, const casacore::Bool forceInMemory=false)
Method to make a scratch partition and even in memory if posssible Useful if temporary subselection/a...
int Int
Definition: aipstype.h:50
casacore::Bool selectSpw(const casacore::String &spwstr)
Select spw and channels for each spw.
casacore::Vector< casacore::Int > antennaId_p
Definition: Partition.h:233
casacore::Bool setmsselect(const casacore::String &spw="", const casacore::String &field="", const casacore::String &baseline="", const casacore::String &scan="", const casacore::String &uvrange="", const casacore::String &taql="", const casacore::String &subarray="", const casacore::String &intent="", const casacore::String &obs="")
select casacore::Time and time averaging or regridding void selectTime();
casacore::String intentString_p
Definition: Partition.h:216
casacore::Matrix< casacore::Double > selTimeRanges_p
Definition: Partition.h:235
static casacore::Bool pickAntennas(casacore::Vector< casacore::Int > &selected_antennaids, casacore::Vector< casacore::String > &selected_antenna_strs, const casacore::Vector< casacore::Int > &antennaids, const casacore::Vector< casacore::String > &antennaSel)
casacore::String uvrangeString_p
Definition: Partition.h:216
casacore::String timeRange_p
Definition: Partition.h:220
casacore::Bool selectSource(const casacore::Vector< casacore::Int > &fieldid)
Select source or field.
PredefinedColumns
The Main table colums with predefined meaning.
Definition: MSMainEnums.h:65
casacore::Bool getDataColumn(casacore::ArrayColumn< casacore::Complex > &data, const casacore::MS::PredefinedColumns colName)
*** Private member functions ***
casacore::MeasurementSet msOut_p
are casacore::Int instead of uInt.)
Definition: Partition.h:229
casacore::MSMainColumns * msc_p
Definition: Partition.h:212
casacore::String obsString_p
Definition: Partition.h:216
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
void selectArray(const casacore::String &subarray)
Select array IDs to use.
casacore::String corrString_p
Definition: Partition.h:220
casacore::MeasurementSet mssel_p
Definition: Partition.h:211
casacore::Int maxnchan_p
scan #, observation, and/or state ID? Must be lowercase at all times.
Definition: Partition.h:224
Partition makes a subset of an existing casacore::MS without remapping any indices or resizing any su...
Definition: Partition.h:80
casacore::String taqlString_p
Definition: Partition.h:216
void selectTime(casacore::Double timeBin=-1.0, casacore::String timerng="")
select time parameters
casacore::Bool fillMainTable(const casacore::Vector< casacore::MS::PredefinedColumns > &colNames)
casacore::Int maxncorr_p
Definition: Partition.h:224
casacore::ROMSColumns * mscIn_p
Definition: Partition.h:213
existing table
Definition: Table.h:170
static casacore::MeasurementSet * setupMS(const casacore::String &msname, const casacore::MeasurementSet &inms, const casacore::Int nchan, const casacore::Int npol, const casacore::String &telescop, const casacore::Vector< casacore::MS::PredefinedColumns > &colNamesTok, const casacore::Int obstype=0)
This sets up a default new ms Declared static as it can be called directly outside of Partition...
casacore::String combine_p
Definition: Partition.h:221
double Double
Definition: aipstype.h:55
casacore::String scanString_p
Definition: Partition.h:216
A class to provide easy read-only access to MeasurementSet columns.
Definition: MSColumns.h:111
casacore::Bool makeSelection()
method that returns the selected ms (?! - but it&#39;s Boolean - RR)
casacore::MeasurementSet ms_p
*** Member variables ***
Definition: Partition.h:211
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool doTimeAver(const casacore::Vector< casacore::MS::PredefinedColumns > &dataColNames)
Read the input, time average it to timeBin_p, and write the output.
Read and write access to an array table column with arbitrary data type.
Definition: Reweighter.h:48
casacore::Vector< casacore::Int > arrayId_p
Definition: Partition.h:234
void selectAntenna(casacore::Vector< casacore::Int > &antennaids, casacore::Vector< casacore::String > &antennaSel)
Select Antennas to split out.
Definition: Partition.h:112
uInt nrow() const
Get the number of rows.
Definition: Table.h:1201
casacore::Bool copyDataFlagsWtSp(const casacore::Vector< casacore::MS::PredefinedColumns > &colNames, const casacore::Bool writeToDataCol)
This method uses VisIter for efficient copy mode data transfer.
casacore::Double n_bytes()
Used in a couple of places to estimate how much memory to grab.
Definition: Partition.h:195
casacore::String arrayExpr_p
Definition: Partition.h:220
static void getDataColMap(casacore::MSMainColumns *msc, casacore::ArrayColumn< casacore::Complex > *mapper, casacore::uInt ntok, const casacore::Vector< casacore::MS::PredefinedColumns > &colEnums)
Fills mapper[ntok] with a map from dataColumn indices to ArrayColumns in the output.
A Table intended to hold astronomical data (a set of Measurements).
casacore::Vector< casacore::Int > spw_p
Definition: Partition.h:230
Partition(casacore::String &theMS, casacore::Table::TableOption option=casacore::Table::Old)
casacore::Bool fillAccessoryMainCols()
casacore::Bool writeDiffSpwShape(const casacore::Vector&lt;casacore::MS::PredefinedColumns&gt;&amp; colNames); ...
A class for easy read-write access to MeasurementSet main table columns.
A class to provide easy read-write access to MeasurementSet columns.
Definition: MSColumns.h:221
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual ~Partition()
void setMS(casacore::MeasurementSet &ms)
Change or Set the casacore::MS this casacore::MSSelector refers to.
casacore::Vector< casacore::String > antennaSelStr_p
Definition: Partition.h:232
casacore::Bool fillAllTables(const casacore::Vector< casacore::MS::PredefinedColumns > &colNames)
(Sub)table fillers.
void verifyColumns(const casacore::MeasurementSet &ms, const casacore::Vector< casacore::MS::PredefinedColumns > &colNames)
unsigned int uInt
Definition: aipstype.h:51
casacore::Bool antennaSel_p
Definition: Partition.h:214
TableOption
Define the possible options how a table can be opened.
Definition: Table.h:168
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42