casa  $Rev:20696$
PlotCal.h
Go to the documentation of this file.
00001 //# PlotCal.h Class to plot calibration tables
00002 //# Copyright (C) 1996-2007
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$
00028 
00029 #include <casa/aips.h>
00030 #include <tableplot/TablePlot/TablePlot.h>
00031 #include <synthesis/CalTables/NewCalTable.h>
00032 
00033 #ifndef CALIBRATION_PLOTCAL_H
00034 #define CALIBRATION_PLOTCAL_H
00035 
00036 
00037 namespace casa { //# NAMESPACE CASA - BEGIN
00038 
00039 // forward declarations:
00040 template <class T> class PtrBlock;
00041 class Record;
00042 class PlotOptions;
00043 class TPConvertTimeX;
00044 
00045 class PlotCal
00046   {
00047 
00048 // <summary> 
00049 // PlotCal: Class to plot calibration tables.
00050 // </summary>
00051 // <use visibility=export>
00052 
00053 // <reviewed reviewer="" date="" tests="" demos="">
00054 
00055 // <prerequisite>
00056 //   <li> <linkto class="TablePlot">TablePlot</linkto> module
00057 // </prerequisite>
00058 //
00059 // <etymology>
00060 // From "Plot" and "Calibration Table"
00061 // </etymology>
00062 //
00063 // <synopsis>
00064 // To plot calibration tables ...encapsulates knowledge of 
00065 // different cal tables 
00066 // </synopsis>
00067 
00068 // <todo asof="2005/12/31">
00069 // (i) make use of cal-iterators
00070 // </todo>
00071 
00072   public:
00073     //Default constructor
00074     PlotCal();
00075 
00076     //Destructor 
00077     virtual ~PlotCal();
00078 
00079     //open a calibration table
00080     Bool open(String tabName);
00081 
00082     //close...detach from tables but keep tablePlot alive
00083     void close();
00084 
00085     //Clear the plot or panel
00086     Bool clearPlot(Int panel=0);
00087 
00088     // Setting the plot look and feel
00089     Bool setPlotParam(Int subplot=111,
00090                       const Bool overplot=False,
00091                       const String& iteration="",
00092                       const Vector<Double>& plotrange=Vector<Double>(0),
00093                       const Bool& showflags=False,
00094                       const String& plotsymbol="ro",
00095                       const String& plotcolor="green",
00096                       const Double& markersize=5.0,
00097                       const Double& fontsize=10.0);
00098     
00099     // Select on caltable using MSSelection helpers
00100     Bool selectCal(const String& antenna="",
00101                    const String& field="",
00102                    const String& spw="",
00103                    const String& time="",
00104                    const String& poln="");
00105 
00106     //Plot the selection and table
00107     Bool oldplot(String plottype=String("PHASE"),
00108                  String poltype=String(""));
00109 
00110     Bool plot(String xaxis="",String yaxis="");
00111 
00112     // Save the plot to an image file.
00113     Bool saveFigure( const String& filename, 
00114                      const Int dpi, 
00115                      const String& orientation,
00116                      const String& papertype,
00117                      const String& facecolor,
00118                      const String& edgecolor );
00119     
00120     // Trigger next iteration
00121     Bool iterPlotNext();
00122 
00123     // stop iterations
00124     Bool iterPlotStop( Bool rmplotter );
00125 
00126 
00127     // mark a region
00128     Bool markRegion(Int nrows, Int ncols, Int panel, Vector<Double>& region);
00129 
00130     // flag the data
00131     Bool flagData(Bool direction);
00132 
00133     // Print Location of data
00134     Bool  locateData();
00135       
00136   private:
00137 
00138     void createCalTab(String& tabName);
00139 
00140     void getAxisTaQL(const String& axis,
00141                      String& taql,
00142                      String& label);
00143     Bool doPlot();
00144 
00145     Int multiTables(const Table& tablein,
00146                     Vector<Table>& tablesout,
00147                     Vector<String>& tablesoutnames,
00148                     Vector<Int>& cdlist,
00149                     Block<String> colNames);
00150 
00151     void subplotToPanel(const Int& subplot, Int& nrows, Int& ncols,
00152                         Int& panel);
00153     //One more function which is very matplotlib specific
00154     void setPlotSymbols(const String& plotsymbol);
00155 
00156     //Fill the option record into plotoption 
00157     void fillPlotOptions();
00158 
00159     // Get MS Meta data for labels and locating
00160     void getMetaRecord();
00161 
00162     Vector<Int> getAntIdx(const String& antenna);
00163     Vector<Int> getFieldIdx(const String& field);
00164     Vector<Int> getSpwIdx(const String& spw,Matrix<Int>& chanId);
00165     Vector<Int> getCalDescIds(const Vector<Int> selspws);
00166     Matrix<Double> getTimeRange(const String& time);
00167 
00168     // get channel freq info for frequency labelling
00169     void getFreqInfo();
00170 
00171     // Handle BPOLY
00172     void virtualBPoly( Table& tabG, Int& nchan);
00173     Double getChebVal(const Vector<Double>& coeff,
00174                       const Double& xinit, const Double& xfinal,
00175                       const Double& x);
00176 
00177     // Handle GSPLINE
00178     void virtualGSpline( Table& tabG );
00179     Double getSplineVal (Double x, 
00180                          Vector<Double>& knots,
00181                          Vector<Double>& coeff);
00182     // Handle K 
00183     Bool timePlotK();
00184     void virtualKTab( Table& tabB, Int& nAnt, 
00185                                Vector<Int>& ant1hash, Vector<Int>& ant2hash );
00186 
00187     // Return which MAIN table column to return for "CAL_DESC_ID",
00188     //  depending on whether we are plotting a new or old table
00189     inline String CDIcol() { return (isNCT_p ? "SPECTRAL_WINDOW_ID" : "CAL_DESC_ID"); };
00190     inline String GAINcol() { return (isNCT_p ? "CPARAM" : "GAIN"); };
00191 
00192     // Private data
00193     TablePlot *tp_p;
00194 
00195     String tabName_p;
00196     String msName_p;
00197 
00198     Table tab_p;
00199     Table tabSel_p;
00200 
00201     String calType_p;
00202 
00203 
00204     Int nxPanels_p, nyPanels_p; 
00205     Bool multiPlot_p;
00206     Bool overPlot_p;
00207     
00208     Bool antSel_p, fldSel_p,spwSel_p;
00209 
00210     Record plotopts_p;
00211     PlotOptions itsPlotOptions;
00212 
00213     String plotType_p, polType_p;
00214     String xAxis_p,yAxis_p;
00215 
00216     // This is the one that will have a flag column
00217     Table virtualTab_p;
00218     PtrBlock<Table *> overlayTabs_p;
00219     Vector<String> plotTaQL_p;
00220     Vector<String> label_p;
00221 
00222     Vector<String> iterAxes_p;
00223     Bool iterating_p;
00224 
00225     String title_p;
00226     String titleMain_p, titlePoln_p, titleSpw_p, titleFld_p, titleAnt_p;
00227     // whichPol_p determines which pol to plot
00228     // 0 = "R" or "X"
00229     // 1 = "L" or "Y"
00230     // 2 = "diff of phase " or "ratio of amplitude" between R and L or X and Y
00231     // 3 = "mean" of  "R" and "L" or "X" and "Y"  
00232     Int whichPol_p;
00233 
00234     Int nCalDesc_p;
00235     Matrix<Int> tabSpws_p,chanId_p;
00236     Vector<Double> startFreq_p;
00237     Vector<Double> stepFreq_p;
00238     Vector<Int> nchan_p;
00239 
00240     // The ResetCallBack
00241     casa::TPResetCallBack *resetCallBack_p;
00242 
00243     // A record containing meta info for callbacks
00244     Record metaRec_p;
00245 
00246     Vector< Vector<Int> > fldlist_p;
00247 
00248     Bool noMS_p;
00249 
00250     Vector<Int> MSstartChan_p;
00251 
00252     // If True, we are plotting a NewCalTable, else the old kind
00253     Bool isNCT_p;
00254 
00255     NewCalTable ct_p;
00256 
00257   };
00258 
00259 
00260 } //# NAMESPACE CASA - END
00261 
00262 #endif
00263    
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines