casacore
 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 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:
99  MSConcat();
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
117  Block<uInt> copyAntennaAndFeed(const MSAntenna& otherAnt,
118  const MSFeed& otherFeed);
119  Block<uInt> copyState(const MSState& otherState);
120  Block<uInt> copyField(const MeasurementSet& otherms);
122  const MSPolarization& otherPol,
123  const MSDataDescription& otherDD);
124  Bool copySource(const MeasurementSet& otherms);
125  Bool updateSource();
127  Bool sourceRowsEquivalent(const MSSourceColumns& sourceCol,
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 
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:118
A Table intended to hold a MeasurementSet PROCESSOR table.
Definition: MSProcessor.h:77
int Int
Definition: aipstype.h:50
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 get(rownr_t rownr, Array< T > &array, Bool resize=False) const
Get the array value in a particular cell (i.e.
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Definition: ArrayBase.h:103
A class to provide easy access to MSObservation columns.
Definition: MSObsColumns.h:80
std::map< Int, Int > newSourceIndex2_p
Definition: MSConcat.h:149
Block< uInt > copyAntennaAndFeed(const MSAntenna &otherAnt, const MSFeed &otherFeed)
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:146
Quantum< Double > itsFreqTol
Definition: MSConcat.h:143
Bool procRowsEquivalent(const MSProcessorColumns &procCol, const uInt &rowi, const uInt &rowj)
A Table intended to hold a MeasurementSet WEATHER table.
Definition: MSWeather.h:78
Bool copyPointingB(MSPointing &otherPoint, const Block< uInt > &newAntIndices)
static IPosition getShape(const MSDataDescColumns &ddCols, const MSSpWindowColumns &spwCols, const MSPolarizationColumns &polCols, uInt whichShape)
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:150
A Table intended to hold a MeasurementSet SYSCAL table.
Definition: MSSysCal.h:78
void setTolerance(Quantum< Double > &freqTol, Quantum< Double > &dirTol)
A Table intended to hold a MeasurementSet ANTENNA table.
Definition: MSAntenna.h:79
std::map< Int, Int > newProcIndexB_p
Definition: MSConcat.h:155
Block< uInt > copyState(const MSState &otherState)
MeasurementSet itsMS
Definition: MSConcat.h:141
A class to provide easy access to MSField columns.
void checkShape(const IPosition &otherShape) const
A class to provide easy access to MSSource columns.
void setRespectForFieldName(const Bool respectFieldName)
void checkCategories(const MSMainColumns &otherCols) const
Bool sourceRowsEquivalent(const MSSourceColumns &sourceCol, const rownr_t &rowi, const rownr_t &rowj, const Bool dontTestDirection=False, const Bool dontTestTransAndRest=False)
std::map< Int, Int > otherObsIdsWithCounterpart_p
Definition: MSConcat.h:153
IPosition itsFixedShape
Definition: MSConcat.h:142
Int getMapValue(const std::map< Int, Int > &m, Int k)
Definition: MSConcat.h:195
Bool checkEphIdInField(const MSFieldColumns &otherFldCol) const
std::map< Int, Int > newSourceIndex_p
Definition: MSConcat.h:148
A Table intended to hold a MeasurementSet STATE table.
Definition: MSState.h:79
Bool copySysCal(const MSSysCal &otherSysCal, const Block< uInt > &newAndIndices)
Bool copyGainCurve(const MeasurementSet &otherMS, const Block< uInt > &newAndIndices)
A class to provide easy access to MSSpectralWindow columns.
A class to provide easy access to MSProcessor columns.
A Table intended to hold a MeasurementSet POLARIZATION table.
void virtualconcat(MeasurementSet &otherMS, const Bool checkShapeAndCateg=True, const String &obsidAndProcAndScanTableName="")
Quantum< Double > itsDirTol
Definition: MSConcat.h:144
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Int copyProcessor(const MSProcessor &otherObs, const Bool remRedunProcId=True)
Read and write access to an array table column with arbitrary data type.
Definition: CopyRecord.h:48
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 updateModelDataKeywords(MeasurementSet &ms)
Bool areEQ(const ScalarColumn< T > &col, rownr_t row_i, rownr_t row_j)
Definition: MSConcat.h:169
std::map< Int, Int > newObsIndexA_p
Definition: MSConcat.h:151
A Table intended to hold astronomical data (a set of Measurements).
A class to provide easy access to MSPolarization columns.
Definition: MSPolColumns.h:74
std::map< Int, Int > newObsIndexB_p
Definition: MSConcat.h:152
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
static IPosition isFixedShape(const TableDesc &td)
std::map< Int, Int > solSystObjects_p
Definition: MSConcat.h:156
A class for easy access to MeasurementSet main table columns.
A class to provide easy access to MeasurementSet columns.
Definition: MSColumns.h:116
String: the storage and methods of handling collections of characters.
Definition: String.h:225
void get(rownr_t rownr, T &value) const
Get the data from a particular cell (i.e.
Definition: ScalarColumn.h:137
Float itsWeightScale
Definition: MSConcat.h:145
Define the structure of a Casacore table.
Definition: TableDesc.h:190
Int copyObservation(const MSObservation &otherObs, const Bool remRedunObsId=True)
Access to a scalar table column with arbitrary data type.
Definition: CopyRecord.h:47
Bool copyPointing(const MSPointing &otherPoint, const Block< uInt > &newAntIndices)
Bool obsRowsEquivalent(const MSObservationColumns &obsCol, const rownr_t &rowi, const rownr_t &rowj)
Vector< Bool > itsChanReversed
Definition: MSConcat.h:147
const Bool True
Definition: aipstype.h:43
std::map< Int, Int > newProcIndexA_p
Definition: MSConcat.h:154
unsigned int uInt
Definition: aipstype.h:51
A class to provide easy access to MSDataDescription columns.
A Table intended to hold a MeasurementSet SPECTRAL_WINDOW table.