CARMA C++
Selfcal.h
Go to the documentation of this file.
1 
11 #ifndef CARMA_SERVICES_SELFCAL_H
12 #define CARMA_SERVICES_SELFCAL_H
13 
14 #include <complex>
15 #include <vector>
16 
17 
18 namespace carma {
19  namespace services {
20 
28  typedef std::complex<double> Complex;
29 
30 
40  class Selfcal {
41 
42  public:
43 
47  Selfcal();
48 
49 
50  virtual ~Selfcal();
51 
55  void zero(void);
56 
61  void setSourceName(std::string& sourceName);
62 
69  void setReferenceAntenna(int refAnt = 0);
70 
75  void setMaxIter(int maxIter = 100);
76 
86  void setMaxAnt(int maxAnt = 0);
87 
95  void setEps(double epsi1 = 1.0e-8, double epsi2 = 1.0e-4);
96 
102  void setDebug(int debug = 0);
103 
109  void setPointSourceModel(double flux);
110 
116  void setPlanetDiskModel(double flux, double bmaj=0, double bmin=0, double bpa=0);
117 
127  void setVis(int ant1, int ant2, const Complex& vis, double weight=1);
128 
142  std::vector<Complex> getVis(bool useAmp = true);
143 
152  std::vector<Complex> getVisErrors(void);
153 
159  double getRMSPhase(void) const {
160  return RMSPhase_;
161  }
162 
168  double getRMSAmp(void) const {
169  return RMSAmp_;
170  }
171 
177  double getIter(void) const {
178  return Niter_;
179  }
180 
187  double getRefAnt(void) const {
188  return refAnt_;
189  }
190 
198  double getMaxAnt(void) const {
199  return maxAnt_;
200  }
201 
202  private:
203 
204  /*
205  * Vis: a convenient container to keep all the baseline based visibilities
206  * together
207  */
208 
209  typedef struct {
210  Complex v; // data
211  Complex m; // model
212  double w; // weight, typically contains 1/sigma^2, systemp, inttime
213  int a1; // a number 0...Nants-1 !!!
214  int a2; // a number 0...Nants-1 (but not equal to ant1)
215  Complex sumvm; // derived quantities, used internally
216  Complex sumvmc; // derived quantities, used internally
217  double sumvv; // derived quantities, used internally
218  } Vis;
219 
220  void visset(Vis &data, const Complex &v, const Complex &m, double w, int a1, int a2);
221  int guess_nants(int Nbaselines);
222  std::vector<Complex> phasol(const std::vector<Vis> &data);
223  std::vector<Complex> amphasol(const std::vector<Vis> &data);
224  void computeRMS(const std::vector<Complex> &gains);
225 
226  /*
227  * Control parameters for selfcal..
228  */
229 
230  double epsi1_;
231  double epsi2_;
232  int maxIter_;
233  std::string sourceName_;
234  int debug_;
235  double flux_;
236 
237  bool autoRef_; // automatically find reference antenna
238  int refAnt_; // reference antenna
239 
240  /*
241  * index for fast antenna lookup
242  *
243  */
244 
245  bool autoAnt_; // if true, automatically determine maxAnt_
246  int maxAnt_; // the maximum ant number (1..) used in the input
247  std::vector<int> antIndex_; // index array into 0s or filled antenna number (Nant)
248 
249 
250  /*
251  * the visibility Data
252  */
253  std::vector<Vis> data_;
254 
255  /*
256  * Computed, and cashed until needed via the getXXX() routines
257  */
258 
259  std::vector<Complex> Verrors_;
260  double RMSPhase_;
261  double RMSAmp_;
262  int Niter_;
263  bool solutionFailed_;
264 
265  }; // end class Selfcal
266 
267  } // end namespace services
268 } // end namespace carma
269 
270 
271 #endif
std::complex< double > Complex
convenient definition of a complex number.
Definition: Selfcal.h:28
std::vector< Complex > getVis(bool useAmp=true)
Return antenna based visibilities (gains really) The returned array will have a length that contains ...
Selfcal()
Constructor.
void setPointSourceModel(double flux)
set the flux of a point source model
double getRMSPhase(void) const
get phase RMS error of the current solution
Definition: Selfcal.h:159
double getRMSAmp(void) const
get amplitude RMS error of the current solution
Definition: Selfcal.h:168
std::vector< Complex > getVisErrors(void)
Return visibility errors for all inputs.
Computes an amplitude or phase selfcal solution on a set of visibilities.
Definition: Selfcal.h:40
double getMaxAnt(void) const
get the maximum numbers of antennae.
Definition: Selfcal.h:198
void setMaxAnt(int maxAnt=0)
set the maximum number of antennae.
void setReferenceAntenna(int refAnt=0)
set the reference antenna.
double getRefAnt(void) const
get the reference antenna.
Definition: Selfcal.h:187
void setPlanetDiskModel(double flux, double bmaj=0, double bmin=0, double bpa=0)
set the flux and size of a (uniform disk) planet.
void setVis(int ant1, int ant2, const Complex &vis, double weight=1)
accumulate visibilities.
void zero(void)
reset the accumulators for a new solution
void setMaxIter(int maxIter=100)
set the maximum number of iterations.
double getIter(void) const
get the number of iterations it took to get a solution
Definition: Selfcal.h:177
void setDebug(int debug=0)
set a debug level (0=nothing, 1=a bit, 2=more)
void setEps(double epsi1=1.0e-8, double epsi2=1.0e-4)
set the relative accuracy levels that need to be achieved in the jacobi iteration.
void setSourceName(std::string &sourceName)
set sourcename