casa
$Rev:20696$
|
00001 //# EPJones.h: Declaration of EPJones (Solvable)VisCal type 00002 //# Copyright (C) 1996,1997,2000,2001,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 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 00028 #ifndef SYNTHESIS_EPJONES_H 00029 #define SYNTHESIS_EPJONES_H 00030 00031 #include <casa/aips.h> 00032 #include <casa/Containers/Record.h> 00033 #include <casa/BasicSL/Complex.h> 00034 #include <synthesis/MeasurementComponents/SolvableVisCal.h> 00035 #include <synthesis/MeasurementComponents/nPBWProjectFT.h> 00036 #include <synthesis/MeasurementComponents/PBMosaicFT.h> 00037 #include <ms/MeasurementSets/MeasurementSet.h> 00038 #include <images/Images/PagedImage.h> 00039 #include <images/Images/ImageInterface.h> 00040 #include <images/Images/ImageInfo.h> 00041 #include <synthesis/TransformMachines/StokesImageUtil.h> 00042 #include <synthesis/MSVis/VisSet.h> 00043 #include <synthesis/CalTables/CalSet.h> 00044 #include <casa/OS/Timer.h> 00045 namespace casa { //# NAMESPACE CASA - BEGIN 00046 00047 // Forward declaration 00048 class VisEquation; 00049 class nPBWProjectFT; 00050 class PBMosaicFT; 00051 00052 // ********************************************************** 00053 // EPJones (pointing errors) 00054 // 00055 00056 class EPJones : public SolvableVisJones { 00057 public: 00058 00059 // Constructor 00060 EPJones(VisSet& vs); 00061 // {throw(AipsError("Use the constructor EPJones(VisSet&, MeasurementSet&) instead"));}; 00062 EPJones(VisSet& vs, MeasurementSet& ms); 00063 // EPJones(const Int& nAnt); // NYI 00064 00065 virtual ~EPJones(); 00066 00067 // Return the type enum 00068 virtual Type type() { return VisCal::E; }; 00069 00070 // Return type name as string 00071 virtual String typeName() { return "EP Jones"; }; 00072 virtual String longTypeName() { return "EP Jones (pointing errors)"; }; 00073 00074 // Type of Jones matrix according to nPar() 00075 Jones::JonesType jonesType() { return Jones::Diagonal; }; 00076 00077 virtual VisCalEnum::VCParType parType() { return setParType(VisCalEnum::REAL);}; 00078 00079 // Specialized access to pointing parameters (no chan axis) 00080 Cube<Float>& loadPar(); 00081 00082 virtual void setModel(const String& modelImage); 00083 // Set the solving parameters 00084 virtual void setSolve(); 00085 virtual void setSolve(const Record& solve); 00086 virtual void setNiter(const Int& niter) {niter_p=niter;} 00087 virtual void setTolerance(const Float& tol) {tolerance_p = tol;} 00088 virtual void setGain(const Float& gain) {gain_p = gain;} 00089 00090 // Arrange to apply (corrupt only) 00091 using SolvableVisCal::setApply; 00092 virtual void setApply(const Record& applypar); 00093 00094 // Apply calibration to a VisBuffer 00095 virtual void applyCal(VisBuffer& vb, 00096 Cube<Complex>& Mout); 00097 00098 // Differentiate a VisBuffer w.r.t. pointng parameters 00099 // 00100 // These effectively compute residuals and derivatives for 00101 // a time-averaged VisBuffer 00102 // 00103 virtual void differentiate(VisBuffer& vb, 00104 Cube<Complex>& Mout, 00105 Array<Complex>& dMout, 00106 Matrix<Bool>& Mflg); 00107 // Differentiate a VisBuffer w.r.t. pointng parameters 00108 virtual void differentiate(VisBuffer& vb, 00109 VisBuffer& dvb0, 00110 VisBuffer& dvb1, 00111 Matrix<Bool>& Mflg); 00112 // 00113 // This one averages the residuals and the derivatives in time. 00114 // 00115 virtual void diffResiduals(VisIter& vi, VisEquation& ve, 00116 VisBuffer& residuals, 00117 VisBuffer& dVr1, 00118 VisBuffer& dVr2, 00119 Matrix<Bool>& flags); 00120 // Guess (throws error because we don't yet solve for this) 00121 virtual void guessPar(VisBuffer& vb); 00122 virtual void guessPar() {pointPar_=0;} 00123 00124 virtual Cube<Float>& solveRPar() {return pointPar_;} 00125 virtual void setRPar(Cube<Float>& val) {pointPar_.resize(val.shape());pointPar_=val;} 00126 virtual void setRPar(Double val) {pointPar_=val;} 00127 00128 // virtual void keep(const Int& slot); 00129 00130 virtual Bool normalizable() { return False; }; 00131 00132 // virtual BaseCalSet& cs() {return *rcs_;}; 00133 virtual void keep(const Int& slot); 00134 00135 inline virtual CalSet<Float>& rcs() {return *rcs_;}; 00136 00137 virtual void inflate(const Vector<Int>& nChan, 00138 const Vector<Int>& startChan, 00139 const Vector<Int>& nSlot); 00140 void initSolve(VisSet& vs); 00141 void initSolvePar(); 00142 void store(); 00143 void store(const String& table,const Bool& append); 00144 Bool verifyForSolve(VisBuffer& vb); 00145 virtual void postSolveMassage(const VisBuffer&); 00146 virtual void selfGatherAndSolve(VisSet& vs,VisEquation& ve); 00147 virtual Bool useGenericGatherForSolve() { return False; }; 00148 virtual Float printFraction(const Int& ) {return 0.1;}; 00149 Array<Float> getOffsets(const Int& spw) {return rcs().par(spw);} 00150 Array<Double> getTime(const Int& spw) {return rcs().time(spw);} 00151 void nearest(const Double time, Array<Float>& vals); 00152 void printRPar(); 00153 00154 protected: 00155 00156 // EP has a pair of real parameters per feed 00157 virtual Int nPar() { return 4; }; 00158 00159 // Jones matrix elements are NOT trivial 00160 virtual Bool trivialJonesElem() { return False; }; 00161 00162 // Fill-in a complex grid with the image values in prepration for 00163 // computing it's FT 00164 virtual void makeComplexGrid(TempImage<Complex>& Grid, 00165 PagedImage<Float>& ModelImage, 00166 VisBuffer& vb); 00167 void printActivity(const Int slotNo, const Int fieldId, const Int spw, const Int nSolutions); 00168 // inline virtual CalSet<Float> rcs() {return *cs_;} 00169 00170 private: 00171 00172 // Local Matrix for referencing pointing pars in a convenient way 00173 Cube<Float> pointPar_; 00174 nPBWProjectFT *pbwp_p; 00175 // PBMosaicFT *pbwp_p; 00176 MeasurementSet *ms_p; 00177 VisSet *vs_p; 00178 // Array<Float> azOff, elOff; 00179 TempImage<Complex> targetVisModel_; 00180 CalSet<Float> *rcs_; 00181 Double maxTimePerSolution, minTimePerSolution, avgTimePerSolution; 00182 Timer timer; 00183 Vector<Int> polMap_p; 00184 Float tolerance_p, gain_p; 00185 Int niter_p; 00186 }; 00187 00188 00189 00190 00191 00192 } //# NAMESPACE CASA - END 00193 00194 #endif 00195