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& 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 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  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 ScalarColumn<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 ArrayColumn<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 
casacore::MSConcat::newSourceIndex_p
std::map< Int, Int > newSourceIndex_p
Definition: MSConcat.h:142
casacore::MSState
A Table intended to hold a MeasurementSet STATE table.
Definition: MSState.h:79
casacore::TableDesc
Define the structure of a Casacore table.
Definition: TableDesc.h:187
casacore::MSConcat::copySysCal
Bool copySysCal(const MSSysCal &otherSysCal, const Block< uInt > &newAndIndices)
casacore::MSSpWindowColumns
A class to provide easy access to MSSpectralWindow columns.
Definition: MSSpWindowColumns.h:82
casacore::IPosition
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
casacore::MSConcat
A class with functions for concatenating MeasurementSets.
Definition: MSConcat.h:77
casacore::MSConcat::MSConcat
MSConcat()
casacore::MSConcat::obsRowsEquivalent
Bool obsRowsEquivalent(const MSObservationColumns &obsCol, const uInt &rowi, const uInt &rowj)
casacore::MSConcat::itsFreqTol
Quantum< Double > itsFreqTol
Definition: MSConcat.h:137
casacore::MSConcat::isFixedShape
static IPosition isFixedShape(const TableDesc &td)
casacore::MSConcat::updateModelDataKeywords
void updateModelDataKeywords(MeasurementSet &ms)
casacore::ArrayBase::nelements
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Definition: ArrayBase.h:99
casacore::MSConcat::itsChanReversed
Vector< Bool > itsChanReversed
Definition: MSConcat.h:141
casacore::MSConcat::doObsA_p
Bool doObsA_p
Definition: MSConcat.h:153
casacore::MSConcat::updateSource
Bool updateSource()
casacore::MSWeather
A Table intended to hold a MeasurementSet WEATHER table.
Definition: MSWeather.h:78
casacore::MSConcat::copyWeather
Bool copyWeather(const MSWeather &otherWeather, const Block< uInt > &newAndIndices)
casacore::ScalarColumn
Access to a scalar table column with arbitrary data type.
Definition: CopyRecord.h:47
casacore::MSConcat::newObsIndexA_p
std::map< Int, Int > newObsIndexA_p
Definition: MSConcat.h:145
casacore::MSConcat::checkShape
void checkShape(const IPosition &otherShape) const
casacore::ArrayColumn
Read and write access to an array table column with arbitrary data type.
Definition: CopyRecord.h:48
casacore::MSConcat::itsRespectForFieldName
Bool itsRespectForFieldName
Definition: MSConcat.h:140
casacore::MSConcat::itsWeightScale
Float itsWeightScale
Definition: MSConcat.h:139
casacore::MSConcat::copyObservation
Int copyObservation(const MSObservation &otherObs, const Bool remRedunObsId=True)
casacore::ArrayColumn::get
void get(uInt rownr, Array< T > &array, Bool resize=False) const
Get the array value in a particular cell (i.e.
casacore::MSAntenna
A Table intended to hold a MeasurementSet ANTENNA table.
Definition: MSAntenna.h:79
casacore::MSConcat::sourceRowsEquivalent
Bool sourceRowsEquivalent(const MSSourceColumns &sourceCol, const uInt &rowi, const uInt &rowj, const Bool dontTestDirection=False, const Bool dontTestTransAndRest=False)
casacore::MSObservation
A Table intended to hold a MeasurementSet OBSERVATION table.
Definition: MSObservation.h:78
casacore::MSConcat::doSource2_p
Bool doSource2_p
Definition: MSConcat.h:151
casacore::Float
float Float
Definition: aipstype.h:54
casacore::MSFeed
A Table intended to hold a MeasurementSet FEED table.
Definition: MSFeed.h:78
casacore::MSConcat::concatenate
void concatenate(const MeasurementSet &otherMS, const uInt handling=0, const String &destMSName="")
casacore::MSConcat::copyPointingB
Bool copyPointingB(MSPointing &otherPoint, const Block< uInt > &newAntIndices)
casacore::MSConcat::solSystObjects_p
std::map< Int, Int > solSystObjects_p
Definition: MSConcat.h:148
casacore::MSConcat::copySource
Bool copySource(const MeasurementSet &otherms)
casacore::MSConcat::virtualconcat
void virtualconcat(MeasurementSet &otherMS, const Bool checkShapeAndCateg=True, const String &obsidAndScanTableName="")
casacore::MSSpectralWindow
A Table intended to hold a MeasurementSet SPECTRAL_WINDOW table.
Definition: MSSpectralWindow.h:78
casacore::MSMainColumns
A class for easy access to MeasurementSet main table columns.
Definition: MSMainColumns.h:106
casacore::False
const Bool False
Definition: aipstype.h:44
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::MSConcat::copySpwAndPol
Block< uInt > copySpwAndPol(const MSSpectralWindow &otherSpw, const MSPolarization &otherPol, const MSDataDescription &otherDD)
casacore::MSConcat::copyPointing
Bool copyPointing(const MSPointing &otherPoint, const Block< uInt > &newAntIndices)
casacore::MSConcat::newObsIndexB_p
std::map< Int, Int > newObsIndexB_p
Definition: MSConcat.h:146
casacore::MSConcat::itsDirTol
Quantum< Double > itsDirTol
Definition: MSConcat.h:138
casacore::MSConcat::doObsB_p
Bool doObsB_p
Definition: MSConcat.h:154
casacore::MSSourceColumns
A class to provide easy access to MSSource columns.
Definition: MSSourceColumns.h:88
casacore::MSObservationColumns
A class to provide easy access to MSObservation columns.
Definition: MSObsColumns.h:80
casacore::MSPointing
A Table intended to hold a MeasurementSet POINTING table.
Definition: MSPointing.h:78
casacore::MSConcat::otherObsIdsWithCounterpart_p
std::map< Int, Int > otherObsIdsWithCounterpart_p
Definition: MSConcat.h:147
casacore::Int
int Int
Definition: aipstype.h:50
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::MSConcat::setTolerance
void setTolerance(Quantum< Double > &freqTol, Quantum< Double > &dirTol)
casacore::areEQ
Bool areEQ(const ScalarColumn< T > &col, uInt row_i, uInt row_j)
Definition: MSConcat.h:159
casacore::True
const Bool True
Definition: aipstype.h:43
casacore::MSDataDescColumns
A class to provide easy access to MSDataDescription columns.
Definition: MSDataDescColumns.h:74
casacore::getMapValue
Int getMapValue(const std::map< Int, Int > &m, Int k)
Definition: MSConcat.h:185
casacore::MSConcat::copyState
Block< uInt > copyState(const MSState &otherState)
casacore::MeasurementSet
A Table intended to hold astronomical data (a set of Measurements).
Definition: MeasurementSet.h:241
casacore::MSConcat::updateSource2
Bool updateSource2()
casacore::Array
template <class T, class U> class vector;
Definition: Array.h:166
casacore::MSConcat::itsFixedShape
IPosition itsFixedShape
Definition: MSConcat.h:136
casacore::String
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::MSConcat::setRespectForFieldName
void setRespectForFieldName(const Bool respectFieldName)
casacore::MSConcat::newSPWIndex_p
std::map< Int, Int > newSPWIndex_p
Definition: MSConcat.h:144
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Block< uInt >
casacore::MSDataDescription
A Table intended to hold a MeasurementSet DATADESCRIPTION table.
Definition: MSDataDescription.h:79
casacore::MSConcat::newSourceIndex2_p
std::map< Int, Int > newSourceIndex2_p
Definition: MSConcat.h:143
casacore::ScalarColumn::get
void get(uInt rownr, T &value) const
Get the data from a particular cell (i.e.
Definition: ScalarColumn.h:137
casacore::MSColumns
A class to provide easy access to MeasurementSet columns.
Definition: MSColumns.h:116
casacore::MSConcat::copyAntennaAndFeed
Block< uInt > copyAntennaAndFeed(const MSAntenna &otherAnt, const MSFeed &otherFeed)
casacore::Vector< Bool >
casacore::MSConcat::setWeightScale
void setWeightScale(const Float weightScale)
casacore::MSSysCal
A Table intended to hold a MeasurementSet SYSCAL table.
Definition: MSSysCal.h:78
casacore::MSConcat::checkCategories
void checkCategories(const MSMainColumns &otherCols) const
casacore::MSConcat::copyField
Block< uInt > copyField(const MeasurementSet &otherms)
casacore::MSPolarization
A Table intended to hold a MeasurementSet POLARIZATION table.
Definition: MSPolarization.h:78
casacore::MSConcat::doSource_p
Bool doSource_p
Definition: MSConcat.h:150
casacore::MSPolarizationColumns
A class to provide easy access to MSPolarization columns.
Definition: MSPolColumns.h:75
casacore::MSConcat::checkEphIdInField
Bool checkEphIdInField(const MSFieldColumns &otherFldCol) const
casacore::MSFieldColumns
A class to provide easy access to MSField columns.
Definition: MSFieldColumns.h:87
casacore::Quantum< Double >
casacore::MSConcat::getShape
static IPosition getShape(const MSDataDescColumns &ddCols, const MSSpWindowColumns &spwCols, const MSPolarizationColumns &polCols, uInt whichShape)
casacore::MSConcat::itsMS
MeasurementSet itsMS
Definition: MSConcat.h:135
casacore::MSConcat::doSPW_p
Bool doSPW_p
Definition: MSConcat.h:152