1 | // Classes to compute Multi-Dish or CRT-like radio interferometer response
|
---|
2 | // R. Ansari - Avril-Mai 2010
|
---|
3 |
|
---|
4 | #ifndef MDISH_SEEN
|
---|
5 | #define MDISH_SEEN
|
---|
6 |
|
---|
7 | #include "machdefs.h" // SOPHYA .h
|
---|
8 | #include "sopnamsp.h" // SOPHYA .h
|
---|
9 | #include <math.h>
|
---|
10 | #include <iostream>
|
---|
11 | #include <vector>
|
---|
12 | #include <string>
|
---|
13 |
|
---|
14 | #include "genericfunc.h" // SOPHYA .h
|
---|
15 | #include "array.h" // SOPHYA .h
|
---|
16 | #include "qhist.h"
|
---|
17 |
|
---|
18 | #ifndef DeuxPI
|
---|
19 | #define DeuxPI 2.*M_PI
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | // -- Four2DResponse : Reponse instrumentale ds le plan k_x,k_y (frequences angulaires theta,phi)
|
---|
23 | // typ=1 : Reponse gaussienne parabole diametre D exp[ - 0.5 (lambda k_g / D )^2 ]
|
---|
24 | // typ=2 : Reponse parabole diametre D Triangle <= kmax= 2 pi D / lambda
|
---|
25 | // typ=3 : Reponse rectangle Dx x Dy Triangle (|kx|,|k_y|) <= (2 pi Dx / lambda, 2 pi Dx / lambda)
|
---|
26 | // typ=22 : Reponse parabole diametre D Triangle <= kmax= 2 pi D / lambda avec un trou au centre
|
---|
27 |
|
---|
28 | class Four2DResponse {
|
---|
29 | public:
|
---|
30 | // On donne dx=D/lambda=Dx/lambda , dy=Dy/lambda
|
---|
31 | Four2DResponse(int typ, double dx, double dy, double lambda=1.);
|
---|
32 |
|
---|
33 | Four2DResponse(Four2DResponse const& a)
|
---|
34 | { typ_ = a.typ_; dx_=a.dx_; dy_=a.dy_; lambdaref_=a.lambdaref_;
|
---|
35 | lambda_=a.lambda_; lambda_ratio_=a.lambda_ratio_; }
|
---|
36 | Four2DResponse& operator=(Four2DResponse const& a)
|
---|
37 | { typ_ = a.typ_; dx_=a.dx_; dy_=a.dy_; lambdaref_=a.lambdaref_;
|
---|
38 | lambda_=a.lambda_; lambda_ratio_=a.lambda_ratio_; return (*this); }
|
---|
39 |
|
---|
40 | inline void setLambdaRef(double lambda=1.)
|
---|
41 | { lambdaref_ = lambda; }
|
---|
42 | inline void setLambda(double lambda=1.)
|
---|
43 | { lambda_ = lambda; lambda_ratio_ = lambda_/lambdaref_; }
|
---|
44 |
|
---|
45 | // Return the 2D response for wave vector (kx,ky)
|
---|
46 | virtual double Value(double kx, double ky);
|
---|
47 | inline double operator()(double kx, double ky)
|
---|
48 | { return Value(kx, ky); }
|
---|
49 | virtual Histo2D GetResponse(int nx=256, int ny=256);
|
---|
50 | inline double D() { return dx_; } ;
|
---|
51 | inline double Dx() { return dx_; } ;
|
---|
52 | inline double Dy() { return dy_; } ;
|
---|
53 |
|
---|
54 | int typ_;
|
---|
55 | double dx_, dy_;
|
---|
56 | double lambdaref_, lambda_;
|
---|
57 | double lambda_ratio_; // lambdaref_/lambda_;
|
---|
58 |
|
---|
59 | };
|
---|
60 |
|
---|
61 |
|
---|
62 | // -- Four2DRespTable : Reponse tabulee instrumentale ds le plan k_x,k_y (angles theta,phi)
|
---|
63 | class Four2DRespTable : public Four2DResponse {
|
---|
64 | public:
|
---|
65 | // Constructeur sans argument, utilise pour lire depuis un fichier
|
---|
66 | Four2DRespTable();
|
---|
67 | // On donne dx=D/lambda=Dx/lambda , dy=Dy/lambda
|
---|
68 | Four2DRespTable(Histo2D const & hrep, double d, double lambda=1.);
|
---|
69 | // Apres renormalisaton Value(kx,ky) <= max
|
---|
70 | double renormalize(double max=1.);
|
---|
71 | // Return the 2D response for wave vector (kx,ky)
|
---|
72 | virtual double Value(double kx, double ky);
|
---|
73 |
|
---|
74 | void writeToPPF(string flnm);
|
---|
75 | void readFromPPF(string flnm);
|
---|
76 |
|
---|
77 | Histo2D hrep_;
|
---|
78 | };
|
---|
79 |
|
---|
80 |
|
---|
81 | // -- Four2DRespRatio: Retourne le rapport de la reponse entre deux objets Four2DResponse
|
---|
82 | class Four2DRespRatio : public Four2DResponse {
|
---|
83 | public:
|
---|
84 | Four2DRespRatio(Four2DResponse& a, Four2DResponse& b, double divzthr=5.e-2);
|
---|
85 | // Return the ratio a.Value(kx,ky) / b.Value(kx, ky) - with protection against divide by zero
|
---|
86 | virtual double Value(double kx, double ky);
|
---|
87 | Four2DResponse& a_;
|
---|
88 | Four2DResponse& b_;
|
---|
89 | double divzthr_;
|
---|
90 | };
|
---|
91 |
|
---|
92 | // Classe toute simple pour representer un element de reception de type dish
|
---|
93 | class Dish {
|
---|
94 | public:
|
---|
95 | // Circular dish
|
---|
96 | Dish(int id, double x, double y, double diam)
|
---|
97 | : id_(id), X(x), Y(y), D(diam), Dx(D), Dy(D), fgcirc_(true) { }
|
---|
98 | // Receiver with rectangular type answer in kx,ky plane
|
---|
99 | Dish(int id, double x, double y, double dx, double dy)
|
---|
100 | : id_(id), X(x), Y(y), D(sqrt(dx*dy)), Dx(dx), Dy(dy), fgcirc_(false) { }
|
---|
101 | Dish(Dish const& a)
|
---|
102 | : id_(a.id_), X(a.X), Y(a.Y), D(a.D), Dx(a.Dx), Dy(a.Dy), fgcirc_(a.fgcirc_) { }
|
---|
103 | inline bool isCircular() { return fgcirc_; }
|
---|
104 | inline int ReflectorId() { return id_; }
|
---|
105 | inline double Diameter() { return D; }
|
---|
106 | inline double DiameterX() { return Dx; }
|
---|
107 | inline double DiameterY() { return Dx; }
|
---|
108 |
|
---|
109 | int id_; // numero de reflecteur
|
---|
110 | double D,X,Y;
|
---|
111 | double Dx, Dy;
|
---|
112 | bool fgcirc_; // false -> rectangular dish
|
---|
113 | };
|
---|
114 |
|
---|
115 |
|
---|
116 | // -------------------------------------------------------------------
|
---|
117 | // -- Pour calculer la reponse ds le plan kx,ky d'un system MultiDish
|
---|
118 | class MultiDish {
|
---|
119 | public:
|
---|
120 | MultiDish(double lambda, double dmax, vector<Dish>& dishes, bool fgnoauto=false);
|
---|
121 |
|
---|
122 | inline void SetThetaPhiRange(double thetamax=0., int ntet=1, double phimax=0., int nphi=1)
|
---|
123 | { thetamax_=thetamax; ntet_=ntet; phimax_=phimax; nphi_=nphi; }
|
---|
124 |
|
---|
125 | inline void SetRespHisNBins(int nx=128, int ny=128)
|
---|
126 | { nx_=nx; ny_=ny; }
|
---|
127 | Histo2D GetResponse();
|
---|
128 |
|
---|
129 | double CumulResp(Four2DResponse& rd, double theta=0., double phi=0.);
|
---|
130 | inline size_t NbDishes() { return dishes_.size(); }
|
---|
131 | inline Dish& operator[](size_t k) { return dishes_[k]; }
|
---|
132 |
|
---|
133 | virtual Histo2D PosDist(int nx=30, int ny=30, double dmax=0.);
|
---|
134 |
|
---|
135 | protected:
|
---|
136 | double AddToHisto(double kx0, double ky0, double x, double y, double w, bool fgfh);
|
---|
137 |
|
---|
138 | double lambda_, dmax_;
|
---|
139 | vector<Dish> dishes_;
|
---|
140 | bool fgnoauto_;
|
---|
141 | double thetamax_, phimax_;
|
---|
142 | int ntet_,nphi_;
|
---|
143 | int nx_, ny_;
|
---|
144 | // Histo2D h2w_, h2cnt_;
|
---|
145 | QHis2D h2w_;
|
---|
146 | int mcnt_;
|
---|
147 | };
|
---|
148 |
|
---|
149 |
|
---|
150 | #endif
|
---|