source: Sophya/trunk/ArchTOIPipe/ProcWSophya/rztoi.cc@ 1730

Last change on this file since 1730 was 1476, checked in by ansari, 24 years ago

compil/portage SGI-CC - Reza 23/4/2001

File size: 5.6 KB
Line 
1#include "array.h"
2#include "rztoi.h"
3#include "toimanager.h"
4#include "pexceptions.h"
5#include "fftpserver.h"
6#include "ctimer.h"
7
8RzTOIProc::RzTOIProc(int w1, int w2, int nmax)
9{
10 cout << "RzTOIProc::RzTOIProc() Width= " << w1 << "," << w2 << " NMax=" << nmax;
11 _width1 = w1;
12 _width2 = w2;
13 _nmax = nmax;
14}
15
16void RzTOIProc::init() {
17 cout << "RzTOIProc::init" << endl;
18 declareInput("in");
19 declareOutput("out");
20 name = "rzproc";
21 upExtra = 1;
22}
23
24void RzTOIProc::run() {
25 // TOIManager* mgr = TOIManager::getManager();
26 int snb = getMinIn();
27 int sne = getMaxIn();
28
29 int istart, iend;
30 int ilast;
31 ilast = istart = snb;
32 iend = sne;
33 int ii, jj;
34
35 try {
36 Timer tm("RzTOIProc::run()");
37
38 FFTPackServer ffts;
39
40 bool fgppf = false;
41 int nkv = 0;
42 // int nkvmx = 8;
43#define nkvmx 8
44 Vector vkin[nkvmx];
45 Vector vkout[nkvmx];
46 TVector< complex<r_8> > vkfft[nkvmx];
47 if (outppf.length() > 0) fgppf = true;
48
49 Vector vin, vout, vsave(_width2);
50 TVector< complex<r_8> > vfft;
51 double vlast = 0.;
52
53 for (int k=0; k<_nmax; k++) {
54 // istart = snb + k*_width1;
55 istart = snb + k*_width1 - k*_width2;
56 iend = istart +_width1;
57 cout << "---RzTOIProc::run() - Processing bloc k= " << k
58 << " istart= " << istart << " iend= " << iend << endl;
59 if (iend > sne) {
60 cout << " RzTOIProc::run() - iend > getMaxIn() -> break " << endl;
61 break;
62 }
63 // Vector vin = getData(0, istart, iend);
64 vin.ReSize(_width1);
65 if (k == 0) {
66 jj = 0;
67 for(ii=istart; ii<iend; ii++)
68 vin(jj++) = getData(0, ii);
69 }
70 else {
71 vin(Range(0,-1,_width2)) = vsave;
72 jj = _width2;
73 for(ii=istart+_width2; ii<iend; ii++)
74 vin(jj++) = getData(0, ii);
75 }
76
77 vsave = vin(Range(_width1-_width2, -1,_width2));
78 cout << "> End of getData() for bloc " << k << endl;
79
80 vout.ReSize(vin.Size());
81 // cout << " DBG : Bloc[" << k << "] FirstSN=" << istart
82 // << " LastSN= " << istart+vout.Size()-_width2-1 << endl;
83 int i;
84 for(i=0; i<vout.Size()-_width2; i++) {
85 vout(i) = vin(Range(i,-1,_width2)).Sum()/(r_8)_width2;
86 putData(0, i+istart, vout(i));
87 vlast = vout(i);
88 }
89
90 for(i=vout.Size()-_width2; i<vout.Size(); i++) {
91 vout(i) = vlast;
92 // putData(0, i+istart, vout(i));
93 }
94
95 cout << ">> End of putData() for bloc[" << k << "] FirstSN="
96 << istart << " LastSN= " << istart+vout.Size()-_width2-1
97 << " Mean vout= " << vout.Sum()/vout.Size() << endl;
98
99 vin -= vout;
100
101 TVector< complex<r_8> > vfft;
102 ffts.FFTForward(vin, vfft);
103 ilast = iend;
104 /*
105 if (fgppf) {
106 string nom;
107 nom = "in" + (string)MuTyV(k);
108 ppo->PutObject(vin, nom);
109 nom = "out" + (string)MuTyV(k);
110 ppo->PutObject(vout, nom);
111 nom = "fft" + (string)MuTyV(k);
112 ppo->PutObject(vfft, nom);
113 }
114 */
115 if (fgppf && (nkv < nkvmx) ) {
116 vkin[nkv] = vin;
117 vkout[nkv] = vout;
118 vkfft[nkv] = vfft;
119 nkv++;
120 }
121
122 tm.Split("End of bloc");
123 }
124
125 if (fgppf) {
126 cout << " Writing to Out PPF ... " << endl;
127 POutPersist ppo(outppf);
128 for(int kkk=0; kkk<nkv; kkk++) {
129 string nom;
130 nom = "in" + (string)MuTyV(kkk);
131 ppo.PutObject(vkin[kkk], nom);
132 nom = "out" + (string)MuTyV(kkk);
133 ppo.PutObject(vkout[kkk], nom);
134 nom = "fft" + (string)MuTyV(kkk);
135 ppo.PutObject(vkfft[kkk], nom);
136 }
137 }
138
139 cout << " Filling with flag!=0 : putData(0, ii, flag) ii: "
140 << iend << " .. " << sne << endl;
141 for(ii=iend-_width2; ii<iend; ii++) {
142 putData(0, ii, vlast, 1);
143 }
144
145 double xxx;
146 for(ii=iend; ii<sne; ii++) {
147 if ((ii-iend)%1000 == 0)
148 cout << " RzTOIProc::run() - Processing sample ii= " << ii
149 << endl;
150 xxx=getData(0,ii);
151 putData(0,ii,xxx,2);
152 }
153
154 }
155 catch (PException & e) {
156 cout << "RzTOIProc: Catched exception " << (string)typeid(e).name()
157 << "\n Msg= " << e.Msg() << endl;
158 }
159}
160
161
162
163RzSimpleTOIProc::RzSimpleTOIProc(int wsz, double fact)
164{
165 if (wsz < 4) wsz = 4;
166 cout << "RzSimpleTOIProc::RzSimpleTOIProc() factor= " << fact
167 << " WSize=" << wsz << endl;
168 _fact = fact;
169 _wsz = wsz;
170}
171
172void RzSimpleTOIProc::init() {
173 cout << "RzSimpleTOIProc::init" << endl;
174 declareInput("in");
175 declareOutput("out");
176 name = "rzsimpleproc";
177 upExtra = 1;
178}
179
180void RzSimpleTOIProc::run() {
181 // TOIManager* mgr = TOIManager::getManager();
182 int snb = getMinIn();
183 int sne = getMaxIn();
184
185 int nstot = sne-snb;
186 int nbloc = nstot/_wsz;
187 cout << " RzSimpleTOIProc::run(): snb=" << snb << " sne="
188 << sne << " NBloc=" << nbloc << endl;
189
190 double val;
191 int snlast = snb;
192 int istart,ii,kb;
193 try {
194 Timer tm("RzSimpleTOIProc::run()");
195 Vector vin(_wsz);
196 for (kb=0; kb<nbloc; kb++) {
197 istart = kb*_wsz+snb;
198 if (kb%2 == 0) { // On parcourt a l'envers
199 cout << " ... Processing bloc[" << kb << "] (Reverse) SampleNum="
200 << istart+_wsz << " ->" << istart << endl;
201 for(ii=_wsz-1; ii>=0; ii--)
202 vin(ii) = getData(0, ii+istart);
203 }
204 else { // On parcourt vers l'avant
205 cout << " ... Processing bloc[" << kb << "] SampleNum="
206 << istart << " ->" << istart+_wsz << endl;
207 for(ii=0; ii<_wsz; ii++)
208 vin(ii) = getData(0, ii+istart);
209 }
210 for(ii=0; ii<_wsz; ii++)
211 putData(0, ii+istart, vin(ii)*_fact);
212 snlast = istart+_wsz;
213 }
214 cout << " ... Processing remaining Samples - SN="
215 << snlast << " ->" << sne << endl;
216 for(ii=snlast; ii<=sne; ii++) {
217 val = getData(0, ii);
218 putData(0, ii, val*_fact);
219 }
220
221
222 }
223 catch (PException & e) {
224 cout << "RzSimpleTOIProc exception " << (string)typeid(e).name()
225 << "\n Msg= " << e.Msg() << endl;
226 }
227}
Note: See TracBrowser for help on using the repository browser.