Line data Source code
1 : //# SolvableVisCal.h: Definitions of interface for SolvableVisCal
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: casa-feedback@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_SOLVABLEVISCAL_H
29 : #define SYNTHESIS_SOLVABLEVISCAL_H
30 :
31 : #include <casacore/casa/aips.h>
32 : #include <casacore/casa/Containers/Record.h>
33 : #include <casacore/casa/BasicSL/Complex.h>
34 : #include <casacore/casa/BasicSL/Constants.h>
35 : #include <synthesis/MeasurementComponents/VisCal.h>
36 : #include <synthesis/MeasurementComponents/CalCorruptor.h>
37 : #include <synthesis/MeasurementComponents/Mueller.h>
38 : #include <synthesis/MeasurementComponents/Jones.h>
39 : #include <synthesis/MeasurementComponents/VisVector.h>
40 : #include <synthesis/TransformMachines/SynthesisError.h>
41 : #include <synthesis/CalTables/NewCalTable.h>
42 : #include <synthesis/CalTables/CLPatchPanel.h>
43 : #include <synthesis/CalTables/CTPatchedInterp.h>
44 : #include <synthesis/CalTables/CalSetMetaInfo.h>
45 : #include <synthesis/CalTables/VisCalEnum.h>
46 : #include <msvis/MSVis/VisSet.h>
47 : #include <msvis/MSVis/CalVisBuffer.h>
48 : #include <msvis/MSVis/VisBuffGroupAcc.h>
49 :
50 : #include <casacore/casa/Logging/LogMessage.h>
51 : #include <casacore/casa/Logging/LogSink.h>
52 : #include <casacore/casa/Logging/LogIO.h>
53 : #include <casacore/casa/OS/Timer.h>
54 :
55 : #include <iostream>
56 : #include <fstream>
57 :
58 : namespace casa { //# NAMESPACE CASA - BEGIN
59 :
60 :
61 : // **********************************************************
62 : // SolvableVisCal
63 : //
64 :
65 : // Forward
66 : class VisEquation;
67 : class SolveDataBuffer;
68 : class SDBList;
69 :
70 : class SolNorm {
71 :
72 : public:
73 :
74 : enum Type { MEAN, MEDIAN, UNKNOWN };
75 :
76 : SolNorm(casacore::Bool donorm=false, casacore::String normtype=casacore::String("mean"));
77 : SolNorm(const SolNorm& other);
78 :
79 128 : inline casacore::Bool donorm() const { return donorm_; };
80 0 : inline Type normtype() const { return normtype_; };
81 0 : inline casacore::String normtypeString() const { return normTypeAsString(normtype_); };
82 :
83 : void report();
84 :
85 : private:
86 :
87 : // data
88 : casacore::Bool donorm_;
89 : Type normtype_;
90 :
91 : static Type normTypeFromString(casacore::String name);
92 : static casacore::String normTypeAsString(Type type);
93 :
94 :
95 : };
96 :
97 :
98 :
99 : class FreqMetaData {
100 :
101 : public:
102 :
103 : FreqMetaData();
104 :
105 : // Calculate appropriately decimated freq meta info from supplied info
106 : void calcFreqMeta(const casacore::Vector< casacore::Vector<casacore::Double> >& msfreq,
107 : const casacore::Vector< casacore::Vector<casacore::Double> >& mswidth,
108 : const casacore::Vector<casacore::uInt>& selspw,
109 : casacore::Bool freqdep,casacore::Bool combspw,
110 : const casacore::Vector<casacore::Int>& spwfanin);
111 :
112 : // Public access to freq meta info
113 : const casacore::Vector<casacore::Double>& freq(casacore::Int spw) const;
114 : const casacore::Vector<casacore::Double>& width(casacore::Int spw) const;
115 : const casacore::Vector<casacore::Double>& effBW(casacore::Int spw) const;
116 :
117 : // Public access to spw fan-in
118 : casacore::Int fannedInSpw(casacore::Int spw) const;
119 :
120 : // Has freq meta data been calculated?
121 : casacore::Bool ok() const;
122 :
123 : // Return list of valid spws
124 : const casacore::Vector<casacore::Int>& validSpws() const;
125 :
126 : private:
127 :
128 : // true if we have run calcFreqMeta (indicates valid freq info contained herein
129 : casacore::Bool ok_;
130 :
131 : // List of valid spws (calc'd in calcFreqMeta)
132 : casacore::Vector<casacore::Int> validspws_;
133 :
134 : // The freq meta data arrays [nSpw][nChan]
135 : casacore::Vector< casacore::Vector<casacore::Double> > freq_, width_, effBW_;
136 :
137 : // When combspw=true, store spw fan-in
138 : casacore::Vector<casacore::Int> spwfanin_;
139 :
140 : };
141 :
142 :
143 :
144 : class SolvableVisCal : virtual public VisCal {
145 : public:
146 :
147 : typedef struct fluxScaleStruct {
148 : casacore::Matrix<casacore::Double> fd;
149 : casacore::Matrix<casacore::Double> fderr;
150 : casacore::Matrix<casacore::Int> numSol;
151 : casacore::Vector<casacore::Double> freq;
152 : casacore::Matrix<casacore::Double> spidx;
153 : casacore::Matrix<casacore::Double> spidxerr;
154 : casacore::Vector<casacore::Double> fitfd;
155 : casacore::Vector<casacore::Double> fitfderr;
156 : casacore::Vector<casacore::Double> fitreffreq;
157 : //casacore::Matrix<casacore::Double> covarmat;
158 : //casacore::PtrBlock<casacore::Matrix<casacore::Double>* > covarmat;
159 : casacore::Vector<casacore::Matrix<casacore::Double> > covarmat;
160 : } fluxScaleStruct;
161 :
162 :
163 : SolvableVisCal(VisSet& vs);
164 :
165 : SolvableVisCal(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
166 :
167 : SolvableVisCal(const MSMetaInfoForCal& msmc);
168 :
169 : SolvableVisCal(const casacore::Int& nAnt);
170 :
171 : virtual ~SolvableVisCal();
172 :
173 : // Access to user-supplied parameters
174 524 : inline casacore::String& calTableName() { return calTableName_; };
175 10 : inline casacore::String& calTableSelect() { return calTableSelect_; };
176 217 : inline casacore::Bool& append() { return append_; };
177 146 : inline casacore::String& tInterpType() { return tInterpType_; };
178 102 : inline casacore::String& fInterpType() { return fInterpType_; };
179 111 : inline casacore::Vector<casacore::Int>& spwMap() { return spwMap_; };
180 124 : inline casacore::String& refantmode() { return refantmode_; };
181 64 : inline casacore::Int& refant() { return refantlist()(0); };
182 760 : inline casacore::Vector<casacore::Int>& refantlist() { return urefantlist_; };
183 32 : inline casacore::Int& minblperant() { return minblperant_; };
184 389 : inline casacore::String& apmode() { return apmode_; };
185 128 : inline casacore::String& solmode() { return solmode_; };
186 96 : inline casacore::Vector<casacore::Float>& rmsthresh() { return rmsthresh_; };
187 399 : inline casacore::String& solint() { return solint_; };
188 192 : inline casacore::String& fsolint() { return fsolint_; };
189 128 : inline casacore::Double& preavg() { return preavg_; };
190 503 : inline casacore::String& corrcomb() { return corrcomb_; };
191 0 : inline const SolNorm& solNorm() { return solnorm_;};
192 128 : inline casacore::Bool solnorm() { return solnorm_.donorm();};
193 321 : inline casacore::Float& minSNR() { return minSNR_; };
194 :
195 32 : inline casacore::String& combine() { return combine_; };
196 564 : inline casacore::Bool combspw() { return upcase(combine_).contains("SPW"); };
197 257 : inline casacore::Bool combfld() { return upcase(combine_).contains("FIELD"); };
198 32 : inline casacore::Bool combscan() { return upcase(combine_).contains("SCAN"); };
199 32 : inline casacore::Bool combobs() { return upcase(combine_).contains("OBS"); };
200 :
201 : // Total number of (complex) parameters per solve
202 : // (specialize to jive with ant- or bln-basedness, etc.)
203 : virtual casacore::Int nTotalPar()=0;
204 :
205 : // Report if calibration available for specified spw
206 : // (if no CalInterp available, assume true)
207 :
208 : // Use generic data gathering mechanism for solve
209 0 : virtual casacore::Bool useGenericGatherForSolve() { return true; };
210 :
211 : // Use generic solution engine for a single solve
212 : // (usually inside the generic gathering mechanism)
213 0 : virtual casacore::Bool useGenericSolveOne() { return useGenericGatherForSolve(); };
214 :
215 : // Solve for point-source X or Q,U?
216 : // nominally no (0)
217 27519 : virtual casacore::Int solvePol() { return 0; };
218 :
219 : // Does normalization by MODEL_DATA commute with this VisCal?
220 : // (if so, permits pre-solve time-averaging)
221 : virtual casacore::Bool normalizable()=0;
222 :
223 : // Should data and model be divided by Stokes I model before average+solve?
224 : // (Nominally false, for now)
225 27519 : virtual casacore::Bool divideByStokesIModelForSolve() { return false; };
226 :
227 : // Is this type capable of accumulation? (nominally no)
228 0 : virtual casacore::Bool accumulatable() { return false; };
229 :
230 : // Is this type capable of smoothing? (nominally no)
231 0 : virtual casacore::Bool smoothable() { return false; };
232 :
233 : // Should only parallel-hands be used in solving?
234 : // (generally no (default=false), but GJones and related
235 : // will override, and eventually this will be a user-set-able
236 : // parameter)
237 0 : virtual casacore::Bool phandonly() { return false; }
238 :
239 : // Access to focus channel
240 0 : inline casacore::Int& focusChan() { return focusChan_; };
241 :
242 : // Is this ready to solve?
243 14040 : inline casacore::Bool isSolved() {return solved_;};
244 :
245 : // Is this solveable? (via this interface, nominally yes)
246 0 : virtual casacore::Bool isSolvable() {return true;};
247 :
248 : // Set the application parameters
249 : virtual void setApply();
250 : virtual void setApply(const casacore::Record& apply);
251 : virtual void setCallib(const casacore::Record& callib,const casacore::MeasurementSet& selms);
252 :
253 0 : virtual void setModel(const casacore::String& )
254 0 : {throw(SynthesisError("Internal error: setModel() not yet supported for non EPJones type."));};
255 :
256 : // Report apply info/params, e.g. for logging
257 : virtual casacore::String applyinfo();
258 :
259 : // Set the solving parameters
260 : virtual void setSolve();
261 : virtual void setSolve(const casacore::Record& solve);
262 :
263 : // Report solve info/params, e.g., for logging
264 : virtual casacore::String solveinfo();
265 :
266 : // Arrange for accumulation
267 : virtual void setAccumulate(VisSet& vs,
268 : const casacore::String& table,
269 : const casacore::String& select,
270 : const casacore::Double& t,
271 : const casacore::Int& refAnt=-1);
272 :
273 : // Default value for parameters
274 0 : virtual casacore::Complex defaultPar() { return casacore::Complex(1.0); };
275 0 : virtual casacore::Float defaultRPar() { return casacore::Float(0.0); };
276 6 : virtual casacore::Complex defaultCPar() { return casacore::Complex(1.0); };
277 :
278 : // Arrange to build a cal table from specified values
279 : virtual void setSpecify(const casacore::Record& specify);
280 :
281 : // Fill a caltable with specified values
282 : virtual void specify(const casacore::Record& specify);
283 :
284 : // Size up the solving arrays, etc. (supports combine)
285 : virtual casacore::Int sizeUpSolve(VisSet& vs, casacore::Vector<casacore::Int>& nChunkPerSol);
286 :
287 : // These inflate methods soon to deprecate (gmoellen, 20121212)
288 : // Inflate the pristine CalSet (from VisSet info)
289 : void inflate(VisSet& vs, const casacore::Bool& fillMeta=false);
290 : // Inflate the pristine CalSet (generically)
291 : virtual void inflate(const casacore::Vector<casacore::Int>& nChanDat,
292 : const casacore::Vector<casacore::Int>& startChanDat,
293 : const casacore::Vector<casacore::Int>& nSlot);
294 :
295 :
296 : // Hazard a guess at the parameters (solveCPar) given the data
297 : virtual void guessPar(VisBuffer& vb)=0;
298 0 : virtual void guessPar(SDBList&,const casacore::Bool&) { throw(casacore::AipsError("SVC::guessPar(SDBList&) NYI!!")); }; // VI2
299 :
300 : // Time-dep solution interval (VI2)
301 32 : inline double solTimeInterval() const { return solTimeInterval_; };
302 :
303 : // Freq-dep solint values (const?!)
304 0 : inline casacore::Double& fintervalHz() { return fintervalHz_; };
305 0 : inline casacore::Double& fintervalCh() { return fintervalCh_(currSpw()); }; // for current Spw
306 0 : const inline casacore::Vector<casacore::Double>& fintervalChV() { return fintervalCh_; }; // all spws
307 0 : casacore::Matrix<casacore::Int> chanAveBounds() { return chanAveBounds_(currSpw()); }; // for current Spw
308 0 : casacore::Matrix<casacore::Int> chanAveBounds(casacore::Int spw) { return chanAveBounds_(spw); };
309 :
310 : // Access to current solution parameters and matrices
311 24 : inline virtual casacore::Cube<casacore::Complex>& solveCPar() {return (*solveCPar_[currSpw()]);};
312 900 : inline virtual casacore::Cube<casacore::Float>& solveRPar() {return (*solveRPar_[currSpw()]);};
313 924 : inline virtual casacore::Cube<casacore::Bool>& solveParOK() {return (*solveParOK_[currSpw()]);};
314 474 : inline virtual casacore::Cube<casacore::Float> & solveParErr() {return (*solveParErr_[currSpw()]);};
315 699 : inline virtual casacore::Cube<casacore::Float> & solveParSNR() {return (*solveParSNR_[currSpw()]);};
316 :
317 114 : inline virtual casacore::Cube<casacore::Complex>& solveAllCPar() {return (*solveAllCPar_[currSpw()]);};
318 900 : inline virtual casacore::Cube<casacore::Float>& solveAllRPar() {return (*solveAllRPar_[currSpw()]);};
319 996 : inline virtual casacore::Cube<casacore::Bool>& solveAllParOK() {return (*solveAllParOK_[currSpw()]);};
320 996 : inline virtual casacore::Cube<casacore::Float> & solveAllParErr() {return (*solveAllParErr_[currSpw()]);};
321 996 : inline virtual casacore::Cube<casacore::Float> & solveAllParSNR() {return (*solveAllParSNR_[currSpw()]);};
322 :
323 : // Access to per-spw solution parameters and matrices
324 0 : inline virtual void solveAllCPar(casacore::Int spw, casacore::Cube<casacore::Complex>& cparSpw)
325 0 : { if (spw<nSpw()) cparSpw = (*solveAllCPar_[spw]);}
326 0 : inline virtual void solveAllRPar(casacore::Int spw, casacore::Cube<casacore::Float>& rparSpw)
327 0 : { if (spw<nSpw()) rparSpw = (*solveAllRPar_[spw]);}
328 0 : inline virtual void solveAllParOK(casacore::Int spw, casacore::Cube<casacore::Bool>& parokSpw)
329 0 : { if (spw<nSpw()) parokSpw = (*solveAllParOK_[spw]);}
330 0 : inline virtual void solveAllParErr(casacore::Int spw, casacore::Cube<casacore::Float>& parerrSpw)
331 0 : { if (spw<nSpw()) parerrSpw = (*solveAllParErr_[spw]);}
332 0 : inline virtual void solveAllParSNR(casacore::Int spw, casacore::Cube<casacore::Float>& parsnrSpw)
333 0 : { if (spw<nSpw()) parsnrSpw = (*solveAllParSNR_[spw]);}
334 :
335 : // Access to source pol parameters
336 0 : inline casacore::Vector<casacore::Complex>& srcPolPar() { return srcPolPar_; };
337 :
338 : // get antenna map
339 225 : virtual std::map<casacore::Int, std::map<casacore::String, casacore::Vector<casacore::Int>>> getAntennaMap() {return antennaMap_;};
340 : // get refant map
341 31 : virtual std::map<casacore::Int, std::map<casacore::Int, casacore::Int>> getRefantMap() {return refantMap_;};
342 :
343 :
344 : // Synchronize the meta data with a solvable VisBuffer
345 : // (returns false if VisBuffer has no valid data)
346 : casacore::Bool syncSolveMeta(VisBuffer& vb, const casacore::Int& fieldId);
347 : casacore::Bool syncSolveMeta(VisBuffGroupAcc& vbga);
348 : void syncSolveMeta(SDBList& sdbs); // VI2 (valid data now checked elsewhere)
349 : // Provide for override of currScan and currObs
350 : void overrideObsScan(casacore::Int obs, casacore::Int scan);
351 :
352 : // If apmode() is "A", convert vb's visibilities to amp + 0i.
353 : // If it is "P", convert them to phase + 0i.
354 : // Otherwise (i.e. "AP"), leave them alone.
355 : virtual void enforceAPonData(VisBuffer& vb);
356 :
357 : // Fill expected and data_unflagged
358 : virtual void expectedUnflagged(SDBList& sdbs);
359 : // Clear antennaMap values
360 : void clearMap();
361 : void clearRefantMap();
362 :
363 : // Verify VisBuffer data sufficient for solving (wts, etc.)
364 : virtual casacore::Bool verifyConstraints(VisBuffGroupAcc& vbag);
365 : virtual casacore::Bool verifyConstraints(SDBList& sdbs); // VI2
366 : virtual casacore::Bool verifyForSolve(VisBuffer& vb);
367 :
368 : // Self- gather and/or solve prototypes
369 : // (triggered by useGenericGatherForSolve=F or useGenericSolveOne=F;
370 : // must be overridden in derived specializations)
371 : virtual void selfGatherAndSolve(VisSet& vs, VisEquation& ve);
372 : virtual void selfSolveOne(VisBuffGroupAcc& vs);
373 0 : virtual void selfSolveOne(SDBList&) { throw(casacore::AipsError("selfSolveOne for VI2/SDB usage NYI for "+typeName())); };
374 :
375 : // Set up data and model for pol solve
376 : void setUpForPolSolve(VisBuffer& vb);
377 : // A VB2-specific version which depends on local specialization
378 : // (this may be further refined later)
379 0 : virtual void setUpForPolSolve(vi::VisBuffer2&) {
380 0 : throw(casacore::AipsError("setUpForPolSolve(VB2) not specialized in "+typeName()+" as required.")); };
381 :
382 : // Differentiate VB model w.r.t. Cal parameters (no 2nd derivative yet)
383 : virtual void differentiate(CalVisBuffer& cvb)=0;
384 0 : virtual void differentiate(SolveDataBuffer&) { throw(casacore::AipsError("SVC::differentiate(SDB) NYI!")); }; // VI2
385 : virtual void differentiate(VisBuffer& vb,
386 : casacore::Cube<casacore::Complex>& V,
387 : casacore::Array<casacore::Complex>& dV,
388 : casacore::Matrix<casacore::Bool>& Vflg)=0;
389 0 : virtual void differentiate(VisBuffer& , // vb.visCube() has the obs. data. vb.modelVisCube() will receive the residuals
390 : VisBuffer& , // 1st. Derivative w.r.t. first parameter
391 : VisBuffer& , // 1st. Derivative w.r.t. second parameter
392 0 : casacore::Matrix<casacore::Bool>& ){ throw(casacore::AipsError("Invalid use of differentiate(vb,dV0,dv1)")); };
393 :
394 :
395 : // Differentiate VB model w.r.t. Source parameters
396 : virtual void diffSrc(VisBuffer& vb,
397 : casacore::Array<casacore::Complex>& dV)=0;
398 :
399 : // Update solve parameters incrementally (additive)
400 : virtual void updatePar(const casacore::Vector<casacore::Complex> dCalPar,const casacore::Vector<casacore::Complex> dSrcPar);
401 : virtual void updatePar(const casacore::Vector<casacore::Complex> dCalPar); // (VI2)
402 :
403 : // Form solution SNR
404 : virtual void formSolveSNR();
405 :
406 : // Apply SNR threshold
407 : virtual void applySNRThreshold();
408 :
409 : // Apply refant (implemented in SVJ)
410 : virtual void reReference()=0;
411 :
412 : // Retrieve the cal flag info as a record
413 : virtual casacore::Record actionRec();
414 :
415 : // Retrieve solve-related info via Record
416 : virtual casacore::Record solveActionRec();
417 :
418 : // Accumulate another VisCal onto this one
419 : virtual void accumulate(SolvableVisCal* incr,
420 : const casacore::Vector<casacore::Int>& fields)=0;
421 :
422 : virtual void smooth(casacore::Vector<casacore::Int>& fields,
423 : const casacore::String& smtype,
424 : const casacore::Double& smtime,
425 : const bool ratesmooth);
426 :
427 : // Report solved-for QU
428 : virtual void reportSolvedQU();
429 :
430 :
431 : // New CalTable handling
432 : virtual void createMemCalTable();
433 : virtual void keep1(casacore::Int ichan);
434 : virtual void keepNCT();
435 : virtual void storeNCT();
436 : void storeNCT(const casacore::String& tableName,const casacore::Bool& append);
437 :
438 : virtual void loadMemCalTable(casacore::String ctname,casacore::String field="");
439 :
440 : // New spwOK
441 : virtual casacore::Bool spwOK(casacore::Int ispw);
442 :
443 : //Is VB OK for calibration?
444 : virtual casacore::Bool VBOKforCalApply(vi::VisBuffer2& vb);
445 :
446 : // Calibration available?
447 : virtual casacore::Bool calAvailable(vi::VisBuffer2&);
448 :
449 : // Post solve tinkering (generic version)
450 : virtual void globalPostSolveTinker();
451 :
452 : // Divide all solutions by their amplitudes
453 : virtual void enforceAPonSoln();
454 :
455 : // Normalize a solution (generic implementation)
456 : virtual void normalize();
457 :
458 : // Determine and apply flux density scaling
459 : virtual void fluxscale(const casacore::String& outfile,
460 : const casacore::Vector<casacore::Int>& refFieldIn,
461 : const casacore::Vector<casacore::Int>& tranFieldIn,
462 : const casacore::Vector<casacore::Int>& inRefSpwMap,
463 : const casacore::Vector<casacore::String>& fldNames,
464 : const casacore::Float& inGainThres,
465 : const casacore::String& antSel,
466 : const casacore::String& timerangeSel,
467 : const casacore::String& scanSel,
468 : fluxScaleStruct& oFluxScaleStruct,
469 : const casacore::String& oListFile,
470 : const casacore::Bool& incremental,
471 : const casacore::Int& fitorder,
472 : const casacore::Bool& display)=0;
473 :
474 : // Report state:
475 0 : inline virtual void state() { stateSVC(true); };
476 :
477 0 : virtual VisCalEnum::VCParType setParType(VisCalEnum::VCParType type)
478 0 : {parType_ = type;return (VisCalEnum::VCParType)parType_;};
479 : virtual void currMetaNote();
480 :
481 : virtual void listCal(const casacore::Vector<casacore::Int> ufldids, const casacore::Vector<casacore::Int> uantids,
482 : const casacore::Matrix<casacore::Int> uchanids, //const casacore::Int& spw, const casacore::Int& chan,
483 : const casacore::String& listfile="",const casacore::Int& pagerows=50)=0;
484 :
485 : // Handle external channel mask
486 0 : inline void setChanMask(casacore::PtrBlock<casacore::Vector<casacore::Bool>*>& chanmask) { chanmask_=&chanmask; };
487 0 : inline void clearChanMask() { chanmask_=NULL; };
488 : void applyChanMask(VisBuffer& vb);
489 : // Log periodic solver activity
490 : virtual void printActivity(const casacore::Int nSlots, const casacore::Int slotNo,
491 : const casacore::Int fieldId, const casacore::Int spw,
492 : const casacore::Int nSolutions);
493 0 : virtual void markTimer() {timer_p.mark();};
494 :
495 :
496 : // -------------
497 : // Set the simulation parameters
498 : virtual void setSimulate(VisSet& vs, casacore::Record& simpar, casacore::Vector<casacore::Double>& solTimes);
499 :
500 : // make a corruptor in a VC-specific way
501 : virtual void createCorruptor(const VisIter& vi,const casacore::Record& simpar, const int nSim);
502 :
503 : // access to simulation variables that are general to all VisCals
504 0 : inline casacore::String& simint() { return simint_; };
505 :
506 : // Simulation info/params, suitable for logging
507 : virtual casacore::String siminfo();
508 :
509 : // Is this calibration simulated?
510 0 : inline casacore::Bool isSimulated() {return simulated_;};
511 :
512 : // object that can simulate the corruption terms
513 : CalCorruptor *corruptor_p;
514 :
515 : // calculate # required slots to simulate this SVC
516 : casacore::Int sizeUpSim(VisSet& vs, casacore::Vector<casacore::Int>& nChunkPerSol, casacore::Vector<casacore::Double>& solTimes);
517 :
518 :
519 : // VI2-related refactor--------------------------------------
520 :
521 : // Set "current" meta info, so internals are registered
522 : // (VI2: replaces meta-inf part of syncSolveMeta;
523 : // NB: does _NOT_ check sum(wt)>0 older syncSolveMeta!)
524 : virtual void setMeta(int obs, int scan, double time,
525 : int spw, const casacore::Vector<double>& freq,
526 : int fld);
527 :
528 : // Reshape solvePar* arrays for the currSpw()
529 : // (ensitive to freqDepPar())
530 : // (VI2: replaces initSolvePar part of sizeUpSolve)
531 : virtual int sizeSolveParCurrSpw(int nVisChan);
532 :
533 : // Set parameters to def values in the currSpw(),
534 : // and optionally sync everything
535 : virtual void setDefSolveParCurrSpw(bool sync=false);
536 :
537 : // Parse solint in VI2 context
538 : void reParseSolintForVI2();
539 :
540 : // Generate the in-memory caltable (empty)
541 : // NB: no subtable revisions
542 : virtual void createMemCalTable2();
543 :
544 : // Set (or verify) freq info in output cal table for specified spw
545 : virtual void setOrVerifyCTFrequencies(int spw);
546 :
547 :
548 :
549 : // Discern frequency meta info for solutions (solve context)
550 : virtual void discernAndSetSolnFrequencies(const casa::vi::VisibilityIterator2& vi,
551 : const casacore::Vector<casacore::uInt>& selspws);
552 :
553 : // Set frequencies in the Caltable (according to discernAndSetSolnFrequencies)
554 : virtual void setCTFrequencies(casacore::Int netspw);
555 :
556 :
557 :
558 : protected:
559 :
560 : // Set to-be-solved-for flag
561 74 : inline void setSolved(const casacore::Bool& flag) {solved_=flag;};
562 :
563 : // Initialize solve parameters (shape)
564 : virtual void initSolvePar()=0;
565 :
566 : // Invalidate diff cal matrices generically
567 : inline virtual void invalidateDiffCalMat()=0;
568 :
569 : // Explicitly synchronize pars with a CalSet slot
570 : using VisCal::syncPar;
571 :
572 : // Set matrix channelization according to a VisSet
573 : virtual void setSolveChannelization(VisSet& vs);
574 :
575 : // Convert Hz to Ch in fsolint
576 : virtual void convertHzToCh();
577 :
578 : // Calculate chan averaging bounds
579 : virtual void setFracChanAve();
580 :
581 : // Inflate an NCT w/ meta-data according to a VisSet
582 : // (for accum)
583 : void inflateNCTwithMetaData(VisSet& vs);
584 :
585 : // Synchronize calibration for solve context
586 : void syncSolveCal();
587 :
588 : // Synchronize parameters for solve context
589 : void syncSolvePar();
590 :
591 : // Calculate parameters by some means (e.g., interpolation from a CalSet)
592 : virtual void calcPar();
593 : virtual void calcParByCLPP();
594 :
595 : // Synchronize the differentiated calibration
596 : virtual void syncDiffMat()=0;
597 :
598 : // Report the SVC-specific state, w/ option for VC::state()
599 : virtual void stateSVC(const casacore::Bool& doVC);
600 :
601 : // Normalize a (complex) solution array (generic)
602 : casacore::Complex normSolnArray(casacore::Array<casacore::Complex>& sol,
603 : const casacore::Array<casacore::Bool>& solOK,
604 : const casacore::Bool doPhase=false);
605 :
606 : virtual casacore::Float calcPowerNorm(casacore::Array<casacore::Float>& amp, const casacore::Array<casacore::Bool>& ok)=0;
607 :
608 : // Logger
609 5747 : casacore::LogIO& logSink() { return logsink_p; };
610 :
611 : // Check if a cal table is appropriate
612 : void verifyCalTable(const casacore::String& caltablename);
613 :
614 : void sortVisSet(VisSet& vs, const casacore::Bool verbose=false);
615 :
616 : casacore::Int parType_;
617 :
618 : // New CalTable
619 : NewCalTable *ct_;
620 : CTPatchedInterp *ci_;
621 : CLPatchPanel *cpp_;
622 : casacore::Vector<casacore::Bool> spwOK_;
623 :
624 : casacore::Double maxTimePerSolution_p, minTimePerSolution_p, avgTimePerSolution_p;
625 : casacore::Float userPrintActivityInterval_p, userPrintActivityFraction_p;
626 : casacore::uInt caiRC_p, cafRC_p;
627 : casacore::Timer timer_p;
628 : // Map for refant information SPW || ANT || VAL
629 : std::map<casacore::Int, std::map<casacore::Int, casacore::Int>> refantMap_;
630 :
631 : // Set state flag to simulate cal terms
632 0 : inline void setSimulated(const casacore::Bool& flag) {simulated_=flag;};
633 :
634 : // RI todo implement calcOneJones like calcAllMueller
635 : // calculate terms during apply, or up front during setSim?
636 4680 : inline casacore::Bool& simOnTheFly() {
637 : // cout << "simOTF=" << onthefly_ << endl;
638 4680 : return onthefly_; };
639 :
640 : // Frequency meta data for solutions (for CalTable labels...)
641 : FreqMetaData freqMetaData_;
642 :
643 :
644 : private:
645 :
646 : // Default ctor is private
647 : SolvableVisCal();
648 :
649 : // Initialize pointers, etc.
650 : void initSVC();
651 :
652 : // Delete pointers
653 : void deleteSVC();
654 :
655 : // Pointer to CTTimeInterp1 factory method (generic)
656 : // SVC specializations may choose to specialize CTTimeInterp1, as needed,
657 : // and override this method accordingly (e.g., see FringeJones.h)
658 29 : virtual CTTIFactoryPtr cttifactoryptr() { return &CTTimeInterp1::factory; };
659 :
660 : // Cal table name
661 : casacore::String calTableName_;
662 : casacore::String calTableSelect_;
663 : casacore::Bool append_;
664 :
665 : // Interpolation types
666 : casacore::String tInterpType_;
667 : casacore::String fInterpType_;
668 :
669 : // Spw mapping
670 : casacore::Vector<casacore::Int> spwMap_;
671 :
672 : // Refant mode
673 : casacore::String refantmode_;
674 :
675 : // Refant
676 : casacore::Vector<casacore::Int> urefantlist_;
677 :
678 : // Min baselines per ant for solve
679 : casacore::Int minblperant_;
680 :
681 : // Solved-for flag
682 : casacore::Bool solved_;
683 :
684 : // Signal apply by callib
685 : casacore::Bool byCallib_;
686 :
687 : // Solving mode
688 : casacore::String apmode_;
689 :
690 : // Solver iteration mode
691 : casacore::String solmode_;
692 : casacore::Vector<casacore::Float> rmsthresh_;
693 :
694 : // User-specified full solint string
695 : casacore::String usolint_;
696 :
697 : // User-specified time-dep solint (string)
698 : casacore::String solint_;
699 :
700 : // Derived time-dep solution interval (s) (VI2)
701 : double solTimeInterval_;
702 :
703 : // User-specified freq-dep solint info
704 : casacore::String fsolint_;
705 :
706 : // Derived frequency intervals
707 : casacore::Double fintervalHz_;
708 : casacore::Vector<casacore::Double> fintervalCh_; // (nSpw)
709 :
710 :
711 : // Channel averaging bounds
712 : casacore::Vector<casacore::Matrix<casacore::Int> > chanAveBounds_; // (nSpw)(2,nOutChan)
713 :
714 : // Preavering interval
715 : casacore::Double preavg_;
716 :
717 : // Combine polarizations
718 : casacore::String corrcomb_;
719 :
720 : // Do solution normalization after a solve
721 : SolNorm solnorm_;
722 :
723 : // SNR threshold
724 : casacore::Float minSNR_;
725 :
726 : // axes to combine for solve
727 : casacore::String combine_;
728 :
729 : // In-focus channel for single-chan solves on multi-chan data
730 : casacore::Int focusChan_;
731 :
732 : // Solving meta-data
733 : casacore::Double dataInterval_;
734 : casacore::Double fitWt_;
735 : casacore::Double fit_;
736 :
737 : // Current parameters
738 : casacore::PtrBlock<casacore::Cube<casacore::Complex>*> solveCPar_; // [nSpw](nPar,1,{1|nElem})
739 : casacore::PtrBlock<casacore::Cube<casacore::Float>*> solveRPar_; // [nSpw](nPar,1,{1|nElem})
740 : casacore::PtrBlock<casacore::Cube<casacore::Bool>*> solveParOK_; // [nSpw](nPar,1,{1|nElm})
741 : casacore::PtrBlock<casacore::Cube<casacore::Float>*> solveParErr_; // [nSpw](nPar,1,{1|nElm})
742 : casacore::PtrBlock<casacore::Cube<casacore::Float>*> solveParSNR_; // [nSpw](nPar,1,{1|nElm})
743 :
744 : casacore::PtrBlock<casacore::Cube<casacore::Complex>*> solveAllCPar_; // [nSpw](nPar,nChan,{1|nElem})
745 : casacore::PtrBlock<casacore::Cube<casacore::Float>*> solveAllRPar_; // [nSpw](nPar,nChan,{1|nElem})
746 : casacore::PtrBlock<casacore::Cube<casacore::Bool>*> solveAllParOK_; // [nSpw](nPar,nChan,{1|nElm})
747 : casacore::PtrBlock<casacore::Cube<casacore::Float>*> solveAllParErr_; // [nSpw](nPar,nChan,{1|nElm})
748 : casacore::PtrBlock<casacore::Cube<casacore::Float>*> solveAllParSNR_; // [nSpw](nPar,nChan,{1|nElm})
749 :
750 : casacore::Vector<casacore::Complex> srcPolPar_;
751 :
752 : // Map for antenna information
753 : std::map<casacore::Int, std::map<casacore::String, casacore::Vector<casacore::Int>>> antennaMap_;
754 : // Map for refant information SPW || ANT || VAL
755 : // std::map<casacore::Int, std::map<casacore::Int, casacore::Int>> refantMap_;
756 :
757 : // A _pointer_ to the external channel mask
758 : casacore::PtrBlock<casacore::Vector<casacore::Bool>*> *chanmask_;
759 :
760 : // LogIO
761 : casacore::LogIO logsink_p;
762 :
763 : // Simulation flag
764 : casacore::Bool simulated_;
765 :
766 : // simulation interval
767 : casacore::String simint_;
768 :
769 : casacore::Bool onthefly_;
770 :
771 : };
772 :
773 :
774 :
775 : // **********************************************************
776 : // SolvableVisMueller
777 : //
778 :
779 : class SolvableVisMueller : public SolvableVisCal, virtual public VisMueller
780 : {
781 :
782 : public:
783 :
784 : SolvableVisMueller(VisSet& vs);
785 :
786 : SolvableVisMueller(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
787 :
788 : SolvableVisMueller(const MSMetaInfoForCal& msmc);
789 :
790 : SolvableVisMueller(const casacore::Int& nAnt);
791 :
792 : virtual ~SolvableVisMueller();
793 :
794 : // Total number of (complex) parameters per solve
795 : // Mueller version: just return number of per-Bln parameters
796 0 : virtual casacore::Int nTotalPar() { return nPar(); };
797 :
798 : // Does normalization by MODEL_DATA commute with this VisCal?
799 0 : virtual casacore::Bool normalizable() { return (this->muellerType() < Mueller::General); };
800 :
801 : // Hazard a guess at the parameters (solvePar) given the data
802 0 : virtual void guessPar(VisBuffer& ) { throw(casacore::AipsError("NYI")); };
803 :
804 : // Differentiate VB model w.r.t. Mueller parameters (no 2nd derivative yet)
805 0 : virtual void differentiate(CalVisBuffer& ) {throw(casacore::AipsError("SVM::differentiate(CVB): NYI")); };
806 0 : virtual void differentiate(SolveDataBuffer& ) {throw(casacore::AipsError("SVM::differentiate(SDB): NYI")); }; // VI2
807 0 : virtual void differentiate(VisBuffer& , // input data
808 : casacore::Cube<casacore::Complex>& , // trial apply (nCorr,nChan,nRow)
809 : casacore::Array<casacore::Complex>& , // 1st deriv (nCorr,nPar,nChan,nRow)
810 0 : casacore::Matrix<casacore::Bool>& ) { throw(casacore::AipsError("NYI")); };
811 : using SolvableVisCal::differentiate;
812 :
813 : // Differentiate VB model w.r.t. Source parameters
814 0 : virtual void diffSrc(VisBuffer& ,
815 0 : casacore::Array<casacore::Complex>& ) {throw(casacore::AipsError("NYI")); };
816 :
817 : // Apply refant (no-op for Muellers)
818 0 : virtual void reReference() {};
819 :
820 : // Accumulate another VisCal onto this one
821 0 : virtual void accumulate(SolvableVisCal* ,
822 0 : const casacore::Vector<casacore::Int>& ) { throw(casacore::AipsError("NYI")); };
823 :
824 : // Scale solutions
825 0 : virtual void fluxscale(const casacore::String&,
826 : const casacore::Vector<casacore::Int>& ,
827 : const casacore::Vector<casacore::Int>& ,
828 : const casacore::Vector<casacore::Int>& ,
829 : const casacore::Vector<casacore::String>& ,
830 : const casacore::Float& ,
831 : const casacore::String& ,
832 : const casacore::String& ,
833 : const casacore::String& ,
834 : SolvableVisCal::fluxScaleStruct&,
835 : const casacore::String&,
836 : const casacore::Bool&,
837 : const casacore::Int&,
838 : const casacore::Bool&)
839 0 : { throw(casacore::AipsError("NYI")); };
840 :
841 : // SVM-specific write to caltable
842 : virtual void keepNCT();
843 :
844 : // Report state:
845 0 : inline virtual void state() { stateSVM(true); };
846 :
847 : // casacore::List calibration solutions in tabular form.
848 0 : virtual void listCal(const casacore::Vector<casacore::Int> ,
849 : const casacore::Vector<casacore::Int> ,
850 : const casacore::Matrix<casacore::Int> ,
851 : const casacore::String& ,
852 : const casacore::Int& )
853 0 : { throw(casacore::AipsError(casacore::String("Calibration listing not supported for "+typeName()))); };
854 :
855 : protected:
856 :
857 : // Number of Cal Matrices to form on baseline axis
858 : // (Mueller, solve context: 1)
859 0 : virtual casacore::Int nCalMat() { return isSolved() ? 1 : nBln(); };
860 :
861 : // Are differentiated M matrices constant in chan & bln?
862 0 : virtual casacore::Bool trivialDM() { return false; };
863 :
864 : // Initialize solve parameter shape
865 : // Mueller version: (nPar(),1,1) (one chan, one baseline)
866 : virtual void initSolvePar();
867 :
868 : // Access to matrix rendering of dM (per par)
869 0 : inline Mueller& dM() { return *dM_; };
870 :
871 : // Access to differentiated Mueller elements
872 0 : inline casacore::Array<casacore::Complex>& diffMElem() {return diffMElem_;};
873 :
874 : // Invalidate diff cal matrices generically (at this level, just M, dM)
875 0 : inline virtual void invalidateDiffCalMat() { invalidateM(); invalidateDM(); };
876 :
877 : // Validation of diffMueller matrices
878 0 : inline void invalidateDM() {DMValid_=false;};
879 0 : inline void validateDM() {DMValid_=true;};
880 0 : inline casacore::Bool DMValid() {return DMValid_;};
881 :
882 : // Synchronize the differentiated calibration (specialization for Mueller);
883 : virtual void syncDiffMat();
884 :
885 : // Synchronize the Muellers AND diffMuellers
886 : virtual void syncDiffMueller();
887 :
888 : // Calculate the ensemble of diff'd Mueller Elements
889 : virtual void calcAllDiffMueller();
890 :
891 : // Calculate one diffMElem
892 : virtual void calcOneDiffMueller(casacore::Matrix<casacore::Complex>& mat, const casacore::Vector<casacore::Complex>& par);
893 :
894 : // Create matrix renderers for dMs
895 : void createDiffMueller();
896 :
897 : // Override VM::setMatByOk in solve context
898 0 : void setMatByOk() { if (!isSolved()) VisMueller::setMatByOk(); };
899 :
900 : // Initialize trivial diff'd Muellers
901 : virtual void initTrivDM();
902 :
903 : // SVM-specific state
904 : virtual void stateSVM(const casacore::Bool& doVC);
905 :
906 : // atomic power normalization calculation
907 : // Mueller version assumes amp in power units
908 : virtual casacore::Float calcPowerNorm(casacore::Array<casacore::Float>& amp, const casacore::Array<casacore::Bool>& ok);
909 :
910 : private:
911 :
912 : // Default ctor is private
913 : SolvableVisMueller();
914 :
915 : // Mueller wrapper for diffMElem_;
916 : Mueller *dM_;
917 :
918 : // Differentiated Mueller matrix elements
919 : casacore::Array<casacore::Complex> diffMElem_; // (nDMEl,nPar,nChanMat,nBln)
920 :
921 : // diffMueller validation
922 : casacore::Bool DMValid_;
923 :
924 :
925 : };
926 :
927 : // **********************************************************
928 : // SolvableVisJones
929 : //
930 :
931 : class SolvableVisJones : public SolvableVisMueller, public VisJones {
932 :
933 : public:
934 :
935 : SolvableVisJones(VisSet& vs);
936 :
937 : SolvableVisJones(casacore::String msname,casacore::Int MSnAnt,casacore::Int MSnSpw);
938 :
939 : SolvableVisJones(const casacore::Int& nAnt);
940 :
941 : SolvableVisJones(const MSMetaInfoForCal& msmc);
942 :
943 : virtual ~SolvableVisJones();
944 :
945 : // Total number of (complex) parameters per solve
946 : // Jones version: nPar()*nAnt()
947 0 : virtual casacore::Int nTotalPar() { return nPar()*nAnt(); };
948 :
949 : // Does normalization by MODEL_DATA commute with this VisCal?
950 27551 : virtual casacore::Bool normalizable() { return (this->jonesType() < Jones::GenLinear); };
951 :
952 : // Differentiate VB model w.r.t. Jones parameters
953 : virtual void differentiate(CalVisBuffer& cvb);
954 : virtual void differentiate(SolveDataBuffer& sdb); // VI2
955 : virtual void differentiate(VisBuffer& vb, // input data
956 : casacore::Cube<casacore::Complex>& V, // trial apply (nCorr,nChan,nRow)
957 : casacore::Array<casacore::Complex>& dV, // 1st deriv (nCorr,nPar,nChan,nRow,2)
958 : casacore::Matrix<casacore::Bool>& Vflg);
959 : using SolvableVisMueller::differentiate;
960 :
961 : // Differentiate VB model w.r.t. Source parameters
962 : virtual void diffSrc(VisBuffer& vb,
963 : casacore::Array<casacore::Complex>& dV);
964 :
965 : // Apply refant
966 : virtual void reReference();
967 :
968 : // Accumulate another VisCal onto this one
969 : virtual void accumulate(SolvableVisCal* incr,
970 : const casacore::Vector<casacore::Int>& fields);
971 :
972 : // Post solve tinkering (Jones version: includes refant application)
973 : virtual void globalPostSolveTinker();
974 :
975 : // Apply reference antenna (generic Jones version)
976 : virtual void applyRefAnt();
977 :
978 : // Fluxscale is implemented here
979 : void fluxscale(const casacore::String& outfile,
980 : const casacore::Vector<casacore::Int>& refFieldIn,
981 : const casacore::Vector<casacore::Int>& tranFieldIn,
982 : const casacore::Vector<casacore::Int>& inRefSpwMap,
983 : const casacore::Vector<casacore::String>& fldNames,
984 : const casacore::Float& inGainThres,
985 : const casacore::String& antSel,
986 : const casacore::String& timerangeSel,
987 : const casacore::String& scanSel,
988 : SolvableVisCal::fluxScaleStruct& oFluxScaleStruct,
989 : const casacore::String& oListFile,
990 : const casacore::Bool& incremental=false,
991 : const casacore::Int& fitorder=1,
992 : const casacore::Bool& display=false);
993 :
994 : // SVJ-specific write to caltable
995 : virtual void keepNCT();
996 :
997 : // Report state:
998 0 : inline virtual void state() { stateSVJ(true); };
999 :
1000 : // Write calibration solutions to the terminal
1001 : virtual void listCal(const casacore::Vector<casacore::Int> ufldids, const casacore::Vector<casacore::Int> uantids,
1002 : const casacore::Matrix<casacore::Int> uchanids,
1003 : const casacore::String& listfile="",const casacore::Int& pagerows=50);
1004 :
1005 : // Write header for listCal output
1006 : int writeHeader(const casacore::uInt numAntCols,
1007 : const casacore::uInt numAnts,
1008 : const casacore::uInt iElem);
1009 :
1010 0 : virtual void nearest(const casacore::Double , casacore::Array<casacore::Float>& ) {};
1011 0 : virtual void nearest(const casacore::Double , casacore::Array<casacore::Complex>& ) {};
1012 :
1013 : //plotting historgram
1014 : void setupPlotter();
1015 : void plotHistogram(const casacore::String& title, const casacore::Int index,
1016 : const casacore::Vector<casacore::Double>& data, const casacore::Int nbin);
1017 :
1018 : protected:
1019 :
1020 : // Number of Cal Matrices to form on baseline axis
1021 : // (Jones, all contexts: nAnt())
1022 0 : virtual casacore::Int nCalMat() { return nAnt(); };
1023 :
1024 : // DM never trivial for SVJ
1025 0 : virtual casacore::Bool trivialDM() { return false; };
1026 :
1027 : // Are differentiated J matrices constant in chan & ant?
1028 0 : inline virtual casacore::Bool trivialDJ() { return false; };
1029 :
1030 : // Initialize solve parameter shape
1031 : // Jones version: (nPar(),1,nAnt()) (one chan, all antennas)
1032 : virtual void initSolvePar();
1033 :
1034 : // Access to matrix rendering of dJ1, dJ2
1035 0 : inline Jones& dJ1() { return *dJ1_; };
1036 0 : inline Jones& dJ2() { return *dJ2_; };
1037 :
1038 : // Access to differentiated Joness
1039 0 : casacore::Array<casacore::Complex>& diffJElem() { return diffJElem_; };
1040 :
1041 : // Invalidate diff cal matrices generically (at this level, M, dM, J, dJ)
1042 0 : inline virtual void invalidateDiffCalMat() {
1043 0 : SolvableVisMueller::invalidateDiffCalMat(); invalidateJ(); invalidateDJ(); };
1044 :
1045 : // Validation of Jones matrix derivatives
1046 0 : inline void invalidateDJ() {DJValid_=false;};
1047 0 : inline void validateDJ() {DJValid_=true;};
1048 0 : inline casacore::Bool DJValid() {return DJValid_;};
1049 :
1050 : // Synchronize the differentiated calibration (specialization for Jones)
1051 : virtual void syncDiffMat();
1052 :
1053 : // Synchronize the Jones AND diffJones matrices
1054 : virtual void syncDiffJones();
1055 :
1056 : // Calculate the ensemble of diff'd Jones Elements
1057 : virtual void calcAllDiffJones();
1058 :
1059 : // Calculate one ant/chan's diffJElem w.r.t. each par
1060 : virtual void calcOneDiffJones(casacore::Matrix<casacore::Complex>& mat, const casacore::Vector<casacore::Complex>& par);
1061 :
1062 : // Create matrix renderers for dJs
1063 : void createDiffJones();
1064 :
1065 : // Override VJ::setMatByOk in solve context
1066 4680 : void setMatByOk() { if (!isSolved()) VisJones::setMatByOk(); };
1067 :
1068 : // Initialize trivial diff'd Jones
1069 : virtual void initTrivDJ();
1070 :
1071 : virtual void stateSVJ(const casacore::Bool& doVC);
1072 :
1073 : // atomic power normalization calculation
1074 : // SVJ version assumes amp in voltage units
1075 : virtual casacore::Float calcPowerNorm(casacore::Array<casacore::Float>& amp, const casacore::Array<casacore::Bool>& ok);
1076 :
1077 : private:
1078 :
1079 : // Default ctor is private
1080 : SolvableVisJones();
1081 :
1082 : // Jones wrappers for diffJElem_;
1083 : Jones *dJ1_;
1084 : Jones *dJ2_;
1085 :
1086 : // Differentiated Jones matrix elements
1087 : casacore::Array<casacore::Complex> diffJElem_; // (nJME,nPar,nChanMat,nAnt,2)
1088 :
1089 : // Validity of Jones matrix derivatives
1090 : casacore::Bool DJValid_;
1091 :
1092 : // Column widths for listing
1093 : casacore::uInt wTime_p, wField_p, wChan_p, wAmp_p,
1094 : wPhase_p, wFlag_p, wPol_p, wAntCol_p,
1095 : wTotal_p, wPreAnt_p;
1096 :
1097 : };
1098 :
1099 : // Global methods
1100 :
1101 : // Discern cal table type from the table itself
1102 : casacore::String calTableType(const casacore::String& tablename);
1103 :
1104 : } //# NAMESPACE CASA - END
1105 :
1106 : #endif
|