DJones.h

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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1