source: Sophya/trunk/Cosmo/RadioBeam/multicyl.cc@ 3191

Last change on this file since 3191 was 3191, checked in by legoff, 19 years ago

Cylinders have different x positions (NS).
This is taken into account in the signal phase shift
and in the exp() term when combining cylinders.
We can have more bins in x than antennas in one cylinder
to see the gain in resolution along x due to several cylinders at different x

File size: 4.9 KB
Line 
1#include "multicyl.h"
2#include "fftpserver.h"
3#include "vector3d.h"
4#include "matharr.h"
5#include "srandgen.h"
6#include "ctimer.h"
7#include "resusage.h"
8
9
10//=================================================
11
12MultiCylinders::MultiCylinders(int nr, int ns)
13{
14 NR = nr;
15 NS = ns;
16
17 SetPrintLevel(0);
18
19 SetBaseFreqDa(2., 0.25);
20 SetNoiseSigma(0.);
21 SetTimeJitter(0.);
22 SetTimeOffsetSigma(0.);
23 SetGains(1., 0., 0);
24 adfg = false; src = NULL;
25 SetSources(new BRSourceGen, true);
26}
27
28MultiCylinders::~MultiCylinders()
29{
30 if (adfg && src) delete src;
31 for(int k=0; k<mCyl.size(); k++) delete mCyl[k];
32}
33
34MultiBeamCyl& MultiCylinders::GetCylinder(int k)
35{
36 if ((k < 0) || (k >= mCyl.size()))
37 throw RangeCheckError("MultiCylinders::GetCylinder(k) k<0 OR k>=NCyl");
38 return (*mCyl[k]);
39}
40
41void MultiCylinders::SetSources(BRSourceGen* brs, bool ad)
42{
43 if (brs == NULL) return;
44 if (adfg && src) delete src;
45 src = brs; adfg=ad;
46}
47
48
49void MultiCylinders::ConfigureCylinders()
50{
51 cout << " MultiCylinders::ConfigureCylinders() with NCyl= " << mCyl.size() << endl;
52 for(int k=0; k<mCyl.size(); k++) {
53 mCyl[k]->SetPrintLevel(PrtLev);
54 mCyl[k]->SetBaseFreqDa(freq0, Da);
55 mCyl[k]->SetNoiseSigma(signoise);
56 mCyl[k]->SetTimeJitter(timejitter);
57 mCyl[k]->SetTimeOffsetSigma(toffsig);
58 mCyl[k]->SetGains(gain, siggain, ngainzero);
59 mCyl[k]->SetSources(src, false);
60 }
61}
62
63
64void MultiCylinders::ReconstructCylinderPlaneS(bool fgzerocentre)
65{
66 Timer tm("RecCylPlaneS");
67 ResourceUsage resu;
68 cout << " MultiCylinders::ReconstructCylinderPlaneS()/Info - NCyl= " << mCyl.size()
69 << " MemSize=" << resu.getMemorySize() << " kb" << endl;
70 ConfigureCylinders();
71
72 char buff[128];
73 for(int k=0; k<mCyl.size(); k++) {
74 cout << "---- Cyl[" << k << "] Calling MultiBeamCyl.ReconstructSourcePlane() ..." << endl;
75 mCyl[k]->ReconstructSourcePlane(fgzerocentre);
76 sprintf(buff,"Cyl[%d].RecSrcPlane()",k);
77 tm.Split(buff);
78 }
79 resu.Update();
80 cout << " MultiCylinders::ReconstructCylinderPlaneS()/Info - Done "
81 << " MemSize=" << resu.getMemorySize() << " kb" << endl;
82}
83
84void MultiCylinders::ReconstructSourceBox(int halfny, double stepangy)
85{
86 ReconstructCylinderPlaneS(true);
87 TMatrix< complex<r_4> > & mtx = GetCylinder(0).getRecSrcPlane();
88 // boite 3D X:angX, Y:angY , Z: freq
89 sa_size_t sz[5] = {0,0,0,0,0};
90// int nx=mtx.NCols(); // uncomment to go back to nxbin = nantenna
91 int nx=256;
92 sz[0] = nx;
93 sz[1] = halfny*2+1;
94 sz[2] = mtx.NRows();
95 TArray< complex<r_4> > & box = getRecSrcBox();
96 box.ReSize(3, sz);
97 // box = complex< r_4 >( 0.f, 0.f );
98 cout << " MultiCylinders::ReconstructSourceBox(" << halfny << "," << stepangy
99 << "=" << Angle(stepangy).ToArcMin() << " ) srcbox:" << endl;
100 Timer tm("RecSrcBox");
101 box.Show(cout);
102
103
104 int pmod = mtx.NRows()/10;
105
106 double fstep = 1.0/(double)NS; // pas en frequence, attention, on a vire la composante continu
107 for(int kf=0; kf<mtx.NRows(); kf++) { // Loop over frequencies
108 double frq = (double)(kf+1.)*fstep + freq0; // + 1 car f=0 a ete vire
109
110 for(int lc=0; lc<mCyl.size(); lc++) { // Loop over cylinders
111 MultiBeamCyl& cyl = GetCylinder(lc);
112
113 TMatrix< complex<r_4> > & recp = cyl.getRecSrcPlane();
114
115 double facl = - 2*M_PI*frq*cyl.getCylinderYPos(); // attention au signe -
116// double facl_x = - 2*M_PI*cyl.getCylinderXPos()/cyl.Da/(double)cyl.NR;
117 double facl_x = - 2*M_PI*cyl.getCylinderXPos()/cyl.Da;
118 double dphi;
119 complex< r_4 > phasefactor;
120 int jyy = 0;
121 for(int jy=-halfny; jy<=halfny; jy++) { // Loop over Y angular steps
122 for(int ix=0; ix<nx; ix++) { // Loop over AngX directions
123 double dphi = facl * sin( (double)jy*stepangy )
124 + facl_x*(double(ix)/double(nx)-1./2.);
125 phasefactor = complex< r_4 > ((r_4) cos(dphi) , (r_4) sin(dphi));
126 // sur recp : index ligne -> frequence , index colonne -> angX ,
127 int ixx=(int)(ix*(double)cyl.NR/double(nx));
128 box(ix, jyy, kf) += recp(kf, ixx)*phasefactor;
129 } //
130 jyy++;
131 } // End of Loop over Y angles
132 } // End of loop over cylinders
133 tm.Nop();
134 if ( (PrtLev>0) && (kf%pmod == 0) )
135 cout << " OK box(angx,angy, freq=kf) done for kf=" << kf
136 << " / Max_kf=" << mtx.NRows() << endl;
137 } // End of loop over over frequencies
138
139 cout << " MultiCylinders::ReconstructSourceBox() done " << endl;
140}
141
142inline float myZmodule(complex<r_4>& z)
143{
144 return (float)sqrt((double)(z.real()*z.real()+z.imag()*z.imag()));
145}
146
147TMatrix< r_4 > MultiCylinders::getRecXYSlice(int kfmin, int kfmax)
148{
149 TArray< complex<r_4> > & box = getRecSrcBox();
150 if ((kfmin < 0) || (kfmin >= box.SizeZ()) || (kfmax < kfmin) || (kfmax >= box.SizeZ()) )
151 throw RangeCheckError("MultiCylinders::getRecXYSlice(kfmin, kfmax)");
152 TMatrix< r_4> rmtx(box.SizeY(), box.SizeX());
153 for(int kf=kfmin; kf<=kfmax; kf++) {
154 for(int jy=0; jy<box.SizeY(); jy++)
155 for(int ix=0; ix<box.SizeX(); ix++)
156 rmtx(jy, ix) += myZmodule(box(ix, jy, kf));
157 }
158 return(rmtx);
159}
Note: See TracBrowser for help on using the repository browser.