[3756] | 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
|
---|
[3783] | 16 | #include "qhist.h"
|
---|
[3756] | 17 |
|
---|
[3783] | 18 | #ifndef DeuxPI
|
---|
[3756] | 19 | #define DeuxPI 2.*M_PI
|
---|
[3783] | 20 | #endif
|
---|
[3756] | 21 |
|
---|
| 22 | // -- Four2DResponse : Reponse instrumentale ds le plan k_x,k_y (angles 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 | class Four2DResponse {
|
---|
| 27 | public:
|
---|
| 28 | // On donne dx=D/lambda=Dx/lambda , dy=Dy/lambda
|
---|
[3789] | 29 | Four2DResponse(int typ, double dx, double dy, double lambda=1.);
|
---|
[3756] | 30 |
|
---|
| 31 | Four2DResponse(Four2DResponse const& a)
|
---|
[3789] | 32 | { typ_ = a.typ_; dx_=a.dx_; dy_=a.dy_; lambdaref_=a.lambdaref_;
|
---|
| 33 | lambda_=a.lambda_; lambda_ratio_=a.lambda_ratio_; }
|
---|
[3756] | 34 | Four2DResponse& operator=(Four2DResponse const& a)
|
---|
[3789] | 35 | { typ_ = a.typ_; dx_=a.dx_; dy_=a.dy_; lambdaref_=a.lambdaref_;
|
---|
| 36 | lambda_=a.lambda_; lambda_ratio_=a.lambda_ratio_; return (*this); }
|
---|
[3756] | 37 |
|
---|
[3787] | 38 | inline void setLambdaRef(double lambda=1.)
|
---|
| 39 | { lambdaref_ = lambda; }
|
---|
| 40 | inline void setLambda(double lambda=1.)
|
---|
[3789] | 41 | { lambda_ = lambda; lambda_ratio_ = lambda_/lambdaref_; }
|
---|
[3787] | 42 |
|
---|
[3756] | 43 | // Return the 2D response for wave vector (kx,ky)
|
---|
| 44 | virtual double Value(double kx, double ky);
|
---|
| 45 | inline double operator()(double kx, double ky)
|
---|
| 46 | { return Value(kx, ky); }
|
---|
| 47 | virtual Histo2D GetResponse(int nx=256, int ny=256);
|
---|
| 48 | inline double D() { return dx_; } ;
|
---|
| 49 | inline double Dx() { return dx_; } ;
|
---|
| 50 | inline double Dy() { return dy_; } ;
|
---|
| 51 |
|
---|
| 52 | int typ_;
|
---|
| 53 | double dx_, dy_;
|
---|
[3787] | 54 | double lambdaref_, lambda_;
|
---|
| 55 | double lambda_ratio_; // lambdaref_/lambda_;
|
---|
| 56 |
|
---|
[3756] | 57 | };
|
---|
| 58 |
|
---|
[3788] | 59 |
|
---|
[3756] | 60 | // -- Four2DRespTable : Reponse tabulee instrumentale ds le plan k_x,k_y (angles theta,phi)
|
---|
| 61 | class Four2DRespTable : public Four2DResponse {
|
---|
| 62 | public:
|
---|
| 63 | // On donne dx=D/lambda=Dx/lambda , dy=Dy/lambda
|
---|
| 64 | Four2DRespTable(Histo2D const & hrep, double d);
|
---|
| 65 | // Return the 2D response for wave vector (kx,ky)
|
---|
| 66 | virtual double Value(double kx, double ky);
|
---|
| 67 | Histo2D hrep_;
|
---|
| 68 | };
|
---|
| 69 |
|
---|
[3788] | 70 |
|
---|
| 71 | // -- Four2DRespRatio: Retourne le rapport de la reponse entre deux objets Four2DResponse
|
---|
| 72 | class Four2DRespRatio : public Four2DResponse {
|
---|
| 73 | public:
|
---|
[3789] | 74 | Four2DRespRatio(Four2DResponse& a, Four2DResponse& b, double divzthr=1.e-1);
|
---|
[3788] | 75 | // Return the ratio a.Value(kx,ky) / b.Value(kx, ky) - with protection against divide by zero
|
---|
| 76 | virtual double Value(double kx, double ky);
|
---|
| 77 | Four2DResponse& a_;
|
---|
| 78 | Four2DResponse& b_;
|
---|
[3789] | 79 | double divzthr_;
|
---|
[3788] | 80 | };
|
---|
| 81 |
|
---|
[3756] | 82 | // Classe toute simple pour representer un element de reception de type dish
|
---|
| 83 | class Dish {
|
---|
| 84 | public:
|
---|
| 85 | // Circular dish
|
---|
| 86 | Dish(int id, double x, double y, double diam)
|
---|
[3769] | 87 | : id_(id), X(x), Y(y), D(diam), Dx(D), Dy(D), fgcirc_(true) { }
|
---|
[3756] | 88 | // Receiver with rectangular type answer in kx,ky plane
|
---|
| 89 | Dish(int id, double x, double y, double dx, double dy)
|
---|
[3769] | 90 | : id_(id), X(x), Y(y), D(sqrt(dx*dy)), Dx(dx), Dy(dy), fgcirc_(false) { }
|
---|
[3756] | 91 | Dish(Dish const& a)
|
---|
| 92 | : id_(a.id_), X(a.X), Y(a.Y), D(a.D), Dx(a.Dx), Dy(a.Dy), fgcirc_(a.fgcirc_) { }
|
---|
| 93 | inline bool isCircular() { return fgcirc_; }
|
---|
| 94 | inline int ReflectorId() { return id_; }
|
---|
[3769] | 95 | inline double Diameter() { return D; }
|
---|
| 96 | inline double DiameterX() { return Dx; }
|
---|
| 97 | inline double DiameterY() { return Dx; }
|
---|
[3756] | 98 |
|
---|
| 99 | int id_; // numero de reflecteur
|
---|
| 100 | double D,X,Y;
|
---|
| 101 | double Dx, Dy;
|
---|
| 102 | bool fgcirc_; // false -> rectangular dish
|
---|
| 103 | };
|
---|
| 104 |
|
---|
| 105 |
|
---|
| 106 | // -------------------------------------------------------------------
|
---|
| 107 | // -- Pour calculer la reponse ds le plan kx,ky d'un system MultiDish
|
---|
| 108 | class MultiDish {
|
---|
| 109 | public:
|
---|
| 110 | MultiDish(double lambda, double dmax, vector<Dish>& dishes, bool fgnoauto=false);
|
---|
| 111 |
|
---|
| 112 | inline void SetThetaPhiRange(double thetamax=0., int ntet=1, double phimax=0., int nphi=1)
|
---|
| 113 | { thetamax_=thetamax; ntet_=ntet; phimax_=phimax; nphi_=nphi; }
|
---|
| 114 |
|
---|
| 115 | inline void SetRespHisNBins(int nx=128, int ny=128)
|
---|
| 116 | { nx_=nx; ny_=ny; }
|
---|
| 117 | Histo2D GetResponse();
|
---|
| 118 |
|
---|
| 119 | double CumulResp(Four2DResponse& rd, double theta=0., double phi=0.);
|
---|
| 120 | inline size_t NbDishes() { return dishes_.size(); }
|
---|
[3769] | 121 | inline Dish& operator[](size_t k) { return dishes_[k]; }
|
---|
[3756] | 122 |
|
---|
[3769] | 123 | virtual Histo2D PosDist(int nx=30, int ny=30, double dmax=0.);
|
---|
| 124 |
|
---|
| 125 | protected:
|
---|
[3756] | 126 | double AddToHisto(double kx0, double ky0, double x, double y, double w, bool fgfh);
|
---|
| 127 |
|
---|
| 128 | double lambda_, dmax_;
|
---|
| 129 | vector<Dish> dishes_;
|
---|
| 130 | bool fgnoauto_;
|
---|
| 131 | double thetamax_, phimax_;
|
---|
| 132 | int ntet_,nphi_;
|
---|
| 133 | int nx_, ny_;
|
---|
| 134 | // Histo2D h2w_, h2cnt_;
|
---|
| 135 | QHis2D h2w_;
|
---|
| 136 | int mcnt_;
|
---|
| 137 | };
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | #endif
|
---|