[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 |
|
---|
[3932] | 5 | Usage: repicon [-parname value] configId OutPPFName
|
---|
[3930] | 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
|
---|
[3947] | 34 | void SaveDTVecDishesH2Resp(POutPersist& po, vector<Dish>& vdishes, Four2DRespTable& mdresp);
|
---|
[3930] | 35 |
|
---|
[3792] | 36 | // ---------------------------------------------------------------------
|
---|
[3947] | 37 | // main program for computing interferometer response in (u,v) plane
|
---|
[3792] | 38 | // R. Ansari - Avril-Juin 2010
|
---|
| 39 | // ---------------------------------------------------------------------
|
---|
| 40 |
|
---|
[3932] | 41 | void Usage()
|
---|
| 42 | {
|
---|
| 43 | cout << " Usage: repicon [-parname Value] configId OutPPFName \n"
|
---|
[3947] | 44 | << " configIds: f4x4,f8x8,f11x11,f20x20, confA,confB,confC,confD, hex12,cross11, \n"
|
---|
[3948] | 45 | << " f4cyl,f8cyl,f4cylp,f4cylp, nan12,nan24,nan36,nan40,nan128 \n"
|
---|
[3947] | 46 | << " f4x4 , f8x8 , f11x11 , f20x20 Filled array of nxn dishes \n"
|
---|
[3932] | 47 | << " confA , confB, confC, confD : semi-filled array of dishes \n"
|
---|
| 48 | << " hex12,cross11 : ASKAP like double hexagonal (12xD=12m), cross config (11xD=12m) \n"
|
---|
[3947] | 49 | << " nan12,nan24,nan36,nan40,nan128: 3,4,6,5,8 cylinder like configurations with 12,24,36,40,128 dishes\n"
|
---|
[3948] | 50 | << " f4cyl, f8cyl , f4cylp, f8cylp : filled array of non perfect/perfect of n cylinders \n"
|
---|
[3936] | 51 | << " f4cylw : filled array of 4 perfect of wide cylinders \n"
|
---|
[3947] | 52 | << " pit2cyl,pit2cylw : 2 cylinders 15mx7m, 20mx10 for z=0.3 at Pittsburg (perfect) \n"
|
---|
| 53 | << " pit4cyl : 4 cylinders 32mx8m for z=0.3-0.7 at Pittsburg (perfect) \n"
|
---|
| 54 | << " [ -parname value] : -renmax -z -prt -D -lmax -eta -autocor \n"
|
---|
[3932] | 55 | << " -renmax MaxValue (default : Do NOT renormalize 2D response value \n"
|
---|
| 56 | << " -z redshift (default=0.7) --> determines Lambda \n"
|
---|
| 57 | << " -D DishDiameter (default=5 m) \n"
|
---|
[3947] | 58 | << " -eta fill_factor (default=0.90) \n"
|
---|
[3932] | 59 | << " -lmax array extension (default=100 m ) for response calculation kmax \n"
|
---|
[3933] | 60 | << " -repnxy Nx,Ny (default=200,200) ResponseTable binning \n"
|
---|
| 61 | << " -beamnxy Nx,Ny (default=200,200) Beam sampling \n"
|
---|
[3932] | 62 | << " -rot ThetaMaxDeg,NTheta,PhiMaxDeg,NPhi (default NO-rotate/pointing -> 23,10,30,15 ) \n"
|
---|
[3947] | 63 | << " -autocor : keep antenna auto-correlation signals (default NO) \n"
|
---|
[3932] | 64 | << " -prt PrtLev,PrtModulo (default=0,10) \n"
|
---|
| 65 | << endl;
|
---|
| 66 | return;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[3792] | 69 | // ------------------ MAIN PROGRAM ------------------------------
|
---|
| 70 | int main(int narg, const char* arg[])
|
---|
| 71 | {
|
---|
| 72 | if (((narg>1)&&(strcmp(arg[1],"-h")==0))||(narg<3)) {
|
---|
[3932] | 73 | Usage();
|
---|
[3792] | 74 | return 1;
|
---|
| 75 | }
|
---|
| 76 | // make sure SOPHYA modules are initialized
|
---|
| 77 | SophyaInit();
|
---|
| 78 | // FitsIOServerInit();
|
---|
| 79 | InitTim();
|
---|
| 80 | //--- decoding command line arguments
|
---|
| 81 | string config = "f8x8" ;
|
---|
| 82 | string outfile = "repicon.ppf";
|
---|
[3796] | 83 | bool fgrenorm=false;
|
---|
| 84 | double rmax=1.;
|
---|
[3932] | 85 | double z_Redshift=0.7 ; // 21 cm at z=0.7 -> 0.357 m
|
---|
| 86 | int prtlev=0;
|
---|
| 87 | int prtmod=10;
|
---|
| 88 |
|
---|
| 89 | double Ddish=5.;
|
---|
[3947] | 90 | double Eta=0.9;
|
---|
[3932] | 91 | bool fgDfixed=false;
|
---|
| 92 | double LMAX = 100.; // taille de la zone, pour calcul kmax
|
---|
| 93 | bool fgLMAXfixed=false;
|
---|
| 94 | double thetamxdeg=23.; // 23 degres : angle d'inclinaison de l'orbite terrestre
|
---|
| 95 | double phimxdeg=30.;
|
---|
| 96 | int nteta=10;
|
---|
| 97 | int nphi=15;
|
---|
| 98 | bool fgpoint=false;
|
---|
[3933] | 99 | int NRX=200;
|
---|
| 100 | int NRY=200;
|
---|
| 101 | int NBX=200;
|
---|
| 102 | int NBY=200;
|
---|
[3947] | 103 | bool fgnoauto=true; // do not keep antenna autocorrelation signal
|
---|
[3933] | 104 |
|
---|
[3932] | 105 | int ka=1;
|
---|
| 106 | while (ka<(narg-1)) {
|
---|
| 107 | if (strcmp(arg[ka],"-renmax")==0) {
|
---|
| 108 | rmax=atof(arg[ka+1]); fgrenorm=true; ka+=2;
|
---|
| 109 | }
|
---|
| 110 | else if (strcmp(arg[ka],"-z")==0) {
|
---|
| 111 | z_Redshift=atof(arg[ka+1]); ka+=2;
|
---|
| 112 | }
|
---|
| 113 | else if (strcmp(arg[ka],"-D")==0) {
|
---|
| 114 | Ddish=atof(arg[ka+1]); fgDfixed=true; ka+=2;
|
---|
| 115 | }
|
---|
[3947] | 116 | else if (strcmp(arg[ka],"-eta")==0) {
|
---|
| 117 | Eta=atof(arg[ka+1]); ka+=2;
|
---|
| 118 | }
|
---|
[3932] | 119 | else if (strcmp(arg[ka],"-lmax")==0) {
|
---|
| 120 | LMAX=atof(arg[ka+1]); fgLMAXfixed=true; ka+=2;
|
---|
| 121 | }
|
---|
[3933] | 122 | else if (strcmp(arg[ka],"-repnxy")==0) {
|
---|
| 123 | sscanf(arg[ka+1],"%d,%d",&NRX,&NRY); ka+=2;
|
---|
| 124 | }
|
---|
| 125 | else if (strcmp(arg[ka],"-beamnxy")==0) {
|
---|
| 126 | sscanf(arg[ka+1],"%d,%d",&NBX,&NBY); ka+=2;
|
---|
| 127 | }
|
---|
[3932] | 128 | else if (strcmp(arg[ka],"-rot")==0) {
|
---|
| 129 | sscanf(arg[ka+1],"%lg,%d,%lg,%d",&thetamxdeg,&nteta,&phimxdeg,&nphi); fgpoint=true; ka+=2;
|
---|
| 130 | }
|
---|
[3947] | 131 | else if (strcmp(arg[ka],"-autocor")==0) {
|
---|
| 132 | fgnoauto=false; ka+=1;
|
---|
| 133 | }
|
---|
[3932] | 134 | else if (strcmp(arg[ka],"-prt")==0) {
|
---|
| 135 | sscanf(arg[ka+1],"%d,%d",&prtlev,&prtmod); ka+=2;
|
---|
| 136 | }
|
---|
| 137 | else break;
|
---|
[3796] | 138 | }
|
---|
[3932] | 139 |
|
---|
| 140 | if ((ka+1)>=narg) {
|
---|
| 141 | cout << " repicon / Argument error " << endl;
|
---|
| 142 | Usage();
|
---|
| 143 | return 2;
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | config = arg[ka];
|
---|
| 147 | outfile = arg[ka+1];
|
---|
[3792] | 148 | //-- end command line arguments
|
---|
| 149 |
|
---|
| 150 | int rc = 1;
|
---|
| 151 | try { // exception handling try bloc at top level
|
---|
[3932] | 152 | cout << " ==== repicon.cc program , (u,v) plane response ==== " << endl;
|
---|
[3933] | 153 |
|
---|
| 154 | H21Conversions conv;
|
---|
| 155 | double LAMBDA=0.357 ; // 21 cm at z=0.7
|
---|
| 156 | conv.setRedshift(z_Redshift);
|
---|
| 157 | LAMBDA = conv.getLambda();
|
---|
[3932] | 158 |
|
---|
[3792] | 159 | double cylW=12.; // Largeur des cylindres
|
---|
[3933] | 160 | double cylRL=2*LAMBDA; // Longeur des elements de reception le long du cylindre
|
---|
[3948] | 161 | double etaW=0.9; // Efficacite de couverture en largeur
|
---|
| 162 | double etaRL=0.8; // Efficacite de couverture le long du cylindre
|
---|
[3930] | 163 |
|
---|
[3792] | 164 | vector<Dish> vdishes;
|
---|
[3947] | 165 | cout << " repicon[1] : creating dish vector/ MultiDish for configuration: " << config
|
---|
| 166 | << " Ddish=" << Ddish << " m. Eta=" << Eta << endl;
|
---|
[3792] | 167 |
|
---|
| 168 | if (config=="f4x4") {
|
---|
| 169 | vdishes=CreateFilledSqConfig(4,Ddish, Eta);
|
---|
| 170 | }
|
---|
| 171 | else if (config=="f8x8") {
|
---|
| 172 | vdishes=CreateFilledSqConfig(8,Ddish, Eta);
|
---|
| 173 | }
|
---|
[3947] | 174 | else if (config=="f11x11") {
|
---|
| 175 | vdishes=CreateFilledSqConfig(11,Ddish, Eta);
|
---|
| 176 | }
|
---|
[3792] | 177 | else if (config=="f20x20") {
|
---|
| 178 | vdishes=CreateFilledSqConfig(20,Ddish, Eta);
|
---|
| 179 | }
|
---|
[3948] | 180 | else if (config=="f4cyl") {
|
---|
| 181 | cylW=12.; cylRL=2*LAMBDA;
|
---|
| 182 | vdishes=CreateFilledCylConfig(4, 100, cylW, cylRL, etaW, etaRL, true);
|
---|
[3792] | 183 | }
|
---|
[3948] | 184 | else if (config=="f4cylp") {
|
---|
| 185 | cylW=12.; cylRL=2*LAMBDA;
|
---|
| 186 | vdishes=CreateFilledCylConfig(4, 100, cylW, cylRL, etaW, etaRL, false);
|
---|
[3792] | 187 | }
|
---|
[3936] | 188 | else if (config=="f4cylw") {
|
---|
| 189 | cylW=25.; cylRL=3*LAMBDA;
|
---|
| 190 | vdishes=CreateFilledCylConfig(4, 100, cylW, cylRL, etaW, etaRL, false);
|
---|
| 191 | }
|
---|
[3947] | 192 | else if (config=="pit2cyl") {
|
---|
| 193 | etaW=0.9; etaRL=0.9;
|
---|
| 194 | cylW=7.; cylRL=2*LAMBDA;
|
---|
| 195 | vdishes=CreateFilledCylConfig(2, 32, cylW, cylRL, etaW, etaRL, false);
|
---|
| 196 | }
|
---|
| 197 | else if (config=="pit2cylw") {
|
---|
| 198 | etaW=0.9; etaRL=0.9;
|
---|
| 199 | cylW=9.; cylRL=2*LAMBDA;
|
---|
| 200 | vdishes=CreateFilledCylConfig(2, 40, cylW, cylRL, etaW, etaRL, false);
|
---|
| 201 | }
|
---|
| 202 | else if (config=="pit4cyl") {
|
---|
| 203 | etaW=0.9; etaRL=0.9;
|
---|
| 204 | cylW=8.; cylRL=2*LAMBDA;
|
---|
| 205 | vdishes=CreateFilledCylConfig(4, 64, cylW, cylRL, etaW, etaRL, false);
|
---|
| 206 | }
|
---|
[3792] | 207 | else if (config=="f8cyl") {
|
---|
[3933] | 208 | cylW=12.; cylRL=2*LAMBDA;
|
---|
[3948] | 209 | vdishes=CreateFilledCylConfig(8, 120, cylW, cylRL, etaW, etaRL, true);
|
---|
[3792] | 210 | }
|
---|
| 211 | else if (config=="f8cylp") {
|
---|
[3933] | 212 | cylW=12.; cylRL=2*LAMBDA;
|
---|
[3948] | 213 | vdishes=CreateFilledCylConfig(8, 120, cylW, cylRL, etaW, etaRL, false);
|
---|
[3792] | 214 | }
|
---|
| 215 | else if (config=="confA") {
|
---|
| 216 | vdishes=CreateConfigA(Ddish, Eta);
|
---|
| 217 | }
|
---|
| 218 | else if (config=="confB") {
|
---|
| 219 | vdishes=CreateConfigB(Ddish, Eta);
|
---|
| 220 | }
|
---|
| 221 | else if (config=="confC") {
|
---|
| 222 | vdishes=CreateConfigC(Ddish, Eta);
|
---|
| 223 | }
|
---|
[3930] | 224 | else if (config=="confD") {
|
---|
| 225 | vdishes=CreateConfigD(Ddish, Eta);
|
---|
| 226 | }
|
---|
[3931] | 227 | else if (config=="cross11") {
|
---|
[3932] | 228 | if (!fgDfixed) Ddish = 12.;
|
---|
[3931] | 229 | double base=20.;
|
---|
| 230 | Eta=0.95;
|
---|
[3932] | 231 | if (!fgLMAXfixed) LMAX = 250.;
|
---|
[3931] | 232 | vdishes=CreateCrossConfig(Ddish,base,Eta);
|
---|
| 233 | }
|
---|
[3930] | 234 | else if (config=="hex12") {
|
---|
[3932] | 235 | if (!fgDfixed) Ddish = 12.;
|
---|
[3930] | 236 | Eta=0.95;
|
---|
[3932] | 237 | if (!fgLMAXfixed) LMAX = 350.;
|
---|
[3931] | 238 | vdishes=CreateDoubleHexagonConfig(Ddish);
|
---|
[3930] | 239 | }
|
---|
[3947] | 240 | else if (config=="nan12") {
|
---|
| 241 | vdishes=CreateConfigNancay12(Ddish, Eta);
|
---|
| 242 | }
|
---|
| 243 | else if (config=="nan24") {
|
---|
| 244 | vdishes=CreateConfigNancay24(Ddish, Eta);
|
---|
| 245 | }
|
---|
| 246 | else if (config=="nan36") {
|
---|
| 247 | vdishes=CreateConfigNancay36(Ddish, Eta);
|
---|
| 248 | }
|
---|
| 249 | else if (config=="nan40") {
|
---|
| 250 | vdishes=CreateConfigNancay40(Ddish, Eta);
|
---|
| 251 | }
|
---|
| 252 | else if (config=="nan128") {
|
---|
| 253 | vdishes=CreateConfigNancay128(Ddish, Eta);
|
---|
| 254 | }
|
---|
[3792] | 255 | else {
|
---|
| 256 | cout << " NON valid configuration option -> exit" << endl;
|
---|
| 257 | return 99;
|
---|
| 258 | }
|
---|
[3933] | 259 |
|
---|
[3932] | 260 | double Dol = LMAX/LAMBDA;
|
---|
| 261 |
|
---|
| 262 | cout << " repicon[1] : Lambda=" << LAMBDA << " LMAX= " << LMAX << " NDishes=" << vdishes.size()
|
---|
[3947] | 263 | << " D-Dish=" << Ddish << " m. " << ((fgnoauto)?" NO-":"With-") << "AutoCorrelation" << endl;
|
---|
[3932] | 264 |
|
---|
[3792] | 265 | MultiDish mdish(LAMBDA, LMAX, vdishes, fgnoauto);
|
---|
[3932] | 266 | mdish.SetPrtLevel(prtlev,prtmod);
|
---|
[3792] | 267 | mdish.SetRespHisNBins(NRX,NRY);
|
---|
[3933] | 268 | mdish.SetBeamNSamples(NBX,NBY);
|
---|
[3932] | 269 | if (fgpoint) {
|
---|
| 270 | cout << " repicon[1.b] : activating pointing , ThetaMaxDeg=" << thetamxdeg << " NTheta=" << nteta
|
---|
[3933] | 271 | << " PhiMaxDeg= " << phimxdeg << " NPhi=" << nphi << endl;
|
---|
[3932] | 272 | mdish.SetThetaPhiRange(Angle(thetamxdeg,Angle::Degree).ToRadian(),nteta,Angle(phimxdeg,Angle::Degree).ToRadian(), nphi);
|
---|
| 273 | }
|
---|
[3792] | 274 | cout << " repicon[2] : calling mdish.GetResponse() ..."<< endl;
|
---|
| 275 |
|
---|
| 276 | Histo2D hrep = mdish.GetResponse();
|
---|
| 277 | PrtTim("Apres mdish.GetResponse()");
|
---|
[3947] | 278 | HProf h1dnoise = mdish.GetProjNoiseLevel();
|
---|
| 279 | HProf h1drep = mdish.GetProjResponse();
|
---|
[3792] | 280 |
|
---|
[3796] | 281 | Four2DRespTable mdresp(hrep, Dol, LAMBDA);
|
---|
| 282 | if (fgrenorm) {
|
---|
| 283 | cout << " repicon[2.b] call to mdresp.renormalize(" << rmax << ")";
|
---|
| 284 | double omax=mdresp.renormalize(rmax);
|
---|
| 285 | cout << " Old Max=" << omax << endl;
|
---|
| 286 | }
|
---|
[3792] | 287 | cout << " repicon[3] : saving Four2DRespTable for config " << config << " to PPF file " << outfile << endl;
|
---|
| 288 | mdresp.writeToPPF(outfile);
|
---|
| 289 |
|
---|
[3930] | 290 | string outfile2 = "hdt_"+outfile;
|
---|
[3947] | 291 | POutPersist po2(outfile2);
|
---|
| 292 | cout << " repicon[4] : saving H1D/H2D-response, multidish config to PPF file " << outfile2 << endl;
|
---|
| 293 | po2 << PPFNameTag("h1dnoise") << h1dnoise;
|
---|
| 294 | po2 << PPFNameTag("h1drep") << h1drep;
|
---|
| 295 | SaveDTVecDishesH2Resp(po2, vdishes, mdresp);
|
---|
[3930] | 296 |
|
---|
[3792] | 297 | rc = 0;
|
---|
| 298 | } // End of try bloc
|
---|
| 299 | catch (PThrowable & exc) { // catching SOPHYA exceptions
|
---|
| 300 | cerr << " repicon.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name()
|
---|
| 301 | << "\n...exc.Msg= " << exc.Msg() << endl;
|
---|
| 302 | rc = 99;
|
---|
| 303 | }
|
---|
| 304 | catch (std::exception & e) { // catching standard C++ exceptions
|
---|
| 305 | cerr << " repicon.cc: Catched std::exception " << " - what()= " << e.what() << endl;
|
---|
| 306 | rc = 98;
|
---|
| 307 | }
|
---|
| 308 | catch (...) { // catching other exceptions
|
---|
| 309 | cerr << " repicon.cc: some other exception (...) was caught ! " << endl;
|
---|
| 310 | rc = 97;
|
---|
| 311 | }
|
---|
| 312 | PrtTim("End-repicon");
|
---|
| 313 | cout << " ==== End of repicon.cc program Rc= " << rc << endl;
|
---|
| 314 | return rc;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
[3930] | 317 | /*-- Nouvelle-Fonction --*/
|
---|
[3947] | 318 | void SaveDTVecDishesH2Resp(POutPersist& po, vector<Dish>& vdishes, Four2DRespTable& mdresp)
|
---|
[3930] | 319 | {
|
---|
| 320 | char* names[5]={"did","posx","posy","diam","diamy"};
|
---|
| 321 | NTuple ntvd(5,names,64,false);
|
---|
| 322 | r_4 xnt[10];
|
---|
| 323 | for(size_t i=0; i<vdishes.size(); i++) {
|
---|
| 324 | xnt[0]=vdishes[i].ReflectorId();
|
---|
| 325 | xnt[1]=vdishes[i].X;
|
---|
| 326 | xnt[2]=vdishes[i].Y;
|
---|
| 327 | if (vdishes[i].isCircular()) {
|
---|
| 328 | xnt[3]=vdishes[i].Diameter();
|
---|
| 329 | xnt[4]=0.;
|
---|
| 330 | }
|
---|
| 331 | else {
|
---|
| 332 | xnt[3]=vdishes[i].DiameterX();
|
---|
| 333 | xnt[4]=vdishes[i].DiameterY();
|
---|
| 334 | }
|
---|
| 335 | ntvd.Fill(xnt);
|
---|
| 336 | }
|
---|
| 337 | Histo2D h2rep=mdresp.GetResponse();
|
---|
| 338 | po << PPFNameTag("mdish") << ntvd;
|
---|
| 339 | po << PPFNameTag("h2rep") << h2rep;
|
---|
| 340 | return;
|
---|
| 341 | }
|
---|
[3792] | 342 |
|
---|