casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MSSpWindowColumns.h
Go to the documentation of this file.
00001 //# MSSpWindowColumns.h: provides easy access to MSSpectralWindow columns
00002 //# Copyright (C) 1996,1999,2000,2002
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 //# $Id: MSSpWindowColumns.h 20299 2008-04-03 05:56:44Z gervandiepen $
00027 
00028 #ifndef MS_MSSPWINDOWCOLUMNS_H
00029 #define MS_MSSPWINDOWCOLUMNS_H
00030 
00031 #include <casa/aips.h>
00032 #include <measures/Measures/MFrequency.h>
00033 #include <measures/Measures/MCFrequency.h>
00034 #include <tables/Tables/ScalarColumn.h>
00035 #include <tables/Tables/ArrayColumn.h>
00036 #include <measures/TableMeasures/ScalarMeasColumn.h>
00037 #include <measures/TableMeasures/ScalarQuantColumn.h>
00038 #include <measures/TableMeasures/ArrayMeasColumn.h>
00039 #include <measures/TableMeasures/ArrayQuantColumn.h>
00040 #include <casa/BasicSL/String.h>
00041 #include <measures/Measures/MeasFrame.h>
00042 #include <ms/MeasurementSets/MSDopplerColumns.h>
00043 #include <ms/MeasurementSets/MSSourceColumns.h>
00044 
00045 namespace casa { //# NAMESPACE CASA - BEGIN
00046 
00047 class MSSpectralWindow;
00048 
00049 // <summary>
00050 // A class to provide easy read-only access to MSASpectralWindow columns
00051 // </summary>
00052 
00053 // <use visibility=export>
00054 
00055 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00056 // </reviewed>
00057 
00058 // <prerequisite>
00059 //   <li> MSSpectralWindow
00060 //   <li> ArrayColumn
00061 //   <li> ScalarColumn
00062 // </prerequisite>
00063 //
00064 // <etymology>
00065 // ROMSSpectralWindowColumns stands for Read-Only MeasurementSet SpectralWindow Table columns.
00066 // </etymology>
00067 //
00068 // <synopsis>
00069 // This class provides read-only access to the columns in the MSSpectralWindow Table.
00070 // It does the declaration of all the Scalar and ArrayColumns with the
00071 // correct types, so the application programmer doesn't have to
00072 // worry about getting those right. There is an access function
00073 // for every predefined column. Access to non-predefined columns will still
00074 // have to be done with explicit declarations.
00075 // See <linkto class=ROMSColumns> ROMSColumns</linkto> for an example.
00076 // </synopsis>
00077 //
00078 // <motivation>
00079 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00080 // </motivation>
00081 
00082 class ROMSSpWindowColumns
00083 {
00084 public:
00085   // Create a columns object that accesses the data in the specified Table
00086   ROMSSpWindowColumns(const MSSpectralWindow& msSpWindow);
00087 
00088   // The destructor does nothing special
00089   ~ROMSSpWindowColumns();
00090 
00091   // Access to columns
00092   // <group>
00093   const ROArrayColumn<Double>& chanFreq() const {return chanFreq_p;}
00094   const ROArrayQuantColumn<Double>& chanFreqQuant() const {
00095     return chanFreqQuant_p;}
00096   const ROArrayMeasColumn<MFrequency>& chanFreqMeas() const {
00097     return chanFreqMeas_p;}
00098   const ROArrayColumn<Double>& chanWidth() const {return chanWidth_p;}
00099   const ROArrayQuantColumn<Double>& chanWidthQuant() const {
00100     return chanWidthQuant_p;}
00101   const ROArrayColumn<Double>& effectiveBW() const {return effectiveBW_p;}
00102   const ROArrayQuantColumn<Double>& effectiveBWQuant() const {
00103     return effectiveBWQuant_p;}
00104   const ROScalarColumn<Int>& freqGroup() const {return freqGroup_p;}
00105   const ROScalarColumn<String>& freqGroupName() const {return freqGroupName_p;}
00106   const ROScalarColumn<Int>& ifConvChain() const {return ifConvChain_p;}
00107   const ROScalarColumn<Bool>& flagRow() const {return flagRow_p;}
00108   const ROScalarColumn<Int>& measFreqRef() const {return measFreqRef_p;}
00109   const ROScalarColumn<String>& name() const {return name_p;}
00110   const ROScalarColumn<Int>& netSideband() const {return netSideband_p;}
00111   const ROScalarColumn<Int>& numChan() const {return numChan_p;}
00112   const ROScalarColumn<Double>& refFrequency() const {return refFrequency_p;}
00113   const ROScalarQuantColumn<Double>& refFrequencyQuant() const {
00114     return refFrequencyQuant_p;}
00115   const ROScalarMeasColumn<MFrequency>& refFrequencyMeas() const {
00116     return refFrequencyMeas_p;}
00117   const ROArrayColumn<Double>& resolution() const {return resolution_p;}
00118   const ROArrayQuantColumn<Double>& resolutionQuant() const {
00119     return resolutionQuant_p;}
00120   const ROScalarColumn<Double>& totalBandwidth() const {
00121     return totalBandwidth_p;}
00122   const ROScalarQuantColumn<Double>& totalBandwidthQuant() const {
00123     return totalBandwidthQuant_p;}
00124   // </group>
00125 
00126   // Access to optional columns
00127   // <group>
00128   const ROArrayColumn<String>& assocNature() const {return assocNature_p;}
00129   const ROArrayColumn<Int>& assocSpwId() const {return assocSpwId_p;}
00130   const ROScalarColumn<Int>& bbcNo() const {return bbcNo_p;}
00131   const ROScalarColumn<Int>& bbcSideband() const {return bbcSideband_p;}
00132   const ROScalarColumn<Int>& dopplerId() const {return dopplerId_p;}
00133   const ROScalarColumn<Int>& receiverId() const {return receiverId_p;}
00134   // </group>
00135 
00136   // Convenience function that returns the number of rows in any of the columns
00137   uInt nrow() const {return chanFreq_p.nrow();}
00138 
00139   // returns the last row that contains a spectral window that has the
00140   // specified reference frequency, number of channels, total-bandwidth and IF
00141   // conversion chain. All frequencies need to match within the specified
00142   // tolerance. Both the totalBandwidth & the tolerance arguments must have the
00143   // same dimensions as the Hz and an AipsError exception is thrown, in debug
00144   // mode, if the dimensions are wrong. In addition to the numerical values the
00145   // frequency reference frame is checked and needs to match the value in the
00146   // MEAS_FREQ_REF column. No conversions to other reference frames are
00147   // done. Will only try to match on rows where FLAG_ROW is false. If tryRow is
00148   // set to a non-negative value then that row is checked first to see if it
00149   // matches. An AIpsError exception is thrown if tryRow is bigger than the
00150   // number of rows in the Table. Returns -1 if no match could be found.
00151   Int matchSpw(const MFrequency& refFreq, uInt nChan, 
00152                const Quantum<Double>& bandwidth, Int ifChain,
00153                const Quantum<Double>& tolerance, Int tryRow=-1) const;
00154   // Similar to above, but also pass in the frame info.                  
00155   Int matchSpw(const MFrequency& refFreq, const MFrequency& chanFreq1, const MeasFrame& measFrm,
00156           const MSDopplerColumns& msdopc, const MSSourceColumns& mssrcc, uInt nChan, 
00157                const Quantum<Double>& bandwidth, Int ifChain,
00158                const Quantum<Double>& tolerance, Int tryRow=-1) const; 
00159   // This is to check that the channels are matched individually
00160   // and also if the spw is matched in reverse; 
00161 
00162   //Same as the above but returns all the possible match that it could find
00163   // in the spectral window table. 
00164   Vector<Int> allMatchedSpw(const MFrequency& refFreq, uInt nChan, 
00165                const Quantum<Double>& bandwidth, Int ifChain,
00166                const Quantum<Double>& tolerance) const;
00167 
00168   //This version does a channel to channel match too and also return
00169   // the reversed if it matches but the channels are in inverse order
00170   // like an upper or lower side band having same characteristics
00171   Int matchSpw(const MFrequency& refFreq, uInt nChan, 
00172                const Quantum<Double>& bandwidth, Int ifChain,
00173                const Quantum<Double>& tolerance, Vector<Double>& otherFreqs, 
00174                Bool& reversed) const;
00175 
00176 protected:
00177   //# default constructor creates a object that is not usable. Use the attach
00178   //# function correct this.
00179   ROMSSpWindowColumns();
00180 
00181   //# attach this object to the supplied table.
00182   void attach(const MSSpectralWindow& msSpWindow);
00183 
00184 private:
00185   //# Make the assignment operator and the copy constructor private to prevent
00186   //# any compiler generated one from being used.
00187   ROMSSpWindowColumns(const ROMSSpWindowColumns&);
00188   ROMSSpWindowColumns& operator=(const ROMSSpWindowColumns&);
00189 
00190   //# Check if any optional columns exist and if so attach them.
00191   void attachOptionalCols(const MSSpectralWindow& msSpWindow);
00192 
00193   //# functions to match the supplied arguments against the values in the
00194   //# specified row.
00195   //<group>
00196   Bool matchRefFrequency(uInt row, MFrequency::Types refType, 
00197                          Double refFreqInHz, Double tolInHz) const;
00198   Bool matchRefFreqCnvtrd(uInt row, MFrequency refOrChanFreq, const Bool isRefFreq, const MeasFrame& measFrm,
00199           const MSDopplerColumns& msdopc, const MSSourceColumns& mssrcc, Double tolInHz) const;
00200   Bool matchChanFreq(uInt row, const Vector<Double>& chanFreqInHz,
00201                      Double tolInHz) const;
00202   Bool matchIfConvChain(uInt row, Int ifChain) const;
00203   Bool matchTotalBandwidth(uInt row, Double bandwidthInHz,
00204                            Double tolInHz) const;
00205   Bool matchNumChan(uInt row, Int nChan) const;
00206   //</group>
00207 
00208 
00209   //# required columns
00210   ROArrayColumn<Double> chanFreq_p;
00211   ROArrayColumn<Double> chanWidth_p;
00212   ROArrayColumn<Double> effectiveBW_p;
00213   ROScalarColumn<Bool> flagRow_p;
00214   ROScalarColumn<Int> freqGroup_p;
00215   ROScalarColumn<String> freqGroupName_p;
00216   ROScalarColumn<Int> ifConvChain_p;
00217   ROScalarColumn<Int> measFreqRef_p;
00218   ROScalarColumn<String> name_p;
00219   ROScalarColumn<Int> netSideband_p;
00220   ROScalarColumn<Int> numChan_p;
00221   ROScalarColumn<Double> refFrequency_p;
00222   ROArrayColumn<Double> resolution_p;
00223   ROScalarColumn<Double> totalBandwidth_p;
00224   //# optional columns
00225   ROArrayColumn<String> assocNature_p;
00226   ROArrayColumn<Int> assocSpwId_p;
00227   ROScalarColumn<Int> bbcNo_p;
00228   ROScalarColumn<Int> bbcSideband_p;
00229   ROScalarColumn<Int> dopplerId_p;
00230   ROScalarColumn<Int> receiverId_p;
00231 
00232   //# Access to Measure columns
00233   ROArrayMeasColumn<MFrequency> chanFreqMeas_p;
00234   ROScalarMeasColumn<MFrequency> refFrequencyMeas_p;
00235 
00236   //# Access to Quantum columns
00237   ROArrayQuantColumn<Double> chanFreqQuant_p;
00238   ROArrayQuantColumn<Double> chanWidthQuant_p;
00239   ROArrayQuantColumn<Double> effectiveBWQuant_p;
00240   ROScalarQuantColumn<Double> refFrequencyQuant_p;
00241   ROArrayQuantColumn<Double> resolutionQuant_p;
00242   ROScalarQuantColumn<Double> totalBandwidthQuant_p;
00243   
00244         // m_frame will be set from VLAFiller before calling matchSpw(), which is need when 
00245         // converting MFrequency to a different frame. ( This did not work out! )
00246    // MeasFrame* m_frame;
00247 
00248 };
00249 
00250 // <summary>
00251 // A class to provide easy read-write access to MSSpectralWindow columns
00252 // </summary>
00253 
00254 // <use visibility=export>
00255 
00256 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
00257 // </reviewed>
00258 
00259 // <prerequisite>
00260 //   <li> MSSpectralWindow
00261 //   <li> ArrayColumn
00262 //   <li> ScalarColumn
00263 // </prerequisite>
00264 //
00265 // <etymology>
00266 // MSSpectralWindowColumns stands for MeasurementSet SpectralWindow Table columns.
00267 // </etymology>
00268 //
00269 // <synopsis>
00270 // This class provides access to the columns in the MSSpectralWindow Table,
00271 // it does the declaration of all the Scalar and ArrayColumns with the
00272 // correct types, so the application programmer doesn't have to
00273 // worry about getting those right. There is an access function
00274 // for every predefined column. Access to non-predefined columns will still
00275 // have to be done with explicit declarations.
00276 // See <linkto class=MSColumns> MSColumns</linkto> for an example.
00277 // </synopsis>
00278 //
00279 // <motivation>
00280 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
00281 // </motivation>
00282 
00283 class MSSpWindowColumns: public ROMSSpWindowColumns
00284 {
00285 public:
00286   // Create a columns object that accesses the data in the specified Table
00287   MSSpWindowColumns(MSSpectralWindow& msSpWindow);
00288 
00289   // The destructor does nothing special
00290   ~MSSpWindowColumns();
00291 
00292   // Read-write access to required columns
00293   // <group>
00294   ArrayColumn<Double>& chanFreq() {return chanFreq_p;}
00295   ArrayMeasColumn<MFrequency>& chanFreqMeas() {return chanFreqMeas_p;}
00296   ArrayQuantColumn<Double>& chanFreqQuant() {return chanFreqQuant_p;}
00297   ArrayColumn<Double>& chanWidth() {return chanWidth_p;}
00298   ArrayQuantColumn<Double>& chanWidthQuant() { return chanWidthQuant_p;}
00299   ArrayColumn<Double>& effectiveBW() {return effectiveBW_p;}
00300   ArrayQuantColumn<Double>& effectiveBWQuant() { return effectiveBWQuant_p;}
00301   ScalarColumn<Bool>& flagRow() {return flagRow_p;}
00302   ScalarColumn<Int>& freqGroup() {return freqGroup_p;}
00303   ScalarColumn<String>& freqGroupName() {return freqGroupName_p;}
00304   ScalarColumn<Int>& ifConvChain() {return ifConvChain_p;}
00305   ScalarColumn<Int>& measFreqRef() {return measFreqRef_p;}
00306   ScalarColumn<String>& name() {return name_p;}
00307   ScalarColumn<Int>& netSideband() {return netSideband_p;}
00308   ScalarColumn<Int>& numChan() {return numChan_p;}
00309   ScalarColumn<Double>& refFrequency() {return refFrequency_p;}
00310   ScalarQuantColumn<Double>& refFrequencyQuant() {return refFrequencyQuant_p;}
00311   ScalarMeasColumn<MFrequency>& refFrequencyMeas() {return refFrequencyMeas_p;}
00312   ArrayColumn<Double>& resolution() {return resolution_p;}
00313   ArrayQuantColumn<Double>& resolutionQuant() { return resolutionQuant_p;}
00314   ScalarColumn<Double>& totalBandwidth() {return totalBandwidth_p;}
00315   ScalarQuantColumn<Double>& totalBandwidthQuant() {
00316     return totalBandwidthQuant_p;}
00317   // </group>
00318 
00319   // Read-write access to optional columns
00320   // <group>
00321   ArrayColumn<String>& assocNature() {return assocNature_p;}
00322   ArrayColumn<Int>& assocSpwId() {return assocSpwId_p;}
00323   ScalarColumn<Int>& bbcNo() {return bbcNo_p;}
00324   ScalarColumn<Int>& bbcSideband() {return bbcSideband_p;}
00325   ScalarColumn<Int>& dopplerId() {return dopplerId_p;}
00326   ScalarColumn<Int>& receiverId() {return receiverId_p;}
00327   // </group>
00328 
00329   // Read-only access to required columns
00330   // <group>
00331   const ROArrayColumn<Double>& chanFreq() const {
00332     return ROMSSpWindowColumns::chanFreq();}
00333   const ROArrayQuantColumn<Double>& chanFreqQuant() const {
00334     return ROMSSpWindowColumns::chanFreqQuant();}
00335   const ROArrayMeasColumn<MFrequency>& chanFreqMeas() const {
00336     return ROMSSpWindowColumns::chanFreqMeas();}
00337   const ROArrayColumn<Double>& chanWidth() const {
00338     return ROMSSpWindowColumns::chanWidth();}
00339   const ROArrayQuantColumn<Double>& chanWidthQuant() const {
00340     return ROMSSpWindowColumns::chanWidthQuant();}
00341   const ROArrayColumn<Double>& effectiveBW() const {
00342     return ROMSSpWindowColumns::effectiveBW();}
00343   const ROArrayQuantColumn<Double>& effectiveBWQuant() const {
00344     return ROMSSpWindowColumns::effectiveBWQuant();}
00345   const ROScalarColumn<Int>& freqGroup() const {
00346     return ROMSSpWindowColumns::freqGroup();}
00347   const ROScalarColumn<String>& freqGroupName() const {
00348     return ROMSSpWindowColumns::freqGroupName();}
00349   const ROScalarColumn<Int>& ifConvChain() const {
00350     return ROMSSpWindowColumns::ifConvChain();}
00351   const ROScalarColumn<Bool>& flagRow() const {
00352     return ROMSSpWindowColumns::flagRow();}
00353   const ROScalarColumn<Int>& measFreqRef() const {
00354     return ROMSSpWindowColumns::measFreqRef();}
00355   const ROScalarColumn<String>& name() const {
00356     return ROMSSpWindowColumns::name();}
00357   const ROScalarColumn<Int>& netSideband() const {
00358     return ROMSSpWindowColumns::netSideband();}
00359   const ROScalarColumn<Int>& numChan() const {
00360     return ROMSSpWindowColumns::numChan();}
00361   const ROScalarColumn<Double>& refFrequency() const {
00362     return ROMSSpWindowColumns::refFrequency();}
00363   const ROScalarQuantColumn<Double>& refFrequencyQuant() const {
00364     return ROMSSpWindowColumns::refFrequencyQuant();}
00365   const ROScalarMeasColumn<MFrequency>& refFrequencyMeas() const {
00366     return ROMSSpWindowColumns::refFrequencyMeas();}
00367   const ROArrayColumn<Double>& resolution() const {
00368     return ROMSSpWindowColumns::resolution();}
00369   const ROArrayQuantColumn<Double>& resolutionQuant() const {
00370     return ROMSSpWindowColumns::resolutionQuant();}
00371   const ROScalarColumn<Double>& totalBandwidth() const {
00372     return ROMSSpWindowColumns::totalBandwidth();}
00373   const ROScalarQuantColumn<Double>& totalBandwidthQuant() const {
00374     return ROMSSpWindowColumns::totalBandwidthQuant();}
00375   // </group>
00376 
00377   // Read-only access to optional columns
00378   // <group>
00379   const ROArrayColumn<String>& assocNature() const {
00380     return ROMSSpWindowColumns::assocNature();}
00381   const ROArrayColumn<Int>& assocSpwId() const {
00382     return ROMSSpWindowColumns::assocSpwId();}
00383   const ROScalarColumn<Int>& bbcNo() const {
00384     return ROMSSpWindowColumns::bbcNo();}
00385   const ROScalarColumn<Int>& bbcSideband() const {
00386     return ROMSSpWindowColumns::bbcSideband();}
00387   const ROScalarColumn<Int>& dopplerId() const {
00388     return ROMSSpWindowColumns::dopplerId();}
00389   const ROScalarColumn<Int>& receiverId() const {
00390     return ROMSSpWindowColumns::receiverId();}
00391   // </group>
00392 
00393 protected:
00394   //# default constructor creates a object that is not usable. Use the attach
00395   //# function correct this.
00396   MSSpWindowColumns();
00397 
00398   //# attach this object to the supplied table.
00399   void attach(MSSpectralWindow& msSpWindow);
00400 
00401 private:
00402   //# Make the assignment operator and the copy constructor private to prevent
00403   //# any compiler generated one from being used.
00404   MSSpWindowColumns(const MSSpWindowColumns&);
00405   MSSpWindowColumns& operator=(const MSSpWindowColumns&);
00406 
00407   //# Check if any optional columns exist and if so attach them.
00408   void attachOptionalCols(MSSpectralWindow& msSpWindow);
00409   
00410   //# required columns
00411   ArrayColumn<Double> chanFreq_p;
00412   ArrayColumn<Double> chanWidth_p;
00413   ArrayColumn<Double> effectiveBW_p;
00414   ScalarColumn<Bool> flagRow_p;
00415   ScalarColumn<Int> freqGroup_p;
00416   ScalarColumn<String> freqGroupName_p;
00417   ScalarColumn<Int> ifConvChain_p;
00418   ScalarColumn<Int> measFreqRef_p;
00419   ScalarColumn<String> name_p;
00420   ScalarColumn<Int> netSideband_p;
00421   ScalarColumn<Int> numChan_p;
00422   ScalarColumn<Double> refFrequency_p;
00423   ArrayColumn<Double> resolution_p;
00424   ScalarColumn<Double> totalBandwidth_p;
00425   //# optional columns
00426   ArrayColumn<String> assocNature_p;
00427   ArrayColumn<Int> assocSpwId_p;
00428   ScalarColumn<Int> bbcNo_p;
00429   ScalarColumn<Int> bbcSideband_p;
00430   ScalarColumn<Int> dopplerId_p;
00431   ScalarColumn<Int> receiverId_p;
00432 
00433   //# Access to Measure columns
00434   ArrayMeasColumn<MFrequency> chanFreqMeas_p;
00435   ScalarMeasColumn<MFrequency> refFrequencyMeas_p;
00436 
00437   //# Access to Quantum columns
00438   ArrayQuantColumn<Double> chanFreqQuant_p;
00439   ArrayQuantColumn<Double> chanWidthQuant_p;
00440   ArrayQuantColumn<Double> effectiveBWQuant_p;
00441   ScalarQuantColumn<Double> refFrequencyQuant_p;
00442   ArrayQuantColumn<Double> resolutionQuant_p;
00443   ScalarQuantColumn<Double> totalBandwidthQuant_p;
00444 };
00445 
00446 } //# NAMESPACE CASA - END
00447 
00448 #endif