source: Sophya/trunk/ArchTOIPipe/TestPipes/sfftc.cc@ 1633

Last change on this file since 1633 was 1485, checked in by ansari, 24 years ago

Ajout de sfftc.cc , test de SimpleFourierFilter - Reza 30/4/2001

File size: 5.9 KB
Line 
1/* Test de processeurs ds simtoipr.cc - Reza Avril 2001
2
3---------------- Exemple d'appel ---------------------
4csh> sfftc -start 104385384 -end 104399964
5 -intoi boloMuV_27 -wtoi 8192 -wfft 4096 inputbolo.fits sfftc.fits sfftc.ppf
6*/
7
8
9
10#include "machdefs.h"
11#include <math.h>
12#include "array.h"
13#include <unistd.h>
14#include <stdexcept>
15#include "toi.h"
16#include "toiprocessor.h"
17#include "fitstoirdr.h"
18#include "fitstoiwtr.h"
19#include "toimanager.h"
20#include "simtoipr.h"
21#include "toiseqbuff.h"
22#include "timing.h"
23#include "sambainit.h"
24
25void Usage(bool fgerr)
26{
27 cout << endl;
28 if (fgerr) {
29 cout << " sfftc : Argument Error ! sfftc -h for usage " << endl;
30 exit(1);
31 }
32 else {
33 cout << "\n Usage : sfftc [-dbg] [-start snb] [-end sne] \n"
34 << " [-wtoi sz] [-wfft sz] [-keepfft n] \n"
35 << " inFitsName outFitsName outPPFName \n"
36 << " -dbg : sets TOISeqBuffered debug level to 1 \n"
37 << " -start snb : sets the start sample num \n"
38 << " -end sne : sets the end sample num \n"
39 << " -intoi toiName : select input TOI name (def boloMuV_27)\n"
40 << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n"
41 << " -wfft sz : sets Fourier filter width \n"
42 << " -keepfft n : Keeps n spectra \n"
43 << endl;
44 exit(0);
45 }
46}
47
48int main(int narg, char** arg) {
49
50 if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
51
52 cout << "sfftc starting - Decoding arguments " << " narg=" << narg << endl;
53
54 bool fgdbg = false;
55 bool fgsetstart = false;
56 int wtoi = 8192;
57 int wfft = 4096;
58 int keepfft = 0;
59 int nmax = 10;
60 int istart = 0;
61 int iend = 0;
62 string infile;
63 string outfile;
64 string outppfname;
65 string intoi = "boloMuV_27";
66
67 if (narg < 4) Usage(true);
68 int ko=1;
69 // decoding arguments
70 for(int ia=1; ia<narg; ia++) {
71 if (strcmp(arg[ia],"-start") == 0) {
72 if (ia == narg-1) Usage(true); // -start est suivi d'un argument
73 istart = atoi(arg[ia+1]); ia++;
74 fgsetstart = true;
75 }
76 else if (strcmp(arg[ia],"-end") == 0) {
77 if (ia == narg-1) Usage(true);
78 iend = atoi(arg[ia+1]); ia++;
79 }
80 else if (strcmp(arg[ia],"-wtoi") == 0) {
81 if (ia == narg-1) Usage(true);
82 wtoi = atoi(arg[ia+1]); ia++;
83 }
84 else if (strcmp(arg[ia],"-wfft") == 0) {
85 if (ia == narg-1) Usage(true);
86 wfft = atoi(arg[ia+1]); ia++;
87 }
88 else if (strcmp(arg[ia],"-keepfft") == 0) {
89 if (ia == narg-1) Usage(true);
90 keepfft = atoi(arg[ia+1]); ia++;
91 }
92 else if (strcmp(arg[ia],"-intoi") == 0) {
93 if (ia == narg-1) Usage(true);
94 intoi = arg[ia+1]; ia++;
95 }
96 else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true;
97
98 else { ko = ia; break; } // Debut des noms
99 }
100
101 if (iend < istart) iend = istart+wtoi*(nmax+5);
102 if ((narg-ko) < 3) Usage(true);
103 infile = arg[ko];
104 outfile = arg[ko+1];
105 outppfname = arg[ko+2];
106
107 cout << " Initializing SOPHYA ... " << endl;
108 SophyaInit();
109 InitTim();
110
111 cout << ">>>> sfftc: Infile= " << infile << " outFile="
112 << outfile << endl;
113 cout << ">>>> Window Size WTOI= " << wtoi << " WFFT= " << wfft
114 << " iStart= " << istart << " iEnd= " << iend << endl;
115 cout << ">>>> InTOIName= " << intoi << endl;
116
117 try {
118 TOIManager* mgr = TOIManager::getManager();
119
120 // mgr->setRequestedSample(11680920,11710584);
121 // mgr->setRequestedSample(104121000, 104946120);
122 if (fgsetstart)
123 mgr->setRequestedSample(istart, iend);
124
125 // FITSTOIReader r("/data/Archeops/bolo11.fits);
126 FITSTOIReader r(infile);
127 cout << "reader created" << endl;
128 // FITSTOIWriter w("/data/Archeops/rz.fits");
129 FITSTOIWriter w(outfile);
130 cout << "fits writer created" << endl;
131
132
133 int w1 = wtoi;
134 TOISeqBuffered * toiin = new TOISeqBuffered("f2in", w1);
135 if (fgdbg) toiin->setDebugLevel(1);
136 TOISeqBuffered * toiout = new TOISeqBuffered("out", w1);
137 if (fgdbg) toiout->setDebugLevel(1);
138 TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1);
139 if (fgdbg) toiincopie->setDebugLevel(1);
140
141
142 cout << " Connecting to FitsReader ... " << endl;
143 r.addOutput(intoi, toiin);
144
145 Vector fcoef(wfft/2);
146 fcoef = RegularSequence(1., -2./wfft);
147 cout << " Creating Fourier Filter ... " << endl;
148 SimpleFourierFilter sfft(fcoef);
149 sfft.KeepSpectra(outppfname, keepfft);
150 cout << " Connecting Fourier Filter ... " << endl;
151 sfft.addInput("in",toiin);
152 sfft.addOutput("out", toiout);
153 sfft.addOutput("incopie", toiincopie);
154
155 cout << " Connecting to output (FitsWriter) " << endl;
156
157 // w.setOutFlags(true);
158 w.addInput("in", toiincopie);
159 w.addInput("out", toiout);
160
161
162 cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
163 r.PrintStatus(cout);
164 cout << " ------ SimpleFourierFilter::PrintStatus() : ----- " << endl;
165 sfft.PrintStatus(cout);
166 cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
167 w.PrintStatus(cout);
168
169 PrtTim("starting threads");
170 r.start();
171 sfft.start();
172 w.start();
173
174 /*
175 for(int jj=0; jj<3; jj++) {
176 cout << *toiin;
177 cout << *toiout;
178 cout << *toiincopie;
179 sleep(1);
180 }
181 */
182
183
184
185 mgr->joinAll();
186 PrtTim("End threads");
187
188 // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
189 // r.PrintStatus(cout);
190 // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
191 // w.PrintStatus(cout);
192
193 cout << " ------ toiin, toiout and toiincopie Status information ------- " << endl;
194 cout << *toiin;
195 cout << *toiout;
196 cout << *toiincopie;
197
198 cout << sfft ;
199
200 }
201 catch (PThrowable & exc) {
202 cerr << "\n sfftc: Catched Exception \n" << (string)typeid(exc).name()
203 << " - Msg= " << exc.Msg() << endl;
204 }
205 catch (const std::exception & sex) {
206 cerr << "\n sfftc: Catched std::exception \n"
207 << (string)typeid(sex).name() << endl;
208 }
209 catch (...) {
210 cerr << "\n sfftc: some other exception was caught ! " << endl;
211 }
212
213 return(0);
214}
Note: See TracBrowser for help on using the repository browser.