NewCalTable.h

Go to the documentation of this file.
00001 //# NewCalTable.h: Calibration table access and creation
00002 //# Copyright (C) 2011
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 adressed 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: NewCalTable.h 37865 2016-08-04 23:07:10Z george.moellenbrock $
00028 
00029 #ifndef CALIBRATION_NEWCALTABLE_H
00030 #define CALIBRATION_NEWCALTABLE_H
00031 
00032 #include <casa/aips.h>
00033 #include <tables/Tables/Table.h>
00034 #include <tables/TaQL/ExprNode.h>
00035 #include <casa/Containers/Record.h>
00036 #include <casa/OS/Path.h>
00037 #include <casa/Utilities/Sort.h>
00038 #include <ms/MeasurementSets/MSObservation.h>
00039 #include <ms/MeasurementSets/MSAntenna.h>
00040 #include <ms/MeasurementSets/MSField.h>
00041 #include <ms/MeasurementSets/MSSpectralWindow.h>
00042 #include <ms/MeasurementSets/MSHistory.h>
00043 #include <ms/MeasurementSets/MSObsColumns.h>
00044 #include <ms/MeasurementSets/MSAntennaColumns.h>
00045 #include <ms/MeasurementSets/MSFieldColumns.h>
00046 #include <ms/MeasurementSets/MSSpWindowColumns.h>
00047 #include <ms/MeasurementSets/MSHistoryColumns.h>
00048 #include <synthesis/CalTables/CTDesc.h>
00049 #include <synthesis/CalTables/CTMainRecord.h>
00050 #include <synthesis/CalTables/CTMainColumns.h>
00051 #include <synthesis/CalTables/VisCalEnum.h>
00052 
00053 namespace casa { //# NAMESPACE CASA - BEGIN
00054 
00055 // <summary> 
00056 // NewCalTable: New Calibration table access and creation
00057 // </summary>
00058 
00059 // <use visibility=export>
00060 
00061 // <reviewed reviewer="" date="" tests="" demos="">
00062 
00063 // <prerequisite>
00064 //   <li> <linkto class="CalTableDesc">CalTableDesc</linkto> module
00065 // </prerequisite>
00066 //
00067 // <etymology>
00068 // From "calibration" and "table".
00069 // </etymology>
00070 //
00071 // <synopsis>
00072 // The NewCalTable classes provide basic access to calibration tables. This 
00073 // includes the creation of calibration tables, sorting and selection
00074 // capabilities, and basic data access. Specializations for baseline-based,
00075 // time-variable and solvable VisJones types, and sub-types, are provided 
00076 // through inheritance.
00077 // </etymology>
00078 //
00079 // <example>
00080 // <srcblock>
00081 // </srcblock>
00082 // </example>
00083 //
00084 // <motivation>
00085 // This class is used by other calibration table accessors and iterators.
00086 // </motivation>
00087 //
00088 // <todo asof="11/06/10">
00089 // </todo>
00090 
00091 
00092 // Typedefs for subtable objects
00093 typedef MSField CTField;
00094 typedef MSObservation CTObservation;
00095 typedef MSAntenna CTAntenna;
00096 typedef MSSpectralWindow CTSpectralWindow;
00097 typedef MSHistory CTHistory;
00098 typedef MSFieldColumns CTFieldColumns;
00099 typedef MSObservationColumns CTObservationColumns;
00100 typedef MSAntennaColumns CTAntennaColumns;
00101 typedef MSSpWindowColumns CTSpWindowColumns;
00102 typedef MSHistoryColumns CTHistoryColumns;
00103 typedef ROMSFieldColumns ROCTFieldColumns;
00104 typedef ROMSObservationColumns ROCTObservationColumns;
00105 typedef ROMSAntennaColumns ROCTAntennaColumns;
00106 typedef ROMSSpWindowColumns ROCTSpWindowColumns;
00107 typedef ROMSHistoryColumns ROCTHistoryColumns;
00108 
00109 class NewCalTable : public Table
00110 {
00111 
00112   friend class SolvableVisCal;
00113 
00114  public:
00115    // Default null constructor, and destructor
00116    NewCalTable();
00117    virtual ~NewCalTable();
00118 
00119    // Construct from a specified table name, calibration table descriptor 
00120    // and table access option. Used for creating new tables.
00121    NewCalTable (const String& tableName, CTDesc& ctableDesc,
00122                 Table::TableOption access = Table::New, 
00123                 Table::TableType ttype = Table::Plain);
00124 
00125    // Construct from setupNewTable 
00126    NewCalTable (SetupNewTable& newTab, uInt nrow = 0, Bool initialize = False);
00127    
00128    // Create an empty NewCalTable conveniently
00129    NewCalTable(String tableName,VisCalEnum::VCParType parType,
00130                String typeName,String msName,Bool doSingleChan);
00131 
00132    // Construct from a specified table name, and access option. Used
00133    // for accessing existing tables.
00134    NewCalTable (const String& tableName, 
00135                 Table::TableOption access = Table::Old, 
00136                 Table::TableType ttype = Table::Memory);
00137 
00138    static NewCalTable createCT(const String& tableName, 
00139                                Table::TableOption access, 
00140                                Table::TableType ttype, 
00141                                Bool doBackCompat=True);
00142 
00143    static NewCalTable* createCTptr(const String& tableName, 
00144                                    Table::TableOption access, 
00145                                    Table::TableType ttype, 
00146                                    Bool doBackCompat=True);
00147 
00148 
00149 
00150    // Construct from an existing table object
00151    NewCalTable (const Table& table);
00152 
00153    // Copy constructor
00154    NewCalTable (const NewCalTable& other);
00155 
00156    // Create a vanilla NewCalTable from shapes (for testing purposes)
00157    //  Default rTime is 2012/01/06/12:00:00
00158    NewCalTable(String tableName,String CorF,
00159                Int nObs=1, Int nScanPerObs=1,Int nTimePerScan=1,
00160                Int nAnt=1, Int nSpw=1, Vector<Int> nChan=Vector<Int>(1,1), 
00161                Int nFld=1, 
00162                Double rTime=0.0, Double tint=0.0,
00163                Bool disk=False, Bool verbose=False);
00164 
00165    // Assignment operator
00166    NewCalTable& operator= (const NewCalTable& other);
00167 
00168    // Handle backward compatibility
00169    static Bool CTBackCompat(const String& caltable);
00170 
00171    // Set the TableInfo record
00172    void setTableInfo();
00173 
00174    // initialize reference to subtables
00175    void createSubTables();
00176    void attachSubTables();
00177    void clearSubtables();
00178 
00179    void copyMemCalSubtables(const NewCalTable& other);
00180    void copyMemCalSubtable(const Table& otherSubtable, Table& subTable);
00181 
00182    // Complex parameters?  (else Float)
00183    Bool isComplex();
00184 
00185    // Report the polarization basis (from header record)
00186    String polBasis();
00187 
00188    // Get a row from cal_main
00189    Record getRowMain (const Int& jrow);
00190     
00191    // Put a row to cal_main
00192    void putRowMain (const Int& jrow, CTMainRecord& tableRec);
00193 
00194    // Get rows of the data from the main table
00195    //   void fillRowsMain ();
00196 
00197    // Set Meta data info from a parent MS 
00198    void setMetaInfo (const String& msName);
00199 
00200    //validate input table desc. over required caltable desc
00201    static Bool conformant(const TableDesc& tabDesc);
00202 
00203    // save to disk
00204    void writeToDisk(const String& tableName); 
00205 
00206    CTObservation& observation() {return observation_p;}
00207    CTAntenna& antenna() {return antenna_p;}
00208    CTField& field() {return field_p;}
00209    CTSpectralWindow& spectralWindow() {return spectralWindow_p;}
00210    CTHistory& history() {return history_p;}
00211    const CTObservation& observation() const {return observation_p;}
00212    const CTAntenna& antenna() const {return antenna_p;}
00213    const CTField& field() const {return field_p;}
00214    const CTSpectralWindow& spectralWindow() const {return spectralWindow_p;}
00215    const CTHistory& history() const {return history_p;}
00216 
00217    // Provide RO access to 
00218    //   inline ROCTMainColumns mcols() const {return ROCTMainColumns(*this);};
00219 
00220    static Complex NCTtestvalueC(Int iant,Int ispw,Double ich,Double time,Double refTime,Double tint);
00221    static Float NCTtestvalueF(Int iant,Int ispw,Double ich,Double time,Double refTime,Double tint);
00222 
00223    // Fill in antenna-based solutions
00224    //  (obsId-less version calls obsId-capable version w/ obsId=0)
00225    void fillAntBasedMainRows(uInt nrows, 
00226                              Double time,Double interval,
00227                              Int fieldId,uInt spwId,Int scanNo,
00228                              const Vector<Int>& ant1list, Int refant,
00229                              const Cube<Complex>& cparam,
00230                              const Cube<Bool>& flag,
00231                              const Cube<Float>& paramErr,
00232                              const Cube<Float>& snr);
00233    void fillAntBasedMainRows(uInt nrows, 
00234                              Double time,Double interval,
00235                              Int fieldId,uInt spwId,Int obsId,Int scanNo,
00236                              const Vector<Int>& ant1list, Int refant,
00237                              const Cube<Complex>& cparam,
00238                              const Cube<Bool>& flag,
00239                              const Cube<Float>& paramErr,
00240                              const Cube<Float>& snr);
00241 
00242    // Reset spw freq info
00243    void setSpwFreqs(Int spw, const Vector<Double>& freq, 
00244                     const Vector<Double>& chanwidth=Vector<Double>());
00245 
00246    // Set FLAG_ROW in SPECTRAL_WINDOW subtable for spws absent in MAIN
00247    void flagAbsentSpws();
00248 
00249    // Merge SPW subtable rows from another NewCalTable
00250    void mergeSpwMetaInfo(const NewCalTable& other);
00251 
00252    // Add a line to the HISTORY table
00253    void addHistoryMessage(String app="",String message="none");
00254 
00255  private:
00256 
00257    // Services for generic test table ctor
00258    //  Default rTime is 2012/01/06/12:00:00
00259    void fillGenericContents(Int nObs=1, Int nScanPerObs=1, Int nTimePerScan=1,
00260                             Int nAnt=1, Int nSpw=1, Vector<Int> nChan=Vector<Int>(1,1), 
00261                             Int nFld=1, 
00262                             Double rTime=0.0, Double tint=0.0,
00263                             Bool verbose=False);
00264    void fillGenericObs(Int nObs);
00265    void fillGenericField(Int nFld);
00266    void fillGenericAntenna(Int nAnt);
00267    void fillGenericSpw(Int nSpw,Vector<Int>& nChan);
00268      
00269    // Force Spw subtable to be all nchan=1
00270    //  (very basic; uses chan n/2 freq)
00271    void makeSpwSingleChan();
00272 
00273    // Handle pre-4.1 caltables that don't have OBS_ID
00274    //  (by adding a phoney one with a single OBS_ID
00275    void addPhoneyObs();
00276 
00277    // Handle Eph objects...
00278    void handleEphObj(const MSField& msfldtab,const String& msName);
00279 
00280 
00281    // The subtables
00282    CTObservation observation_p;
00283    CTAntenna antenna_p;
00284    CTField field_p;
00285    CTSpectralWindow spectralWindow_p;
00286    CTHistory history_p;
00287 
00288  };
00289 
00290 } //# NAMESPACE CASA - END
00291 
00292 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1