1 | #include "spherethetaphi.h"
|
---|
2 | #include "nbmath.h"
|
---|
3 | #include <complex>
|
---|
4 | #include "piocmplx.h"
|
---|
5 | #include <iostream.h>
|
---|
6 |
|
---|
7 |
|
---|
8 | //***************************************************************
|
---|
9 | //++
|
---|
10 | // Class SphereThetaPhi
|
---|
11 | //
|
---|
12 | //
|
---|
13 | // include spherethetaphi.h nbmath.h
|
---|
14 | //
|
---|
15 | // Découpage de la sphère selon theta et phi, chaque
|
---|
16 | // hémisphère étant découpé en (m-1) parallèles (l'équateur compte pour du
|
---|
17 | // beurre), chacune des m bandes de theta ainsi définies étant découpée par
|
---|
18 | // des méridiens équirepartis, ce découpage étant fait de sorte que tous
|
---|
19 | // les pixels aient la même surface et soient le plus carré possible.
|
---|
20 | // On commence par découper l'hémisphère de z positif en partant du pôle et
|
---|
21 | // en allant vers l'équateur. Le premier pixel est la calotte polaire,
|
---|
22 | // il est circulaire et centré sur theta=0.
|
---|
23 | //--
|
---|
24 | //++
|
---|
25 | //
|
---|
26 | // Links Parents
|
---|
27 | //
|
---|
28 | // SphericalMap
|
---|
29 | //--
|
---|
30 | //++
|
---|
31 | //
|
---|
32 | // Links Descendants
|
---|
33 | //
|
---|
34 | //
|
---|
35 | //--
|
---|
36 |
|
---|
37 | /* --Methode-- */
|
---|
38 | //++
|
---|
39 | // Titre Constructeurs
|
---|
40 | //--
|
---|
41 | //++
|
---|
42 |
|
---|
43 | template <class T>
|
---|
44 | SphereThetaPhi<T>::SphereThetaPhi()
|
---|
45 |
|
---|
46 | //--
|
---|
47 | {
|
---|
48 | InitNul();
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | /* --Methode-- */
|
---|
53 |
|
---|
54 | //++
|
---|
55 | template <class T>
|
---|
56 | SphereThetaPhi<T>::SphereThetaPhi(int m)
|
---|
57 |
|
---|
58 | // Constructeur : m est le nombre de bandes en theta sur un hémisphère
|
---|
59 | // (la calotte constituant la premiere bande).
|
---|
60 | // pet est le nombre de pixels (pétales) de la bande en contact avec la
|
---|
61 | // calotte polaire. Pour l'instant pet est inopérant!
|
---|
62 | //--
|
---|
63 | {
|
---|
64 | InitNul();
|
---|
65 | Pixelize(m);
|
---|
66 | }
|
---|
67 |
|
---|
68 | template <class T>
|
---|
69 | SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s)
|
---|
70 | {
|
---|
71 | if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
|
---|
72 | NTheta_= s.NTheta_;
|
---|
73 | NPix_ = s.NPix_;
|
---|
74 | NPhi_ = new int[NTheta_];
|
---|
75 | Theta_ = new double[NTheta_+1];
|
---|
76 | TNphi_ = new int[NTheta_+1];
|
---|
77 | for(int k = 0; k < NTheta_; k++)
|
---|
78 | {
|
---|
79 | NPhi_[k] = s.NPhi_[k];
|
---|
80 | Theta_[k]= s.Theta_[k];
|
---|
81 | TNphi_[k]= s.TNphi_[k];
|
---|
82 | }
|
---|
83 | Theta_[NTheta_]= s.Theta_[NTheta_];
|
---|
84 | TNphi_[NTheta_]= s.TNphi_[NTheta_];
|
---|
85 | Omega_ = s.Omega_;
|
---|
86 | pixels_= s.pixels_;
|
---|
87 | }
|
---|
88 |
|
---|
89 | //++
|
---|
90 | // Titre Destructeur
|
---|
91 | //--
|
---|
92 | //++
|
---|
93 | template <class T>
|
---|
94 | SphereThetaPhi<T>::~SphereThetaPhi()
|
---|
95 |
|
---|
96 | //--
|
---|
97 | {
|
---|
98 | Clear();
|
---|
99 | }
|
---|
100 |
|
---|
101 | //++
|
---|
102 | // Titre Méthodes
|
---|
103 | //--
|
---|
104 | template <class T>
|
---|
105 | void SphereThetaPhi<T>::InitNul()
|
---|
106 | //
|
---|
107 | // initialise à zéro les variables de classe pointeurs
|
---|
108 | {
|
---|
109 | NTheta_= 0;
|
---|
110 | NPix_ = 0;
|
---|
111 | Theta_ = NULL;
|
---|
112 | NPhi_ = NULL;
|
---|
113 | TNphi_ = NULL;
|
---|
114 | pixels_.Reset();
|
---|
115 | }
|
---|
116 |
|
---|
117 | /* --Methode-- */
|
---|
118 | template <class T>
|
---|
119 | void SphereThetaPhi<T>::Clear()
|
---|
120 |
|
---|
121 | {
|
---|
122 | if(Theta_) delete[] Theta_;
|
---|
123 | if(NPhi_ ) delete[] NPhi_;
|
---|
124 | if(TNphi_) delete[] TNphi_;
|
---|
125 | InitNul();
|
---|
126 | }
|
---|
127 |
|
---|
128 | //++
|
---|
129 | template <class T>
|
---|
130 | void SphereThetaPhi<T>::Resize(int m)
|
---|
131 | // re-pixelize the sphere
|
---|
132 | //--
|
---|
133 | {
|
---|
134 | Clear();
|
---|
135 | Pixelize(m);
|
---|
136 | }
|
---|
137 |
|
---|
138 | /* --Methode-- */
|
---|
139 | //++
|
---|
140 | template <class T>
|
---|
141 | int SphereThetaPhi<T>::NbPixels() const
|
---|
142 |
|
---|
143 | // Retourne le nombre de pixels du découpage
|
---|
144 | //--
|
---|
145 | {
|
---|
146 | return(NPix_);
|
---|
147 | }
|
---|
148 |
|
---|
149 | /* --Methode-- */
|
---|
150 | //++
|
---|
151 | template <class T>
|
---|
152 | T& SphereThetaPhi<T>::PixVal(int k)
|
---|
153 |
|
---|
154 | // Retourne la valeur du contenu du pixel d'indice k
|
---|
155 | //--
|
---|
156 | {
|
---|
157 | if((k < 0) || (k >= NPix_))
|
---|
158 | {
|
---|
159 | //THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range"));
|
---|
160 | cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl;
|
---|
161 | THROW(rangeCheckErr);
|
---|
162 | }
|
---|
163 | return pixels_(k);
|
---|
164 | }
|
---|
165 |
|
---|
166 | //++
|
---|
167 | template <class T>
|
---|
168 | T const& SphereThetaPhi<T>::PixVal(int k) const
|
---|
169 |
|
---|
170 | // Retourne la valeur du contenu du pixel d'indice k
|
---|
171 | //--
|
---|
172 | {
|
---|
173 | if((k < 0) || (k >= NPix_))
|
---|
174 | {
|
---|
175 | cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl;
|
---|
176 | //THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range"));
|
---|
177 | throw "SphereThetaPhi::PIxVal Pixel index out of range";
|
---|
178 | }
|
---|
179 | return *(pixels_.Data()+k);
|
---|
180 | }
|
---|
181 |
|
---|
182 | /* --Methode-- */
|
---|
183 | //++
|
---|
184 | template <class T>
|
---|
185 | int SphereThetaPhi<T>::PixIndexSph(double theta, double phi) const
|
---|
186 |
|
---|
187 | // Retourne l'indice du pixel vers lequel pointe une direction définie par
|
---|
188 | // ses coordonnées sphériques
|
---|
189 | //--
|
---|
190 | {
|
---|
191 | double dphi;
|
---|
192 | int i,j,k;
|
---|
193 | bool fgzn = false;
|
---|
194 |
|
---|
195 | if((theta > Pi) || (theta < 0.)) return(-1);
|
---|
196 | if((phi < 0.) || (phi > DeuxPi)) return(-1);
|
---|
197 | if(theta > Pi*0.5) {fgzn = true; theta = Pi-theta;}
|
---|
198 |
|
---|
199 | // La bande d'indice kt est limitée par les valeurs de theta contenues dans
|
---|
200 | // Theta_[kt] et Theta_[kt+1]
|
---|
201 | for( i=1; i< NTheta_; i++ )
|
---|
202 | if( theta < Theta_[i] ) break;
|
---|
203 |
|
---|
204 | dphi= DeuxPi/(double)NPhi_[i-1];
|
---|
205 |
|
---|
206 | if (fgzn) k= NPix_-TNphi_[i]+(int)(phi/dphi);
|
---|
207 | else k= TNphi_[i-1]+(int)(phi/dphi);
|
---|
208 | return(k);
|
---|
209 | }
|
---|
210 |
|
---|
211 | /* --Methode-- */
|
---|
212 | //++
|
---|
213 | template <class T>
|
---|
214 | void SphereThetaPhi<T>::PixThetaPhi(int k,double& theta,double& phi) const
|
---|
215 |
|
---|
216 | // Retourne les coordonnées (theta,phi) du milieu du pixel d'indice k
|
---|
217 | //--
|
---|
218 | {
|
---|
219 | int i;
|
---|
220 | bool fgzn = false;
|
---|
221 |
|
---|
222 | if((k < 0) || (k >= NPix_)) {theta = -99999.; phi = -99999.; return; }
|
---|
223 | if( k >= NPix_/2) {fgzn = true; k = NPix_-1-k;}
|
---|
224 |
|
---|
225 | // recupère l'indice i de la tranche qui contient le pixel k
|
---|
226 | for( i=0; i< NTheta_; i++ )
|
---|
227 | if( k < TNphi_[i+1] ) break;
|
---|
228 |
|
---|
229 | // angle theta
|
---|
230 | theta= 0.5*(Theta_[i]+Theta_[i+1]);
|
---|
231 | if (fgzn) theta= Pi-theta;
|
---|
232 |
|
---|
233 | // angle phi
|
---|
234 | k -= TNphi_[i];
|
---|
235 | phi= DeuxPi/(double)NPhi_[i]*(double)(k+.5);
|
---|
236 | if (fgzn) phi= DeuxPi-phi;
|
---|
237 | }
|
---|
238 |
|
---|
239 | //++
|
---|
240 | template <class T>
|
---|
241 | double SphereThetaPhi<T>::PixSolAngle(int dummy) const
|
---|
242 |
|
---|
243 | // Pixel Solid angle (steradians)
|
---|
244 | // All the pixels have the same solid angle. The dummy argument is
|
---|
245 | // for compatibility with eventual pixelizations which would not
|
---|
246 | // fulfil this requirement.
|
---|
247 | //--
|
---|
248 | {
|
---|
249 | return Omega_;
|
---|
250 | }
|
---|
251 |
|
---|
252 | /* --Methode-- */
|
---|
253 | //++
|
---|
254 | template <class T>
|
---|
255 | void SphereThetaPhi<T>::Limits(int k,double& tetMin,double& tetMax,double& phiMin,double& phiMax)
|
---|
256 |
|
---|
257 | // Retourne les valeurs de theta et phi limitant le pixel d'indice k
|
---|
258 | //--
|
---|
259 | {
|
---|
260 | int j;
|
---|
261 | double dphi;
|
---|
262 | bool fgzn= false;
|
---|
263 |
|
---|
264 | if((k < 0) || (k >= NPix_)) {
|
---|
265 | tetMin= -99999.;
|
---|
266 | phiMin= -99999.;
|
---|
267 | tetMax= -99999.;
|
---|
268 | phiMax= -99999.;
|
---|
269 | return;
|
---|
270 | }
|
---|
271 |
|
---|
272 | // si on se trouve dans l'hémisphère Sud
|
---|
273 | if(k >= NPix_/2) {
|
---|
274 | fgzn= true;
|
---|
275 | k= NPix_-1-k;
|
---|
276 | }
|
---|
277 |
|
---|
278 | // on recupere l'indice i de la tranche qui contient le pixel k
|
---|
279 | int i;
|
---|
280 | for( i=0; i< NTheta_; i++ )
|
---|
281 | if(k < TNphi_[i+1]) break;
|
---|
282 |
|
---|
283 | // valeurs limites de theta dans l'hemisphere Nord
|
---|
284 | tetMin= Theta_[i];
|
---|
285 | tetMax= Theta_[i+1];
|
---|
286 | // valeurs limites de theta dans l'hemisphere Sud
|
---|
287 | if (fgzn) {
|
---|
288 | tetMin= Pi-Theta_[i+1];
|
---|
289 | tetMax= Pi-Theta_[i];
|
---|
290 | }
|
---|
291 |
|
---|
292 | // pixel correspondant dans l'hemisphere Nord
|
---|
293 | if (fgzn) k= TNphi_[i+1]-k+TNphi_[i]-1;
|
---|
294 |
|
---|
295 | // indice j de discretisation ( phi= j*dphi )
|
---|
296 | j= k-TNphi_[i];
|
---|
297 | dphi= DeuxPi/(double)NPhi_[i];
|
---|
298 |
|
---|
299 | // valeurs limites de phi
|
---|
300 | phiMin= dphi*(double)(j);
|
---|
301 | phiMax= dphi*(double)(j+1);
|
---|
302 | return;
|
---|
303 | }
|
---|
304 |
|
---|
305 | /* --Methode-- */
|
---|
306 | //++
|
---|
307 | template <class T>
|
---|
308 | int SphereThetaPhi<T>::NbThetaSlices() const
|
---|
309 |
|
---|
310 | // Retourne le nombre de tranches en theta sur la sphere
|
---|
311 | //--
|
---|
312 | {
|
---|
313 | int nbslices;
|
---|
314 | nbslices= 2*NTheta_;
|
---|
315 | return(nbslices);
|
---|
316 | }
|
---|
317 |
|
---|
318 | /* --Methode-- */
|
---|
319 | //++
|
---|
320 | template <class T>
|
---|
321 | int SphereThetaPhi<T>::NPhi(int kt) const
|
---|
322 |
|
---|
323 | // Retourne le nombre de pixels en phi de la tranche kt
|
---|
324 | //--
|
---|
325 | {
|
---|
326 | int nbpix;
|
---|
327 | // verification
|
---|
328 | if((kt < 0) || (kt >= 2*NTheta_)) return(-1);
|
---|
329 |
|
---|
330 | // si on se trouve dans l'hemisphere Sud
|
---|
331 | if(kt >= NTheta_) {
|
---|
332 | kt= 2*NTheta_-1-kt;
|
---|
333 | }
|
---|
334 |
|
---|
335 | // nombre de pixels
|
---|
336 | nbpix= NPhi_[kt];
|
---|
337 | return(nbpix);
|
---|
338 | }
|
---|
339 |
|
---|
340 |
|
---|
341 | /* --Methode-- */
|
---|
342 | //++
|
---|
343 | template <class T>
|
---|
344 | void SphereThetaPhi<T>::Theta(int kt,double& tetMin,double& tetMax)
|
---|
345 |
|
---|
346 | // Retourne les valeurs de theta limitant la tranche kt
|
---|
347 | //--
|
---|
348 | {
|
---|
349 | bool fgzn= false;
|
---|
350 | // verification
|
---|
351 | if( (kt< 0) || (kt>= 2*NTheta_) ) {
|
---|
352 | tetMin= -99999.;
|
---|
353 | tetMax= -99999.;
|
---|
354 | return;
|
---|
355 | }
|
---|
356 |
|
---|
357 | // si on se trouve dans l'hemisphere Sud
|
---|
358 | if( kt >= NTheta_ ) {
|
---|
359 | fgzn= true;
|
---|
360 | kt= 2*NTheta_-1-kt;
|
---|
361 | }
|
---|
362 |
|
---|
363 | // valeurs limites de theta dans l'hemisphere Nord
|
---|
364 | tetMin= Theta_[kt];
|
---|
365 | tetMax= Theta_[kt+1];
|
---|
366 | // valeurs limites de theta dans l'hemisphere Sud
|
---|
367 | if (fgzn) {
|
---|
368 | tetMin= Pi-Theta_[kt+1];
|
---|
369 | tetMax= Pi-Theta_[kt];
|
---|
370 | }
|
---|
371 | }
|
---|
372 |
|
---|
373 | /* --Methode-- */
|
---|
374 | //++
|
---|
375 | template <class T>
|
---|
376 | void SphereThetaPhi<T>::Phi(int kt,int jp,double& phiMin,double& phiMax)
|
---|
377 |
|
---|
378 | // Retourne les valeurs de phi limitant le pixel jp de la tranche kt
|
---|
379 | //--
|
---|
380 | {
|
---|
381 | // verification
|
---|
382 | if((kt < 0) || (kt >= 2*NTheta_)) {
|
---|
383 | phiMin= -99999.;
|
---|
384 | phiMax= -99999.;
|
---|
385 | return;
|
---|
386 | }
|
---|
387 |
|
---|
388 | // si on se trouve dans l'hemisphere Sud
|
---|
389 | if(kt >= NTheta_) kt= 2*NTheta_-1-kt;
|
---|
390 |
|
---|
391 | // verifie si la tranche kt contient au moins jp pixels
|
---|
392 | if( (jp< 0) || (jp >= NPhi_[kt]) ) {
|
---|
393 | phiMin= -88888.;
|
---|
394 | phiMax= -88888.;
|
---|
395 | return;
|
---|
396 | }
|
---|
397 |
|
---|
398 | double dphi= DeuxPi/(double)NPhi_[kt];
|
---|
399 | phiMin= dphi*(double)(jp);
|
---|
400 | phiMax= dphi*(double)(jp+1);
|
---|
401 | return;
|
---|
402 | }
|
---|
403 |
|
---|
404 | /* --Methode-- */
|
---|
405 | //++
|
---|
406 | template <class T>
|
---|
407 | int SphereThetaPhi<T>::Index(int kt,int jp) const
|
---|
408 |
|
---|
409 | // Retourne l'indice du pixel d'indice jp dans la tranche kt
|
---|
410 | //--
|
---|
411 | {
|
---|
412 | int k;
|
---|
413 | bool fgzn= false;
|
---|
414 |
|
---|
415 | // si on se trouve dans l'hemisphere Sud
|
---|
416 | if(kt >= NTheta_) {
|
---|
417 | fgzn= true;
|
---|
418 | kt= 2*NTheta_-1-kt;
|
---|
419 | }
|
---|
420 |
|
---|
421 | // si la tranche kt contient au moins i pixels
|
---|
422 | if( (jp>=0) && (jp<NPhi_[kt]) )
|
---|
423 | {
|
---|
424 | // dans l'hemisphere Sud
|
---|
425 | if (fgzn) k= NPix_-TNphi_[kt+1]+jp;
|
---|
426 | // dans l'hemisphere Nord
|
---|
427 | else k= TNphi_[kt]+jp;
|
---|
428 | }
|
---|
429 | else
|
---|
430 | {
|
---|
431 | k= 9999;
|
---|
432 | printf("\n la tranche %d ne contient pas un pixel de rang %d",kt,jp);
|
---|
433 | }
|
---|
434 | return(k);
|
---|
435 | }
|
---|
436 |
|
---|
437 | /* --Methode-- */
|
---|
438 | //++
|
---|
439 | template <class T>
|
---|
440 | void SphereThetaPhi<T>::ThetaPhiIndex(int k,int& kt,int& jp)
|
---|
441 |
|
---|
442 | // Retourne les indices kt et jp du pixel d'indice k
|
---|
443 | //--
|
---|
444 | {
|
---|
445 | bool fgzn= false;
|
---|
446 | // si on se trouve dans l'hemisphere Sud
|
---|
447 | if(k >= NPix_/2)
|
---|
448 | {
|
---|
449 | fgzn= true;
|
---|
450 | k= NPix_-1-k;
|
---|
451 | }
|
---|
452 |
|
---|
453 | // on recupere l'indice kt de la tranche qui contient le pixel k
|
---|
454 | int i;
|
---|
455 | for(i = 0; i < NTheta_; i++)
|
---|
456 | if(k < TNphi_[i+1]) break;
|
---|
457 |
|
---|
458 | // indice kt de tranche
|
---|
459 | if (fgzn) kt= 2*NTheta_-1-i;
|
---|
460 | else kt= i;
|
---|
461 |
|
---|
462 | // indice jp de pixel
|
---|
463 | if (fgzn) jp= TNphi_[i+1]-k-1;
|
---|
464 | else jp= k-TNphi_[i];
|
---|
465 | }
|
---|
466 | //++
|
---|
467 | template <class T>
|
---|
468 | void SphereThetaPhi<T>::Pixelize(int m)
|
---|
469 |
|
---|
470 | // effectue le découpage en pixels (m et pet ont la même signification
|
---|
471 | // que pour le constructeur)
|
---|
472 | //
|
---|
473 | // Chaque bande de theta sera découpée en partant de phi=0 ...
|
---|
474 | // L'autre hémisphère est parcourue dans le même sens en phi et de
|
---|
475 | // l'équateur vers le pôle (le pixel qui suit le dernier de la bande la plus
|
---|
476 | // proche de l'équateur a z>0 est celui de plus petit phi de la bande la
|
---|
477 | // plus proche de l'equateur a z<0).
|
---|
478 | //--
|
---|
479 | {
|
---|
480 | int ntotpix,i,j;
|
---|
481 |
|
---|
482 | // Decodage et controle des arguments d'appel :
|
---|
483 | // au moins 2 et au plus 16384 bandes d'un hemisphere en theta
|
---|
484 | if (m < 2) m = 2;
|
---|
485 | if (m > 16384) m = 16384;
|
---|
486 |
|
---|
487 | // On memorise les arguments d'appel
|
---|
488 | NTheta_ = m;
|
---|
489 |
|
---|
490 | // On commence par decouper l'hemisphere z>0.
|
---|
491 | // Creation des vecteurs contenant :
|
---|
492 | // Les valeurs limites de theta (une valeur de plus que le nombre de bandes...)
|
---|
493 | Theta_= new double[m+1];
|
---|
494 |
|
---|
495 | // Le nombre de pixels en phi de chacune des bandes en theta
|
---|
496 | NPhi_ = new int[m];
|
---|
497 |
|
---|
498 | // Le nombre/Deuxpi total des pixels contenus dans les bandes de z superieur a une
|
---|
499 | // bande donnee (mTPphi[m] contient le nombre de pixels total de l'hemisphere)
|
---|
500 | TNphi_= new int[m+1];
|
---|
501 |
|
---|
502 | // Calcul du nombre total de pixels dans chaque bande pour optimiser
|
---|
503 | // le rapport largeur/hauteur des pixels
|
---|
504 |
|
---|
505 | //calotte polaire
|
---|
506 | TNphi_[0]= 0;
|
---|
507 | NPhi_[0] = 1;
|
---|
508 |
|
---|
509 | //bandes jusqu'a l'equateur
|
---|
510 | for(j = 1; j < m; j++)
|
---|
511 | {
|
---|
512 | TNphi_[j]= TNphi_[j-1]+NPhi_[j-1];
|
---|
513 | NPhi_[j] = (int)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ;
|
---|
514 | }
|
---|
515 |
|
---|
516 | // Nombre total de pixels sur l'hemisphere
|
---|
517 | ntotpix = TNphi_[m-1]+NPhi_[m-1];
|
---|
518 | TNphi_[m]= ntotpix;
|
---|
519 | // et sur la sphere entiere
|
---|
520 | NPix_= 2*ntotpix;
|
---|
521 |
|
---|
522 | // Creation et initialisation du vecteur des contenus des pixels
|
---|
523 | pixels_.ReSize(NPix_);
|
---|
524 | pixels_.Reset();
|
---|
525 |
|
---|
526 | // Determination des limites des bandes en theta :
|
---|
527 | // omeg est l'angle solide couvert par chaque pixel,
|
---|
528 | // une bande donnee kt couvre un angle solide NPhi_[kt]*omeg
|
---|
529 | // egal a 2* Pi*(cos Theta_[kt]-cos Theta_[kt+1]). De meme, l'angle solide
|
---|
530 | //de la
|
---|
531 | // calotte allant du pole a la limite haute de la bande kt vaut
|
---|
532 | // 2* Pi*(1.-cos Theta_[kt+1])= TNphi_[kt]*omeg...
|
---|
533 |
|
---|
534 | double omeg2pi= 1./(double)ntotpix;
|
---|
535 | Omega_ = omeg2pi*DeuxPi;
|
---|
536 |
|
---|
537 | for(j=0; j <= m; j++)
|
---|
538 | {
|
---|
539 | Theta_[j]= acos(1.-(double)TNphi_[j]*omeg2pi);
|
---|
540 | }
|
---|
541 | }
|
---|
542 |
|
---|
543 | //++
|
---|
544 | template <class T>
|
---|
545 | void SphereThetaPhi<T>::GetThetaSlice(int index,double& theta, TVector<double>& phi, TVector<T>& value) const
|
---|
546 |
|
---|
547 | // Retourne, pour la tranche en theta d'indice 'index' le theta
|
---|
548 | // correspondant, un vecteur (Peida) contenant les phi des pixels de
|
---|
549 | // la tranche, un vecteur (Peida) contenant les valeurs de pixel
|
---|
550 | // correspondantes
|
---|
551 | //--
|
---|
552 |
|
---|
553 | {
|
---|
554 | cout << "entree GetThetaSlice, couche no " << index << endl;
|
---|
555 |
|
---|
556 | if(index < 0 || index > NbThetaSlices())
|
---|
557 | {
|
---|
558 | // THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range"));
|
---|
559 | cout << " SphereThetaPhi::GetThetaSlice : exceptions a mettre en place" <<endl;
|
---|
560 | THROW(rangeCheckErr);
|
---|
561 | }
|
---|
562 |
|
---|
563 | int iring= Index(index,0);
|
---|
564 | int bid = this->NPhi(index);
|
---|
565 | int lring = bid;
|
---|
566 | cout << " iring= " << iring << " lring= " << lring << endl;
|
---|
567 |
|
---|
568 | phi.ReSize(lring);
|
---|
569 | value.ReSize(lring);
|
---|
570 | double Te= 0.;
|
---|
571 | double Fi= 0.;
|
---|
572 | for(int kk = 0; kk < lring; kk++)
|
---|
573 | {
|
---|
574 | PixThetaPhi(kk+iring,Te,Fi);
|
---|
575 | phi(kk)= Fi;
|
---|
576 | value(kk)= PixVal(kk+iring);
|
---|
577 | }
|
---|
578 | theta= Te;
|
---|
579 | }
|
---|
580 |
|
---|
581 | template <class T>
|
---|
582 | void SphereThetaPhi<T>::setmNPhi(int* array, int m)
|
---|
583 | //remplit le tableau contenant le nombre de pixels en phi de chacune des bandes en theta
|
---|
584 | //--
|
---|
585 | {
|
---|
586 | NPhi_= new int[m];
|
---|
587 | for(int k = 0; k < m; k++) NPhi_[k]= array[k];
|
---|
588 | }
|
---|
589 |
|
---|
590 | template <class T>
|
---|
591 | void SphereThetaPhi<T>::setmTNphi(int* array, int m)
|
---|
592 | //remplit le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes
|
---|
593 | //--
|
---|
594 | {
|
---|
595 | TNphi_= new int[m];
|
---|
596 | for(int k = 0; k < m; k++) TNphi_[k]= array[k];
|
---|
597 | }
|
---|
598 |
|
---|
599 | template <class T>
|
---|
600 | void SphereThetaPhi<T>::setmTheta(double* array, int m)
|
---|
601 | //remplit le tableau contenant les valeurs limites de theta
|
---|
602 | //--
|
---|
603 | {
|
---|
604 | Theta_= new double[m];
|
---|
605 | for(int k = 0; k < m; k++) Theta_[k]= array[k];
|
---|
606 | }
|
---|
607 |
|
---|
608 | template <class T>
|
---|
609 | void SphereThetaPhi<T>::setDataBlock(T* data, int m)
|
---|
610 | // remplit le vecteur des contenus des pixels
|
---|
611 | {
|
---|
612 | pixels_.FillFrom(m,data);
|
---|
613 | }
|
---|
614 |
|
---|
615 | template <class T>
|
---|
616 | void SphereThetaPhi<T>::print(ostream& os) const
|
---|
617 | {
|
---|
618 | if(mInfo_) os << " DVList Info= " << *mInfo_ << endl;
|
---|
619 | //
|
---|
620 | os << " NTheta_= " << NTheta_ << endl;
|
---|
621 | os << " NPix_ = " << NPix_ << endl;
|
---|
622 | os << " Omega_ = " << Omega_ << endl;
|
---|
623 |
|
---|
624 | os << " contenu de NPhi_ : ";
|
---|
625 | int i;
|
---|
626 | for(i=0; i < NTheta_; i++)
|
---|
627 | {
|
---|
628 | if(i%5 == 0) os << endl;
|
---|
629 | os << NPhi_[i] <<", ";
|
---|
630 | }
|
---|
631 | os << endl;
|
---|
632 |
|
---|
633 | os << " contenu de Theta_ : ";
|
---|
634 | for(i=0; i < NTheta_+1; i++)
|
---|
635 | {
|
---|
636 | if(i%5 == 0) os << endl;
|
---|
637 | os << Theta_[i] <<", ";
|
---|
638 | }
|
---|
639 | os << endl;
|
---|
640 |
|
---|
641 | os << " contenu de TNphi_ : ";
|
---|
642 | for(i=0; i < NTheta_+1; i++)
|
---|
643 | {
|
---|
644 | if(i%5 == 0) os << endl;
|
---|
645 | os << TNphi_[i] <<", ";
|
---|
646 | }
|
---|
647 | os << endl;
|
---|
648 |
|
---|
649 | os << " contenu de pixels : ";
|
---|
650 | for(i=0; i < NPix_; i++)
|
---|
651 | {
|
---|
652 | if(i%5 == 0) os << endl;
|
---|
653 | os << pixels_(i) <<", ";
|
---|
654 | }
|
---|
655 | os << endl;
|
---|
656 | }
|
---|
657 |
|
---|
658 | ///////////////////////////////////////////////////////////
|
---|
659 | // --------------------------------------------------------
|
---|
660 | // Les objets delegues pour la gestion de persistance
|
---|
661 | // --------------------------------------------------------
|
---|
662 | //////////////////////////////////////////////////////////
|
---|
663 |
|
---|
664 | template <class T>
|
---|
665 | FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi()
|
---|
666 | {
|
---|
667 | dobj= new SphereThetaPhi<T>;
|
---|
668 | ownobj= true;
|
---|
669 | }
|
---|
670 |
|
---|
671 | template <class T>
|
---|
672 | FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(string const& filename)
|
---|
673 | {
|
---|
674 | dobj= new SphereThetaPhi<T>;
|
---|
675 | ownobj= true;
|
---|
676 | Read(filename);
|
---|
677 | }
|
---|
678 |
|
---|
679 | template <class T>
|
---|
680 | FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(const SphereThetaPhi<T>& obj)
|
---|
681 | {
|
---|
682 | dobj= new SphereThetaPhi<T>(obj);
|
---|
683 | ownobj= true;
|
---|
684 | }
|
---|
685 |
|
---|
686 | template <class T>
|
---|
687 | FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(SphereThetaPhi<T>* obj)
|
---|
688 | {
|
---|
689 | dobj= obj;
|
---|
690 | ownobj= false;
|
---|
691 | }
|
---|
692 |
|
---|
693 | template <class T>
|
---|
694 | FIO_SphereThetaPhi<T>::~FIO_SphereThetaPhi()
|
---|
695 | {
|
---|
696 | if (ownobj && dobj) delete dobj;
|
---|
697 | }
|
---|
698 |
|
---|
699 | template <class T>
|
---|
700 | AnyDataObj* FIO_SphereThetaPhi<T>::DataObj()
|
---|
701 | {
|
---|
702 | return(dobj);
|
---|
703 | }
|
---|
704 |
|
---|
705 | template <class T>
|
---|
706 | void FIO_SphereThetaPhi<T>::ReadSelf(PInPersist& is)
|
---|
707 | {
|
---|
708 | cout << " FIO_SphereThetaPhi:: ReadSelf " << endl;
|
---|
709 |
|
---|
710 | if(dobj == NULL)
|
---|
711 | {
|
---|
712 | dobj= new SphereThetaPhi<T>;
|
---|
713 | }
|
---|
714 |
|
---|
715 | // Pour savoir s'il y avait un DVList Info associe
|
---|
716 | char strg[256];
|
---|
717 | is.GetLine(strg, 255);
|
---|
718 | bool hadinfo= false;
|
---|
719 | if(strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo= true;
|
---|
720 | if(hadinfo)
|
---|
721 | { // Lecture eventuelle du DVList Info
|
---|
722 | is >> dobj->Info();
|
---|
723 | }
|
---|
724 |
|
---|
725 | int mNTheta;
|
---|
726 | is.GetI4(mNTheta);
|
---|
727 | dobj->setSizeIndex(mNTheta);
|
---|
728 |
|
---|
729 | int mNPix;
|
---|
730 | is.GetI4(mNPix);
|
---|
731 | dobj->setNbPixels(mNPix);
|
---|
732 |
|
---|
733 | double mOmeg;
|
---|
734 | is.GetR8(mOmeg);
|
---|
735 | dobj->setPixSolAngle(mOmeg);
|
---|
736 |
|
---|
737 | int* mNphi= new int[mNTheta];
|
---|
738 | is.GetI4s(mNphi, mNTheta);
|
---|
739 | dobj->setmNPhi(mNphi, mNTheta);
|
---|
740 | delete [] mNphi;
|
---|
741 |
|
---|
742 | int* mTNphi= new int[mNTheta+1];
|
---|
743 | is.GetI4s(mTNphi, mNTheta+1);
|
---|
744 | dobj->setmTNphi(mTNphi, mNTheta+1);
|
---|
745 | delete [] mTNphi;
|
---|
746 |
|
---|
747 | double* mTheta= new double[mNTheta+1];
|
---|
748 | is.GetR8s(mTheta, mNTheta+1);
|
---|
749 | dobj->setmTheta(mTheta, mNTheta+1);
|
---|
750 | delete [] mTheta;
|
---|
751 |
|
---|
752 | T* mPixels= new T[mNPix];
|
---|
753 | PIOSReadArray(is, mPixels, mNPix);
|
---|
754 | dobj->setDataBlock(mPixels, mNPix);
|
---|
755 | delete [] mPixels;
|
---|
756 | }
|
---|
757 |
|
---|
758 | template <class T>
|
---|
759 | void FIO_SphereThetaPhi<T>::WriteSelf(POutPersist& os) const
|
---|
760 | {
|
---|
761 | cout << " FIO_SphereThetaPhi:: WriteSelf " << endl;
|
---|
762 |
|
---|
763 | if(dobj == NULL)
|
---|
764 | {
|
---|
765 | cout << " WriteSelf:: dobj= null " << endl;
|
---|
766 | return;
|
---|
767 | }
|
---|
768 |
|
---|
769 | char strg[256];
|
---|
770 | int mNTheta= dobj->SizeIndex();
|
---|
771 | int mNPix = dobj->NbPixels();
|
---|
772 |
|
---|
773 | if(dobj->ptrInfo())
|
---|
774 | {
|
---|
775 | sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d HasInfo",mNTheta,mNPix);
|
---|
776 | os.PutLine(strg);
|
---|
777 | os << dobj->Info();
|
---|
778 | }
|
---|
779 | else
|
---|
780 | {
|
---|
781 | sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d ",mNTheta,mNPix);
|
---|
782 | os.PutLine(strg);
|
---|
783 | }
|
---|
784 |
|
---|
785 | os.PutI4(mNTheta);
|
---|
786 | os.PutI4(mNPix);
|
---|
787 | os.PutR8(dobj->PixSolAngle(0));
|
---|
788 | os.PutI4s(dobj->getmNPhi() , mNTheta);
|
---|
789 | os.PutI4s(dobj->getmTNphi(), mNTheta+1);
|
---|
790 | os.PutR8s(dobj->getmTheta(), mNTheta+1);
|
---|
791 | //os.Put((dobj->getDataBlock())->Data(), mNPix);
|
---|
792 | PIOSWriteArray(os,(dobj->getDataBlock())->Data(), mNPix);
|
---|
793 | }
|
---|
794 |
|
---|
795 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
796 | #pragma define_template SphereThetaPhi<double>
|
---|
797 | #pragma define_template SphereThetaPhi<float>
|
---|
798 | #pragma define_template SphereThetaPhi< complex<float> >
|
---|
799 | #pragma define_template SphereThetaPhi< complex<double> >
|
---|
800 | #pragma define_template FIO_SphereThetaPhi<double>
|
---|
801 | #pragma define_template FIO_SphereThetaPhi<float>
|
---|
802 | #pragma define_template FIO_SphereThetaPhi< complex<float> >
|
---|
803 | #pragma define_template FIO_SphereThetaPhi< complex<double> >
|
---|
804 | #endif
|
---|
805 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
|
---|
806 | template class SphereThetaPhi<double>;
|
---|
807 | template class SphereThetaPhi<float>;
|
---|
808 | template class SphereThetaPhi< complex<float> >;
|
---|
809 | template class SphereThetaPhi< complex<double> >;
|
---|
810 | template class FIO_SphereThetaPhi<double>;
|
---|
811 | template class FIO_SphereThetaPhi<float>;
|
---|
812 | template class FIO_SphereThetaPhi< complex<float> >;
|
---|
813 | template class FIO_SphereThetaPhi< complex<double> >;
|
---|
814 | #endif
|
---|