casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DJones.h
Go to the documentation of this file.
1 //# DJones.h: Declaration of standard Polarization Calibration types
2 //# Copyright (C) 1996,1997,2000,2001,2002,2003,2011
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_DJONES_H
29 #define SYNTHESIS_DJONES_H
30 
31 #include <casa/aips.h>
32 #include <casa/Containers/Record.h>
33 #include <casa/BasicSL/Complex.h>
39 
40 namespace casa { //# NAMESPACE CASA - BEGIN
41 
42 // Forward declarations
43 class VisEquation;
44 
45 // **********************************************************
46 // DJones
47 //
48 
49 class DJones : public SolvableVisJones {
50 public:
51 
52  // Constructor
53  DJones(VisSet& vs);
54  DJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
56  DJones(const casacore::Int& nAnt);
57 
58  virtual ~DJones();
59 
60  // Local setapply
62  virtual void setApply(const casacore::Record& apply);
63 
64  // D-specific solve setup
66  void setSolve(const casacore::Record& solvepar);
67 
68  // Return the type enum
69  virtual Type type() { return VisCal::D; };
70 
71  // Return type name as string
72  virtual casacore::String typeName() { return "Dgen Jones"; };
73  virtual casacore::String longTypeName() { return "Dgen Jones (instrumental polarization"; };
74 
75  // Type of Jones matrix according to nPar()
76  // Do GENERAL matrix algebra
77  virtual Jones::JonesType jonesType() { return Jones::General; };
78 
79  // We can solve for polarization with D
80  virtual casacore::Int solvePol() { return solvePol_; };
81 
82  // Specialization that conditions raw data & model for OTF pol solving
83  virtual void setUpForPolSolve(vi::VisBuffer2& vb);
84 
85  // Hazard a guess at parameters
86  virtual void guessPar(VisBuffer& vb);
87  virtual void guessPar(SDBList& sdbs);
88 
89  // Update the parameters from solving
90  // (in linear approx, we always set the source update to zero, for now!)
91  virtual void updatePar(const casacore::Vector<casacore::Complex> dCalPar,
93 
94  // SNR is 1/err for D-terms (?)
95  virtual void formSolveSNR();
96 
97  // D-specific post-solve stuff
98  virtual void globalPostSolveTinker();
99 
100  // D-specific reReference
101  // TBD: non-triv impl
102  virtual void reReference() { cout << "reReference!" << endl;};
103 
104  virtual void applyRefAnt();
105 
106  // Method to list the D results
107  virtual void logResults();
108 
109  virtual void createCorruptor(const VisIter& vi,
110  const casacore::Record& simpar,
111  const casacore::Int nSim);
112 protected:
113 
114  // D has two casacore::Complex parameters
115  virtual casacore::Int nPar() { return 2; };
116 
117  // Jones matrix elements are trivial?
118  // true if GenLinear, false if General
120  // dD/dp are trivial
121  virtual casacore::Bool trivialDJ() { return true; };
122 
123  // Non-trivial Jones matrix calculation
126 
127  // Initialize trivial dJs
128  virtual void initTrivDJ();
129 
130 private:
131 
134 
135 
136 
137 };
138 
139 // **********************************************************
140 // DfJones (freq-dep D) (general)
141 //
142 
143 class DfJones : public DJones {
144 public:
145 
146  // Constructor
147  DfJones(VisSet& vs);
148  DfJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
149  DfJones(const MSMetaInfoForCal& msmc);
150  DfJones(const casacore::Int& nAnt);
151 
152  virtual ~DfJones();
153 
154  // Return type name as string
155  virtual casacore::String typeName() { return "Dfgen Jones"; };
156  virtual casacore::String longTypeName() { return "Dfgen Jones (frequency-dependent instrumental polarization"; };
157 
158  // This is the freq-dep version of D
159  // (this is the ONLY fundamental difference from D)
160  virtual casacore::Bool freqDepPar() { return true; };
161 
162 };
163 
164 
165 
166 // **********************************************************
167 // DlinJones (linearized DJones)
168 //
169 
170 class DlinJones : public DJones {
171 public:
172 
173  // Constructor
174  DlinJones(VisSet& vs);
177  DlinJones(const casacore::Int& nAnt);
178 
179  virtual ~DlinJones();
180 
181  // Return type name as string
182  virtual casacore::String typeName() { return "D Jones"; };
183  virtual casacore::String longTypeName() { return "D Jones (instrumental polarization"; };
184 
185  // Type of Jones matrix according to nPar()
186  // Do linearized matrix algebra
188 
189 };
190 
191 // **********************************************************
192 // DflinJones (freq-dep, linearized DJones)
193 //
194 
195 class DflinJones : public DlinJones {
196 public:
197 
198  // Constructor
199  DflinJones(VisSet& vs);
202  DflinJones(const casacore::Int& nAnt);
203 
204  virtual ~DflinJones();
205 
206  // Return type name as string
207  virtual casacore::String typeName() { return "Df Jones"; };
208  virtual casacore::String longTypeName() { return "Df Jones (frequency-dependent instrumental polarization"; };
209 
210  // This is the freq-dep version of D
211  // (this is the ONLY fundamental difference from D)
212  virtual casacore::Bool freqDepPar() { return true; };
213 
214 };
215 
216 // **********************************************************
217 // DllsJones (LLS DJones solve, General apply)
218 //
219 
220 
221 class DllsJones : public DJones {
222 public:
223 
224  // Constructor
225  DllsJones(VisSet& vs);
228  DllsJones(const casacore::Int& nAnt);
229 
230 
231  virtual ~DllsJones();
232 
233  // Return type name as string
234  virtual casacore::String typeName() { return "DLLS Jones"; };
235  virtual casacore::String longTypeName() { return "DLLS Jones (instrumental polarization)"; };
236 
237  // Type of Jones matrix
239 
240  // Dlin now uses generic gather, but solves for itself per solution
241  virtual casacore::Bool useGenericGatherForSolve() { return true; };
242  virtual casacore::Bool useGenericSolveOne() { return false; }
243 
244  // Local implementation of selfSolveOne (generalized signature)
245  // call solveOneVB with the first (and only?) VB
246  virtual void selfSolveOne(VisBuffGroupAcc& vbga) { this->solveOneVB(vbga(0)); };
247  virtual void selfSolveOne(SDBList& sdbs) { this->solveOne(sdbs); };
248 
249 
250 protected:
251 
252  // LSQ Solver for 1 VB
253  virtual void solveOneVB(const VisBuffer& vb);
254  virtual void solveOneSDB(SolveDataBuffer& sdb);
255 
256  // LSQ Solver for an SDBList (which may contain multiple SDBs over time/spw)
257  virtual void solveOne(SDBList& sdbs);
258 
259 
260 };
261 
262 // **********************************************************
263 // DfllsJones (freq-dep, LLS DJones solve, General apply)
264 //
265 
266 class DfllsJones : public DllsJones {
267 public:
268 
269  // Constructor
270  DfllsJones(VisSet& vs);
273  DfllsJones(const casacore::Int& nAnt);
274 
275  virtual ~DfllsJones();
276 
277  // Return type name as string
278  virtual casacore::String typeName() { return "DfLLS Jones"; };
279  virtual casacore::String longTypeName() { return "DfLLS Jones (frequency-dependent instrumental polarization"; };
280 
281  // This is the freq-dep version of D
282  // (this is the ONLY fundamental difference from D)
283  virtual casacore::Bool freqDepPar() { return true; };
284 
285 };
286 
287 /*
288 
289 // **********************************************************
290 // X: position angle calibration (for circulars!)
291 // (rendered as a Mueller for now)
292 
293 class XMueller : public SolvableVisMueller {
294 public:
295 
296  // Constructor
297  XMueller(VisSet& vs);
298  XMueller(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
299  XMueller(const MSMetaInfoForCal& msmc);
300  XMueller(const casacore::Int& nAnt);
301 
302  virtual ~XMueller();
303 
304  // Return the type enum
305  virtual Type type() { return VisCal::X; };
306 
307  // Return type name as string
308  virtual casacore::String typeName() { return "X Mueller"; };
309  virtual casacore::String longTypeName() { return "X Mueller (baseline-based)"; };
310 
311  // Type of Jones matrix according to nPar()
312  virtual Mueller::MuellerType muellerType() { return Mueller::Diagonal; };
313 
314  // Local setApply
315  using SolvableVisCal::setApply;
316  virtual void setApply(const casacore::Record& apply);
317 
318  // Local setSolve
319  using SolvableVisCal::setSolve;
320  void setSolve(const casacore::Record& solvepar);
321 
322  // Turn off normalization by model....
323  virtual casacore::Bool normalizable() { return false; };
324 
325  // X gathers/solves for itself
326  virtual casacore::Bool useGenericGatherForSolve() { return false; };
327 
328  // X gathers/solves for itself
329  virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
330  virtual void newselfSolve(VisSet& vs, VisEquation& ve); // new supports combine
331 
332 
333 protected:
334 
335  // X has just 1 complex parameter, storing a phase
336  virtual casacore::Int nPar() { return 1; };
337 
338  // Jones matrix elements are trivial
339  virtual casacore::Bool trivialMuellerElem() { return false; };
340 
341  // Calculate the X matrix for all ants
342  virtual void calcAllMueller();
343 
344  // Solve in one VB for the position angle
345  virtual void solveOneVB(const VisBuffer& vb);
346 
347 private:
348 
349  // <nothing>
350 
351 };
352 
353 
354 
355 // **********************************************************
356 // X: position angle calibration (for circulars!)
357 //
358 class XJones : public SolvableVisJones {
359 public:
360 
361  // Constructor
362  XJones(VisSet& vs);
363  XJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
364  XJones(const MSMetaInfoForCal& msmc);
365  XJones(const casacore::Int& nAnt);
366 
367 
368  virtual ~XJones();
369 
370  // Return the type enum
371  virtual Type type() { return VisCal::X; };
372 
373  // Return type name as string
374  virtual casacore::String typeName() { return "X Jones"; };
375  virtual casacore::String longTypeName() { return "X Jones (antenna-based)"; };
376 
377  // Type of Jones matrix according to nPar()
378  virtual Jones::JonesType jonesType() { return Jones::Diagonal; };
379 
380  // Local setApply
381  using SolvableVisCal::setApply;
382  virtual void setApply(const casacore::Record& apply);
383 
384  // Local setSolve
385  using SolvableVisCal::setSolve;
386  void setSolve(const casacore::Record& solvepar);
387 
388  // X is normalizable by the model
389  virtual casacore::Bool normalizable() { return true; };
390 
391  // X generically gathers, but solves for itself per solution
392  virtual casacore::Bool useGenericGatherForSolve() { return true; };
393  virtual casacore::Bool useGenericSolveOne() { return false; }
394 
395  // X gathers/solves for itself
396  virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
397  virtual void newselfSolve(VisSet& vs, VisEquation& ve); // new supports combine
398 
399  // When genericall gathering, solve using first VB only in VBGA
400  virtual void selfSolveOne(VisBuffGroupAcc& vbga) { this->solveOneVB(vbga(0)); };
401  virtual void selfSolveOne(SDBList& sdbs) { this->solveOne(sdbs); };
402 
403 
404 protected:
405 
406  // X has just 1 complex parameter, storing a phase
407  virtual casacore::Int nPar() { return 1; };
408 
409  // Jones matrix elements are trivial
410  virtual casacore::Bool trivialJonesElem() { return false; };
411 
412  // Calculate the X matrix for all ants
413  virtual void calcAllJones();
414 
415  // Solve in one VB for the position angle
416  virtual void solveOneVB(const VisBuffer& vb);
417  virtual void solveOneSDB(SolveDataBuffer& sdb);
418 
419  virtual void solveOne(SDBList& sdbs);
420 
421 private:
422 
423  // <nothing>
424 
425 };
426 
427 
428 // **********************************************************
429 // Xf: position angle calibration (for circulars!)
430 // (channel-dependent)
431 class XfJones : public XJones {
432 public:
433 
434  // Constructor
435  XfJones(VisSet& vs);
436  XfJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
437  XfJones(const MSMetaInfoForCal& msmc);
438  XfJones(const casacore::Int& nAnt);
439 
440  virtual ~XfJones();
441 
442  // Return the type enum
443  virtual Type type() { return VisCal::X; };
444 
445  // Return type name as string
446  virtual casacore::String typeName() { return "Xf Jones"; };
447  virtual casacore::String longTypeName() { return "Xf Jones (antenna-based)"; };
448 
449  // This is the freq-dep version of X
450  // (this is the ONLY fundamental difference from X)
451  virtual casacore::Bool freqDepPar() { return true; };
452 
453 protected:
454 
455  // Use nchan>=1 shaping
456  // (TBD: this should be generalized!)
457  void initSolvePar();
458 
459 
460 };
461 
462 
463 // X-Y phase
464 class GlinXphJones : public GJones {
465 public:
466 
467  // Constructor
468  GlinXphJones(VisSet& vs);
469  GlinXphJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
470  GlinXphJones(const MSMetaInfoForCal& msmc);
471  GlinXphJones(const casacore::Int& nAnt);
472 
473  virtual ~GlinXphJones();
474 
475  // Return the type enum (position UPSTREAM of D, not downstream like G)
476  virtual Type type() { return VisCal::X; };
477 
478  // Return type name as string
479  virtual casacore::String typeName() { return "GlinXph Jones"; };
480  virtual casacore::String longTypeName() { return "GlinXph Jones (X-Y phase)"; };
481 
482  // Local setapply (unsets calWt)
483  using SolvableVisJones::setApply;
484  virtual void setApply(const casacore::Record& apply);
485 
486  // NOT FreqDep
487  virtual casacore::Bool freqDepPar() { return false; };
488 
489  // Though derived from GJones, this type actually uses the cross-hands
490  virtual casacore::Bool phandonly() { return false; };
491 
492  // GlinXphJones specialization
493  virtual casacore::Bool useGenericGatherForSolve() { return true; };
494  virtual casacore::Bool useGenericSolveOne() { return false; }
495 
496  virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve);
497 
498  // Handle trivial vbga generated by generic gather-for-solve
499  virtual void selfSolveOne(VisBuffGroupAcc& vbga);
500  virtual void selfSolveOne(SDBList& sdbs);
501 
502 protected:
503 
504 
505  // Solver for one VB, that collapses baselines and cross-hands first,
506  // then solves for XY-phase and QU
507  virtual void solveOneVB(const VisBuffer& vb);
508  virtual void solveOne(SDBList& sdbs);
509 
510  // Write QU info into table keywords
511  virtual void globalPostSolveTinker();
512 
513  // Derived QU_ info
514  casacore::Matrix<casacore::Float> QU_;
515 
516 
517 };
518 
519 
520 // Freq-dep XY-phase
521 class GlinXphfJones : public GlinXphJones {
522 public:
523 
524  // Constructor
525  GlinXphfJones(VisSet& vs);
526  GlinXphfJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
527  GlinXphfJones(const MSMetaInfoForCal& msmc);
528  GlinXphfJones(const casacore::Int& nAnt);
529 
530 
531  virtual ~GlinXphfJones();
532  // Return type name as string
533  // Return type name as string
534  virtual casacore::String typeName() { return "GlinXphf Jones"; };
535  virtual casacore::String longTypeName() { return "GlinXphf Jones (X-Y phase)"; };
536 
537  // This is the freq-dep version of GlinXphJones
538  // (this is the ONLY fundamental difference from GlinXphJones)
539  virtual casacore::Bool freqDepPar() { return true; };
540 
541 
542 };
543 
544 */
545 
546 
547 } //# NAMESPACE CASA - END
548 
549 #endif
550 
virtual void applyRefAnt()
Apply reference antenna (generic Jones version)
DfJones(VisSet &vs)
Constructor.
DJones(VisSet &vs)
Constructor.
virtual void solveOneVB(const VisBuffer &vb)
LSQ Solver for 1 VB.
virtual void globalPostSolveTinker()
D-specific post-solve stuff.
int Int
Definition: aipstype.h:50
virtual void setUpForPolSolve(vi::VisBuffer2 &vb)
Specialization that conditions raw data &amp; model for OTF pol solving.
virtual casacore::Bool trivialJonesElem()
Jones matrix elements are trivial? true if GenLinear, false if General.
Definition: DJones.h:119
DlinJones (linearized DJones)
Definition: DJones.h:170
virtual casacore::Bool useGenericGatherForSolve()
Dlin now uses generic gather, but solves for itself per solution.
Definition: DJones.h:241
virtual casacore::String longTypeName()
Definition: DJones.h:183
virtual casacore::Int solvePol()
We can solve for polarization with D.
Definition: DJones.h:80
void apply(const Jones &j1, VisVector &v, const Jones &j2)
Apply a pair of Jones to a VisVector:
virtual void createCorruptor(const VisIter &vi, const casacore::Record &simpar, const casacore::Int nSim)
make a corruptor in a VC-specific way
DlinJones(VisSet &vs)
Constructor.
DllsJones (LLS DJones solve, General apply)
Definition: DJones.h:221
virtual casacore::String longTypeName()
Definition: DJones.h:208
virtual casacore::Bool freqDepPar()
This is the freq-dep version of D (this is the ONLY fundamental difference from D) ...
Definition: DJones.h:160
virtual casacore::String typeName()
Return type name as string.
Definition: DJones.h:155
virtual ~DlinJones()
virtual void setApply()
Set the application parameters.
casacore::Int & nAnt()
Definition: VisCal.h:237
DfllsJones (freq-dep, LLS DJones solve, General apply)
Definition: DJones.h:266
virtual void calcOneJones(casacore::Vector< casacore::Complex > &mat, casacore::Vector< casacore::Bool > &mOk, const casacore::Vector< casacore::Complex > &par, const casacore::Vector< casacore::Bool > &pOk)
Non-trivial Jones matrix calculation.
virtual casacore::String typeName()
Return type name as string.
Definition: DJones.h:72
virtual ~DllsJones()
virtual casacore::String typeName()
Return type name as string.
Definition: DJones.h:207
SolveDataBuffer is a container for VisBuffer2 data and related residual and differentiation results r...
virtual casacore::Bool freqDepPar()
This is the freq-dep version of D (this is the ONLY fundamental difference from D) ...
Definition: DJones.h:212
virtual Jones::JonesType jonesType()
Type of Jones matrix.
Definition: DJones.h:238
virtual Jones::JonesType jonesType()
Type of Jones matrix according to nPar() Do GENERAL matrix algebra.
Definition: DJones.h:77
DJones
Definition: DJones.h:49
virtual casacore::String typeName()
Return type name as string.
Definition: DJones.h:182
virtual void guessPar(VisBuffer &vb)
Hazard a guess at parameters.
Type
Allowed types of VisCal matrices - &#39;correct&#39; order enum Type{UVMOD,Mf,M,K,B,G,D,C,E,P,T,EP,F}; enum Type{Test=0,ANoise,M,KAntPos,K,B,G,J,D,X,C,P,E,T,F,A,ALL};.
Definition: VisCal.h:62
virtual void solveOne(SDBList &sdbs)
LSQ Solver for an SDBList (which may contain multiple SDBs over time/spw)
virtual ~DJones()
virtual casacore::String longTypeName()
Definition: DJones.h:279
virtual void selfSolveOne(VisBuffGroupAcc &vbga)
Local implementation of selfSolveOne (generalized signature) call solveOneVB with the first (and only...
Definition: DJones.h:246
virtual ~DfJones()
DfllsJones(VisSet &vs)
Constructor.
virtual Jones::JonesType jonesType()
Type of Jones matrix according to nPar() Do linearized matrix algebra.
Definition: DJones.h:187
casacore::Int solvePol_
Definition: DJones.h:132
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void initTrivDJ()
Initialize trivial dJs.
virtual ~DflinJones()
virtual casacore::Bool useGenericSolveOne()
Use generic solution engine for a single solve (usually inside the generic gathering mechanism) ...
Definition: DJones.h:242
A class to group separately averaged VisBuffers.
DflinJones(VisSet &vs)
Constructor.
virtual casacore::Bool trivialDJ()
dD/dp are trivial
Definition: DJones.h:121
virtual void solveOneSDB(SolveDataBuffer &sdb)
virtual ~DfllsJones()
virtual void formSolveSNR()
SNR is 1/err for D-terms (?)
D is like ANoise but has a complex amplitude (different sigma in real/imag), and a systematic offset...
Definition: CalCorruptor.h:196
virtual void reReference()
D-specific reReference TBD: non-triv impl.
Definition: DJones.h:102
virtual void logResults()
Method to list the D results.
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
virtual void selfSolveOne(SDBList &sdbs)
Definition: DJones.h:247
virtual casacore::String typeName()
Return type name as string.
Definition: DJones.h:278
const MSMetaInfoForCal & msmc() const
Access to the MSMetaInfoForCal (throws if none)
Definition: VisCal.h:338
virtual casacore::String longTypeName()
Definition: DJones.h:156
virtual casacore::Bool freqDepPar()
This is the freq-dep version of D (this is the ONLY fundamental difference from D) ...
Definition: DJones.h:283
virtual casacore::String longTypeName()
Definition: DJones.h:73
virtual Type type()
Return the type enum.
Definition: DJones.h:69
SolvableVisJones
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual casacore::Int nPar()
D has two casacore::Complex parameters.
Definition: DJones.h:115
virtual casacore::String longTypeName()
Definition: DJones.h:235
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
VisibilityIterator iterates through one or more writable MeasurementSets.
DJonesCorruptor * dcorruptor_p
Definition: DJones.h:133
DflinJones (freq-dep, linearized DJones)
Definition: DJones.h:195
virtual void setSolve()
Set the solving parameters.
DfJones (freq-dep D) (general)
Definition: DJones.h:143
virtual void updatePar(const casacore::Vector< casacore::Complex > dCalPar, const casacore::Vector< casacore::Complex > dSrcPar)
Update the parameters from solving (in linear approx, we always set the source update to zero...
DllsJones(VisSet &vs)
Constructor.
virtual casacore::String typeName()
Return type name as string.
Definition: DJones.h:234