casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
StandardVisCal.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_STANDARDVISCAL_H
00029 #define SYNTHESIS_STANDARDVISCAL_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/CalCorruptor.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 // Forward declarations
00041 class VisEquation;
00042 class TJonesCorruptor;
00043 
00044 
00045 // **********************************************************
00046 //  PJones
00047 //
00048 
00049 class PJones : public VisJones {
00050 public:
00051 
00052   // Constructor
00053   PJones(VisSet& vs);
00054   //   PJones(const Int& nAnt);  // NYI
00055 
00056   virtual ~PJones();
00057 
00058   // Return the type enum
00059   virtual Type type() { return VisCal::P; };
00060 
00061   // Return type name as string
00062   virtual String typeName()     { return "P Jones"; };
00063   virtual String longTypeName() { return "P Jones (parallactic angle phase)"; };
00064 
00065   // Type of Jones matrix according to nPar()
00066   Jones::JonesType jonesType() { return pjonestype_; };
00067 
00068 protected:
00069 
00070   // P has one trivial Complex parameter
00071   virtual Int nPar() { return 1; };
00072 
00073   virtual Vector<Float>& pa() { return pa_; };
00074 
00075   // Jones matrix elements are NOT trivial
00076   virtual Bool trivialJonesElem() { return False; };
00077 
00078   // Calculate parallactic angle
00079   virtual void calcPar();
00080 
00081   // We need to locally form the Jones according to 
00082   //  the correlations we have
00083   virtual void syncJones(const Bool& doInv);
00084 
00085   // Calculate a single PJones matrix 
00086   virtual void calcOneJones(Vector<Complex>& mat, Vector<Bool>& mOk,
00087                             const Vector<Complex>& par, const Vector<Bool>& pOk );
00088 
00089 private:
00090 
00091   Jones::JonesType pjonestype_;
00092 
00093   Vector<Float> pa_;
00094   
00095 };
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 // **********************************************************
00108 //  TJones
00109 //
00110 
00111 class TJones : public SolvableVisJones {
00112 public:
00113 
00114   // Constructor
00115   TJones(VisSet& vs);
00116   TJones(const Int& nAnt);
00117 
00118   virtual ~TJones();
00119 
00120   // Return the type enum
00121   virtual Type type() { return VisCal::T; };
00122 
00123   // Return type name as string
00124   virtual String typeName()     { return "T Jones"; };
00125   virtual String longTypeName() { return "T Jones (polarization-independent troposphere"; };
00126 
00127   // Type of Jones matrix according to nPar()
00128   virtual Jones::JonesType jonesType() { return Jones::Scalar; };
00129 
00130   // This type is accumulatable
00131   virtual Bool accumulatable() { return True; };
00132 
00133   // This type is smoothable
00134   virtual Bool smoothable() { return True; };
00135 
00136   // Hazard a guess at parameters
00137   virtual void guessPar(VisBuffer& vb);
00138 
00139   // Set up corruptor
00140   virtual void createCorruptor(const VisIter& vi, const Record& simpar, const Int nSim);
00141 
00142 protected:
00143 
00144   // T has one trivial complex parameter
00145   virtual Int nPar() { return 1; };
00146 
00147   // Jones matrix elements are trivial
00148   virtual Bool trivialJonesElem() { return True; };
00149 
00150   // Are diff'd Js trivial?
00151   virtual Bool trivialDJ() { return True; };
00152 
00153   // Initialize trivial dJs
00154   virtual void initTrivDJ();
00155 
00156 private:
00157 
00158   // object that can simulate the corruption terms - internal to T;
00159   // public access is only to the CalCorruptor parts
00160   AtmosCorruptor *tcorruptor_p;
00161 
00162 };
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 // **********************************************************
00174 //  TfJones (freq-dep T)
00175 //
00176 
00177 class TfJones : public TJones {
00178 public:
00179 
00180   // Constructor
00181   TfJones(VisSet& vs);
00182   TfJones(const Int& nAnt);
00183 
00184   virtual ~TfJones();
00185 
00186   // Return the type enum
00187   virtual Type type() { return VisCal::T; };
00188 
00189   // Return type name as string
00190   virtual String typeName()     { return "Tf Jones"; };
00191   virtual String longTypeName() { return "Tf Jones (frequency-dependent atmospheric complex gain"; };
00192 
00193   // This is the freq-dep version of T
00194   //   (this is the ONLY fundamental difference from T)
00195   virtual Bool freqDepPar() { return True; };
00196 
00197 protected:
00198 
00199   // <nothing>
00200 
00201 private:
00202 
00203   // <nothing>
00204   
00205 };
00206 
00207 
00208 
00209 
00210 
00211 // **********************************************************
00212 //  GJones
00213 //
00214 
00215 class GJones : public SolvableVisJones {
00216 public:
00217 
00218   // Constructor
00219   GJones(VisSet& vs);
00220   GJones(const Int& nAnt);
00221 
00222   virtual ~GJones();
00223 
00224   // Return the type enum
00225   virtual Type type() { return VisCal::G; };
00226 
00227   // Return type name as string
00228   virtual String typeName()     { return "G Jones"; };
00229   virtual String longTypeName() { return "G Jones (electronic Gain)"; };
00230 
00231   // Type of Jones matrix according to nPar()
00232   virtual Jones::JonesType jonesType() { return Jones::Diagonal; };
00233 
00234   // This type is accumulatable
00235   virtual Bool accumulatable() { return True; };
00236 
00237   // This type is smoothable
00238   virtual Bool smoothable() { return True; };
00239 
00240   // Nominally, we will only use parallel hands for now
00241   virtual Bool phandonly() { return True; };
00242 
00243   // Hazard a guess at parameters
00244   virtual void guessPar(VisBuffer& vb);
00245 
00246   virtual void createCorruptor(const VisIter& vi, const Record& simpar, const Int nSim);
00247 
00248 protected:
00249 
00250   // G has two trivial Complex parameters
00251   virtual Int nPar() { return 2; };
00252 
00253   // Jones matrix elements are trivial
00254   virtual Bool trivialJonesElem() { return True; };
00255 
00256   // dG/dp are trivial
00257   virtual Bool trivialDJ() { return True; };
00258 
00259   // Initialize trivial dJs
00260   virtual void initTrivDJ();
00261 
00262 private:
00263 
00264   GJonesCorruptor *gcorruptor_p;
00265   
00266 };
00267 
00268 
00269 
00270 // **********************************************************
00271 //  BJones  (freq-dep GJones)
00272 //
00273 
00274 class BJones : public GJones {
00275 public:
00276 
00277   // Constructor
00278   BJones(VisSet& vs);
00279   BJones(const Int& nAnt);
00280 
00281   virtual ~BJones();
00282 
00283   // Return the type enum
00284   virtual Type type() { return VisCal::B; };
00285 
00286   // Return type name as string
00287   virtual String typeName()     { return "B Jones"; };
00288   virtual String longTypeName() { return "B Jones (bandpass)"; };
00289 
00290   // Local setSolve
00291   using GJones::setSolve;
00292   virtual void setSolve(const Record& solve);
00293 
00294   // This is the freq-dep version of G 
00295   //   (this is the ONLY fundamental difference from G)
00296   virtual Bool freqDepPar() { return True; };
00297 
00298   virtual void normalize();
00299 
00300   // Specialize post solve operations (adds chan gap fill)
00301   virtual void globalPostSolveTinker();
00302   
00303   // Fill in bracketted channel gaps in solutions
00304   virtual void fillChanGaps();
00305   virtual void fillChanGapArray(Array<Complex>& sol,
00306                                 Array<Bool>& solOK);
00307 
00308 protected:
00309 
00310   // B-specific weight scaling factors
00311   virtual void syncWtScale();
00312 
00313 private:
00314 
00315   // widest channel gap to fill by interpolation
00316   Int maxchangap_p;
00317 
00318 
00319 };
00320 
00321 
00322 
00323 // **********************************************************
00324 //  JJones
00325 //
00326 
00327 class JJones : public SolvableVisJones {
00328 public:
00329 
00330   // Constructor
00331   JJones(VisSet& vs);
00332   JJones(const Int& nAnt);
00333 
00334   virtual ~JJones();
00335 
00336   // J-specific solve setup
00337   using SolvableVisJones::setSolve;
00338   void setSolve(const Record& solvepar);
00339 
00340   // Return the type enum
00341   virtual Type type() { return VisCal::J; };
00342 
00343   // Return type name as string
00344   virtual String typeName()     { return "J Jones"; };
00345   virtual String longTypeName() { return "J Jones (generic polarized gain)"; };
00346 
00347   // Type of Jones matrix according to nPar()
00348   virtual Jones::JonesType jonesType() { return Jones::General; };
00349 
00350   // Hazard a guess at parameters
00351   virtual void guessPar(VisBuffer& vb);
00352 
00353   // J-specific reReference
00354   // TBD: non-triv impl
00355   virtual void reReference() {};
00356 
00357 protected:
00358 
00359   // J has four trivial Complex parameters
00360   virtual Int nPar() { return 4; };
00361 
00362   // Jones matrix elements are trivial
00363   virtual Bool trivialJonesElem() { return True; };
00364 
00365   // dJ/dp are trivial
00366   virtual Bool trivialDJ() { return True; };
00367 
00368   // Initialize trivial dJs
00369   virtual void initTrivDJ();
00370 
00371 private:
00372 
00373   // <nothing>
00374   
00375 };
00376 
00377 
00378 // **********************************************************
00379 //  M: baseline-based (closure) 
00380 //
00381 
00382 
00383 class MMueller : public SolvableVisMueller {
00384 public:
00385 
00386   // Constructor
00387   MMueller(VisSet& vs);
00388   MMueller(const Int& nAnt);
00389 
00390   virtual ~MMueller();
00391 
00392   // Return the type enum
00393   virtual Type type() { return VisCal::M; };
00394 
00395   // Return type name as string
00396   virtual String typeName()     { return "M Mueller"; };
00397   virtual String longTypeName() { return "M Mueller (baseline-based)"; };
00398 
00399   // Type of Jones matrix according to nPar()
00400   virtual Mueller::MuellerType muellerType() { return Mueller::Diag2; };
00401 
00402   // Local setApply
00403   using SolvableVisCal::setApply;
00404   virtual void setApply(const Record& apply);
00405 
00406   // M gathers/solves for itself
00407   virtual Bool useGenericGatherForSolve() { return False; };
00408 
00409   // M solves for itself (by copying averaged data)
00410   virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve) { newselfSolve(vs,ve); };
00411   virtual void newselfSolve(VisSet& vs, VisEquation& ve);  // new supports combine
00412 
00413   // Local M version only supports normalization
00414   virtual void globalPostSolveTinker();
00415 
00416   virtual void createCorruptor(const VisIter& vi, const Record& simpar, const Int nSim);
00417 protected:
00418 
00419   // M currently has just 2 complex parameters, i.e., both parallel hands
00420   virtual Int nPar() { return 2; };
00421 
00422   // Jones matrix elements are trivial
00423   virtual Bool trivialMuellerElem() { return True; };
00424 
00425 private:
00426   AtmosCorruptor *atmcorruptor_p;
00427 
00428 };
00429 
00430 
00431 
00432 
00433 
00434 
00435 // **********************************************************
00436 //  MfMueller (freq-dep MMueller)
00437 //
00438 
00439 class MfMueller : public MMueller {
00440 public:
00441 
00442   // Constructor
00443   MfMueller(VisSet& vs);
00444   MfMueller(const Int& nAnt);
00445 
00446   virtual ~MfMueller();
00447 
00448   // Return the type enum
00449   virtual Type type() { return VisCal::M; };
00450 
00451   // Return type name as string
00452   virtual String typeName()     { return "Mf Mueller"; };
00453   virtual String longTypeName() { return "Mf Mueller (closure bandpass)"; };
00454 
00455   // This is the freq-dep version of M
00456   //   (this is the ONLY fundamental difference from M)
00457   virtual Bool freqDepPar() { return True; };
00458 
00459   // Normalize baseline spectra (after B)
00460   virtual void normalize();
00461 
00462 protected:
00463 
00464   // <nothing>
00465 
00466 private:
00467 
00468   // <nothing>
00469 
00470 };
00471 
00472 
00473 
00474 
00475 // **********************************************************
00476 //  TOPac 
00477 //
00478 
00479 class TOpac : public TJones {
00480 public:
00481 
00482   // Constructor
00483   TOpac(VisSet& vs);
00484   //  TOpac(const Int& nAnt);  // NYI
00485 
00486   virtual ~TOpac();
00487 
00488   // Return the type enum
00489   virtual Type type() { return VisCal::T; };
00490 
00491   // Return type name as string
00492   virtual String typeName()     { return "TOpac"; };
00493   virtual String longTypeName() { return "TOpac (Opacity corrections in amplitude)"; };
00494 
00495   // Type of Jones matrix according to nPar()
00496   Jones::JonesType jonesType() { return Jones::Scalar; };
00497 
00498   // We have Float parameters
00499   virtual VisCalEnum::VCParType parType() { return VisCalEnum::REAL; };
00500 
00501   // Local specialization of setApply to extract opacity
00502   void setApply(const Record& applypar);
00503 
00504   // Report apply-related info
00505   String applyinfo();
00506 
00507 protected:
00508 
00509   // TOpac has one Float par per ant
00510   virtual Int nPar() { return 1; };
00511 
00512   // Jones matrix elements are NOT trivial
00513   virtual Bool trivialJonesElem() { return False; };
00514 
00515   // Access to z.a. data
00516   Vector<Double>& za() { return za_; };
00517 
00518   // Calculate parameters (in this case, the z.a.)
00519   virtual void calcPar();
00520 
00521   // Calculate the TOpac matrix for all ants
00522   virtual void calcAllJones();
00523 
00524 private:
00525 
00526   // avoid compiler warnings
00527   using TJones::setApply;  
00528 
00529   // opacity per spw
00530   Vector<Double> opacity_;
00531 
00532   // zenith angle per antenna
00533   Vector<Double> za_;
00534   
00535 };
00536 
00537 
00538 // **********************************************************
00539 //  TfOpac (freq-dep TOpac)
00540 //
00541 
00542 class TfOpac : public TOpac {
00543 public:
00544 
00545   // Constructor
00546   TfOpac(VisSet& vs);
00547   //  TfOpac(const Int& nAnt);
00548 
00549   virtual ~TfOpac();
00550 
00551   // Return the type enum
00552   virtual Type type() { return VisCal::T; };
00553 
00554   // Return type name as string
00555   virtual String typeName()     { return "TfOpac"; };
00556   virtual String longTypeName() { return "TfOpac (frequency-dependent opacity"; };
00557 
00558   // This is the freq-dep version of TOpac
00559   //   (this is the ONLY fundamental difference from TOpac)
00560   virtual Bool freqDepPar() { return True; };
00561 
00562 protected:
00563 
00564   // <nothing>
00565 
00566 private:
00567 
00568   // <nothing>
00569   
00570 };
00571 
00572 
00573 } //# NAMESPACE CASA - END
00574 
00575 #endif
00576