casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FringeJones.h
Go to the documentation of this file.
1 //# FringeJones.h: Declaration of fringe-fitting VisCal
2 //# Copyright (C) 1996,1997,2000,2001,2002,2003,2011,2016
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_FRINGEJONES_H
29 #define SYNTHESIS_FRINGEJONES_H
30 
31 #include <casa/aips.h>
35 
36 namespace casa { //# NAMESPACE CASA - BEGIN
37 
38 // Rate-aware time interpolation engine
40 
41 public:
42 
43  // From NewCalTable
45  const casacore::String& timetype,
48 
49  // Destructor
50  virtual ~CTRateAwareTimeInterp1();
51 
52  // Interpolate, given timestamp; returns T if new result
54 
55  // static factory method to make CTRateAwareTimeInterp1
56  // NB: returns pointer to a _generic_ CTTimeInterp1
58  const casacore::String& timetype,
61  return new casa::CTRateAwareTimeInterp1(ct,timetype,result,rflag); }
62 
63 private:
64 
65  // Refine time-dep phase with rate info
66  void applyPhaseRate(casacore::Bool single);
67 
68  // Default ctor is unusable
69  // CTRateAwareTimeInterp1();
70 
71 };
72 
73 // A utility class that provides an API that allows clients to find
74 // grid indices in time and frequency from a SBDList that can include
75 // multiple spectral windows.
77 public:
81 private:
83  std::set< casacore::Int > spwins;
84  std::set< casacore::Double > times;
85  // You can't store references in a map.
86  // C++ 11 has a reference_wrapper type, but for now:
87  std::map< casacore::Int, casacore::Vector<casacore::Double> const * > spwIdToFreqMap;
88 public:
90  casacore::Int nSPW() { return spwins.size(); }
95  void checkAllGridpoints();
96 };
97 
98 
99 // DelayRateFFT is responsible for the two-dimensional FFT of
100 // visibility phases to find an estimate for deay. rate and phase
101 // offset parameters during fringe-fitting.
103  // The idiom used in KJones solvers is:
104  // DelayFFT delfft1(vbga(ibuf), ptbw, refant());
105  // delfft1.FFT();
106  // delfft1.shift(f0[0]);
107  // delfft1.searchPeak();
108  // This class is designed to follow that API (without the shift).
109 private:
111  // SBDListGridManager handles all the sizing and interpolating of
112  // multiple spectral windows onto a single frequency grid.
118  //casacore::Int nSPWChan_;
122  //casacore::Double t0_, t1_;
123  //casacore::Double padBW_;
129  //
132  std::map< casacore::Int, std::set<casacore::Int> > activeAntennas_;
133  std::set<casacore::Int> allActiveAntennas_;
136 
137 public:
141  );
146  );
147  // The following are copied from KJones.h definition of DelayFFT.
148  const std::map<casacore::Int, std::set<casacore::Int> >& getActiveAntennas() const
149  { return activeAntennas_; }
150  const std::set<casacore::Int>& getActiveAntennasCorrelation(casacore::Int icor) const
151  { return activeAntennas_.find(icor)->second; }
152  void removeAntennasCorrelation(casacore::Int, std::set< casacore::Int >);
153  const casacore::Array<casacore::Complex>& Vpad() const { return Vpad_; }
154  const casacore::Matrix<casacore::Bool>& flag() const { return flag_; }
155  const casacore::Matrix<casacore::Float>& param() const { return param_; }
158  casacore::Int refant() const { return refant_; }
160 
161  void FFT();
162  std::pair<casacore::Bool, casacore::Float> xinterp(casacore::Float alo, casacore::Float amax, casacore::Float ahi);
163  void searchPeak();
165 
166  void printActive();
167 }; // End of class DelayRateFFT.
168 
169 
170 
171 // Fringe-fitting (parametrized phase) VisCal
172 class FringeJones : public GJones {
173 public:
174  // Constructor
175  // TBD: MSMetaInfoForCal-aware version; deprecate older ones
176  FringeJones(VisSet& vs);
180 
181  virtual ~FringeJones();
182 
183  // We have casacore::Float parameters
185 
186  // Return the type enum
187  virtual Type type() { return VisCal::K; };
188 
189  // Return type name as string
190  virtual casacore::String typeName() { return "Fringe Jones"; };
191  virtual casacore::String longTypeName() { return "Fringe Jones (parametrized phase)"; };
192 
193  // Type of Jones matrix according to nPar()
195 
196  virtual bool timeDepMat() { return true; };
197 
198  // Freq dependence (delays)
199  virtual casacore::Bool freqDepPar() { return false; };
200  // If the following is false frequency spectrum is squashed to one point.
201  virtual casacore::Bool freqDepMat() { return true; };
202 
203  // Local setApply to enforce calWt=F for delays
204  virtual void setApply(const casacore::Record& apply);
205  virtual void setApply();
206  using GJones::setApply;
207  virtual void setCallib(const casacore::Record& callib,
208  const casacore::MeasurementSet& selms);
209 
210  // Local setSolve (traps lack of refant)
211  virtual void setSolve(const casacore::Record& solve);
212  using GJones::setSolve;
213 
214  // Default parameter value
215  virtual casacore::Complex defaultPar() { return casacore::Complex(0.0); };
216 
217  // FIXME: was omitted
218  virtual void specify(const casacore::Record& specify);
219 
220  // This type is not yet accumulatable
221  virtual casacore::Bool accumulatable() { return false; };
222 
223  // This type is smoothable
224  virtual casacore::Bool smoothable() { return true; };
225 
226  // Delay to phase calculator
227  virtual void calcAllJones();
228 
229  // Hazard a guess at parameters (unneeded here)
230  // TBD? Needed?
231  virtual void guessPar(VisBuffer& ) {};
232 
233  // FringeJones uses generic gather, but solves for itself per solution
234  virtual casacore::Bool useGenericGatherForSolve() { return true; };
235  virtual casacore::Bool useGenericSolveOne() { return false; }
236 
237  // Post solve tinkering
238  virtual void globalPostSolveTinker();
239 
240  // Local implementation of selfSolveOne (generalized signature)
241  // virtual void selfSolveOne(VisBuffGroupAcc& vbga);
242  virtual void selfSolveOne(SDBList&);
243 
244  virtual void solveOneVB(const VisBuffer&);
245 
246  // SolveDataBuffer is being phased out; we no longer support it.
247  // virtual void solveOneSDB(const SolveDataBuffer&);
248 
249  virtual casacore::Bool& zeroRates() { return zeroRates_; }
250  virtual casacore::Bool& globalSolve() { return globalSolve_; }
251  virtual casacore::Int& maxits() { return maxits_; }
254 
255  // Apply reference antenna
256  virtual void applyRefAnt();
257 
258  virtual casacore::Int& refant() { return refant_; }
259 
260 protected:
261 
262  // phase, delay, rate
263  // TBD: Need to cater for parameter opt-out (e.g., no rate solve, etc.)
264  virtual casacore::Int nPar() { return 8; };
265 
266  // Jones matrix elements are NOT trivial
267  virtual casacore::Bool trivialJonesElem() { return false; };
268 
269  // dJ/dp are trivial
270  // TBD: make this default in SVC?
271  virtual casacore::Bool trivialDJ() { return false; };
272 
273  // Initialize trivial dJs
274  // TBD: make this default in SVC?
275  virtual void initTrivDJ() {};
276 
277  // Reference frequencies
279 
280 
281 
282 private:
283 
284  // Pointer to CTRateAwareTimeInterp1 factory method
285  // This ensures the rates are incorporated into the time-dep interpolation
288 
289  casacore::Int refant_; // Override
295 };
296 
297 
298 } //# NAMESPACE CASA - END
299 
300 #endif
virtual void setApply()
Set the application parameters.
virtual void selfSolveOne(SDBList &)
Local implementation of selfSolveOne (generalized signature) virtual void selfSolveOne(VisBuffGroupAc...
casacore::Int refant_
Definition: FringeJones.h:289
virtual casacore::Bool freqDepMat()
If the following is false frequency spectrum is squashed to one point.
Definition: FringeJones.h:201
int Int
Definition: aipstype.h:50
casacore::Array< casacore::Complex > Vpad_
casacore::Double t0_, t1_; casacore::Double padBW_;
Definition: FringeJones.h:124
virtual ~CTRateAwareTimeInterp1()
Destructor.
casacore::Int swStartIndex(casacore::Int spw)
casacore::Matrix< casacore::Float > delay() const
std::set< casacore::Int > allActiveAntennas_
Definition: FringeJones.h:133
CTTimeInterp1 *(* CTTIFactoryPtr)(NewCalTable &, const casacore::String &, casacore::Array< casacore::Float > &, casacore::Array< casacore::Bool > &)
Pointer to static factory methods for CTTimeInterp1.
virtual void applyRefAnt()
Apply reference antenna.
virtual casacore::Bool useGenericSolveOne()
Use generic solution engine for a single solve (usually inside the generic gathering mechanism) ...
Definition: FringeJones.h:235
casacore::Int nPadChan_
casacore::Int nSPWChan_;
Definition: FringeJones.h:119
casacore::Int refant_
The idiom used in KJones solvers is: DelayFFT delfft1(vbga(ibuf), ptbw, refant()); delfft1...
Definition: FringeJones.h:110
const casacore::Matrix< casacore::Float > & param() const
Definition: FringeJones.h:155
A utility class that provides an API that allows clients to find grid indices in time and frequency f...
Definition: FringeJones.h:76
casacore::Double df
Definition: FringeJones.h:78
casacore::Array< casacore::Double > delayWindow_
Definition: FringeJones.h:292
casacore::Int nSPW()
Definition: FringeJones.h:90
casacore::Array< casacore::Double > & delayWindow_
Definition: FringeJones.h:134
virtual casacore::Complex defaultPar()
Default parameter value.
Definition: FringeJones.h:215
void apply(const Jones &j1, VisVector &v, const Jones &j2)
Apply a pair of Jones to a VisVector:
const std::map< casacore::Int, std::set< casacore::Int > > & getActiveAntennas() const
The following are copied from KJones.h definition of DelayFFT.
Definition: FringeJones.h:148
virtual void solveOneVB(const VisBuffer &)
const std::set< casacore::Int > & getActiveAntennasCorrelation(casacore::Int icor) const
Definition: FringeJones.h:150
const casacore::Array< casacore::Complex > & Vpad() const
Definition: FringeJones.h:153
virtual casacore::Bool useGenericGatherForSolve()
FringeJones uses generic gather, but solves for itself per solution.
Definition: FringeJones.h:234
virtual casacore::Int & refant()
Definition: FringeJones.h:258
virtual casacore::Bool trivialJonesElem()
Jones matrix elements are NOT trivial.
Definition: FringeJones.h:267
Rate-aware time interpolation engine.
Definition: FringeJones.h:39
casacore::Int refant() const
Definition: FringeJones.h:158
virtual casacore::Int nPar()
phase, delay, rate TBD: Need to cater for parameter opt-out (e.g., no rate solve, etc...
Definition: FringeJones.h:264
ABSTRACT TOOL CLASSES A PlotTool is a higher level event handler for a PlotCanvas The idea is to take common tasks which may require multiple events and put them in one place PlotTools also provide additional functionality in that they can be active and blocking non blocking The PlotCanvas will only send events to active and will not send events to later tools or event handlers if the latest tool was blocking In this way a single tool can be used to handle ALL user interaction via the GUI at one time
Definition: PlotTool.h:43
std::map< casacore::Int, casacore::Vector< casacore::Double > const * > spwIdToFreqMap
You can&#39;t store references in a map.
Definition: FringeJones.h:87
std::map< casacore::Int, std::set< casacore::Int > > activeAntennas_
Definition: FringeJones.h:132
virtual void globalPostSolveTinker()
Post solve tinkering.
virtual void setApply()
Set the application parameters.
casacore::Int nPadT_
Definition: FringeJones.h:116
casacore::Int & nAnt()
Definition: VisCal.h:237
SDBListGridManager(SDBList &sdbs_)
casacore::Array< casacore::Int > xcount_
Definition: FringeJones.h:125
virtual casacore::Bool freqDepPar()
Freq dependence (delays)
Definition: FringeJones.h:199
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
virtual void setCallib(const casacore::Record &callib, const casacore::MeasurementSet &selms)
virtual casacore::Bool interpolate(casacore::Double time)
Interpolate, given timestamp; returns T if new result.
virtual casacore::Array< casacore::Double > & rateWindow()
Definition: FringeJones.h:253
virtual Jones::JonesType jonesType()
Type of Jones matrix according to nPar()
Definition: FringeJones.h:194
virtual void initTrivDJ()
Initialize trivial dJs TBD: make this default in SVC?
Definition: FringeJones.h:275
casacore::Int nPadFactor_
Definition: FringeJones.h:114
virtual Type type()
Return the type enum.
Definition: FringeJones.h:187
casacore::Array< casacore::Float > sumw_
Definition: FringeJones.h:126
casacore::Double fmin
Definition: FringeJones.h:78
casacore::Double df_all_
Definition: FringeJones.h:121
casacore::Int nt_
Definition: FringeJones.h:115
casacore::Double tmin
Definition: FringeJones.h:79
virtual CTTIFactoryPtr cttifactoryptr()
Pointer to CTRateAwareTimeInterp1 factory method This ensures the rates are incorporated into the tim...
Definition: FringeJones.h:286
casacore::Double get_df_all()
Definition: FringeJones.h:159
virtual void specify(const casacore::Record &specify)
FIXME: was omitted.
Fringe-fitting (parametrized phase) VisCal.
Definition: FringeJones.h:172
virtual void calcAllJones()
Delay to phase calculator.
casacore::Double f0_
Definition: FringeJones.h:121
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
casacore::Int nSPWChan
Definition: FringeJones.h:80
casacore::Matrix< casacore::Bool > flag_
Definition: FringeJones.h:131
casacore::Vector< casacore::Double > KrefFreqs_
Reference frequencies.
Definition: FringeJones.h:275
double Double
Definition: aipstype.h:55
virtual void guessPar(VisBuffer &)
Hazard a guess at parameters (unneeded here) TBD? Needed?
Definition: FringeJones.h:231
casacore::Double dt
Definition: FringeJones.h:79
virtual casacore::Bool & zeroRates()
SolveDataBuffer is being phased out; we no longer support it.
Definition: FringeJones.h:249
casacore::Double df_
Definition: FringeJones.h:121
casacore::Bool zeroRates_
Definition: FringeJones.h:290
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 casacore::Bool trivialDJ()
dJ/dp are trivial TBD: make this default in SVC?
Definition: FringeJones.h:271
casacore::Int bigFreqGridIndex(casacore::Double f)
Definition: FringeJones.h:91
casacore::Array< casacore::Float > sumww_
Definition: FringeJones.h:127
float Float
Definition: aipstype.h:54
CTRateAwareTimeInterp1(NewCalTable &ct, const casacore::String &timetype, casacore::Array< casacore::Float > &result, casacore::Array< casacore::Bool > &rflag)
From NewCalTable.
const casacore::Matrix< casacore::Bool > & flag() const
Definition: FringeJones.h:154
void applyPhaseRate(casacore::Bool single)
Refine time-dep phase with rate info.
SDBListGridManager gm_
SBDListGridManager handles all the sizing and interpolating of multiple spectral windows onto a singl...
Definition: FringeJones.h:113
virtual casacore::Int & maxits()
Definition: FringeJones.h:251
A Table intended to hold astronomical data (a set of Measurements).
DelayRateFFT is responsible for the two-dimensional FFT of visibility phases to find an estimate for ...
Definition: FringeJones.h:102
casacore::Matrix< casacore::Float > rate() const
void removeAntennasCorrelation(casacore::Int, std::set< casacore::Int >)
std::set< casacore::Double > times
Definition: FringeJones.h:84
casacore::Int getTimeIndex(casacore::Double t)
Definition: FringeJones.h:92
casacore::Int totalChans
Definition: FringeJones.h:80
virtual ~FringeJones()
virtual casacore::Array< casacore::Double > & delayWindow()
Definition: FringeJones.h:252
const MSMetaInfoForCal & msmc() const
Access to the MSMetaInfoForCal (throws if none)
Definition: VisCal.h:338
virtual casacore::Bool smoothable()
This type is smoothable.
Definition: FringeJones.h:224
casacore::Array< casacore::Double > & rateWindow_
Definition: FringeJones.h:135
std::set< casacore::Int > spwins
Definition: FringeJones.h:83
virtual bool timeDepMat()
Matrices time-dependent per parameter set (nominally no)
Definition: FringeJones.h:196
casacore::Vector< T > solve(const casacore::Matrix< T > &A, const casacore::Vector< T > &y, double &ferr, double &berr)
Given a matrix &quot;A&quot;, and given some vector &quot;y&quot; which is the right hand side of the equation &quot;Ax=y&quot;...
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Int maxits_
Definition: FringeJones.h:294
DelayRateFFT(SDBList &sdbs, casacore::Int refant, casacore::Array< casacore::Double > &delayWindow_, casacore::Array< casacore::Double > &rateWindow_)
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
std::pair< casacore::Bool, casacore::Float > xinterp(casacore::Float alo, casacore::Float amax, casacore::Float ahi)
casacore::Int nElem_
Definition: FringeJones.h:120
casacore::Array< casacore::Double > rateWindow_
Definition: FringeJones.h:293
casacore::Double fmax
Definition: FringeJones.h:78
virtual casacore::String longTypeName()
Definition: FringeJones.h:191
casacore::Matrix< casacore::Float > param_
Definition: FringeJones.h:130
static CTTimeInterp1 * factory(NewCalTable &ct, const casacore::String &timetype, casacore::Array< casacore::Float > &result, casacore::Array< casacore::Bool > &rflag)
static factory method to make CTRateAwareTimeInterp1 NB: returns pointer to a generic CTTimeInterp1 ...
Definition: FringeJones.h:57
long round(double d)
casacore::Bool globalSolve_
Definition: FringeJones.h:291
casacore::Float snr(casacore::Int icorr, casacore::Int ielem, casacore::Float delay, casacore::Float rate)
casacore::Int nChan_
Definition: FringeJones.h:117
virtual void setSolve()
Set the solving parameters.
void calculateSNR(casacore::Int, DelayRateFFT)
FringeJones(VisSet &vs)
Constructor TBD: MSMetaInfoForCal-aware version; deprecate older ones.
casacore::Double dt_
Definition: FringeJones.h:121
casacore::Int nChannels()
Definition: FringeJones.h:93
virtual VisCalEnum::VCParType parType()
We have casacore::Float parameters.
Definition: FringeJones.h:184
casacore::Int nCorr_
Definition: FringeJones.h:128
virtual casacore::Bool & globalSolve()
Definition: FringeJones.h:250
virtual casacore::Bool accumulatable()
This type is not yet accumulatable.
Definition: FringeJones.h:221
virtual casacore::String typeName()
Return type name as string.
Definition: FringeJones.h:190
casacore::Double tmax
Definition: FringeJones.h:79