source: Sophya/trunk/SophyaLib/Samba/spherethetaphi.cc@ 633

Last change on this file since 633 was 604, checked in by ansari, 26 years ago

Bugs InitNul et autres - Reza 20/11/99

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