casacore
MSConcat.h
Go to the documentation of this file.
1 //# MSConcat.h: A class for concatenating MeasurementSets.
2 //# Copyright (C) 2000,2002,2003
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_MSCONCAT_H
30 #define MS_MSCONCAT_H
31 
32 #include <casacore/casa/aips.h>
33 #include <casacore/ms/MeasurementSets/MSColumns.h>
34 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
35 #include <casacore/casa/Arrays/IPosition.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 class TableDesc;
40 class ROMSMainColumns;
41 class ROMSDataDescColumns;
42 class ROMSSpWindowColumns;
43 class ROMSPolarizationColumns;
44 class MSAntenna;
45 class MSDataDescription;
46 class MSFeed;
47 class MSField;
48 class MSPolarization;
49 class MSSpectralWindow;
50 template <class T> class Block;
51 
52 // <summary>A class with functions for concatenating MeasurementSets</summary>
53 
54 // <use visibility=export>
55 
56 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
57 // </reviewed>
58 
59 // <prerequisite>
60 // <li> SomeClass
61 // <li> SomeOtherClass
62 // <li> some concept
63 // </prerequisite>
64 //
65 // <etymology>
66 // </etymology>
67 //
68 // <synopsis>
69 // </synopsis>
70 //
71 // <example>
72 // </example>
73 //
74 // <motivation>
75 // </motivation>
76 //
77 // <templating arg=T>
78 // <li>
79 // <li>
80 // </templating>
81 //
82 // <thrown>
83 // <li>
84 // <li>
85 // </thrown>
86 //
87 // <todo asof="yyyy/mm/dd">
88 // <li> add this feature
89 // <li> fix this bug
90 // <li> start discussion of this possible extension
91 // </todo>
92 
93 class MSConcat: public MSColumns
94 {
95 public:
97 
98  void virtualconcat(MeasurementSet& otherMS,
99  const Bool checkShapeAndCateg=True,
100  const String& obsidAndScanTableName="");
101 
102  void concatenate(const MeasurementSet& otherMS,
103  const uInt handling=0, // 0 (default): complete concat of all tables
104  // 1 : don't concatenate the MAIN table
105  // 2 : don't concatenate the POINTING table
106  // 3 : neither concat MAIN nor POINTING table
107  const String& destMSName=""); // support for virtual concat
108 
109  void setTolerance(Quantum<Double>& freqTol, Quantum<Double>& dirTol);
110  void setWeightScale(const Float weightScale);
111  void setRespectForFieldName(const Bool respectFieldName); // If True, fields of same direction are not merged
112  // if their name is different
113 
114 private:
115  MSConcat();
116  static IPosition isFixedShape(const TableDesc& td);
117  static IPosition getShape(const ROMSDataDescColumns& ddCols,
118  const ROMSSpWindowColumns& spwCols,
119  const ROMSPolarizationColumns& polCols,
120  uInt whichShape);
121  void checkShape(const IPosition& otherShape) const;
122  void checkCategories(const ROMSMainColumns& otherCols) const;
123  Bool checkEphIdInField(const ROMSFieldColumns& otherFldCol) const;
124  Bool copyPointing(const MSPointing& otherPoint, const Block<uInt>& newAntIndices);
125  Bool copyPointingB(MSPointing& otherPoint, const Block<uInt>& newAntIndices);
126  Bool copySysCal(const MSSysCal& otherSysCal, const Block<uInt>& newAndIndices);
127  Bool copyWeather(const MSWeather& otherWeather, const Block<uInt>& newAndIndices);
128  Int copyObservation(const MSObservation& otherObs, const Bool remRedunObsId=True);
129  // by default remove redundant observation table rows
130  Block<uInt> copyAntennaAndFeed(const MSAntenna& otherAnt,
131  const MSFeed& otherFeed);
132  Block<uInt> copyState(const MSState& otherState);
133  Block<uInt> copyField(const MeasurementSet& otherms);
135  const MSPolarization& otherPol,
136  const MSDataDescription& otherDD);
137  Bool copySource(const MeasurementSet& otherms);
138  Bool updateSource();
140  Bool sourceRowsEquivalent(const MSSourceColumns& sourceCol,
141  const uInt& rowi, const uInt& rowj,
142  const Bool dontTestDirection=False,
143  const Bool dontTestTransAndRest=False);
144 
146  const uInt& rowi, const uInt& rowj);
147 
148 
150 
165 
171 
172 };
173 
174 template<class T>
175 Bool areEQ(const ROScalarColumn<T>& col, uInt row_i, uInt row_j)
176 {
177  T value_i, value_j;
178  col.get(row_i, value_i);
179  col.get(row_j, value_j);
180  return (value_i == value_j);
181 }
182 
183 template<class T>
184 Bool areEQ(const ROArrayColumn<T>& col, uInt row_i, uInt row_j)
185 {
186  Bool rval(False);
187  Array<T> arr_i;
188  Array<T> arr_j;
189 
190  col.get(row_i, arr_i, True);
191  col.get(row_j, arr_j, True);
192  Int ni = arr_i.nelements();
193  Int nj = arr_j.nelements();
194  if( (ni==0 && nj==0) || // no data is regarded as equal
195  allEQ(arr_i, arr_j)){
196  rval = True;
197  }
198  return rval;
199 }
200 
201 
202 
203 } //# NAMESPACE CASACORE - END
204 
205 #endif
206 
207 
208 
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
SimpleOrderedMap< Int, Int > solSystObjects_p
Definition: MSConcat.h:164
SimpleOrderedMap< Int, Int > otherObsIdsWithCounterpart_p
Definition: MSConcat.h:163
int Int
Definition: aipstype.h:50
Bool checkEphIdInField(const ROMSFieldColumns &otherFldCol) const
void concatenate(const MeasurementSet &otherMS, const uInt handling=0, const String &destMSName="")
A Table intended to hold a MeasurementSet OBSERVATION table.
Definition: MSObservation.h:78
void checkShape(const IPosition &otherShape) const
A class to provide easy read-write access to MSObservation columns.
Definition: MSObsColumns.h:181
Block< uInt > copyAntennaAndFeed(const MSAntenna &otherAnt, const MSFeed &otherFeed)
by default remove redundant observation table rows
A class to provide easy access to MSField columns.
A Table intended to hold a MeasurementSet POINTING table.
Definition: MSPointing.h:78
A Table intended to hold a MeasurementSet DATADESCRIPTION table.
Bool itsRespectForFieldName
Definition: MSConcat.h:156
Quantum< Double > itsFreqTol
Definition: MSConcat.h:153
A Table intended to hold a MeasurementSet WEATHER table.
Definition: MSWeather.h:78
Bool areEQ(const ROScalarColumn< T > &col, uInt row_i, uInt row_j)
Definition: MSConcat.h:175
Bool copyPointingB(MSPointing &otherPoint, const Block< uInt > &newAntIndices)
SimpleOrderedMap< Int, Int > newObsIndexB_p
Definition: MSConcat.h:162
Bool copySource(const MeasurementSet &otherms)
A Table intended to hold a MeasurementSet FEED table.
Definition: MSFeed.h:78
Block< uInt > copyField(const MeasurementSet &otherms)
SimpleOrderedMap< Int, Int > newSPWIndex_p
Definition: MSConcat.h:160
A Table intended to hold a MeasurementSet SYSCAL table.
Definition: MSSysCal.h:78
A class to provide easy read-only access to MSASpectralWindow columns.
void setTolerance(Quantum< Double > &freqTol, Quantum< Double > &dirTol)
A Table intended to hold a MeasurementSet ANTENNA table.
Definition: MSAntenna.h:79
Block< uInt > copyState(const MSState &otherState)
MeasurementSet itsMS
Definition: MSConcat.h:151
A class to provide easy read-write access to MSSource columns.
void setRespectForFieldName(const Bool respectFieldName)
IPosition itsFixedShape
Definition: MSConcat.h:152
SimpleOrderedMap< Int, Int > newObsIndexA_p
Definition: MSConcat.h:161
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Definition: ArrayBase.h:99
A Table intended to hold a MeasurementSet STATE table.
Definition: MSState.h:79
static IPosition getShape(const ROMSDataDescColumns &ddCols, const ROMSSpWindowColumns &spwCols, const ROMSPolarizationColumns &polCols, uInt whichShape)
Bool copySysCal(const MSSysCal &otherSysCal, const Block< uInt > &newAndIndices)
Bool sourceRowsEquivalent(const MSSourceColumns &sourceCol, const uInt &rowi, const uInt &rowj, const Bool dontTestDirection=False, const Bool dontTestTransAndRest=False)
A Table intended to hold a MeasurementSet POLARIZATION table.
A class to provide easy read-only access to MSDataDesc columns.
Quantum< Double > itsDirTol
Definition: MSConcat.h:154
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A class with functions for concatenating MeasurementSets.
Definition: MSConcat.h:93
Bool copyWeather(const MSWeather &otherWeather, const Block< uInt > &newAndIndices)
void setWeightScale(const Float weightScale)
void checkCategories(const ROMSMainColumns &otherCols) const
float Float
Definition: aipstype.h:54
const Bool False
Definition: aipstype.h:44
Block< uInt > copySpwAndPol(const MSSpectralWindow &otherSpw, const MSPolarization &otherPol, const MSDataDescription &otherDD)
void virtualconcat(MeasurementSet &otherMS, const Bool checkShapeAndCateg=True, const String &obsidAndScanTableName="")
void updateModelDataKeywords(MeasurementSet &ms)
template <class T, class U> class vector;
Definition: Array.h:169
A Table intended to hold astronomical data (a set of Measurements).
MSConcat()
if their name is different
static IPosition isFixedShape(const TableDesc &td)
A class to provide easy read-only access to MSPolarization columns.
Definition: MSPolColumns.h:75
SimpleOrderedMap< Int, Int > newSourceIndex_p
Definition: MSConcat.h:158
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
Float itsWeightScale
Definition: MSConcat.h:155
Define the structure of a Casacore table.
Definition: TableDesc.h:186
Int copyObservation(const MSObservation &otherObs, const Bool remRedunObsId=True)
Bool copyPointing(const MSPointing &otherPoint, const Block< uInt > &newAntIndices)
Vector< Bool > itsChanReversed
Definition: MSConcat.h:157
const Bool True
Definition: aipstype.h:43
this file contains all the compiler specific defines
Definition: mainpage.dox:28
Bool obsRowsEquivalent(const MSObservationColumns &obsCol, const uInt &rowi, const uInt &rowj)
A class for easy read-only access to MeasurementSet main table columns.
SimpleOrderedMap< Int, Int > newSourceIndex2_p
Definition: MSConcat.h:159
unsigned int uInt
Definition: aipstype.h:51
A Table intended to hold a MeasurementSet SPECTRAL_WINDOW table.