casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UVMod.h
Go to the documentation of this file.
1 //# UVMod.h: Definitions of interface for UV-modelling in calibrater
2 //# Copyright (C) 1996,1997,2000,2001,2002,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be adressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 
28 #ifndef SYNTHESIS_UVMOD_H
29 #define SYNTHESIS_UVMOD_H
30 
31 #include <casa/aips.h>
32 #include <casa/Containers/Record.h>
33 #include <casa/BasicSL/Complex.h>
34 #include <casa/BasicSL/Constants.h>
36 #include <msvis/MSVis/VisSet.h>
39 #include <casa/Arrays/Array.h>
40 #include <casa/Arrays/Vector.h>
41 #include <casa/Arrays/Matrix.h>
45 
46 
47 namespace casa { //# NAMESPACE CASA - BEGIN
48 
49 // <summary>
50 // VisCal: Model multiplicative errors for the <linkto class="VisEquation">VisEquation</linkto>
51 // </summary>
52 
53 // <use visibility=export>
54 
55 // <reviewed reviewer="" date="" tests="" demos="">
56 
57 // <prerequisite>
58 // <li> <linkto class="MeasurementComponents">MeasurementComponents</linkto> module
59 // <li> <linkto class="VisSet">VisSet</linkto> module
60 // <li> <linkto class="VisEquation">VisEquation</linkto> module
61 // </prerequisite>
62 //
63 // <etymology>
64 // VisCal describes an interface for multiplicative errors to be used in
65 // the <linkto class="VisEquation">VisEquation</linkto>. It is an Abstract Base Class: most methods
66 // must be defined in derived classes.
67 // </etymology>
68 //
69 // <synopsis>
70 //
71 // See <linkto class="VisEquation">VisEquation</linkto> for definition of the
72 // Visibility Measurement Equation.
73 //
74 // The following examples illustrate how an VisCal can be
75 // used:
76 // <ul>
77 // <li> Simulation: random multiplicative gains of a certain scaling
78 // can be applied: <linkto class="SimVisCal">SimVisCal</linkto>
79 // <li> casacore::Time variable multiplicative errors: <linkto class="TimeVarVisCal">TimeVarVisCal</linkto>
80 // <li> Solvable time variable multiplicatiove errors: <linkto class="SolvableVisCal">SolvableVisCal</linkto>
81 // </ul>
82 // </synopsis>
83 //
84 // <example>
85 // <srcblock>
86 // // Read the VisSet from disk
87 // VisSet vs("3c84.MS");
88 //
89 // VisEquation ve(vs);
90 //
91 // // Make an VisCal
92 // PhaseScreenVisCal coac(vs);
93 //
94 // // Correct the visset
95 // ve.correct();
96 // </srcblock>
97 // </example>
98 //
99 // <motivation>
100 // The properties of an multiplicative component must be described
101 // for the <linkto class="VisEquation">VisEquation</linkto>.
102 // </motivation>
103 //
104 // <todo asof="97/10/01">
105 // </todo>
106 
107 // **********************************************************
108 // VisCal
109 //
110 
111 class UVMod {
112 public:
113 
114  UVMod(VisSet& vs);
115 
116  virtual ~UVMod();
117 
118  inline casacore::Int& nPar() { return nPar_; };
119 
120  void setModel(const ComponentType::Shape type,
122  const casacore::Vector<casacore::Bool> invary);
123 
125 
127 
128 protected:
129 
130  // Initial solving data
131  void initSolve();
132 
133  // Calculate residuals (incl. diff'd) and chi2
134  virtual void residual();
135  void chiSquare();
136 
137  // Internal solving methods
138  void accGradHess();
139  void solveGradHess(const casacore::Bool& doCovar=false);
142  void printPar(const casacore::Int& iter);
143 
144  // Access to VisSet
145  inline VisSet& vs() { return *vs_; };
146 
147  // Access to ComponentList
148  inline ComponentList& cl() { return *cl_; };
149 
150  // Access to SkyComponents by id
151  inline SkyComponent& skycomp(const casacore::uInt id) { return cl_->component(id); };
152 
153  // Access to current VisBuffer
154  inline VisBuffer& svb() { return *svb_; };
155 
156  // Access to fieldId we are fitting for
157  inline casacore::Int& fitfld() { return fitfld_; };
158  inline casacore::MDirection& pc() { return pc_; };
159 
160  // Accessors to current svb's (differentiated) Residuals
161  inline casacore::Cube<casacore::DComplex>& R() { return R_; };
163 
164  // Access to chi2
165  inline casacore::Double& chiSq() { return chiSq_; };
166  inline casacore::Double& lastChiSq() { return lastChiSq_; };
167  inline casacore::Double& sumWt() { return sumWt_; };
168  inline casacore::Int& nWt() { return nWt_; };
170 
171  // Access to parameters, & grad,hess,dp
172  inline casacore::Double& lamb() { return lamb_; };
180  inline casacore::Int& nVary() { return nVary_; };
181 
182 
183 private:
184 
185  // Associated VisSet (LOCAL)
186  VisSet* vs_;
187 
188  // ComponentList (LOCAL)
190 
191  // VisBuffer (from outside)
193 
194  // FieldId in fit
196 
197  // Phase center w.r.t. which modelfitting is done
199 
200  // Total Number of parameters
202 
203  // Residual/Differentiation caches
206 
207  // Chi2, sum wts
212 
214 
215  // Parameter storage
218 
219  // Gradient, Hessian, par update
228 
229 };
230 
231 }
232 #endif
virtual void residual()
Calculate residuals (incl.
A Measure: astronomical direction.
Definition: MDirection.h:174
int Int
Definition: aipstype.h:50
casacore::Vector< casacore::Double > & lastGrad()
Definition: UVMod.h:175
casacore::Vector< casacore::Bool > & vary()
Definition: UVMod.h:179
casacore::Bool updPar()
casacore::Matrix< casacore::Double > & lastHess()
Definition: UVMod.h:177
VisBuffer * svb_
VisBuffer (from outside)
Definition: UVMod.h:192
Shape
The shapes of all the components.
casacore::Matrix< casacore::Double > & hess()
Definition: UVMod.h:176
UVMod(VisSet &vs)
void initSolve()
Initial solving data.
SkyComponent & skycomp(const casacore::uInt id)
Access to SkyComponents by id.
Definition: UVMod.h:151
ComponentList & cl()
Access to ComponentList.
Definition: UVMod.h:148
virtual Type type()
Return the type enum.
casacore::Matrix< casacore::Double > hess_
Definition: UVMod.h:223
casacore::Int & nPar()
Definition: UVMod.h:118
casacore::Int & fitfld()
Access to fieldId we are fitting for.
Definition: UVMod.h:157
casacore::Double chiSq_
Chi2, sum wts.
Definition: UVMod.h:208
casacore::Int & nVary()
Definition: UVMod.h:180
void solveGradHess(const casacore::Bool &doCovar=false)
VisCal: Model multiplicative errors for the VisEquation.
Definition: UVMod.h:111
casacore::Cube< casacore::DComplex > & R()
Accessors to current svb&#39;s (differentiated) Residuals.
Definition: UVMod.h:161
casacore::Int nPar_
Total Number of parameters.
Definition: UVMod.h:201
casacore::Int & nWt()
Definition: UVMod.h:168
void setModel(const ComponentType::Shape type, const casacore::Vector< casacore::Double > inpar, const casacore::Vector< casacore::Bool > invary)
casacore::Double & chiSq()
Access to chi2.
Definition: UVMod.h:165
casacore::Double lamb_
Gradient, Hessian, par update.
Definition: UVMod.h:220
VisSet * vs_
Associated VisSet (LOCAL)
Definition: UVMod.h:180
casacore::Vector< casacore::Bool > vary_
Definition: UVMod.h:226
casacore::Int nWt_
Definition: UVMod.h:211
VisBuffer & svb()
Access to current VisBuffer.
Definition: UVMod.h:154
void accGradHess()
Internal solving methods.
casacore::Double lastChiSq_
Definition: UVMod.h:209
casacore::Array< casacore::DComplex > dR_
Definition: UVMod.h:205
casacore::Vector< casacore::Bool > polWt_
Definition: UVMod.h:213
double Double
Definition: aipstype.h:55
casacore::Double & sumWt()
Definition: UVMod.h:167
casacore::Vector< casacore::Double > par_
Parameter storage.
Definition: UVMod.h:216
casacore::Int nVary_
Definition: UVMod.h:227
ComponentList * cl_
ComponentList (LOCAL)
Definition: UVMod.h:189
casacore::Vector< casacore::Double > lastGrad_
Definition: UVMod.h:222
VisSet & vs()
Access to VisSet.
Definition: UVMod.h:145
casacore::Bool modelfit(const casacore::Int &maxiter, const casacore::String file)
casacore::Double & lamb()
Access to parameters, &amp; grad,hess,dp.
Definition: UVMod.h:172
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Vector< casacore::Double > lastPar_
Definition: UVMod.h:217
casacore::MDirection pc_
Phase center w.r.t.
Definition: UVMod.h:198
casacore::Double sumWt_
Definition: UVMod.h:210
virtual ~UVMod()
casacore::Vector< casacore::Double > dpar_
Definition: UVMod.h:225
casacore::Matrix< casacore::Double > lastHess_
Definition: UVMod.h:224
casacore::Double & lastChiSq()
Definition: UVMod.h:166
casacore::Vector< casacore::Double > grad_
Definition: UVMod.h:221
casacore::MDirection & pc()
Definition: UVMod.h:158
void printPar(const casacore::Int &iter)
casacore::Int fitfld_
FieldId in fit.
Definition: UVMod.h:195
A class for manipulating groups of components.
A component of a model of the sky.
Definition: SkyComponent.h:130
casacore::Cube< casacore::DComplex > R_
Residual/Differentiation caches.
Definition: UVMod.h:204
String: the storage and methods of handling collections of characters.
Definition: String.h:223
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
casacore::Vector< casacore::Double > & dpar()
Definition: UVMod.h:178
casacore::Vector< casacore::Double > & grad()
Definition: UVMod.h:174
casacore::Bool setCompPar()
casacore::Vector< casacore::Double > & lastPar()
Definition: UVMod.h:173
const SkyComponent & component(const casacore::uInt &index) const
returns a reference to the specified element in the list.
casacore::Vector< casacore::Double > & par()
Definition: UVMod.h:126
void chiSquare()
casacore::Array< casacore::DComplex > & dR()
Definition: UVMod.h:162
unsigned int uInt
Definition: aipstype.h:51
casacore::Vector< casacore::Bool > & polWt()
Definition: UVMod.h:169
Defines nreal time structures used by the VLA table filler.
Definition: nreal.h:100