1 | // Dominique YVON, CEA/DAPNIA/SPP 02/2000
|
---|
2 |
|
---|
3 | #include <stdio.h>
|
---|
4 | #include <stdlib.h>
|
---|
5 | #include <iostream>
|
---|
6 |
|
---|
7 |
|
---|
8 | #include "makebolotimeline.h"
|
---|
9 | #include "bruit.h"
|
---|
10 | //#include "fitsio.h"
|
---|
11 |
|
---|
12 | #ifdef __MWERKS__
|
---|
13 | #include "dyyield.h"
|
---|
14 | #include "macenvvariables.h"
|
---|
15 | #define SetNlatLSource (256) // version debug
|
---|
16 | #define NbSAMPLE (200000) // Pour le debug
|
---|
17 | #else
|
---|
18 | # define ERROR_LABEL -32768
|
---|
19 | #define SetNlatLSource (1024) // version de production CXX
|
---|
20 | #define NbSAMPLE (2684300)
|
---|
21 | #endif
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 | #include "alllobe.h"
|
---|
26 | #include "alllightsources.h"
|
---|
27 | #include "sigcalctools.h"
|
---|
28 | #include "allfilter.h"
|
---|
29 |
|
---|
30 |
|
---|
31 | int MakeArcheopsTimelines(char FilePointes[]);
|
---|
32 | int GenTimLin1_F(long Nbsample, double TStep, float fknee);
|
---|
33 |
|
---|
34 | int MakeArcheopsTimelines(char FilePointes[])
|
---|
35 | {
|
---|
36 |
|
---|
37 | // On genre des timelines de bruit en 1/f
|
---|
38 | GenTimLin1_F(NbSAMPLE,5.83e-3,1.);
|
---|
39 | GenTimLin1_F(NbSAMPLE,5.83e-3,0.5);
|
---|
40 | GenTimLin1_F(NbSAMPLE,5.83e-3,0.1);
|
---|
41 |
|
---|
42 |
|
---|
43 | // On passe aux cartes de fonds physiques
|
---|
44 | // Initialisations
|
---|
45 | char filename[150]="";
|
---|
46 |
|
---|
47 | // cerr.setf(ios::scientific);
|
---|
48 | cerr<< "C'est parti"<<endl;
|
---|
49 |
|
---|
50 | // Des Lobes
|
---|
51 | LobeGaussien GLobeTrapChan1(8./60.,75.e9,600.e9); //degrs, freqmin, Freqmax
|
---|
52 | LobeGaussien GLobeTrapChan2(8./60.,75.e9,600.e9);
|
---|
53 | LobeGaussien GLobeTrapChan3(8./60.,75.e9,600.e9);
|
---|
54 |
|
---|
55 | #ifndef __MWERKS__
|
---|
56 | /* char* PATHResults=getenv("PATHResults");
|
---|
57 | char* PATHDataLScr=getenv("PATHDataLScr");
|
---|
58 | char* PATHCarteLobe=getenv("PATHCarteLobe");
|
---|
59 | */
|
---|
60 | char* PathInstrumentData=getenv("PathInstrumentData");
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | // Des Filtres
|
---|
64 | sprintf(filename, "%sfiltretrap99chan1.dat",PathInstrumentData);
|
---|
65 | TabulatedFilter FiltreTrapChan1(filename);
|
---|
66 | sprintf(filename, "%sfiltretrap99chan2.dat",PathInstrumentData);
|
---|
67 | TabulatedFilter FiltreTrapChan2(filename);
|
---|
68 | sprintf(filename, "%sfiltretrap99chan3.dat",PathInstrumentData);
|
---|
69 | TabulatedFilter FiltreTrapChan3(filename);
|
---|
70 |
|
---|
71 | /*
|
---|
72 | // On imprime les filtres
|
---|
73 | ofstream Cfilter1("TraceFiltre1", ios::out);
|
---|
74 | FiltreTrapChan1.TraceFiltre(Cfilter1);
|
---|
75 | ofstream Cfilter2("TraceFiltre2", ios::out);
|
---|
76 | FiltreTrapChan2.TraceFiltre(Cfilter2);
|
---|
77 | ofstream Cfilter3("TraceFiltre3", ios::out);
|
---|
78 | FiltreTrapChan3.TraceFiltre(Cfilter3);
|
---|
79 | */
|
---|
80 |
|
---|
81 | // /*
|
---|
82 | // Les Processus Physiques
|
---|
83 | // LightSynchro Synchro(SetNlatLSource); // Pas pour Archeops
|
---|
84 | LightDiffDust DiffDust(SetNlatLSource);
|
---|
85 | LightCMBPrim CMBPrim(SetNlatLSource); // Pour debuter
|
---|
86 | // Le bruit reste chacun de le gnerer
|
---|
87 | LightDipole CMBDipole;
|
---|
88 |
|
---|
89 | // On definit les timeline desirees
|
---|
90 |
|
---|
91 | char fileOut[150];
|
---|
92 |
|
---|
93 | // Bolo 1_1 soit bolo11.
|
---|
94 | sprintf(fileOut, "ASigPred_bolo1_1Dipole");
|
---|
95 | MakeBoloTimeline TL1_1Dipole(fileOut,CMBDipole,GLobeTrapChan1,
|
---|
96 | FiltreTrapChan1,RayleighJeans);
|
---|
97 |
|
---|
98 | sprintf(fileOut, "ASigPred_bolo1_1CMBPrim");
|
---|
99 | MakeBoloTimeline TL1_1CMBPrim(fileOut, CMBPrim,GLobeTrapChan1,
|
---|
100 | FiltreTrapChan1,RayleighJeans);
|
---|
101 |
|
---|
102 | sprintf(fileOut, "ASigPred_bolo1_1DiffDust");
|
---|
103 | MakeBoloTimeline TL1_1DiffDust(fileOut,DiffDust,GLobeTrapChan1,
|
---|
104 | FiltreTrapChan1,RayleighJeans);
|
---|
105 |
|
---|
106 | // Bolo 1_3 soit bolo13.
|
---|
107 | sprintf(fileOut, "ASigPred_bolo1_3Dipole");
|
---|
108 | MakeBoloTimeline TL1_3Dipole(fileOut, CMBDipole,GLobeTrapChan1,
|
---|
109 | FiltreTrapChan1,RayleighJeans);
|
---|
110 |
|
---|
111 | sprintf(fileOut, "ASigPred_bolo1_3CMBPrim");
|
---|
112 | MakeBoloTimeline TL1_3CMBPrim(fileOut, CMBPrim,GLobeTrapChan1,
|
---|
113 | FiltreTrapChan1,RayleighJeans);
|
---|
114 |
|
---|
115 | sprintf(fileOut, "ASigPred_bolo1_3DiffDust");
|
---|
116 | MakeBoloTimeline TL1_3DiffDust(fileOut,DiffDust,GLobeTrapChan1,
|
---|
117 | FiltreTrapChan1,RayleighJeans);
|
---|
118 |
|
---|
119 | // Bolo 2_4 soit bolo9.
|
---|
120 | sprintf(fileOut, "ASigPred_bolo2_4Dipole");
|
---|
121 | MakeBoloTimeline TL2_4Dipole(fileOut, CMBDipole,GLobeTrapChan2,
|
---|
122 | FiltreTrapChan2,RayleighJeans);
|
---|
123 |
|
---|
124 | sprintf(fileOut, "ASigPred_bolo2_4CMBPrim");
|
---|
125 | MakeBoloTimeline TL2_4CMBPrim(fileOut, CMBPrim,GLobeTrapChan2,
|
---|
126 | FiltreTrapChan2,RayleighJeans);
|
---|
127 |
|
---|
128 | sprintf(fileOut, "ASigPred_bolo2_4DiffDust");
|
---|
129 | MakeBoloTimeline TL2_4DiffDust(fileOut,DiffDust,GLobeTrapChan2,
|
---|
130 | FiltreTrapChan2,RayleighJeans);
|
---|
131 |
|
---|
132 | // Bolo 2_5 soit bolo4.
|
---|
133 | sprintf(fileOut, "ASigPred_bolo2_5Dipole");
|
---|
134 | MakeBoloTimeline TL2_5Dipole(fileOut, CMBDipole,GLobeTrapChan2,
|
---|
135 | FiltreTrapChan2,RayleighJeans);
|
---|
136 |
|
---|
137 | sprintf(fileOut, "ASigPred_bolo2_5CMBPrim");
|
---|
138 | MakeBoloTimeline TL2_5CMBPrim(fileOut, CMBPrim,GLobeTrapChan2,
|
---|
139 | FiltreTrapChan2,RayleighJeans);
|
---|
140 |
|
---|
141 | sprintf(fileOut, "ASigPred_bolo2_5DiffDust");
|
---|
142 | MakeBoloTimeline TL2_5DiffDust(fileOut,DiffDust,GLobeTrapChan2,
|
---|
143 | FiltreTrapChan2,RayleighJeans);
|
---|
144 |
|
---|
145 | // Bolo 3_6 soit bolo15.
|
---|
146 | sprintf(fileOut, "ASigPred_bolo3_6Dipole");
|
---|
147 | MakeBoloTimeline TL3_6Dipole(fileOut, CMBDipole,GLobeTrapChan3,
|
---|
148 | FiltreTrapChan3,RayleighJeans);
|
---|
149 |
|
---|
150 | sprintf(fileOut, "ASigPred_bolo3_6CMBPrim");
|
---|
151 | MakeBoloTimeline TL3_6CMBPrim(fileOut, CMBPrim,GLobeTrapChan3,
|
---|
152 | FiltreTrapChan3,RayleighJeans);
|
---|
153 |
|
---|
154 | sprintf(fileOut, "ASigPred_bolo3_6DiffDust");
|
---|
155 | MakeBoloTimeline TL3_6DiffDust(fileOut,DiffDust,GLobeTrapChan3,
|
---|
156 | FiltreTrapChan3,RayleighJeans);
|
---|
157 |
|
---|
158 |
|
---|
159 | // Il faut maintenant lire le fichier des pointages
|
---|
160 |
|
---|
161 | #ifndef __MWERKS__
|
---|
162 | char* PathTimeline=getenv("PathTimeline");
|
---|
163 | #endif
|
---|
164 |
|
---|
165 | char FileName[150];
|
---|
166 | sprintf(FileName, "%s%s",PathTimeline,FilePointes);
|
---|
167 | ifstream InFile(FileName);
|
---|
168 |
|
---|
169 | #ifdef __MWERKS__
|
---|
170 | // Cxx est trop con!
|
---|
171 | if (!InFile.is_open())
|
---|
172 | #else
|
---|
173 | if (!InFile)
|
---|
174 | #endif
|
---|
175 | { cerr<< "Erreur a l'ouverture du fichier de donnees :"<<FileName<< endl;
|
---|
176 | exit(-1);
|
---|
177 | }
|
---|
178 |
|
---|
179 | long SamplNumber;
|
---|
180 | float alphaBolo2_5,deltaBolo2_5, alphaBolo2_4,deltaBolo2_4,
|
---|
181 | alphaBolo1_1,deltaBolo1_1, alphaBolo1_3,deltaBolo1_3,
|
---|
182 | alphaBolo3_6, deltaBolo3_6;
|
---|
183 | char Line[200];
|
---|
184 |
|
---|
185 | int nbParamLu;
|
---|
186 | long compteur=0;
|
---|
187 | // On genre les timelines
|
---|
188 | while(!InFile.eof())
|
---|
189 | {
|
---|
190 | // On lit les directions pointes
|
---|
191 | InFile.getline(Line,200);
|
---|
192 | nbParamLu=sscanf(Line," %d %f %f %f %f %f %f %f %f %f %f",
|
---|
193 | &SamplNumber, &alphaBolo2_5,&deltaBolo2_5, &alphaBolo2_4,&deltaBolo2_4,
|
---|
194 | &alphaBolo1_1,&deltaBolo1_1, &alphaBolo1_3,&deltaBolo1_3,
|
---|
195 | &alphaBolo3_6, &deltaBolo3_6);
|
---|
196 | if (nbParamLu!=11) {
|
---|
197 | cerr<<" Problme a la lecture du fichier: "<<FileName<<endl;
|
---|
198 | cerr<<" Ligne :"<<Line<<endl;
|
---|
199 | }
|
---|
200 | else
|
---|
201 | {
|
---|
202 | // On remplit les fichiers correspondants
|
---|
203 | TL1_1Dipole.addToStreamArchTOI(alphaBolo1_1,deltaBolo1_1);
|
---|
204 | TL1_1CMBPrim.addToStreamArchTOI(alphaBolo1_1,deltaBolo1_1);
|
---|
205 | TL1_1DiffDust.addToStreamArchTOI(alphaBolo1_1,deltaBolo1_1);
|
---|
206 |
|
---|
207 | TL1_3Dipole.addToStreamArchTOI(alphaBolo1_3,deltaBolo1_3);
|
---|
208 | TL1_3CMBPrim.addToStreamArchTOI(alphaBolo1_3,deltaBolo1_3);
|
---|
209 | TL1_3DiffDust.addToStreamArchTOI(alphaBolo1_3,deltaBolo1_3);
|
---|
210 |
|
---|
211 | TL2_4Dipole.addToStreamArchTOI(alphaBolo2_4,deltaBolo2_4);
|
---|
212 | TL2_4CMBPrim.addToStreamArchTOI(alphaBolo2_4,deltaBolo2_4);
|
---|
213 | TL2_4DiffDust.addToStreamArchTOI(alphaBolo2_4,deltaBolo2_4);
|
---|
214 |
|
---|
215 | TL2_5Dipole.addToStreamArchTOI(alphaBolo2_5,deltaBolo2_5);
|
---|
216 | TL2_5CMBPrim.addToStreamArchTOI(alphaBolo2_5,deltaBolo2_5);
|
---|
217 | TL2_5DiffDust.addToStreamArchTOI(alphaBolo2_5,deltaBolo2_5);
|
---|
218 |
|
---|
219 | TL3_6Dipole.addToStreamArchTOI(alphaBolo3_6,deltaBolo3_6);
|
---|
220 | TL3_6CMBPrim.addToStreamArchTOI(alphaBolo3_6,deltaBolo3_6);
|
---|
221 | TL3_6DiffDust.addToStreamArchTOI(alphaBolo3_6,deltaBolo3_6);
|
---|
222 |
|
---|
223 | compteur++;
|
---|
224 |
|
---|
225 | #ifdef __MWERKS__
|
---|
226 | DY_yield();
|
---|
227 | #endif
|
---|
228 |
|
---|
229 | if((compteur%1000)==0)
|
---|
230 | { cout<<"Compteur= "<<compteur<<endl;
|
---|
231 | /* // Version Debug a commenter
|
---|
232 | double pourcent=100.*compteur/NbSAMPLE;
|
---|
233 | cout<<"Travail effectue a :"<<pourcent<<" %"<<endl;
|
---|
234 | */ }
|
---|
235 |
|
---|
236 | if(compteur==NbSAMPLE)
|
---|
237 | { cout<<" Arret sur option de debugging"<<endl; //BUGGG
|
---|
238 | break;
|
---|
239 | }
|
---|
240 | }
|
---|
241 | }
|
---|
242 |
|
---|
243 | #ifndef __MWERKS__
|
---|
244 | char* PATHResults=getenv("PATHResults");
|
---|
245 | #endif
|
---|
246 |
|
---|
247 | char filecur[150];
|
---|
248 |
|
---|
249 | // On remplit le ReadMe
|
---|
250 | sprintf(filecur,"%sArchSigPredTimeLineReadMe",PATHResults);
|
---|
251 | ofstream ReadMe(filecur, ios::out|ios::trunc);
|
---|
252 |
|
---|
253 | ReadMe<<"Files containning timeline stream"<<endl;
|
---|
254 | ReadMe<<"Generated using ArchSignalPredictor, D. Yvon /03/2000"<<endl;
|
---|
255 | ReadMe<<"Templates used: as provided by R. Teyssier"<<endl;
|
---|
256 | ReadMe<<"Resolution of computation: "<< SetNlatLSource <<" Nlat Healpix"<< endl;
|
---|
257 | ReadMe<<"Number of consecutive samples generated:"<<compteur<<endl;
|
---|
258 | ReadMe<<"Samples with undefined pointing skipped."<<endl;
|
---|
259 | ReadMe<<"Dominique Yvon, DAPNIA/SPP, 03/2000"<<endl;
|
---|
260 | ReadMe.close(); // J'espere que c'est assez
|
---|
261 |
|
---|
262 | return 0;
|
---|
263 | }
|
---|
264 |
|
---|
265 | #include "fitstarray.h"
|
---|
266 |
|
---|
267 | int GenTimLin1_F(long Nbsample, double TStep, float fknee)
|
---|
268 | {
|
---|
269 | #ifndef __MWERKS__
|
---|
270 | char* PATHResults=getenv("PATHResults");
|
---|
271 | #endif
|
---|
272 |
|
---|
273 | char filecur[150];
|
---|
274 |
|
---|
275 | // On remplit le ReadMe
|
---|
276 | sprintf(filecur,"%sTimLineNoisetot%2.2fReadMe", PATHResults,fknee);
|
---|
277 | ofstream ReadMe(filecur, ios::out|ios::trunc);
|
---|
278 |
|
---|
279 | ReadMe<<"File containning noise timeline"<<endl;
|
---|
280 | ReadMe<<"Generated using SumNoise et Memnoise of F. Couchot and R. Ansari"<<endl;
|
---|
281 | ReadMe<<"Generation of a white noise of sigma=1."<<" Any unit"<<endl;
|
---|
282 | ReadMe<<"1/f noise added with knee frequency :"<< fknee<<" Hz"<< endl;
|
---|
283 | ReadMe<<"Timestep for generation: "<<TStep<<" Second"<<endl;
|
---|
284 | ReadMe<<"Number of consecutive samples generated:"<<Nbsample<<endl;
|
---|
285 | ReadMe<<"Dominique Yvon, DAPNIA/SPP, 03/2000"<<endl;
|
---|
286 |
|
---|
287 | ReadMe.close(); // J'espere que c'est assez
|
---|
288 |
|
---|
289 | // On bosse
|
---|
290 | SumNoise NoiseGen(fknee);
|
---|
291 |
|
---|
292 | TVector<float> Array(Nbsample);
|
---|
293 | cout<< " vous avez reserv un espace memoire de :"<<Nbsample*sizeof(float)<<endl;
|
---|
294 | for(int i=0; i<Nbsample; i++)
|
---|
295 | { Array(i)= NoiseGen.Noise();
|
---|
296 | if((i%1000)==0) {
|
---|
297 | cout<<"GenTimLin1_F, i= "<< i <<endl;
|
---|
298 | }
|
---|
299 | }
|
---|
300 |
|
---|
301 | // Write my fitFile, Version avec FitsIOServer
|
---|
302 | sprintf(filecur,"%sTimLineNoisetot%2.2f.fits",PATHResults,fknee);/* name for new FITS file */
|
---|
303 | FITS_TArray <float> FTArray(Array);
|
---|
304 | FTArray.Write(filecur);
|
---|
305 |
|
---|
306 | return 0;
|
---|
307 | } |
---|