casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
DJones.h
Go to the documentation of this file.
00001 //# StandardVisCal.h: Declaration of standard (Solvable)VisCal types
00002 //# Copyright (C) 1996,1997,2000,2001,2002,2003,2011
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_DJONES_H
00029 #define SYNTHESIS_DJONES_H
00030 
00031 #include <casa/aips.h>
00032 #include <casa/Containers/Record.h>
00033 #include <casa/BasicSL/Complex.h>
00034 #include <synthesis/MeasurementComponents/VisCal.h>
00035 #include <synthesis/MeasurementComponents/SolvableVisCal.h>
00036 #include <synthesis/MeasurementComponents/StandardVisCal.h>
00037 #include <synthesis/MeasurementComponents/CalCorruptor.h>
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 // Forward declarations
00042 class VisEquation;
00043 
00044 // **********************************************************
00045 //  DJones
00046 //
00047 
00048 class DJones : public SolvableVisJones {
00049 public:
00050 
00051   // Constructor
00052   DJones(VisSet& vs);
00053   DJones(const Int& nAnt);
00054 
00055   virtual ~DJones();
00056 
00057   // Local setapply
00058   using SolvableVisJones::setApply;
00059   virtual void setApply(const Record& apply);
00060 
00061   // D-specific solve setup
00062   using SolvableVisJones::setSolve;
00063   void setSolve(const Record& solvepar);
00064 
00065   // Return the type enum
00066   virtual Type type() { return VisCal::D; };
00067 
00068   // Return type name as string
00069   virtual String typeName()     { return "Dgen Jones"; };
00070   virtual String longTypeName() { return "Dgen Jones (instrumental polarization"; };
00071 
00072   // Type of Jones matrix according to nPar()
00073   //   Do GENERAL matrix algebra
00074   virtual Jones::JonesType jonesType() { return Jones::General; };
00075 
00076   // We can solve for polarization with D
00077   virtual Int solvePol() { return solvePol_; };
00078 
00079   // Hazard a guess at parameters
00080   virtual void guessPar(VisBuffer& vb);
00081 
00082   // Update the parameters from solving
00083   //  (in linear approx, we always set the source update to zero, for now!)
00084   virtual void updatePar(const Vector<Complex> dCalPar,
00085                          const Vector<Complex> dSrcPar);
00086 
00087   // SNR is 1/err for D-terms (?)
00088   virtual void formSolveSNR();
00089 
00090   // D-specific post-solve stuff
00091   virtual void globalPostSolveTinker();
00092 
00093   // D-specific reReference
00094   // TBD: non-triv impl
00095   virtual void reReference() { cout << "reReference!" << endl;};
00096 
00097   virtual void applyRefAnt();
00098 
00099   // Method to list the D results
00100   virtual void logResults();
00101 
00102   virtual void createCorruptor(const VisIter& vi, 
00103                                const Record& simpar, 
00104                                const Int nSim);
00105 protected:
00106 
00107   // D has two Complex parameters
00108   virtual Int nPar() { return 2; };
00109 
00110   // Jones matrix elements are trivial?
00111   //  True if GenLinear, False if General
00112   virtual Bool trivialJonesElem() { return (jonesType()==Jones::GenLinear); };  
00113   // dD/dp are trivial
00114   virtual Bool trivialDJ() { return True; };
00115 
00116   // Non-trivial Jones matrix calculation
00117   virtual void calcOneJones(Vector<Complex>& mat, Vector<Bool>& mOk,
00118                             const Vector<Complex>& par, const Vector<Bool>& pOk);
00119 
00120   // Initialize trivial dJs
00121   virtual void initTrivDJ();
00122 
00123 private:
00124 
00125   Int solvePol_;
00126   DJonesCorruptor *dcorruptor_p;
00127   
00128 
00129   
00130 };
00131 
00132 // **********************************************************
00133 //  DfJones (freq-dep D)  (general)
00134 //
00135 
00136 class DfJones : public DJones {
00137 public:
00138 
00139   // Constructor
00140   DfJones(VisSet& vs);
00141   DfJones(const Int& nAnt);
00142 
00143   virtual ~DfJones();
00144 
00145   // Return type name as string
00146   virtual String typeName()     { return "Dfgen Jones"; };
00147   virtual String longTypeName() { return "Dfgen Jones (frequency-dependent instrumental polarization"; };
00148 
00149   // This is the freq-dep version of D 
00150   //   (this is the ONLY fundamental difference from D)
00151   virtual Bool freqDepPar() { return True; };
00152   
00153 };
00154 
00155 
00156 
00157 // **********************************************************
00158 //  DlinJones   (linearized DJones)
00159 //
00160 
00161 class DlinJones : public DJones {
00162 public:
00163 
00164   // Constructor
00165   DlinJones(VisSet& vs);
00166   DlinJones(const Int& nAnt);
00167 
00168   virtual ~DlinJones();
00169 
00170   // Return type name as string
00171   virtual String typeName()     { return "D Jones"; };
00172   virtual String longTypeName() { return "D Jones (instrumental polarization"; };
00173 
00174   // Type of Jones matrix according to nPar()
00175   //  Do linearized matrix algebra
00176   virtual Jones::JonesType jonesType() { return Jones::GenLinear; };
00177 
00178 };
00179 
00180 // **********************************************************
00181 //  DflinJones (freq-dep, linearized DJones)
00182 //
00183 
00184 class DflinJones : public DlinJones {
00185 public:
00186 
00187   // Constructor
00188   DflinJones(VisSet& vs);
00189   DflinJones(const Int& nAnt);
00190 
00191   virtual ~DflinJones();
00192 
00193   // Return type name as string
00194   virtual String typeName()     { return "Df Jones"; };
00195   virtual String longTypeName() { return "Df Jones (frequency-dependent instrumental polarization"; };
00196 
00197   // This is the freq-dep version of D 
00198   //   (this is the ONLY fundamental difference from D)
00199   virtual Bool freqDepPar() { return True; };
00200 
00201 };
00202 
00203 // **********************************************************
00204 //  DllsJones   (LLS DJones solve, General apply)
00205 //
00206 
00207 class DllsJones : public DJones {
00208 public:
00209 
00210   // Constructor
00211   DllsJones(VisSet& vs);
00212   DllsJones(const Int& nAnt);
00213 
00214   virtual ~DllsJones();
00215 
00216   // Return type name as string
00217   virtual String typeName()     { return "DLLS Jones"; };
00218   virtual String longTypeName() { return "DLLS Jones (instrumental polarization)"; };
00219 
00220   // Type of Jones matrix 
00221   virtual Jones::JonesType jonesType() { return Jones::General; };
00222 
00223   // Dlin now uses generic gather, but solves for itself per solution
00224   virtual Bool useGenericGatherForSolve() { return True; };
00225   virtual Bool useGenericSolveOne() { return False; }
00226 
00227 protected:
00228 
00229   // Local implementation of selfSolveOne (generalized signature)
00230   //   call solveOneVB with the first (and only?) VB
00231   virtual void selfSolveOne(VisBuffGroupAcc& vbga) { this->solveOneVB(vbga(0)); };
00232 
00233   // LSQ Solver for 1 VB
00234   virtual void solveOneVB(const VisBuffer& vb);
00235 
00236 
00237 };
00238 
00239 // **********************************************************
00240 //  DfllsJones (freq-dep, LLS DJones solve, General apply)
00241 //
00242 
00243 class DfllsJones : public DllsJones {
00244 public:
00245 
00246   // Constructor
00247   DfllsJones(VisSet& vs);
00248   DfllsJones(const Int& nAnt);
00249 
00250   virtual ~DfllsJones();
00251 
00252   // Return type name as string
00253   virtual String typeName()     { return "DfLLS Jones"; };
00254   virtual String longTypeName() { return "DfLLS Jones (frequency-dependent instrumental polarization"; };
00255 
00256   // This is the freq-dep version of D 
00257   //   (this is the ONLY fundamental difference from D)
00258   virtual Bool freqDepPar() { return True; };
00259 
00260 };
00261 
00262 
00263 // **********************************************************
00264 //  X: position angle calibration (for circulars!)
00265 //    (rendered as a Mueller for now)
00266 
00267 class XMueller : public SolvableVisMueller {
00268 public:
00269 
00270   // Constructor
00271   XMueller(VisSet& vs);
00272   XMueller(const Int& nAnt);
00273 
00274   virtual ~XMueller();
00275 
00276   // Return the type enum
00277   virtual Type type() { return VisCal::X; };
00278 
00279   // Return type name as string
00280   virtual String typeName()     { return "X Mueller"; };
00281   virtual String longTypeName() { return "X Mueller (baseline-based)"; };
00282 
00283   // Type of Jones matrix according to nPar()
00284   virtual Mueller::MuellerType muellerType() { return Mueller::Diagonal; };
00285 
00286   // Local setApply
00287   using SolvableVisCal::setApply;
00288   virtual void setApply(const Record& apply);
00289 
00290   // Local setSolve
00291   using SolvableVisCal::setSolve;
00292   void setSolve(const Record& solvepar);
00293 
00294   // Turn off normalization by model....
00295   virtual Bool normalizable() { return False; };
00296 
00297   // X gathers/solves for itself
00298   virtual Bool useGenericGatherForSolve() { return False; };
00299 
00300   // X gathers/solves for itself 
00301   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
00302   virtual void newselfSolve(VisSet& vs, VisEquation& ve);  // new supports combine
00303 
00304 
00305 protected:
00306 
00307   // X has just 1 complex parameter, storing a phase
00308   virtual Int nPar() { return 1; };
00309 
00310   // Jones matrix elements are trivial
00311   virtual Bool trivialMuellerElem() { return False; };
00312 
00313   // Calculate the X matrix for all ants
00314   virtual void calcAllMueller();
00315 
00316   // Solve in one VB for the position angle
00317   virtual void solveOneVB(const VisBuffer& vb);
00318 
00319 private:
00320 
00321   // <nothing>
00322 
00323 };
00324 
00325 
00326 
00327 // **********************************************************
00328 //  X: position angle calibration (for circulars!)
00329 //
00330 class XJones : public SolvableVisJones {
00331 public:
00332 
00333   // Constructor
00334   XJones(VisSet& vs);
00335   XJones(const Int& nAnt);
00336 
00337   virtual ~XJones();
00338 
00339   // Return the type enum
00340   virtual Type type() { return VisCal::X; };
00341 
00342   // Return type name as string
00343   virtual String typeName()     { return "X Jones"; };
00344   virtual String longTypeName() { return "X Jones (antenna-based)"; };
00345 
00346   // Type of Jones matrix according to nPar()
00347   virtual Jones::JonesType jonesType() { return Jones::Diagonal; };
00348 
00349   // Local setApply
00350   using SolvableVisCal::setApply;
00351   virtual void setApply(const Record& apply);
00352 
00353   // Local setSolve
00354   using SolvableVisCal::setSolve;
00355   void setSolve(const Record& solvepar);
00356 
00357   // X is normalizable by the model
00358   virtual Bool normalizable() { return True; };
00359 
00360   // X generically gathers, but solves for itself per solution
00361   virtual Bool useGenericGatherForSolve() { return True; };
00362   virtual Bool useGenericSolveOne() { return False; }
00363 
00364   // X gathers/solves for itself 
00365   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
00366   virtual void newselfSolve(VisSet& vs, VisEquation& ve);  // new supports combine
00367 
00368   // When genericall gathering, solve using first VB only in VBGA
00369   virtual void selfSolveOne(VisBuffGroupAcc& vbga) { this->solveOneVB(vbga(0)); };
00370 
00371 
00372 protected:
00373 
00374   // X has just 1 complex parameter, storing a phase
00375   virtual Int nPar() { return 1; };
00376 
00377   // Jones matrix elements are trivial
00378   virtual Bool trivialJonesElem() { return False; };
00379 
00380   // Calculate the X matrix for all ants
00381   virtual void calcAllJones();
00382 
00383   // Solve in one VB for the position angle
00384   virtual void solveOneVB(const VisBuffer& vb);
00385 
00386 private:
00387 
00388   // <nothing>
00389 
00390 };
00391 
00392 
00393 // **********************************************************
00394 //  Xf: position angle calibration (for circulars!)
00395 //     (channel-dependent)
00396 class XfJones : public XJones {
00397 public:
00398 
00399   // Constructor
00400   XfJones(VisSet& vs);
00401   XfJones(const Int& nAnt);
00402 
00403   virtual ~XfJones();
00404 
00405   // Return the type enum
00406   virtual Type type() { return VisCal::X; };
00407 
00408   // Return type name as string
00409   virtual String typeName()     { return "Xf Jones"; };
00410   virtual String longTypeName() { return "Xf Jones (antenna-based)"; };
00411 
00412   // This is the freq-dep version of X 
00413   //   (this is the ONLY fundamental difference from X)
00414   virtual Bool freqDepPar() { return True; };
00415 
00416 protected:
00417 
00418   // Use nchan>=1 shaping
00419   //  (TBD: this should be generalized!)
00420   void initSolvePar();
00421 
00422 
00423 };
00424 
00425 
00426 // X-Y phase 
00427 class GlinXphJones : public GJones {
00428 public:
00429 
00430   // Constructor
00431   GlinXphJones(VisSet& vs);
00432   GlinXphJones(const Int& nAnt);
00433 
00434   virtual ~GlinXphJones();
00435 
00436   // Return the type enum  (position UPSTREAM of D, not downstream like G)
00437   virtual Type type() { return VisCal::X; };
00438 
00439   // Return type name as string
00440   virtual String typeName()     { return "GlinXph Jones"; };
00441   virtual String longTypeName() { return "GlinXph Jones (X-Y phase)"; };
00442 
00443   // NOT FreqDep
00444   virtual Bool freqDepPar() { return False; };
00445 
00446   // Though derived from GJones, this type actually uses the cross-hands
00447   virtual Bool phandonly() { return False; };
00448 
00449   // GlinXphJones specialization
00450   virtual Bool useGenericGatherForSolve() { return True; }; 
00451   virtual Bool useGenericSolveOne() { return False; }
00452 
00453   //  virtual Bool useGenericGatherForSolve() { return False; }; 
00454   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve);
00455 
00456 protected:
00457 
00458   // Handle trivial vbga generated by generic gather-for-solve
00459   virtual void selfSolveOne(VisBuffGroupAcc& vbga);
00460 
00461   // Solver for one VB, that collapses baselines and cross-hands first,
00462   //  then solves for XY-phase and QU
00463   virtual void solveOneVB(const VisBuffer& vb);
00464 
00465   // Write QU info into table keywords
00466   virtual void globalPostSolveTinker();
00467 
00468   // Derived QU_ info
00469   Matrix<Float> QU_;
00470 
00471 
00472 };
00473 
00474 
00475 // Freq-dep XY-phase
00476 class GlinXphfJones : public GlinXphJones {
00477 public:
00478 
00479   // Constructor
00480   GlinXphfJones(VisSet& vs);
00481   GlinXphfJones(const Int& nAnt);
00482 
00483   virtual ~GlinXphfJones();
00484   // Return type name as string
00485   // Return type name as string
00486   virtual String typeName()     { return "GlinXphf Jones"; };
00487   virtual String longTypeName() { return "GlinXphf Jones (X-Y phase)"; };
00488 
00489   // This is the freq-dep version of GlinXphJones
00490   //   (this is the ONLY fundamental difference from GlinXphJones)
00491   virtual Bool freqDepPar() { return True; };
00492 
00493 
00494 };
00495 
00496 
00497 
00498 
00499 } //# NAMESPACE CASA - END
00500 
00501 #endif
00502