[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:
|
---|
[3792] | 63 | // Constructeur sans argument, utilise pour lire depuis un fichier
|
---|
| 64 | Four2DRespTable();
|
---|
[3756] | 65 | // On donne dx=D/lambda=Dx/lambda , dy=Dy/lambda
|
---|
[3792] | 66 | Four2DRespTable(Histo2D const & hrep, double d, double lambda=1.);
|
---|
[3756] | 67 | // Return the 2D response for wave vector (kx,ky)
|
---|
| 68 | virtual double Value(double kx, double ky);
|
---|
[3792] | 69 |
|
---|
| 70 | void writeToPPF(string flnm);
|
---|
| 71 | void readFromPPF(string flnm);
|
---|
| 72 |
|
---|
[3756] | 73 | Histo2D hrep_;
|
---|
| 74 | };
|
---|
| 75 |
|
---|
[3788] | 76 |
|
---|
| 77 | // -- Four2DRespRatio: Retourne le rapport de la reponse entre deux objets Four2DResponse
|
---|
| 78 | class Four2DRespRatio : public Four2DResponse {
|
---|
| 79 | public:
|
---|
[3789] | 80 | Four2DRespRatio(Four2DResponse& a, Four2DResponse& b, double divzthr=1.e-1);
|
---|
[3788] | 81 | // Return the ratio a.Value(kx,ky) / b.Value(kx, ky) - with protection against divide by zero
|
---|
| 82 | virtual double Value(double kx, double ky);
|
---|
| 83 | Four2DResponse& a_;
|
---|
| 84 | Four2DResponse& b_;
|
---|
[3789] | 85 | double divzthr_;
|
---|
[3788] | 86 | };
|
---|
| 87 |
|
---|
[3756] | 88 | // Classe toute simple pour representer un element de reception de type dish
|
---|
| 89 | class Dish {
|
---|
| 90 | public:
|
---|
| 91 | // Circular dish
|
---|
| 92 | Dish(int id, double x, double y, double diam)
|
---|
[3769] | 93 | : id_(id), X(x), Y(y), D(diam), Dx(D), Dy(D), fgcirc_(true) { }
|
---|
[3756] | 94 | // Receiver with rectangular type answer in kx,ky plane
|
---|
| 95 | Dish(int id, double x, double y, double dx, double dy)
|
---|
[3769] | 96 | : id_(id), X(x), Y(y), D(sqrt(dx*dy)), Dx(dx), Dy(dy), fgcirc_(false) { }
|
---|
[3756] | 97 | Dish(Dish const& a)
|
---|
| 98 | : id_(a.id_), X(a.X), Y(a.Y), D(a.D), Dx(a.Dx), Dy(a.Dy), fgcirc_(a.fgcirc_) { }
|
---|
| 99 | inline bool isCircular() { return fgcirc_; }
|
---|
| 100 | inline int ReflectorId() { return id_; }
|
---|
[3769] | 101 | inline double Diameter() { return D; }
|
---|
| 102 | inline double DiameterX() { return Dx; }
|
---|
| 103 | inline double DiameterY() { return Dx; }
|
---|
[3756] | 104 |
|
---|
| 105 | int id_; // numero de reflecteur
|
---|
| 106 | double D,X,Y;
|
---|
| 107 | double Dx, Dy;
|
---|
| 108 | bool fgcirc_; // false -> rectangular dish
|
---|
| 109 | };
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 | // -------------------------------------------------------------------
|
---|
| 113 | // -- Pour calculer la reponse ds le plan kx,ky d'un system MultiDish
|
---|
| 114 | class MultiDish {
|
---|
| 115 | public:
|
---|
| 116 | MultiDish(double lambda, double dmax, vector<Dish>& dishes, bool fgnoauto=false);
|
---|
| 117 |
|
---|
| 118 | inline void SetThetaPhiRange(double thetamax=0., int ntet=1, double phimax=0., int nphi=1)
|
---|
| 119 | { thetamax_=thetamax; ntet_=ntet; phimax_=phimax; nphi_=nphi; }
|
---|
| 120 |
|
---|
| 121 | inline void SetRespHisNBins(int nx=128, int ny=128)
|
---|
| 122 | { nx_=nx; ny_=ny; }
|
---|
| 123 | Histo2D GetResponse();
|
---|
| 124 |
|
---|
| 125 | double CumulResp(Four2DResponse& rd, double theta=0., double phi=0.);
|
---|
| 126 | inline size_t NbDishes() { return dishes_.size(); }
|
---|
[3769] | 127 | inline Dish& operator[](size_t k) { return dishes_[k]; }
|
---|
[3756] | 128 |
|
---|
[3769] | 129 | virtual Histo2D PosDist(int nx=30, int ny=30, double dmax=0.);
|
---|
| 130 |
|
---|
| 131 | protected:
|
---|
[3756] | 132 | double AddToHisto(double kx0, double ky0, double x, double y, double w, bool fgfh);
|
---|
| 133 |
|
---|
| 134 | double lambda_, dmax_;
|
---|
| 135 | vector<Dish> dishes_;
|
---|
| 136 | bool fgnoauto_;
|
---|
| 137 | double thetamax_, phimax_;
|
---|
| 138 | int ntet_,nphi_;
|
---|
| 139 | int nx_, ny_;
|
---|
| 140 | // Histo2D h2w_, h2cnt_;
|
---|
| 141 | QHis2D h2w_;
|
---|
| 142 | int mcnt_;
|
---|
| 143 | };
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | #endif
|
---|