[3160] | 1 | #include "sopnamsp.h"
|
---|
| 2 | #include "machdefs.h"
|
---|
| 3 | #include <math.h>
|
---|
| 4 | #include <iostream>
|
---|
| 5 | #include <typeinfo>
|
---|
| 6 |
|
---|
| 7 | #include "tvector.h"
|
---|
| 8 | #include "srandgen.h"
|
---|
| 9 | #include "fioarr.h"
|
---|
| 10 | #include "sopemtx.h"
|
---|
| 11 | #include "pexceptions.h"
|
---|
| 12 | #include "matharr.h"
|
---|
| 13 |
|
---|
| 14 | #include "sambainit.h"
|
---|
| 15 |
|
---|
| 16 | // #include "tarrinit.h"
|
---|
| 17 |
|
---|
| 18 | #include "timing.h"
|
---|
| 19 |
|
---|
| 20 | #include "multicyl.h"
|
---|
| 21 | #include "mbeamcyl.h"
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | // Declaration des fonctions de ce fichier
|
---|
| 25 | static int test1cyl(string& ppfname);
|
---|
| 26 | static int testmulticyl(string& ppfname);
|
---|
| 27 |
|
---|
| 28 | //-----------------------------------------------------------
|
---|
| 29 | // -------------- Parametres de simulation -----------------
|
---|
| 30 | //-----------------------------------------------------------
|
---|
| 31 | static int MR = 256; // Nombre de recepteur
|
---|
| 32 | static int NE = 1024; // Nombre d'echantillon en temps;
|
---|
| 33 | static double freq0 = 2.; // frequence de base
|
---|
| 34 | static double da = 0.25; // pas des antennes le long du cylindre
|
---|
| 35 | static double snoise = 1.0; // sigma du bruit
|
---|
| 36 | static double tjit = 0.05; // sigma du jitter en temps
|
---|
| 37 | static double tos = 0.02; // sigma des offsets en temps
|
---|
| 38 | static double gmean = 1.; // gain moyen
|
---|
| 39 | static double gsig = 0.; // sigma des gains
|
---|
| 40 | static int nantgz = 0; // nb d'antennes morts (-> gain=0)
|
---|
| 41 | static int prtlevel = 0; // niveau de print
|
---|
| 42 | //-----------------------------------------------------------
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | /* --------------------------------------------------------
|
---|
| 46 | Le main programme de test des classes de reconstruction
|
---|
| 47 | multilobe radio - R. Ansari , Sep06 -- 2007
|
---|
| 48 | --------------------------------------------------------- */
|
---|
| 49 |
|
---|
| 50 | int main(int narg, char* arg[])
|
---|
| 51 | {
|
---|
| 52 |
|
---|
| 53 | SophyaInit();
|
---|
| 54 | InitTim(); // Initializing the CPU timer
|
---|
| 55 |
|
---|
| 56 | string ppfname = "treccyl.ppf";
|
---|
| 57 | int act = 1;
|
---|
| 58 | if (narg < 3) {
|
---|
| 59 | cout << "Usage: treccyl act ppfname [PrtLev=0] \n"
|
---|
| 60 | << " act= X ou XY , ppfname= treccyl.ppf par defaut" << endl;
|
---|
| 61 | return 1;
|
---|
| 62 | }
|
---|
| 63 | if (strcmp(arg[1],"XY") == 0) act = 2;
|
---|
| 64 | if (narg > 2) ppfname = arg[2];
|
---|
| 65 | if (narg > 3) prtlevel = atoi(arg[3]);
|
---|
| 66 |
|
---|
| 67 | int rc = 0;
|
---|
| 68 | try {
|
---|
| 69 | if (act == 2) rc = testmulticyl(ppfname);
|
---|
| 70 | else rc = test1cyl(ppfname);
|
---|
| 71 | cout << "treccy/Info - FIN " << endl;
|
---|
| 72 | }
|
---|
| 73 | catch (PThrowable& exc) {
|
---|
| 74 | cerr << " treccyl.cc catched Exception " << exc.Msg() << endl;
|
---|
| 75 | rc = 77;
|
---|
| 76 | }
|
---|
| 77 | catch (std::exception& sex) {
|
---|
| 78 | cerr << "\n treccyl.cc std::exception :"
|
---|
| 79 | << (string)typeid(sex).name() << "\n msg= "
|
---|
| 80 | << sex.what() << endl;
|
---|
| 81 | }
|
---|
| 82 | catch (...) {
|
---|
| 83 | cerr << " treccyl.cc catched unknown (...) exception " << endl;
|
---|
| 84 | rc = 78;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | return rc;
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | //--- Fonction de test : reconstruction plan AngX-Frequence (1 cylindre)
|
---|
| 92 | int test1cyl(string& ppfname)
|
---|
| 93 | {
|
---|
| 94 |
|
---|
| 95 | // BRSourceGen sg;
|
---|
| 96 | int nsrc = 60;
|
---|
| 97 | BRSourceGen sg(nsrc);
|
---|
| 98 | // sg.WritePPF(string("brsrc1.ppf"));
|
---|
| 99 |
|
---|
| 100 | cout << "=== test1cyl: BRSourceGen NbSrc= " << sg.NbSources()
|
---|
| 101 | << " NbRecep=" << MR << " NSamples=" << NE << endl;
|
---|
| 102 |
|
---|
| 103 | // BRSourceGen sg(string("brsrc1.ppf"));
|
---|
| 104 | if (prtlevel > 1) sg.Print(cout);
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | MultiBeamCyl mb(MR, NE);
|
---|
| 108 | mb.SetPrintLevel(prtlevel);
|
---|
| 109 | mb.SetBaseFreqDa(freq0, da);
|
---|
| 110 | mb.SetNoiseSigma(snoise);
|
---|
| 111 | mb.SetTimeJitter(tjit);
|
---|
| 112 | mb.SetTimeOffsetSigma(tos);
|
---|
| 113 | mb.SetGains(gmean, gsig, nantgz);
|
---|
| 114 |
|
---|
| 115 | mb.SetSources(sg);
|
---|
| 116 |
|
---|
| 117 | mb.ComputeTimeVectors();
|
---|
| 118 | mb.ComputeSignalVector(0, true);
|
---|
| 119 | cout << "treccy/test1cyl: signal vectors OK " << endl;
|
---|
| 120 | PrtTim("test1cyl:[1] ");
|
---|
| 121 |
|
---|
| 122 | POutPersist po(ppfname);
|
---|
| 123 | po << PPFNameTag("signal") << mb.signal;
|
---|
| 124 | po << PPFNameTag("sigjitt") << mb.sigjitt;
|
---|
| 125 | po << PPFNameTag("f_sig") << mb.f_sig;
|
---|
| 126 | po << PPFNameTag("f_sigjit") << mb.f_sigjit;
|
---|
| 127 |
|
---|
| 128 | NTuple ntsrc = sg.Convert2Table(freq0);
|
---|
| 129 | po << PPFNameTag("ntsrc") << ntsrc;
|
---|
| 130 |
|
---|
| 131 | cout << "treccy/test1cyl: - sig/f_sig,ntsrc to OutPPF OK " << endl;
|
---|
| 132 | PrtTim("test1cyl[2] ");
|
---|
| 133 |
|
---|
| 134 | mb.ReconstructSourcePlane(true);
|
---|
| 135 | {
|
---|
| 136 | TMatrix<r_4> srcplane = module(mb.getRecSrcPlane() );
|
---|
| 137 | po << PPFNameTag("recsrcplane") << srcplane;
|
---|
| 138 | }
|
---|
| 139 | PrtTim("test1cyl[3] ");
|
---|
| 140 |
|
---|
| 141 | return 0;
|
---|
| 142 |
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | //--- Fonction de test : reconstruction cube AngX-AngY-Frequence (multi-cylindre)
|
---|
| 147 | int testmulticyl(string& ppfname)
|
---|
| 148 | {
|
---|
| 149 |
|
---|
| 150 | // BRSourceGen sg;
|
---|
| 151 | int nsf = 10;
|
---|
| 152 | vector<double> frq;
|
---|
| 153 | frq.push_back(0.1);
|
---|
| 154 | frq.push_back(0.27);
|
---|
| 155 | frq.push_back(0.38);
|
---|
| 156 |
|
---|
| 157 |
|
---|
| 158 | cout << "treccy/testmulticyl: BRSourceGen sg([frq=0.1,0.27,0.38], " << nsf << ")" << endl;
|
---|
| 159 | BRSourceGen sg(frq, nsf, M_PI/3, M_PI/1000);
|
---|
| 160 | // sg.WritePPF(string("brsrcm.ppf"));
|
---|
| 161 | // BRSourceGen sg(string("brsrcm.ppf"));
|
---|
| 162 | cout << "=== testmulticyl: BRSourceGen NbSrc= " << sg.NbSources()
|
---|
| 163 | << " NbRecep=" << MR << " NSamples=" << NE << endl;
|
---|
| 164 | if (prtlevel > 1) sg.Print(cout);
|
---|
| 165 |
|
---|
| 166 |
|
---|
| 167 | MultiCylinders mcyl (MR, NE);
|
---|
| 168 | mcyl.SetPrintLevel(prtlevel);
|
---|
| 169 | mcyl.SetBaseFreqDa(freq0, da);
|
---|
| 170 | mcyl.SetNoiseSigma(snoise);
|
---|
| 171 | mcyl.SetTimeJitter(tjit);
|
---|
| 172 | mcyl.SetTimeOffsetSigma(tos);
|
---|
| 173 | mcyl.SetGains(gmean, gsig, nantgz);
|
---|
| 174 |
|
---|
| 175 | mcyl.AddCylinder(0.);
|
---|
| 176 | mcyl.AddCylinder(100.);
|
---|
| 177 | mcyl.AddCylinder(300.);
|
---|
| 178 | mcyl.AddCylinder(700.);
|
---|
| 179 | mcyl.AddCylinder(1500.);
|
---|
| 180 |
|
---|
| 181 | mcyl.SetSources(sg);
|
---|
| 182 |
|
---|
| 183 | PrtTim("testmulticyl[1] ");
|
---|
| 184 |
|
---|
| 185 | // mcyl.ReconstructCylinderPlaneS(true);
|
---|
| 186 | mcyl.ReconstructSourceBox();
|
---|
| 187 |
|
---|
| 188 | POutPersist po(ppfname);
|
---|
| 189 |
|
---|
| 190 | NTuple ntsrc = sg.Convert2Table(freq0);
|
---|
| 191 | po << PPFNameTag("ntsrc") << ntsrc;
|
---|
| 192 |
|
---|
| 193 | {
|
---|
| 194 | TMatrix<r_4> srcplane0 = module(mcyl.GetCylinder(0).getRecSrcPlane());
|
---|
| 195 | po << PPFNameTag("recsrcplane0") << srcplane0;
|
---|
| 196 | }
|
---|
| 197 |
|
---|
| 198 | {
|
---|
| 199 | TMatrix<r_4> srcplane3 = module(mcyl.GetCylinder(3).getRecSrcPlane());
|
---|
| 200 | po << PPFNameTag("recsrcplane3") << srcplane3;
|
---|
| 201 | }
|
---|
| 202 |
|
---|
| 203 | PrtTim("testmulticyl[2] ");
|
---|
| 204 |
|
---|
| 205 | int kfmin, kfmax;
|
---|
| 206 | po << PPFNameTag("recsrcbox") << mcyl.getRecSrcBox();
|
---|
| 207 | kfmin = mcyl.getRecSrcBox().SizeZ()*frq[0] - 3; kfmax = kfmin+6;
|
---|
| 208 | {
|
---|
| 209 | TMatrix<r_4> slice0 = mcyl.getRecXYSlice(kfmin, kfmax);
|
---|
| 210 | po << PPFNameTag("recXYf0") << slice0;
|
---|
| 211 | }
|
---|
| 212 | kfmin = mcyl.getRecSrcBox().SizeZ()*frq[1] - 3; kfmax = kfmin+6;
|
---|
| 213 | {
|
---|
| 214 | TMatrix<r_4> slice1 = mcyl.getRecXYSlice(kfmin, kfmax);
|
---|
| 215 | po << PPFNameTag("recXYf1") << slice1;
|
---|
| 216 | }
|
---|
| 217 | kfmin = mcyl.getRecSrcBox().SizeZ()*frq[2] - 3; kfmax = kfmin+6;
|
---|
| 218 | {
|
---|
| 219 | TMatrix<r_4> slice2 = mcyl.getRecXYSlice(kfmin, kfmax);
|
---|
| 220 | po << PPFNameTag("recXYf2") << slice2;
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | PrtTim("testmulticyl[3] ");
|
---|
| 224 |
|
---|
| 225 | return 0;
|
---|
| 226 |
|
---|
| 227 | }
|
---|