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