casa
$Rev:20696$
|
00001 //# UVMod.h: Definitions of interface for UV-modelling in calibrater 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_UVMOD_H 00029 #define SYNTHESIS_UVMOD_H 00030 00031 #include <casa/aips.h> 00032 #include <casa/Containers/Record.h> 00033 #include <casa/BasicSL/Complex.h> 00034 #include <casa/BasicSL/Constants.h> 00035 #include <synthesis/MeasurementEquations/Iterate.h> 00036 #include <synthesis/MSVis/VisSet.h> 00037 #include <measures/Measures/MDirection.h> 00038 #include <measures/Measures/MPosition.h> 00039 #include <casa/Arrays/Array.h> 00040 #include <casa/Arrays/Vector.h> 00041 #include <casa/Arrays/Matrix.h> 00042 #include <components/ComponentModels/ComponentType.h> 00043 #include <components/ComponentModels/ComponentList.h> 00044 #include <components/ComponentModels/SkyComponent.h> 00045 00046 00047 namespace casa { //# NAMESPACE CASA - BEGIN 00048 00049 // <summary> 00050 // VisCal: Model multiplicative errors for the <linkto class="VisEquation">VisEquation</linkto> 00051 // </summary> 00052 00053 // <use visibility=export> 00054 00055 // <reviewed reviewer="" date="" tests="" demos=""> 00056 00057 // <prerequisite> 00058 // <li> <linkto class="MeasurementComponents">MeasurementComponents</linkto> module 00059 // <li> <linkto class="VisSet">VisSet</linkto> module 00060 // <li> <linkto class="VisEquation">VisEquation</linkto> module 00061 // </prerequisite> 00062 // 00063 // <etymology> 00064 // VisCal describes an interface for multiplicative errors to be used in 00065 // the <linkto class="VisEquation">VisEquation</linkto>. It is an Abstract Base Class: most methods 00066 // must be defined in derived classes. 00067 // </etymology> 00068 // 00069 // <synopsis> 00070 // 00071 // See <linkto class="VisEquation">VisEquation</linkto> for definition of the 00072 // Visibility Measurement Equation. 00073 // 00074 // The following examples illustrate how an VisCal can be 00075 // used: 00076 // <ul> 00077 // <li> Simulation: random multiplicative gains of a certain scaling 00078 // can be applied: <linkto class="SimVisCal">SimVisCal</linkto> 00079 // <li> Time variable multiplicative errors: <linkto class="TimeVarVisCal">TimeVarVisCal</linkto> 00080 // <li> Solvable time variable multiplicatiove errors: <linkto class="SolvableVisCal">SolvableVisCal</linkto> 00081 // </ul> 00082 // </synopsis> 00083 // 00084 // <example> 00085 // <srcblock> 00086 // // Read the VisSet from disk 00087 // VisSet vs("3c84.MS"); 00088 // 00089 // VisEquation ve(vs); 00090 // 00091 // // Make an VisCal 00092 // PhaseScreenVisCal coac(vs); 00093 // 00094 // // Correct the visset 00095 // ve.correct(); 00096 // </srcblock> 00097 // </example> 00098 // 00099 // <motivation> 00100 // The properties of an multiplicative component must be described 00101 // for the <linkto class="VisEquation">VisEquation</linkto>. 00102 // </motivation> 00103 // 00104 // <todo asof="97/10/01"> 00105 // </todo> 00106 00107 // ********************************************************** 00108 // VisCal 00109 // 00110 00111 class UVMod { 00112 public: 00113 00114 UVMod(VisSet& vs); 00115 00116 virtual ~UVMod(); 00117 00118 inline Int& nPar() { return nPar_; }; 00119 00120 void setModel(const ComponentType::Shape type, 00121 const Vector<Double> inpar, 00122 const Vector<Bool> invary); 00123 00124 Bool modelfit(const Int& maxiter, const String file); 00125 00126 inline Vector<Double>& par() { return par_; }; 00127 00128 protected: 00129 00130 // Initial solving data 00131 void initSolve(); 00132 00133 // Calculate residuals (incl. diff'd) and chi2 00134 virtual void residual(); 00135 void chiSquare(); 00136 00137 // Internal solving methods 00138 void accGradHess(); 00139 void solveGradHess(const Bool& doCovar=False); 00140 Bool updPar(); 00141 Bool setCompPar(); 00142 void printPar(const Int& iter); 00143 00144 // Access to VisSet 00145 inline VisSet& vs() { return *vs_; }; 00146 00147 // Access to ComponentList 00148 inline ComponentList& cl() { return *cl_; }; 00149 00150 // Access to SkyComponents by id 00151 inline SkyComponent& skycomp(const uInt id) { return cl_->component(id); }; 00152 00153 // Access to current VisBuffer 00154 inline VisBuffer& svb() { return *svb_; }; 00155 00156 // Access to fieldId we are fitting for 00157 inline Int& fitfld() { return fitfld_; }; 00158 inline MDirection& pc() { return pc_; }; 00159 00160 // Accessors to current svb's (differentiated) Residuals 00161 inline Cube<DComplex>& R() { return R_; }; 00162 inline Array<DComplex>& dR() { return dR_; }; 00163 00164 // Access to chi2 00165 inline Double& chiSq() { return chiSq_; }; 00166 inline Double& lastChiSq() { return lastChiSq_; }; 00167 inline Double& sumWt() { return sumWt_; }; 00168 inline Int& nWt() { return nWt_; }; 00169 inline Vector<Bool>& polWt() { return polWt_; }; 00170 00171 // Access to parameters, & grad,hess,dp 00172 inline Double& lamb() { return lamb_; }; 00173 inline Vector<Double>& lastPar() { return lastPar_; }; 00174 inline Vector<Double>& grad() { return grad_; }; 00175 inline Vector<Double>& lastGrad() { return lastGrad_; }; 00176 inline Matrix<Double>& hess() { return hess_; }; 00177 inline Matrix<Double>& lastHess() { return lastHess_; }; 00178 inline Vector<Double>& dpar() { return dpar_; }; 00179 inline Vector<Bool>& vary() { return vary_; }; 00180 inline Int& nVary() { return nVary_; }; 00181 00182 00183 private: 00184 00185 // Associated VisSet (LOCAL) 00186 VisSet* vs_; 00187 00188 // ComponentList (LOCAL) 00189 ComponentList* cl_; 00190 00191 // VisBuffer (from outside) 00192 VisBuffer* svb_; 00193 00194 // FieldId in fit 00195 Int fitfld_; 00196 00197 // Phase center w.r.t. which modelfitting is done 00198 MDirection pc_; 00199 00200 // Total Number of parameters 00201 Int nPar_; 00202 00203 // Residual/Differentiation caches 00204 Cube<DComplex> R_; 00205 Array<DComplex> dR_; 00206 00207 // Chi2, sum wts 00208 Double chiSq_; 00209 Double lastChiSq_; 00210 Double sumWt_; 00211 Int nWt_; 00212 00213 Vector<Bool> polWt_; 00214 00215 // Parameter storage 00216 Vector<Double> par_; 00217 Vector<Double> lastPar_; 00218 00219 // Gradient, Hessian, par update 00220 Double lamb_; 00221 Vector<Double> grad_; 00222 Vector<Double> lastGrad_; 00223 Matrix<Double> hess_; 00224 Matrix<Double> lastHess_; 00225 Vector<Double> dpar_; 00226 Vector<Bool> vary_; 00227 Int nVary_; 00228 00229 }; 00230 00231 } 00232 #endif