casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef MS_MSCONCAT_H
27#define MS_MSCONCAT_H
28
29#include <casacore/casa/aips.h>
30#include <casacore/ms/MeasurementSets/MSColumns.h>
31#include <casacore/ms/MeasurementSets/MeasurementSet.h>
32#include <casacore/casa/Arrays/IPosition.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36class TableDesc;
37class MSMainColumns;
38class MSDataDescColumns;
39class MSSpWindowColumns;
40class MSPolarizationColumns;
41class MSAntenna;
42class MSDataDescription;
43class MSFeed;
44class MSField;
45class MSPolarization;
46class MSSpectralWindow;
47template <class T> class Block;
48
49// <summary>A class with functions for concatenating MeasurementSets</summary>
50
51// <use visibility=export>
52
53// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
54// </reviewed>
55
56// <prerequisite>
57// </prerequisite>
58//
59// <etymology>
60// </etymology>
61//
62// <synopsis>
63// </synopsis>
64//
65// <example>
66// </example>
67//
68// <motivation>
69// </motivation>
70//
71// <todo asof="yyyy/mm/dd">
72// </todo>
73
74class MSConcat: public MSColumns
75{
76public:
78
80 const Bool checkShapeAndCateg=True,
81 const String& obsidAndProcAndScanTableName="");
82
83 void concatenate(const MeasurementSet& otherMS,
84 const uInt handling=0, //# 0 (default): complete concat of all tables
85 //# 1 : don't concatenate the MAIN table
86 //# 2 : don't concatenate the POINTING table
87 //# 3 : neither concat MAIN nor POINTING table
88 const String& destMSName=""); //# support for virtual concat
89
91 void setWeightScale(const Float weightScale);
92 void setRespectForFieldName(const Bool respectFieldName); //# If True, fields of same direction are not merged
93 //# if their name is different
94
95private:
97 static IPosition isFixedShape(const TableDesc& td);
98 static IPosition getShape(const MSDataDescColumns& ddCols,
99 const MSSpWindowColumns& spwCols,
100 const MSPolarizationColumns& polCols,
101 uInt whichShape);
102 void checkShape(const IPosition& otherShape) const;
103 void checkCategories(const MSMainColumns& otherCols) const;
104 Bool checkEphIdInField(const MSFieldColumns& otherFldCol) const;
105 Bool copyPointing(const MSPointing& otherPoint, const Block<uInt>& newAntIndices);
106 Bool copyPointingB(MSPointing& otherPoint, const Block<uInt>& newAntIndices);
107 Bool copySysCal(const MSSysCal& otherSysCal, const Block<uInt>& newAndIndices);
108 Bool copyWeather(const MSWeather& otherWeather, const Block<uInt>& newAndIndices);
109 Bool copyGainCurve(const MeasurementSet& otherMS, const Block<uInt>& newAndIndices);
110 Bool copyPhaseCal(const MeasurementSet& otherMS, const Block<uInt>& newAndIndices);
111 Bool copyEOP(const MeasurementSet& otherMS);
112 Int copyObservation(const MSObservation& otherObs, const Bool remRedunObsId=True);
113 //# by default remove redundant observation table rows
114 Int copyProcessor(const MSProcessor& otherObs, const Bool remRedunProcId=True);
115 //# by default remove redundant processor table rows
117 const MSFeed& otherFeed);
118 Block<uInt> copyState(const MSState& otherState);
121 const MSPolarization& otherPol,
122 const MSDataDescription& otherDD);
127 const rownr_t& rowi, const rownr_t& rowj,
128 const Bool dontTestDirection=False,
129 const Bool dontTestTransAndRest=False);
130
132 const rownr_t& rowi, const rownr_t& rowj);
133
135 const uInt& rowi, const uInt& rowj);
136
137
139
147 std::map <Int, Int> newSourceIndex_p;
148 std::map <Int, Int> newSourceIndex2_p;
149 std::map <Int, Int> newSPWIndex_p;
150 std::map <Int, Int> newObsIndexA_p;
151 std::map <Int, Int> newObsIndexB_p;
152 std::map <Int, Int> otherObsIdsWithCounterpart_p;
153 std::map <Int, Int> newProcIndexA_p;
154 std::map <Int, Int> newProcIndexB_p;
155 std::map <Int, Int> solSystObjects_p;
156
164
165};
166
167template<class T>
168Bool areEQ(const ScalarColumn<T>& col, rownr_t row_i, rownr_t row_j)
169{
170 T value_i, value_j;
171 col.get(row_i, value_i);
172 col.get(row_j, value_j);
173 return (value_i == value_j);
174}
175
176template<class T>
177Bool areEQ(const ArrayColumn<T>& col, rownr_t row_i, rownr_t row_j)
178{
179 Bool rval(False);
180 Array<T> arr_i;
181 Array<T> arr_j;
182
183 col.get(row_i, arr_i, True);
184 col.get(row_j, arr_j, True);
185 size_t ni = arr_i.nelements();
186 size_t nj = arr_j.nelements();
187 if( (ni==0 && nj==0) || // no data is regarded as equal
188 allEQ(arr_i, arr_j)){
189 rval = True;
190 }
191 return rval;
192}
193
194inline Int getMapValue (const std::map<Int,Int>& m, Int k)
195{
196 auto iter = m.find(k);
197 return (iter == m.end() ? -1 : iter->second);
198}
199
200
201} //# NAMESPACE CASACORE - END
202
203#endif
204
205
206
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Definition ArrayBase.h:101
void get(rownr_t rownr, Array< T > &array, Bool resize=False) const
Get the array value in a particular cell (i.e.
simple 1-D array
Definition Block.h:198
std::map< Int, Int > newProcIndexB_p
Definition MSConcat.h:154
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:150
void checkCategories(const MSMainColumns &otherCols) const
Block< uInt > copyField(const MeasurementSet &otherms)
void setWeightScale(const Float weightScale)
void checkShape(const IPosition &otherShape) const
Block< uInt > copySpwAndPol(const MSSpectralWindow &otherSpw, const MSPolarization &otherPol, const MSDataDescription &otherDD)
std::map< Int, Int > newSourceIndex_p
Definition MSConcat.h:147
Quantum< Double > itsFreqTol
Definition MSConcat.h:142
std::map< Int, Int > newSPWIndex_p
Definition MSConcat.h:149
std::map< Int, Int > otherObsIdsWithCounterpart_p
Definition MSConcat.h:152
std::map< Int, Int > solSystObjects_p
Definition MSConcat.h:155
std::map< Int, Int > newSourceIndex2_p
Definition MSConcat.h:148
Int copyObservation(const MSObservation &otherObs, const Bool remRedunObsId=True)
Bool itsRespectForFieldName
Definition MSConcat.h:145
Bool checkEphIdInField(const MSFieldColumns &otherFldCol) const
Block< uInt > copyState(const MSState &otherState)
Quantum< Double > itsDirTol
Definition MSConcat.h:143
MeasurementSet itsMS
Definition MSConcat.h:140
Bool copyWeather(const MSWeather &otherWeather, const Block< uInt > &newAndIndices)
Vector< Bool > itsChanReversed
Definition MSConcat.h:146
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="")
Bool copyPhaseCal(const MeasurementSet &otherMS, const Block< uInt > &newAndIndices)
Int copyProcessor(const MSProcessor &otherObs, const Bool remRedunProcId=True)
Block< uInt > copyAntennaAndFeed(const MSAntenna &otherAnt, const MSFeed &otherFeed)
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:141
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:151
Bool copyEOP(const MeasurementSet &otherMS)
Bool copyGainCurve(const MeasurementSet &otherMS, const Block< uInt > &newAndIndices)
std::map< Int, Int > newProcIndexA_p
Definition MSConcat.h:153
void get(rownr_t rownr, T &value) const
Get the data from a particular cell (i.e.
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
float Float
Definition aipstype.h:52
Int getMapValue(const std::map< Int, Int > &m, Int k)
Definition MSConcat.h:194
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
Bool areEQ(const ScalarColumn< T > &col, rownr_t row_i, rownr_t row_j)
Definition MSConcat.h:168
uInt64 rownr_t
Define the type of a row number in a table.
Definition aipsxtype.h:44