casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AMueller.h
Go to the documentation of this file.
1 //# AMueller.h: Additive closure errors
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_AMUELLER_H
29 #define SYNTHESIS_AMUELLER_H
30 
31 #include <casa/aips.h>
32 #include <casa/BasicSL/Complex.h>
35 
36 namespace casa { //# NAMESPACE CASA - BEGIN
37 
38 class VisBuffGroupAcc;
39 
40 class AMueller : public MMueller {
41 public:
42 
43  // Constructor
44  AMueller(VisSet& vs);
46  AMueller(const MSMetaInfoForCal& msmc);
47  AMueller(const casacore::Int& nAnt);
48 
49  virtual ~AMueller();
50 
51  // Return the type enum
52  virtual Type type() { return VisCal::A; };
53 
54  // Return type name as string
55  virtual casacore::String typeName() { return "A Mueller"; };
56  virtual casacore::String longTypeName() { return "A Mueller (baseline-based)"; };
57 
58  // Algebraic type of Mueller matrix
59  // (this is the key distinguishing characteristic)
61 
62  // Local setsolve (overrides preavg)
64  // Parameters particular to this class:
65  // fitorder: Order of the polynomial fit. If 0, it is just an average.
66  virtual void setSolve(const casacore::Record& solvepar);
67 
68  // AMueller's caltables have polynomial orders where channels would normally
69  // go. setSolve() above sets the number of "channels", but
70  // SolvableVisCal::setSolveChannelization() would just reset it to 1 if it
71  // was not overrode here.
72  virtual void setSolveChannelization(VisSet& vs);
73 
74  // Size up the solving arrays, etc. (supports combine)
76 
77  // The fitorder = 0 version (in M) skips casacore::LinearFitSVD by just averaging.
79 
80  // Only called if useGenericGatherForSolve() == true. If
81  // useGenericGatherForSolve() == true, then genericGatherAndSolve() will call
82  // AMueller's selfSolveOne(). Otherwise MMueller's selfGatherAndSolve() will
83  // do everything.
84  virtual casacore::Bool useGenericSolveOne() {return false;}
85 
86  // Per-solution self-solving inside generic gather. Flexible enough for
87  // fitorder != 0, but overkill otherwise.
88  virtual void selfSolveOne(VisBuffGroupAcc& vbga);
89 
90  virtual void storeNCT();
91 
92  virtual void setApply() {SolvableVisCal::setApply();}
93  virtual void setApply(const casacore::Record& applypar);
94 
95  // Apply this calibration to vb. AMueller does NOT support trial
96  // and ignores it!
97  virtual void applyCal(VisBuffer& vb, casacore::Cube<casacore::Complex>& Vout, casacore::Bool trial=false);
98  // VB2 version (for apply context only!)
99  virtual void applyCal2(vi::VisBuffer2& vb,
101  casacore::Bool trial=false);
102 
103  // Freq dependence
104  virtual casacore::Bool freqDepPar() { return false; };
106  return fitorder_p != 0 || nChanPar() > 1; // The latter is for applying.
107  }
108 
109  // We do not normalize by the model, since we are estimating
110  // directly from the data (we should optimize here by avoiding
111  // the model I/O)
112  virtual casacore::Bool normalizable() {return false;};
113 
114  // Specialize corrupt to pre-zero model for corruption
115  //using VisMueller::corrupt;
116  virtual void corrupt(VisBuffer& vb);
117  //virtual void corrupt(VisBuffer& vb, casacore::Cube<casacore::Complex>& Mout);
118 
119  // Set (repeatedly, unfortunately) whether or not subtraction is being done,
120  // and IF fitorder == 0, sync matrices for current meta data (VisMueller
121  // override). (Mueller matrices aren't used for fitorder != 0.)
122  void syncCalMat(const casacore::Bool& doInv)
123  {
124  doSub_p = doInv;
125  if(fitorder_p == 0)
126  VisMueller::syncCalMat(doInv);
127  }
128 
129 protected:
130  virtual casacore::Int nPar() {
131  if(nCorr_p < 0)
132  hurl("nPar()", "nPar() called before being set.");
133  return nCorr_p;
134  }
135 
136 private:
137  void init(); // Common code for the c'tors.
138 
139  // Logs and throws msg as an exception from origin.
140  void hurl(const casacore::String& origin, const casacore::String& msg);
141 
142  // Initialized to 0 in the initialization lists of the c'tors.
143  casacore::Int fitorder_p; // Stores the order of the fitted polynomials.
144 
145  casacore::Bool doSub_p; // For apply, whether or not to subtract or give the continuum
146  // estimate.
147  casacore::Int nCorr_p; // # of correlations. -1 if not yet known.
148 
149  // Resized and set to impossible values in init().
150  casacore::Vector<casacore::Double> lofreq_p; // Lowest and highest frequencies (Hz) used
152  casacore::Vector<casacore::uInt> totnumchan_p; // The total number of input channels that will be
153  // looked at (including masked ones!)
154  casacore::Vector<casacore::Bool> spwApplied_p; // Just keeps track of which spws have been
155  // applied to.
156 };
157 
158 // Additive noise
159 // In practice, this is not really solvable, but it
160 // is a SVM because we need access to general simulation methods
161 class ANoise : public SolvableVisMueller {
162 public:
163 
164  // Constructor
165  ANoise(VisSet& vs);
166  ANoise(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
167  ANoise(const MSMetaInfoForCal& msmc);
168  ANoise(const casacore::Int& nAnt);
169 
170 
171  virtual ~ANoise();
172 
173  // Return the type enum
174  virtual Type type() { return VisCal::ANoise; };
175 
176  // Return type name as string
177  virtual casacore::String typeName() { return "A Noise"; };
178  virtual casacore::String longTypeName() { return "A Noise (baseline-based)"; };
179 
180  // Algebraic type of Mueller matrix
181  // (this is the key distinguishing characteristic)
183 
184  // Overide solvability
185  virtual casacore::Bool isSolvable() { return false; };
186 
187  // this is inherently freqdep:
188  virtual casacore::Bool freqDepPar() { return true; };
189 
190  virtual void createCorruptor(const VisIter& vi, const casacore::Record& simpar, const casacore::Int nSim);
191 
192 protected:
193  // umm... 2 for each of parallel hands?
194  virtual casacore::Int nPar() { return 2; };
195 
196  // Jones matrix elements are trivial
197  virtual casacore::Bool trivialMuellerElem() { return (!simOnTheFly()); };
198 
199  // override VC default of timeDepMat=F for OTF simulatio:
200  virtual casacore::Bool timeDepMat() { return simOnTheFly(); };
201 
202  // Calculate an ensemble of Mueller matrices (all baselines, channels)
203  // overrriding VisCal::calcAllMueller
204  virtual void calcAllMueller();
205 
206  // Calculate a single Mueller matrix by some means
207  // override SolvableVisMueller::calcOneMueller
210 
211 private:
213 
214 };
215 
216 } //# NAMESPACE CASA - END
217 
218 #endif
int Int
Definition: aipstype.h:50
virtual casacore::Bool useGenericGatherForSolve()
The fitorder = 0 version (in M) skips casacore::LinearFitSVD by just averaging.
Definition: AMueller.h:78
SolvableVisMueller
Additive noise In practice, this is not really solvable, but it is a SVM because we need access to ge...
Definition: AMueller.h:161
virtual casacore::Bool useGenericSolveOne()
Only called if useGenericGatherForSolve() == true.
Definition: AMueller.h:84
virtual void setSolveChannelization(VisSet &vs)
AMueller&#39;s caltables have polynomial orders where channels would normally go.
virtual Type type()
Return the type enum.
Definition: AMueller.h:52
ANoiseCorruptor * acorruptor_p
Definition: AMueller.h:212
virtual void corrupt(VisBuffer &vb)
Specialize corrupt to pre-zero model for corruption using VisMueller::corrupt;
virtual void calcOneMueller(casacore::Vector< casacore::Complex > &mat, casacore::Vector< casacore::Bool > &mOk, const casacore::Vector< casacore::Complex > &par, const casacore::Vector< casacore::Bool > &pOk)
Calculate a single Mueller matrix by some means override SolvableVisMueller::calcOneMueller.
casacore::Vector< casacore::Double > lofreq_p
Resized and set to impossible values in init().
Definition: AMueller.h:150
virtual casacore::String typeName()
Return type name as string.
Definition: AMueller.h:55
M: baseline-based (closure)
virtual casacore::Bool timeDepMat()
override VC default of timeDepMat=F for OTF simulatio:
Definition: AMueller.h:200
virtual casacore::Int sizeUpSolve(VisSet &vs, casacore::Vector< casacore::Int > &nChunkPerSol)
Size up the solving arrays, etc.
virtual casacore::Bool freqDepPar()
Freq dependence.
Definition: AMueller.h:104
virtual casacore::Int nPar()
M currently has just 2 complex parameters, i.e., both parallel hands.
Definition: AMueller.h:130
virtual casacore::String typeName()
Return type name as string.
Definition: AMueller.h:177
virtual void createCorruptor(const VisIter &vi, const casacore::Record &simpar, const casacore::Int nSim)
make a corruptor in a VC-specific way
virtual void setApply()
Set the application parameters.
casacore::Int & nAnt()
Definition: VisCal.h:237
virtual void syncCalMat(const casacore::Bool &doInv=false)
{ throw(casacore::AipsError(&quot;VisMueller::applyCal2 NYI!!!!!!!!!!!!!&quot;)); };
void syncCalMat(const casacore::Bool &doInv)
virtual void corrupt(VisBuffer&amp; vb, casacore::Cube&lt;casacore::Complex&gt;&amp; Mout);
Definition: AMueller.h:122
virtual ~AMueller()
virtual casacore::String longTypeName()
Definition: AMueller.h:178
ANoise(VisSet &vs)
Constructor.
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 setSolve(const casacore::Record &solvepar)
Parameters particular to this class: fitorder: Order of the polynomial fit.
AMueller(VisSet &vs)
Constructor.
virtual casacore::Bool freqDepMat()
Definition: AMueller.h:105
virtual void applyCal2(vi::VisBuffer2 &vb, casacore::Cube< casacore::Complex > &Vout, casacore::Cube< casacore::Float > &Wout, casacore::Bool trial=false)
VB2 version (for apply context only!)
casacore::Vector< casacore::Bool > spwApplied_p
looked at (including masked ones!)
Definition: AMueller.h:154
casacore::Vector< casacore::uInt > totnumchan_p
Definition: AMueller.h:152
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 ~ANoise()
virtual void applyCal(VisBuffer &vb, casacore::Cube< casacore::Complex > &Vout, casacore::Bool trial=false)
Apply this calibration to vb.
A class to group separately averaged VisBuffers.
void hurl(const casacore::String &origin, const casacore::String &msg)
Logs and throws msg as an exception from origin.
virtual Mueller::MuellerType muellerType()
Algebraic type of Mueller matrix (this is the key distinguishing characteristic)
Definition: AMueller.h:182
casacore::Int nCorr_p
estimate.
Definition: AMueller.h:147
virtual Origin origin() const =0
ABSTRACT METHODS //.
virtual void selfSolveOne(VisBuffGroupAcc &vbga)
Per-solution self-solving inside generic gather.
casacore::Bool doSub_p
Definition: AMueller.h:145
virtual casacore::Bool freqDepPar()
this is inherently freqdep:
Definition: AMueller.h:188
virtual casacore::Bool trivialMuellerElem()
Jones matrix elements are trivial.
Definition: AMueller.h:197
virtual Type type()
Return the type enum.
Definition: AMueller.h:174
virtual void calcAllMueller()
Calculate an ensemble of Mueller matrices (all baselines, channels) overrriding VisCal::calcAllMuelle...
virtual Mueller::MuellerType muellerType()
Algebraic type of Mueller matrix (this is the key distinguishing characteristic)
Definition: AMueller.h:60
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
virtual casacore::Int nPar()
umm...
Definition: AMueller.h:194
virtual casacore::Bool normalizable()
We do not normalize by the model, since we are estimating directly from the data (we should optimize ...
Definition: AMueller.h:112
virtual casacore::String longTypeName()
Definition: AMueller.h:56
const MSMetaInfoForCal & msmc() const
Access to the MSMetaInfoForCal (throws if none)
Definition: VisCal.h:338
virtual casacore::Bool isSolvable()
Overide solvability.
Definition: AMueller.h:185
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::Int fitorder_p
Initialized to 0 in the initialization lists of the c&#39;tors.
Definition: AMueller.h:143
VisibilityIterator iterates through one or more writable MeasurementSets.
casacore::Vector< casacore::Double > hifreq_p
Definition: AMueller.h:151
virtual void setApply()
Definition: AMueller.h:92
virtual void setSolve()
Set the solving parameters.
virtual void storeNCT()
casacore::Bool & simOnTheFly()
RI todo implement calcOneJones like calcAllMueller calculate terms during apply, or up front during s...