| [3792] | 1 | #include "machdefs.h" | 
|---|
|  | 2 | #include "sopnamsp.h" | 
|---|
|  | 3 | #include <iostream> | 
|---|
|  | 4 | #include <string> | 
|---|
|  | 5 | #include <math.h> | 
|---|
|  | 6 |  | 
|---|
|  | 7 | #include <typeinfo> | 
|---|
|  | 8 |  | 
|---|
|  | 9 | #include "mdish.h" | 
|---|
|  | 10 | #include "specpk.h" | 
|---|
|  | 11 | #include "interfconfigs.h" | 
|---|
|  | 12 |  | 
|---|
|  | 13 | #include "histinit.h" | 
|---|
|  | 14 | // #include "fiosinit.h" | 
|---|
|  | 15 | // #include "fitsioserver.h" | 
|---|
|  | 16 |  | 
|---|
|  | 17 | #include "randr48.h" | 
|---|
|  | 18 |  | 
|---|
|  | 19 | #include "timing.h" | 
|---|
|  | 20 | #include "ctimer.h" | 
|---|
|  | 21 |  | 
|---|
|  | 22 | typedef DR48RandGen RandomGenerator ; | 
|---|
|  | 23 |  | 
|---|
|  | 24 | // --------------------------------------------------------------------- | 
|---|
|  | 25 | // Test main program for computing interferometer response un (u,v) plane | 
|---|
|  | 26 | // R. Ansari  - Avril-Juin 2010 | 
|---|
|  | 27 | // --------------------------------------------------------------------- | 
|---|
|  | 28 |  | 
|---|
|  | 29 |  | 
|---|
|  | 30 |  | 
|---|
|  | 31 |  | 
|---|
|  | 32 | //------------------------------------------------------------------------- | 
|---|
|  | 33 | //      ------------------ MAIN PROGRAM ------------------------------ | 
|---|
|  | 34 | //------------------------------------------------------------------------- | 
|---|
|  | 35 | int main(int narg, const char* arg[]) | 
|---|
|  | 36 | { | 
|---|
|  | 37 | if (((narg>1)&&(strcmp(arg[1],"-h")==0))||(narg<3))  { | 
|---|
| [3796] | 38 | cout << " Usage: repicon configId OutPPFName [Lambda=0.357] [RenormalizeMax]" | 
|---|
| [3792] | 39 | << " configs: f4x4 , f8x8 , f20x20 Filled array of nxn dishes \n" | 
|---|
|  | 40 | << "          confA , confB, confC : semi-filled array of dishes \n" | 
|---|
|  | 41 | << "          f3cyl, f8cyl , f3cylp, f8cylp : filled array of non perfect/perfect of n cylinders " << endl; | 
|---|
|  | 42 | return 1; | 
|---|
|  | 43 | } | 
|---|
|  | 44 | cout << " ==== repicon.cc program , (u,v) plane response ==== " << endl; | 
|---|
|  | 45 | // make sure SOPHYA modules are initialized | 
|---|
|  | 46 | SophyaInit(); | 
|---|
|  | 47 | //  FitsIOServerInit(); | 
|---|
|  | 48 | InitTim(); | 
|---|
|  | 49 | //--- decoding command line arguments | 
|---|
|  | 50 | string config = "f8x8" ; | 
|---|
|  | 51 | if (narg>1) config = arg[1]; | 
|---|
|  | 52 | string outfile = "repicon.ppf"; | 
|---|
|  | 53 | if (narg>2) outfile = arg[2]; | 
|---|
|  | 54 | if (outfile==".")  outfile = "repicon.ppf"; | 
|---|
|  | 55 | double LAMBDA=0.357 ;  // 21 cm at z=0.7 | 
|---|
| [3796] | 56 | if (narg>3) LAMBDA = atof(arg[3]); | 
|---|
|  | 57 | bool fgrenorm=false; | 
|---|
|  | 58 | double rmax=1.; | 
|---|
|  | 59 | if (narg>4) { | 
|---|
|  | 60 | rmax=atof(arg[4]); | 
|---|
|  | 61 | fgrenorm=true; | 
|---|
|  | 62 | } | 
|---|
| [3792] | 63 | //-- end command line arguments | 
|---|
|  | 64 |  | 
|---|
|  | 65 | int rc = 1; | 
|---|
|  | 66 | try {  // exception handling try bloc at top level | 
|---|
|  | 67 |  | 
|---|
|  | 68 | double Ddish = 5.; | 
|---|
|  | 69 | double Ddish2 = 7.5; | 
|---|
|  | 70 | double Eta=0.95; | 
|---|
|  | 71 | double cylW=12.;   // Largeur des cylindres | 
|---|
|  | 72 | double cylRL=0.5;  // Longeur des elements de reception le long du cylindre | 
|---|
|  | 73 | double etaW=0.95;   // Efficacite de couverture en largeur | 
|---|
|  | 74 | double etaRL=0.9;   // Efficacite de couverture le long du cylindre | 
|---|
|  | 75 | int cnt=0; | 
|---|
|  | 76 |  | 
|---|
|  | 77 | vector<Dish> vdishes; | 
|---|
|  | 78 | cout << " repicon[1] : creating dish vector/ MultiDish for configuration: " << config << endl; | 
|---|
|  | 79 |  | 
|---|
|  | 80 | bool fgpoint=false; | 
|---|
|  | 81 | if (config=="f4x4") { | 
|---|
|  | 82 | vdishes=CreateFilledSqConfig(4,Ddish, Eta); | 
|---|
|  | 83 | } | 
|---|
|  | 84 | else if (config=="f8x8") { | 
|---|
|  | 85 | vdishes=CreateFilledSqConfig(8,Ddish, Eta); | 
|---|
|  | 86 | } | 
|---|
|  | 87 | else if (config=="f20x20") { | 
|---|
|  | 88 | vdishes=CreateFilledSqConfig(20,Ddish, Eta); | 
|---|
|  | 89 | } | 
|---|
|  | 90 | else if (config=="f3cyl") { | 
|---|
|  | 91 | cylW=10.;   cylRL=0.5; | 
|---|
|  | 92 | vdishes=CreateFilledCylConfig(3, 128, cylW, cylRL, etaW, etaRL, true); | 
|---|
|  | 93 | } | 
|---|
|  | 94 | else if (config=="f3cylp") { | 
|---|
|  | 95 | cylW=10.;   cylRL=0.5; | 
|---|
|  | 96 | vdishes=CreateFilledCylConfig(3, 128, cylW, cylRL, etaW, etaRL, false); | 
|---|
|  | 97 | } | 
|---|
|  | 98 | else if (config=="f8cyl") { | 
|---|
|  | 99 | cylW=12.;   cylRL=0.5; | 
|---|
|  | 100 | vdishes=CreateFilledCylConfig(8, 192, cylW, cylRL, etaW, etaRL, true); | 
|---|
|  | 101 | } | 
|---|
|  | 102 | else if (config=="f8cylp") { | 
|---|
|  | 103 | cylW=12.;   cylRL=0.5; | 
|---|
|  | 104 | vdishes=CreateFilledCylConfig(8, 192, cylW, cylRL, etaW, etaRL, false); | 
|---|
|  | 105 | } | 
|---|
|  | 106 | else if (config=="confA") { | 
|---|
|  | 107 | fgpoint=true; | 
|---|
|  | 108 | vdishes=CreateConfigA(Ddish, Eta); | 
|---|
|  | 109 | } | 
|---|
|  | 110 | else if (config=="confB") { | 
|---|
|  | 111 | fgpoint=true; | 
|---|
|  | 112 | vdishes=CreateConfigB(Ddish, Eta); | 
|---|
|  | 113 | } | 
|---|
|  | 114 | else if (config=="confC") { | 
|---|
|  | 115 | fgpoint=true; | 
|---|
|  | 116 | vdishes=CreateConfigC(Ddish, Eta); | 
|---|
|  | 117 | } | 
|---|
|  | 118 | else { | 
|---|
|  | 119 | cout << " NON valid configuration option -> exit" << endl; | 
|---|
|  | 120 | return 99; | 
|---|
|  | 121 | } | 
|---|
|  | 122 |  | 
|---|
|  | 123 | double D = 100.; | 
|---|
|  | 124 | double Dol = D/LAMBDA; | 
|---|
|  | 125 |  | 
|---|
|  | 126 | double LMAX = D; | 
|---|
|  | 127 | bool fgnoauto = true; | 
|---|
| [3796] | 128 | int NRX=200; | 
|---|
|  | 129 | int NRY=200; | 
|---|
| [3792] | 130 |  | 
|---|
|  | 131 | MultiDish mdish(LAMBDA, LMAX, vdishes, fgnoauto); | 
|---|
|  | 132 | mdish.SetRespHisNBins(NRX,NRY); | 
|---|
|  | 133 | if (fgpoint) | 
|---|
|  | 134 | mdish.SetThetaPhiRange(M_PI/6.,12, M_PI/6., 12); | 
|---|
|  | 135 | cout << " repicon[2] : calling mdish.GetResponse() ..."<< endl; | 
|---|
|  | 136 |  | 
|---|
|  | 137 | Histo2D hrep = mdish.GetResponse(); | 
|---|
|  | 138 | PrtTim("Apres mdish.GetResponse()"); | 
|---|
|  | 139 |  | 
|---|
| [3796] | 140 | Four2DRespTable mdresp(hrep, Dol, LAMBDA); | 
|---|
|  | 141 | if (fgrenorm) { | 
|---|
|  | 142 | cout << " repicon[2.b] call to mdresp.renormalize(" << rmax << ")"; | 
|---|
|  | 143 | double omax=mdresp.renormalize(rmax); | 
|---|
|  | 144 | cout << " Old Max=" << omax << endl; | 
|---|
|  | 145 | } | 
|---|
| [3792] | 146 | cout << " repicon[3] : saving Four2DRespTable for config " << config << " to PPF file " << outfile << endl; | 
|---|
|  | 147 | mdresp.writeToPPF(outfile); | 
|---|
|  | 148 |  | 
|---|
|  | 149 | rc = 0; | 
|---|
|  | 150 | }  // End of try bloc | 
|---|
|  | 151 | catch (PThrowable & exc) {  // catching SOPHYA exceptions | 
|---|
|  | 152 | cerr << " repicon.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name() | 
|---|
|  | 153 | << "\n...exc.Msg= " << exc.Msg() << endl; | 
|---|
|  | 154 | rc = 99; | 
|---|
|  | 155 | } | 
|---|
|  | 156 | catch (std::exception & e) {  // catching standard C++ exceptions | 
|---|
|  | 157 | cerr << " repicon.cc: Catched std::exception "  << " - what()= " << e.what() << endl; | 
|---|
|  | 158 | rc = 98; | 
|---|
|  | 159 | } | 
|---|
|  | 160 | catch (...) {  // catching other exceptions | 
|---|
|  | 161 | cerr << " repicon.cc: some other exception (...) was caught ! " << endl; | 
|---|
|  | 162 | rc = 97; | 
|---|
|  | 163 | } | 
|---|
|  | 164 | PrtTim("End-repicon"); | 
|---|
|  | 165 | cout << " ==== End of repicon.cc program  Rc= " << rc << endl; | 
|---|
|  | 166 | return rc; | 
|---|
|  | 167 | } | 
|---|
|  | 168 |  | 
|---|
|  | 169 |  | 
|---|