casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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 // </prerequisite>
61 //
62 // <etymology>
63 // </etymology>
64 //
65 // <synopsis>
66 // </synopsis>
67 //
68 // <example>
69 // </example>
70 //
71 // <motivation>
72 // </motivation>
73 //
74 // <todo asof="yyyy/mm/dd">
75 // </todo>
76 
77 class MSConcat: public MSColumns
78 {
79 public:
81 
82  void virtualconcat(MeasurementSet& otherMS,
83  const Bool checkShapeAndCateg=True,
84  const String& obsidAndScanTableName="");
85 
86  void concatenate(const MeasurementSet& otherMS,
87  const uInt handling=0, //# 0 (default): complete concat of all tables
88  //# 1 : don't concatenate the MAIN table
89  //# 2 : don't concatenate the POINTING table
90  //# 3 : neither concat MAIN nor POINTING table
91  const String& destMSName=""); //# support for virtual concat
92 
93  void setTolerance(Quantum<Double>& freqTol, Quantum<Double>& dirTol);
94  void setWeightScale(const Float weightScale);
95  void setRespectForFieldName(const Bool respectFieldName); //# If True, fields of same direction are not merged
96  //# if their name is different
97 
98 private:
99  MSConcat();
100  static IPosition isFixedShape(const TableDesc& td);
101  static IPosition getShape(const ROMSDataDescColumns& ddCols,
102  const ROMSSpWindowColumns& spwCols,
103  const ROMSPolarizationColumns& polCols,
104  uInt whichShape);
105  void checkShape(const IPosition& otherShape) const;
106  void checkCategories(const ROMSMainColumns& otherCols) const;
107  Bool checkEphIdInField(const ROMSFieldColumns& otherFldCol) const;
108  Bool copyPointing(const MSPointing& otherPoint, const Block<uInt>& newAntIndices);
109  Bool copyPointingB(MSPointing& otherPoint, const Block<uInt>& newAntIndices);
110  Bool copySysCal(const MSSysCal& otherSysCal, const Block<uInt>& newAndIndices);
111  Bool copyWeather(const MSWeather& otherWeather, const Block<uInt>& newAndIndices);
112  Int copyObservation(const MSObservation& otherObs, const Bool remRedunObsId=True);
113  //# by default remove redundant observation table rows
114  Block<uInt> copyAntennaAndFeed(const MSAntenna& otherAnt,
115  const MSFeed& otherFeed);
116  Block<uInt> copyState(const MSState& otherState);
117  Block<uInt> copyField(const MeasurementSet& otherms);
119  const MSPolarization& otherPol,
120  const MSDataDescription& otherDD);
121  Bool copySource(const MeasurementSet& otherms);
122  Bool updateSource();
124  Bool sourceRowsEquivalent(const MSSourceColumns& sourceCol,
125  const uInt& rowi, const uInt& rowj,
126  const Bool dontTestDirection=False,
127  const Bool dontTestTransAndRest=False);
128 
130  const uInt& rowi, const uInt& rowj);
131 
132 
134 
142  std::map <Int, Int> newSourceIndex_p;
143  std::map <Int, Int> newSourceIndex2_p;
144  std::map <Int, Int> newSPWIndex_p;
145  std::map <Int, Int> newObsIndexA_p;
146  std::map <Int, Int> newObsIndexB_p;
147  std::map <Int, Int> otherObsIdsWithCounterpart_p;
148  std::map <Int, Int> solSystObjects_p;
149 
155 
156 };
157 
158 template<class T>
159 Bool areEQ(const ROScalarColumn<T>& col, uInt row_i, uInt row_j)
160 {
161  T value_i, value_j;
162  col.get(row_i, value_i);
163  col.get(row_j, value_j);
164  return (value_i == value_j);
165 }
166 
167 template<class T>
168 Bool areEQ(const ROArrayColumn<T>& col, uInt row_i, uInt row_j)
169 {
170  Bool rval(False);
171  Array<T> arr_i;
172  Array<T> arr_j;
173 
174  col.get(row_i, arr_i, True);
175  col.get(row_j, arr_j, True);
176  Int ni = arr_i.nelements();
177  Int nj = arr_j.nelements();
178  if( (ni==0 && nj==0) || // no data is regarded as equal
179  allEQ(arr_i, arr_j)){
180  rval = True;
181  }
182  return rval;
183 }
184 
185 inline Int getMapValue (const std::map<Int,Int>& m, Int k)
186 {
187  auto iter = m.find(k);
188  return (iter == m.end() ? -1 : iter->second);
189 }
190 
191 
192 } //# NAMESPACE CASACORE - END
193 
194 #endif
195 
196 
197 
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
int Int
Definition: aipstype.h:50
void checkCategories(const ROMSMainColumns &otherCols) 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
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Definition: ArrayBase.h:99
A class to provide easy read-write access to MSObservation columns.
Definition: MSObsColumns.h:181
std::map< Int, Int > newSourceIndex2_p
Definition: MSConcat.h:143
Block< uInt > copyAntennaAndFeed(const MSAntenna &otherAnt, const MSFeed &otherFeed)
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:140
Quantum< Double > itsFreqTol
Definition: MSConcat.h:137
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:159
Bool copyPointingB(MSPointing &otherPoint, const Block< uInt > &newAntIndices)
Bool copySource(const MeasurementSet &otherms)
A Table intended to hold a MeasurementSet FEED table.
Definition: MSFeed.h:78
Block< uInt > copyField(const MeasurementSet &otherms)
std::map< Int, Int > newSPWIndex_p
Definition: MSConcat.h:144
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:135
Bool checkEphIdInField(const ROMSFieldColumns &otherFldCol) const
void checkShape(const IPosition &otherShape) const
A class to provide easy read-write access to MSSource columns.
void setRespectForFieldName(const Bool respectFieldName)
std::map< Int, Int > otherObsIdsWithCounterpart_p
Definition: MSConcat.h:147
IPosition itsFixedShape
Definition: MSConcat.h:136
Int getMapValue(const std::map< Int, Int > &m, Int k)
Definition: MSConcat.h:185
std::map< Int, Int > newSourceIndex_p
Definition: MSConcat.h:142
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:138
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A class with functions for concatenating MeasurementSets.
Definition: MSConcat.h:77
Bool copyWeather(const MSWeather &otherWeather, const Block< uInt > &newAndIndices)
void setWeightScale(const Float weightScale)
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 &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
std::map< Int, Int > newObsIndexA_p
Definition: MSConcat.h:145
A Table intended to hold astronomical data (a set of Measurements).
std::map< Int, Int > newObsIndexB_p
Definition: MSConcat.h:146
static IPosition isFixedShape(const TableDesc &td)
A class to provide easy read-only access to MSPolarization columns.
Definition: MSPolColumns.h:75
std::map< Int, Int > solSystObjects_p
Definition: MSConcat.h:148
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:139
Define the structure of a Casacore table.
Definition: TableDesc.h:187
Int copyObservation(const MSObservation &otherObs, const Bool remRedunObsId=True)
Bool copyPointing(const MSPointing &otherPoint, const Block< uInt > &newAntIndices)
Vector< Bool > itsChanReversed
Definition: MSConcat.h:141
const Bool True
Definition: aipstype.h:43
Bool obsRowsEquivalent(const MSObservationColumns &obsCol, const uInt &rowi, const uInt &rowj)
A class for easy read-only access to MeasurementSet main table columns.
unsigned int uInt
Definition: aipstype.h:51
A Table intended to hold a MeasurementSet SPECTRAL_WINDOW table.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42