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 MSMainColumns;
41 class MSDataDescColumns;
42 class MSSpWindowColumns;
43 class MSPolarizationColumns;
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& obsidAndProcAndScanTableName="");
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:
100  static IPosition isFixedShape(const TableDesc& td);
101  static IPosition getShape(const MSDataDescColumns& ddCols,
102  const MSSpWindowColumns& spwCols,
103  const MSPolarizationColumns& polCols,
104  uInt whichShape);
105  void checkShape(const IPosition& otherShape) const;
106  void checkCategories(const MSMainColumns& otherCols) const;
107  Bool checkEphIdInField(const MSFieldColumns& 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  Bool copyGainCurve(const MeasurementSet& otherMS, const Block<uInt>& newAndIndices);
113  Int copyObservation(const MSObservation& otherObs, const Bool remRedunObsId=True);
114  //# by default remove redundant observation table rows
115  Int copyProcessor(const MSProcessor& otherObs, const Bool remRedunProcId=True);
116  //# by default remove redundant processor table rows
118  const MSFeed& otherFeed);
119  Block<uInt> copyState(const MSState& otherState);
122  const MSPolarization& otherPol,
123  const MSDataDescription& otherDD);
124  Bool copySource(const MeasurementSet& otherms);
128  const rownr_t& rowi, const rownr_t& rowj,
129  const Bool dontTestDirection=False,
130  const Bool dontTestTransAndRest=False);
131 
133  const rownr_t& rowi, const rownr_t& rowj);
134 
136  const uInt& rowi, const uInt& rowj);
137 
138 
140 
148  std::map <Int, Int> newSourceIndex_p;
149  std::map <Int, Int> newSourceIndex2_p;
150  std::map <Int, Int> newSPWIndex_p;
151  std::map <Int, Int> newObsIndexA_p;
152  std::map <Int, Int> newObsIndexB_p;
153  std::map <Int, Int> otherObsIdsWithCounterpart_p;
154  std::map <Int, Int> newProcIndexA_p;
155  std::map <Int, Int> newProcIndexB_p;
156  std::map <Int, Int> solSystObjects_p;
157 
165 
166 };
167 
168 template<class T>
169 Bool areEQ(const ScalarColumn<T>& col, rownr_t row_i, rownr_t row_j)
170 {
171  T value_i, value_j;
172  col.get(row_i, value_i);
173  col.get(row_j, value_j);
174  return (value_i == value_j);
175 }
176 
177 template<class T>
178 Bool areEQ(const ArrayColumn<T>& col, rownr_t row_i, rownr_t row_j)
179 {
180  Bool rval(False);
181  Array<T> arr_i;
182  Array<T> arr_j;
183 
184  col.get(row_i, arr_i, True);
185  col.get(row_j, arr_j, True);
186  size_t ni = arr_i.nelements();
187  size_t nj = arr_j.nelements();
188  if( (ni==0 && nj==0) || // no data is regarded as equal
189  allEQ(arr_i, arr_j)){
190  rval = True;
191  }
192  return rval;
193 }
194 
195 inline Int getMapValue (const std::map<Int,Int>& m, Int k)
196 {
197  auto iter = m.find(k);
198  return (iter == m.end() ? -1 : iter->second);
199 }
200 
201 
202 } //# NAMESPACE CASACORE - END
203 
204 #endif
205 
206 
207 
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Definition: ArrayBase.h:103
void get(rownr_t rownr, Array< T > &array, Bool resize=False) const
Get the array value in a particular cell (i.e.
std::map< Int, Int > newProcIndexB_p
Definition: MSConcat.h:155
Bool copyPointing(const MSPointing &otherPoint, const Block< uInt > &newAntIndices)
Bool sourceRowsEquivalent(const MSSourceColumns &sourceCol, const rownr_t &rowi, const rownr_t &rowj, const Bool dontTestDirection=False, const Bool dontTestTransAndRest=False)
void updateModelDataKeywords(MeasurementSet &ms)
std::map< Int, Int > newObsIndexA_p
Definition: MSConcat.h:151
void checkCategories(const MSMainColumns &otherCols) const
void setWeightScale(const Float weightScale)
void checkShape(const IPosition &otherShape) const
std::map< Int, Int > newSourceIndex_p
Definition: MSConcat.h:148
Quantum< Double > itsFreqTol
Definition: MSConcat.h:143
std::map< Int, Int > newSPWIndex_p
Definition: MSConcat.h:150
std::map< Int, Int > otherObsIdsWithCounterpart_p
Definition: MSConcat.h:153
std::map< Int, Int > solSystObjects_p
Definition: MSConcat.h:156
Block< uInt > copyField(const MeasurementSet &otherms)
std::map< Int, Int > newSourceIndex2_p
Definition: MSConcat.h:149
Int copyObservation(const MSObservation &otherObs, const Bool remRedunObsId=True)
Bool itsRespectForFieldName
Definition: MSConcat.h:146
Bool checkEphIdInField(const MSFieldColumns &otherFldCol) const
Block< uInt > copySpwAndPol(const MSSpectralWindow &otherSpw, const MSPolarization &otherPol, const MSDataDescription &otherDD)
Quantum< Double > itsDirTol
Definition: MSConcat.h:144
Block< uInt > copyAntennaAndFeed(const MSAntenna &otherAnt, const MSFeed &otherFeed)
MeasurementSet itsMS
Definition: MSConcat.h:141
Bool copyWeather(const MSWeather &otherWeather, const Block< uInt > &newAndIndices)
Vector< Bool > itsChanReversed
Definition: MSConcat.h:147
static IPosition getShape(const MSDataDescColumns &ddCols, const MSSpWindowColumns &spwCols, const MSPolarizationColumns &polCols, uInt whichShape)
void virtualconcat(MeasurementSet &otherMS, const Bool checkShapeAndCateg=True, const String &obsidAndProcAndScanTableName="")
void concatenate(const MeasurementSet &otherMS, const uInt handling=0, const String &destMSName="")
Int copyProcessor(const MSProcessor &otherObs, const Bool remRedunProcId=True)
Bool copySysCal(const MSSysCal &otherSysCal, const Block< uInt > &newAndIndices)
void setRespectForFieldName(const Bool respectFieldName)
void setTolerance(Quantum< Double > &freqTol, Quantum< Double > &dirTol)
IPosition itsFixedShape
Definition: MSConcat.h:142
Bool procRowsEquivalent(const MSProcessorColumns &procCol, const uInt &rowi, const uInt &rowj)
Bool obsRowsEquivalent(const MSObservationColumns &obsCol, const rownr_t &rowi, const rownr_t &rowj)
Bool copySource(const MeasurementSet &otherms)
Bool copyPointingB(MSPointing &otherPoint, const Block< uInt > &newAntIndices)
static IPosition isFixedShape(const TableDesc &td)
MSConcat(MeasurementSet &ms)
std::map< Int, Int > newObsIndexB_p
Definition: MSConcat.h:152
Float itsWeightScale
Definition: MSConcat.h:145
Bool copyGainCurve(const MeasurementSet &otherMS, const Block< uInt > &newAndIndices)
std::map< Int, Int > newProcIndexA_p
Definition: MSConcat.h:154
Block< uInt > copyState(const MSState &otherState)
void get(rownr_t rownr, T &value) const
Get the data from a particular cell (i.e.
Definition: ScalarColumn.h:137
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
unsigned int uInt
Definition: aipstype.h:51
float Float
Definition: aipstype.h:54
Int getMapValue(const std::map< Int, Int > &m, Int k)
Definition: MSConcat.h:195
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43
Bool areEQ(const ScalarColumn< T > &col, rownr_t row_i, rownr_t row_j)
Definition: MSConcat.h:169
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46