[3930] | 1 | /* ------------------------ Projet BAORadio --------------------
|
---|
| 2 | Calcul de la reponse 2D (plan (u,v) d'un interferometre
|
---|
| 3 | R. Ansari , C. Magneville - Juin-Dec 2010
|
---|
| 4 |
|
---|
| 5 | Usage: repicon configId OutPPFName [z_Redshift=0.7] [RenormalizeMax]
|
---|
| 6 | --------------------------------------------------------------- */
|
---|
| 7 |
|
---|
[3792] | 8 | #include "machdefs.h"
|
---|
| 9 | #include "sopnamsp.h"
|
---|
| 10 | #include <iostream>
|
---|
| 11 | #include <string>
|
---|
| 12 | #include <math.h>
|
---|
| 13 |
|
---|
| 14 | #include <typeinfo>
|
---|
| 15 |
|
---|
| 16 | #include "mdish.h"
|
---|
| 17 | #include "specpk.h"
|
---|
| 18 | #include "interfconfigs.h"
|
---|
[3930] | 19 | #include "radutil.h"
|
---|
[3792] | 20 |
|
---|
[3930] | 21 | #include "ntuple.h"
|
---|
[3792] | 22 | #include "histinit.h"
|
---|
| 23 | // #include "fiosinit.h"
|
---|
| 24 | // #include "fitsioserver.h"
|
---|
| 25 |
|
---|
| 26 | #include "randr48.h"
|
---|
| 27 |
|
---|
| 28 | #include "timing.h"
|
---|
| 29 | #include "ctimer.h"
|
---|
| 30 |
|
---|
| 31 | typedef DR48RandGen RandomGenerator ;
|
---|
| 32 |
|
---|
[3930] | 33 | // pour sauver la reponse mdresp et la config des dishes dans un fichier PPF
|
---|
| 34 | void SaveDTVecDishesH2Resp(string& outfile, vector<Dish>& vdishes, Four2DRespTable& mdresp);
|
---|
| 35 |
|
---|
[3792] | 36 | // ---------------------------------------------------------------------
|
---|
[3930] | 37 | // main program for computing interferometer response un (u,v) plane
|
---|
[3792] | 38 | // R. Ansari - Avril-Juin 2010
|
---|
| 39 | // ---------------------------------------------------------------------
|
---|
| 40 |
|
---|
| 41 | // ------------------ MAIN PROGRAM ------------------------------
|
---|
| 42 | int main(int narg, const char* arg[])
|
---|
| 43 | {
|
---|
| 44 | if (((narg>1)&&(strcmp(arg[1],"-h")==0))||(narg<3)) {
|
---|
[3930] | 45 | cout << " Usage: repicon configId OutPPFName [z_redshift=0.7] [RenormalizeMax] \n"
|
---|
[3931] | 46 | << " configs: f4x4 , f8x8 , f20x20 Filled array of nxn dishes (D=5m) \n"
|
---|
[3930] | 47 | << " confA , confB, confC, confD : semi-filled array of dishes \n"
|
---|
[3931] | 48 | << " hex12,cross11 : ASKAP like double hexagonal (12xD=12m), cross config (11xD=12m) \n"
|
---|
[3792] | 49 | << " f3cyl, f8cyl , f3cylp, f8cylp : filled array of non perfect/perfect of n cylinders " << endl;
|
---|
| 50 | return 1;
|
---|
| 51 | }
|
---|
| 52 | cout << " ==== repicon.cc program , (u,v) plane response ==== " << endl;
|
---|
| 53 | // make sure SOPHYA modules are initialized
|
---|
| 54 | SophyaInit();
|
---|
| 55 | // FitsIOServerInit();
|
---|
| 56 | InitTim();
|
---|
| 57 | //--- decoding command line arguments
|
---|
| 58 | string config = "f8x8" ;
|
---|
| 59 | if (narg>1) config = arg[1];
|
---|
| 60 | string outfile = "repicon.ppf";
|
---|
| 61 | if (narg>2) outfile = arg[2];
|
---|
| 62 | if (outfile==".") outfile = "repicon.ppf";
|
---|
| 63 | double LAMBDA=0.357 ; // 21 cm at z=0.7
|
---|
[3796] | 64 | if (narg>3) LAMBDA = atof(arg[3]);
|
---|
| 65 | bool fgrenorm=false;
|
---|
| 66 | double rmax=1.;
|
---|
| 67 | if (narg>4) {
|
---|
| 68 | rmax=atof(arg[4]);
|
---|
| 69 | fgrenorm=true;
|
---|
| 70 | }
|
---|
[3792] | 71 | //-- end command line arguments
|
---|
| 72 |
|
---|
| 73 | int rc = 1;
|
---|
| 74 | try { // exception handling try bloc at top level
|
---|
| 75 |
|
---|
| 76 | double Ddish = 5.;
|
---|
| 77 | double Ddish2 = 7.5;
|
---|
| 78 | double Eta=0.95;
|
---|
| 79 | double cylW=12.; // Largeur des cylindres
|
---|
| 80 | double cylRL=0.5; // Longeur des elements de reception le long du cylindre
|
---|
| 81 | double etaW=0.95; // Efficacite de couverture en largeur
|
---|
| 82 | double etaRL=0.9; // Efficacite de couverture le long du cylindre
|
---|
[3930] | 83 |
|
---|
| 84 | double D = 100.; // Taille de la zone
|
---|
| 85 |
|
---|
[3792] | 86 | int cnt=0;
|
---|
| 87 |
|
---|
| 88 | vector<Dish> vdishes;
|
---|
| 89 | cout << " repicon[1] : creating dish vector/ MultiDish for configuration: " << config << endl;
|
---|
| 90 |
|
---|
| 91 | bool fgpoint=false;
|
---|
| 92 | if (config=="f4x4") {
|
---|
| 93 | vdishes=CreateFilledSqConfig(4,Ddish, Eta);
|
---|
| 94 | }
|
---|
| 95 | else if (config=="f8x8") {
|
---|
| 96 | vdishes=CreateFilledSqConfig(8,Ddish, Eta);
|
---|
| 97 | }
|
---|
| 98 | else if (config=="f20x20") {
|
---|
| 99 | vdishes=CreateFilledSqConfig(20,Ddish, Eta);
|
---|
| 100 | }
|
---|
| 101 | else if (config=="f3cyl") {
|
---|
| 102 | cylW=10.; cylRL=0.5;
|
---|
| 103 | vdishes=CreateFilledCylConfig(3, 128, cylW, cylRL, etaW, etaRL, true);
|
---|
| 104 | }
|
---|
| 105 | else if (config=="f3cylp") {
|
---|
| 106 | cylW=10.; cylRL=0.5;
|
---|
| 107 | vdishes=CreateFilledCylConfig(3, 128, cylW, cylRL, etaW, etaRL, false);
|
---|
| 108 | }
|
---|
| 109 | else if (config=="f8cyl") {
|
---|
| 110 | cylW=12.; cylRL=0.5;
|
---|
| 111 | vdishes=CreateFilledCylConfig(8, 192, cylW, cylRL, etaW, etaRL, true);
|
---|
| 112 | }
|
---|
| 113 | else if (config=="f8cylp") {
|
---|
| 114 | cylW=12.; cylRL=0.5;
|
---|
| 115 | vdishes=CreateFilledCylConfig(8, 192, cylW, cylRL, etaW, etaRL, false);
|
---|
| 116 | }
|
---|
| 117 | else if (config=="confA") {
|
---|
| 118 | fgpoint=true;
|
---|
| 119 | vdishes=CreateConfigA(Ddish, Eta);
|
---|
| 120 | }
|
---|
| 121 | else if (config=="confB") {
|
---|
| 122 | fgpoint=true;
|
---|
| 123 | vdishes=CreateConfigB(Ddish, Eta);
|
---|
| 124 | }
|
---|
| 125 | else if (config=="confC") {
|
---|
| 126 | fgpoint=true;
|
---|
| 127 | vdishes=CreateConfigC(Ddish, Eta);
|
---|
| 128 | }
|
---|
[3930] | 129 | else if (config=="confD") {
|
---|
| 130 | fgpoint=true;
|
---|
| 131 | vdishes=CreateConfigD(Ddish, Eta);
|
---|
| 132 | }
|
---|
[3931] | 133 | else if (config=="cross11") {
|
---|
| 134 | fgpoint=true;
|
---|
| 135 | Ddish = 12.;
|
---|
| 136 | double base=20.;
|
---|
| 137 | Eta=0.95;
|
---|
| 138 | D=250.;
|
---|
| 139 | vdishes=CreateCrossConfig(Ddish,base,Eta);
|
---|
| 140 | }
|
---|
[3930] | 141 | else if (config=="hex12") {
|
---|
| 142 | fgpoint=true;
|
---|
| 143 | Ddish = 12.;
|
---|
| 144 | Eta=0.95;
|
---|
| 145 | D=350.;
|
---|
[3931] | 146 | vdishes=CreateDoubleHexagonConfig(Ddish);
|
---|
[3930] | 147 | }
|
---|
[3931] | 148 |
|
---|
[3792] | 149 | else {
|
---|
| 150 | cout << " NON valid configuration option -> exit" << endl;
|
---|
| 151 | return 99;
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | double Dol = D/LAMBDA;
|
---|
| 155 | double LMAX = D;
|
---|
| 156 | bool fgnoauto = true;
|
---|
[3796] | 157 | int NRX=200;
|
---|
| 158 | int NRY=200;
|
---|
[3792] | 159 |
|
---|
| 160 | MultiDish mdish(LAMBDA, LMAX, vdishes, fgnoauto);
|
---|
| 161 | mdish.SetRespHisNBins(NRX,NRY);
|
---|
[3931] | 162 | if (fgpoint) // 23 degres : angle d'inclinaison de l'orbite terrestre
|
---|
| 163 | mdish.SetThetaPhiRange(Angle(23.,Angle::Degree).ToRadian(),10, M_PI/6., 15);
|
---|
[3792] | 164 | cout << " repicon[2] : calling mdish.GetResponse() ..."<< endl;
|
---|
| 165 |
|
---|
| 166 | Histo2D hrep = mdish.GetResponse();
|
---|
| 167 | PrtTim("Apres mdish.GetResponse()");
|
---|
| 168 |
|
---|
[3796] | 169 | Four2DRespTable mdresp(hrep, Dol, LAMBDA);
|
---|
| 170 | if (fgrenorm) {
|
---|
| 171 | cout << " repicon[2.b] call to mdresp.renormalize(" << rmax << ")";
|
---|
| 172 | double omax=mdresp.renormalize(rmax);
|
---|
| 173 | cout << " Old Max=" << omax << endl;
|
---|
| 174 | }
|
---|
[3792] | 175 | cout << " repicon[3] : saving Four2DRespTable for config " << config << " to PPF file " << outfile << endl;
|
---|
| 176 | mdresp.writeToPPF(outfile);
|
---|
| 177 |
|
---|
[3930] | 178 | string outfile2 = "hdt_"+outfile;
|
---|
| 179 | cout << " repicon[4] : saving H2D-response, multidish config to PPF file " << outfile2 << endl;
|
---|
| 180 | SaveDTVecDishesH2Resp(outfile2, vdishes, mdresp);
|
---|
| 181 |
|
---|
[3792] | 182 | rc = 0;
|
---|
| 183 | } // End of try bloc
|
---|
| 184 | catch (PThrowable & exc) { // catching SOPHYA exceptions
|
---|
| 185 | cerr << " repicon.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name()
|
---|
| 186 | << "\n...exc.Msg= " << exc.Msg() << endl;
|
---|
| 187 | rc = 99;
|
---|
| 188 | }
|
---|
| 189 | catch (std::exception & e) { // catching standard C++ exceptions
|
---|
| 190 | cerr << " repicon.cc: Catched std::exception " << " - what()= " << e.what() << endl;
|
---|
| 191 | rc = 98;
|
---|
| 192 | }
|
---|
| 193 | catch (...) { // catching other exceptions
|
---|
| 194 | cerr << " repicon.cc: some other exception (...) was caught ! " << endl;
|
---|
| 195 | rc = 97;
|
---|
| 196 | }
|
---|
| 197 | PrtTim("End-repicon");
|
---|
| 198 | cout << " ==== End of repicon.cc program Rc= " << rc << endl;
|
---|
| 199 | return rc;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
[3930] | 202 | /*-- Nouvelle-Fonction --*/
|
---|
| 203 | void SaveDTVecDishesH2Resp(string& outfile, vector<Dish>& vdishes, Four2DRespTable& mdresp)
|
---|
| 204 | {
|
---|
| 205 | char* names[5]={"did","posx","posy","diam","diamy"};
|
---|
| 206 | NTuple ntvd(5,names,64,false);
|
---|
| 207 | r_4 xnt[10];
|
---|
| 208 | for(size_t i=0; i<vdishes.size(); i++) {
|
---|
| 209 | xnt[0]=vdishes[i].ReflectorId();
|
---|
| 210 | xnt[1]=vdishes[i].X;
|
---|
| 211 | xnt[2]=vdishes[i].Y;
|
---|
| 212 | if (vdishes[i].isCircular()) {
|
---|
| 213 | xnt[3]=vdishes[i].Diameter();
|
---|
| 214 | xnt[4]=0.;
|
---|
| 215 | }
|
---|
| 216 | else {
|
---|
| 217 | xnt[3]=vdishes[i].DiameterX();
|
---|
| 218 | xnt[4]=vdishes[i].DiameterY();
|
---|
| 219 | }
|
---|
| 220 | ntvd.Fill(xnt);
|
---|
| 221 | }
|
---|
| 222 | Histo2D h2rep=mdresp.GetResponse();
|
---|
| 223 | POutPersist po(outfile);
|
---|
| 224 | po << PPFNameTag("mdish") << ntvd;
|
---|
| 225 | po << PPFNameTag("h2rep") << h2rep;
|
---|
| 226 | return;
|
---|
| 227 | }
|
---|
[3792] | 228 |
|
---|