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

Last change on this file since 1437 was 1437, checked in by ansari, 25 years ago

Protections diverses dans TOIProcessor et FITSTOIReader/Writer
Ajout d'un TOI (TOISeqBuffered) avec gestion d'un buffer entre put/get
Ajout de processeurs de test (RZTOIProc...) , programme test associe
et SMakefile (pour compil avec SOPHYA)

Reza 12/3/2001

File size: 4.1 KB
RevLine 
[1437]1#include "rztoi.h"
2#include "toimanager.h"
3#include "pexceptions.h"
4#include "fftpserver.h"
5#include "timing.h"
6
7RzTOIProc::RzTOIProc(int w1, int w2, int nmax)
8{
9 cout << "RzTOIProc::RzTOIProc() Width= " << w1 << "," << w2 << " NMax=" << nmax;
10 _width1 = w1;
11 _width2 = w2;
12 _nmax = nmax;
13}
14
15void RzTOIProc::init() {
16 cout << "RzTOIProc::init" << endl;
17 declareInput("signal");
18 declareOutput("sfout");
19 name = "rzproc";
20 upExtra = 1;
21}
22
23void RzTOIProc::run() {
24 // TOIManager* mgr = TOIManager::getManager();
25 int snb = getMinIn();
26 int sne = getMaxIn();
27
28 int istart, iend;
29 int ilast;
30 ilast = istart = snb;
31 iend = sne;
32 int ii, jj;
33
34 try {
35
36 FFTPackServer ffts;
37
38 bool fgppf = false;
39 int nkv = 0;
40 int nkvmx = 8;
41 Vector vkin[nkvmx];
42 Vector vkout[nkvmx];
43 TVector< complex<r_8> > vkfft[nkvmx];
44 if (outppf.length() > 0) fgppf = true;
45
46 Vector vin, vout;
47 TVector< complex<r_8> > vfft;
48
49 for (int k=0; k<_nmax; k++) {
50 istart = snb + k*_width1;
51 // if (k>0) istart -= _width2;
52 iend = istart +_width1;
53 cout << " RzTOIProc::run() - Processing bloc k= " << k
54 << " istart= " << istart << " iend= " << iend << endl;
55 if (iend > sne) {
56 cout << " RzTOIProc::run() - iend > getMaxIn() -> break " << endl;
57 break;
58 }
59 // Vector vin = getData(0, istart, iend);
60 vin.ReSize(_width1);
61 jj = 0;
62 for(ii=istart; ii<iend; ii++)
63 vin(jj++) = getData(0, ii);
64
65 cout << " End of getData() for bloc " << k << endl;
66
67 vout.ReSize(vin.Size());
68 double vlast = 0.;
69 for(int i=0; i<vout.Size()-_width2; i++) {
70 vout(i) = vin(Range(i,-1,_width2)).Sum()/(r_8)_width2;
71 putData(0, i+istart, vout(i));
72 vlast = vout(i);
73 }
74
75 for(int i=vout.Size()-_width2; i<vout.Size(); i++) {
76 vout(i) = vlast;
77 putData(0, i+istart, vout(i));
78 }
79
80 cout << " End of putData() for bloc " << k << " Mean vout= "
81 << vout.Sum()/vout.Size() << endl;
82
83 vin -= vout;
84
85 TVector< complex<r_8> > vfft;
86 ffts.FFTForward(vin, vfft);
87 ilast = iend;
88 /*
89 if (fgppf) {
90 string nom;
91 nom = "in" + (string)MuTyV(k);
92 ppo->PutObject(vin, nom);
93 nom = "out" + (string)MuTyV(k);
94 ppo->PutObject(vout, nom);
95 nom = "fft" + (string)MuTyV(k);
96 ppo->PutObject(vfft, nom);
97 }
98 */
99 if (fgppf && (nkv < nkvmx) ) {
100 vkin[nkv] = vin;
101 vkout[nkv] = vout;
102 vkfft[nkv] = vfft;
103 nkv++;
104 }
105 PrtTim("End of bloc");
106 }
107
108 if (fgppf) {
109 cout << " Writing to Out PPF ... " << endl;
110 POutPersist ppo(outppf);
111 for(int kkk=0; kkk<nkv; kkk++) {
112 string nom;
113 nom = "in" + (string)MuTyV(kkk);
114 ppo.PutObject(vkin[kkk], nom);
115 nom = "out" + (string)MuTyV(kkk);
116 ppo.PutObject(vkout[kkk], nom);
117 nom = "fft" + (string)MuTyV(kkk);
118 ppo.PutObject(vkfft[kkk], nom);
119 }
120 }
121
122 cout << " Filling -9999 : putData(0, ii, -9999.) ii: "
123 << iend << " .. " << sne << endl;
124 double xxx;
125 for(ii=iend; ii<sne; ii++) {
126 if ((ii-iend)%1000 == 0)
127 cout << " RzTOIProc::run() - Processing sample ii= " << ii
128 << endl;
129 xxx=getData(0,ii);
130 putData(0,ii,xxx-9999.);
131 }
132
133 }
134 catch (PException & e) {
135 cout << "RzTOIProc exception Msg= " << e.Msg() << endl;
136 }
137}
138
139
140
141RzSimpleTOIProc::RzSimpleTOIProc(double fact, int npr)
142{
143 cout << "RzSimpleTOIProc::RzSimpleTOIProc() factor= " << fact
144 << " npr=" << npr << endl;
145 _fact = fact;
146 _nprt = npr;
147}
148
149void RzSimpleTOIProc::init() {
150 cout << "RzSimpleTOIProc::init" << endl;
151 declareInput("signal");
152 declareOutput("sfout");
153 name = "rzsimpleproc";
154 upExtra = 1;
155}
156
157void RzSimpleTOIProc::run() {
158 // TOIManager* mgr = TOIManager::getManager();
159 int snb = getMinIn();
160 int sne = getMaxIn();
161
162 cout << " RzSimpleTOIProc::run(): snb=" << snb << " sne=" << sne << endl;
163
164 double val;
165 try {
166 for (int k=snb; k<sne; k++) {
167 if ((k-snb)%_nprt == 0)
168 cout << " RzSimpleTOIProc::run() - Processing sample k= " << k
169 << endl;
170
171 val = getData(0, k);
172 putData(0, k, val*_fact);
173 }
174 }
175 catch (PException & e) {
176 cout << "RzSimpleTOIProc exception Msg= " << e.Msg() << endl;
177 }
178}
Note: See TracBrowser for help on using the repository browser.