MSConcat.h

Go to the documentation of this file.
00001 //# MSConcat.h: A class for concatenating MeasurementSets.
00002 //# Copyright (C) 2000,2002,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id$
00028 
00029 #ifndef MS_MSCONCAT_H
00030 #define MS_MSCONCAT_H
00031 
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/ms/MeasurementSets/MSColumns.h>
00034 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
00035 #include <casacore/casa/Arrays/IPosition.h>
00036 
00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00038 
00039 class TableDesc;
00040 class ROMSMainColumns;
00041 class ROMSDataDescColumns;
00042 class ROMSSpWindowColumns;
00043 class ROMSPolarizationColumns;
00044 class MSAntenna;
00045 class MSDataDescription;
00046 class MSFeed;
00047 class MSField;
00048 class MSPolarization;
00049 class MSSpectralWindow;
00050 template <class T> class Block;
00051 
00052 // <summary>A class with functions for concatenating MeasurementSets</summary>
00053 
00054 // <use visibility=export>
00055 
00056 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00057 // </reviewed>
00058 
00059 // <prerequisite>
00060 //   <li> SomeClass
00061 //   <li> SomeOtherClass
00062 //   <li> some concept
00063 // </prerequisite>
00064 //
00065 // <etymology>
00066 // </etymology>
00067 //
00068 // <synopsis>
00069 // </synopsis>
00070 //
00071 // <example>
00072 // </example>
00073 //
00074 // <motivation>
00075 // </motivation>
00076 //
00077 // <templating arg=T>
00078 //    <li>
00079 //    <li>
00080 // </templating>
00081 //
00082 // <thrown>
00083 //    <li>
00084 //    <li>
00085 // </thrown>
00086 //
00087 // <todo asof="yyyy/mm/dd">
00088 //   <li> add this feature
00089 //   <li> fix this bug
00090 //   <li> start discussion of this possible extension
00091 // </todo>
00092 
00093 class MSConcat: public MSColumns
00094 {
00095 public:
00096   MSConcat(MeasurementSet& ms);
00097 
00098   void virtualconcat(MeasurementSet& otherMS, 
00099                      const Bool checkShapeAndCateg=True,
00100                      const String& obsidAndScanTableName="");
00101 
00102   void concatenate(const MeasurementSet& otherMS,
00103                    const uInt handling=0,   // 0 (default): complete concat of all tables
00104                                             // 1 : don't concatenate the MAIN table
00105                                             // 2 : don't concatenate the POINTING table
00106                                             // 3 : neither concat MAIN nor POINTING table
00107                    const String& destMSName=""); // support for virtual concat
00108 
00109   void setTolerance(Quantum<Double>& freqTol, Quantum<Double>& dirTol); 
00110   void setWeightScale(const Float weightScale); 
00111   void setRespectForFieldName(const Bool respectFieldName); // If True, fields of same direction are not merged
00112                                                             // if their name is different
00113 
00114 private:
00115   MSConcat();
00116   static IPosition isFixedShape(const TableDesc& td);
00117   static IPosition getShape(const ROMSDataDescColumns& ddCols, 
00118                             const ROMSSpWindowColumns& spwCols, 
00119                             const ROMSPolarizationColumns& polCols, 
00120                             uInt whichShape);
00121   void checkShape(const IPosition& otherShape) const;
00122   void checkCategories(const ROMSMainColumns& otherCols) const;
00123   Bool checkEphIdInField(const ROMSFieldColumns& otherFldCol) const;
00124   Bool copyPointing(const MSPointing& otherPoint, const Block<uInt>& newAntIndices);
00125   Bool copyPointingB(MSPointing& otherPoint, const Block<uInt>& newAntIndices);
00126   Int copyObservation(const MSObservation& otherObs, const Bool remRedunObsId=True);
00127                              // by default remove redundant observation table rows
00128   Block<uInt> copyAntennaAndFeed(const MSAntenna& otherAnt,
00129                                  const MSFeed& otherFeed);
00130   Block<uInt> copyState(const MSState& otherState);
00131   Block<uInt> copyField(const MeasurementSet& otherms);
00132   Block<uInt> copySpwAndPol(const MSSpectralWindow& otherSpw,
00133                             const MSPolarization& otherPol,
00134                             const MSDataDescription& otherDD);
00135   Bool copySource(const MeasurementSet& otherms);
00136   Bool updateSource();
00137   Bool updateSource2();
00138   Bool sourceRowsEquivalent(const MSSourceColumns& sourceCol, 
00139                             const uInt& rowi, const uInt& rowj,
00140                             const Bool dontTestDirection=False,
00141                             const Bool dontTestTransAndRest=False);
00142 
00143   Bool obsRowsEquivalent(const MSObservationColumns& obsCol, 
00144                          const uInt& rowi, const uInt& rowj);
00145 
00146 
00147   void updateModelDataKeywords(MeasurementSet& ms);
00148 
00149   MeasurementSet itsMS;
00150   IPosition itsFixedShape;
00151   Quantum<Double> itsFreqTol;
00152   Quantum<Double> itsDirTol;
00153   Float itsWeightScale;
00154   Bool itsRespectForFieldName;
00155   Vector<Bool> itsChanReversed;
00156   SimpleOrderedMap <Int, Int> newSourceIndex_p;
00157   SimpleOrderedMap <Int, Int> newSourceIndex2_p;
00158   SimpleOrderedMap <Int, Int> newSPWIndex_p;
00159   SimpleOrderedMap <Int, Int> newObsIndexA_p;
00160   SimpleOrderedMap <Int, Int> newObsIndexB_p;
00161   SimpleOrderedMap <Int, Int> otherObsIdsWithCounterpart_p;
00162   SimpleOrderedMap <Int, Int> solSystObjects_p;
00163 
00164   Bool doSource_p;
00165   Bool doSource2_p;
00166   Bool doSPW_p;
00167   Bool doObsA_p;
00168   Bool doObsB_p;
00169 
00170 };
00171 
00172 template<class T>
00173 Bool areEQ(const ROScalarColumn<T>& col, uInt row_i, uInt row_j) 
00174 {
00175   T value_i, value_j;
00176   col.get(row_i, value_i);
00177   col.get(row_j, value_j);
00178   return (value_i == value_j);
00179 }
00180 
00181 template<class T>
00182 Bool areEQ(const ROArrayColumn<T>& col, uInt row_i, uInt row_j) 
00183 {
00184   Bool rval(False);
00185   Array<T> arr_i;
00186   Array<T> arr_j;
00187   
00188   col.get(row_i, arr_i, True);
00189   col.get(row_j, arr_j, True);
00190   Int ni = arr_i.nelements();
00191   Int nj = arr_j.nelements();
00192   if( (ni==0 && nj==0) ||    // no data is regarded as equal
00193       allEQ(arr_i, arr_j)){
00194     rval = True;
00195   }
00196   return rval;
00197 }
00198 
00199 
00200 
00201 } //# NAMESPACE CASACORE - END
00202 
00203 #endif
00204 
00205 
00206 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1