Changeset 726 in Sophya for trunk/SophyaLib/Samba
- Timestamp:
- Feb 21, 2000, 5:38:11 PM (26 years ago)
- Location:
- trunk/SophyaLib/Samba
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Samba/spherethetaphi.cc
r701 r726 68 68 NTheta_= s.NTheta_; 69 69 NPix_ = s.NPix_; 70 NPhi_ = new int_4[NTheta_]; 71 Theta_ = new double[NTheta_+1]; 72 TNphi_ = new int_4[NTheta_+1]; 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_]; 70 NPhi_.ReSize(NTheta_); 71 Theta_.ReSize(NTheta_+1); 72 TNphi_.ReSize(NTheta_+1); 73 74 NPhi_ = s.NPhi_; 75 TNphi_ = s.TNphi_; 76 Theta_ = s.Theta_; 81 77 Omega_ = s.Omega_; 82 78 } … … 90 86 91 87 //-- 92 { 93 Clear(); 94 } 88 {} 95 89 96 90 //++ … … 100 94 void SphereThetaPhi<T>::InitNul() 101 95 // 102 // initialise à zéro les variables de classe pointeurs103 96 { 104 97 NTheta_= 0; 105 98 NPix_ = 0; 106 Theta_ = NULL;107 NPhi_ = NULL;108 TNphi_ = NULL;109 99 // pixels_.Reset(); Pas de reset par InitNul (en cas de share) - Reza 20/11/99 $CHECK$ 110 100 } 111 101 112 /* --Methode-- */113 template <class T>114 void SphereThetaPhi<T>::Clear()115 116 {117 if(Theta_) delete[] Theta_;118 if(NPhi_ ) delete[] NPhi_;119 if(TNphi_) delete[] TNphi_;120 InitNul();121 }122 102 123 103 //++ … … 127 107 //-- 128 108 { 129 Clear();109 InitNul(); 130 110 Pixelize(m); 131 111 } … … 152 132 if((k < 0) || (k >= NPix_)) 153 133 { 154 //THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 155 cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl; 156 THROW(rangeCheckErr); 134 throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range"); 157 135 } 158 136 return pixels_(k); … … 168 146 if((k < 0) || (k >= NPix_)) 169 147 { 170 cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl; 171 //THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 172 throw "SphereThetaPhi::PIxVal Pixel index out of range"; 148 throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range"); 173 149 } 174 150 return *(pixels_.Data()+k); … … 204 180 // Theta_[kt] et Theta_[kt+1] 205 181 for( i=1; i< NTheta_; i++ ) 206 if( theta < Theta_ [i]) break;207 208 dphi= DeuxPi/(double)NPhi_ [i-1];209 210 if (fgzn) k= NPix_-TNphi_ [i]+(int_4)(phi/dphi);211 else k= TNphi_ [i-1]+(int_4)(phi/dphi);182 if( theta < Theta_(i) ) break; 183 184 dphi= DeuxPi/(double)NPhi_(i-1); 185 186 if (fgzn) k= NPix_-TNphi_(i)+(int_4)(phi/dphi); 187 else k= TNphi_(i-1)+(int_4)(phi/dphi); 212 188 return(k); 213 189 } … … 229 205 // recupère l'indice i de la tranche qui contient le pixel k 230 206 for( i=0; i< NTheta_; i++ ) 231 if( k < TNphi_ [i+1]) break;207 if( k < TNphi_(i+1) ) break; 232 208 233 209 // angle theta 234 theta= 0.5*(Theta_ [i]+Theta_[i+1]);210 theta= 0.5*(Theta_(i)+Theta_(i+1)); 235 211 if (fgzn) theta= Pi-theta; 236 212 237 213 // angle phi 238 k -= TNphi_ [i];239 phi= DeuxPi/(double)NPhi_ [i]*(double)(k+.5);214 k -= TNphi_(i); 215 phi= DeuxPi/(double)NPhi_(i)*(double)(k+.5); 240 216 if (fgzn) phi= DeuxPi-phi; 241 217 } … … 290 266 int i; 291 267 for( i=0; i< NTheta_; i++ ) 292 if(k < TNphi_ [i+1]) break;268 if(k < TNphi_(i+1)) break; 293 269 294 270 // valeurs limites de theta dans l'hemisphere Nord 295 tetMin= Theta_ [i];296 tetMax= Theta_ [i+1];271 tetMin= Theta_(i); 272 tetMax= Theta_(i+1); 297 273 // valeurs limites de theta dans l'hemisphere Sud 298 274 if (fgzn) { 299 tetMin= Pi -Theta_[i+1];300 tetMax= Pi -Theta_[i];275 tetMin= Pi - Theta_(i+1); 276 tetMax= Pi - Theta_(i); 301 277 } 302 278 303 279 // pixel correspondant dans l'hemisphere Nord 304 if (fgzn) k= TNphi_ [i+1]-k+TNphi_[i]-1;280 if (fgzn) k= TNphi_(i+1)-k+TNphi_(i)-1; 305 281 306 282 // indice j de discretisation ( phi= j*dphi ) 307 j= k-TNphi_ [i];308 dphi= DeuxPi/(double)NPhi_ [i];283 j= k-TNphi_(i); 284 dphi= DeuxPi/(double)NPhi_(i); 309 285 310 286 // valeurs limites de phi … … 317 293 //++ 318 294 template <class T> 319 int_4 SphereThetaPhi<T>::NbThetaSlices() const295 uint_4 SphereThetaPhi<T>::NbThetaSlices() const 320 296 321 297 // Return number of theta-slices on the sphere 322 298 //-- 323 299 { 300 if (NTheta_<=0) 301 { 302 throw PException(" sphere not pixelized, NbSlice=0 "); 303 } 324 304 return( 2*NTheta_); 325 305 } … … 343 323 344 324 // nombre de pixels 345 nbpix= NPhi_ [kt];325 nbpix= NPhi_(kt); 346 326 return(nbpix); 347 327 } … … 371 351 372 352 // valeurs limites de theta dans l'hemisphere Nord 373 tetMin= Theta_ [kt];374 tetMax= Theta_ [kt+1];353 tetMin= Theta_(kt); 354 tetMax= Theta_(kt+1); 375 355 // valeurs limites de theta dans l'hemisphere Sud 376 356 if (fgzn) { 377 tetMin= Pi -Theta_[kt+1];378 tetMax= Pi -Theta_[kt];357 tetMin= Pi - Theta_(kt+1); 358 tetMax= Pi - Theta_(kt); 379 359 } 380 360 } … … 399 379 400 380 // verifie si la tranche kt contient au moins jp pixels 401 if( (jp< 0) || (jp >= NPhi_ [kt]) ) {381 if( (jp< 0) || (jp >= NPhi_(kt)) ) { 402 382 phiMin= -88888.; 403 383 phiMax= -88888.; … … 405 385 } 406 386 407 double dphi= DeuxPi/(double)NPhi_ [kt];387 double dphi= DeuxPi/(double)NPhi_(kt); 408 388 phiMin= dphi*(double)(jp); 409 389 phiMax= dphi*(double)(jp+1); … … 429 409 430 410 // si la tranche kt contient au moins i pixels 431 if( (jp>=0) && (jp<NPhi_ [kt]) )411 if( (jp>=0) && (jp<NPhi_(kt)) ) 432 412 { 433 413 // dans l'hemisphere Sud 434 if (fgzn) k= NPix_-TNphi_ [kt+1]+jp;414 if (fgzn) k= NPix_-TNphi_(kt+1)+jp; 435 415 // dans l'hemisphere Nord 436 else k= TNphi_ [kt]+jp;416 else k= TNphi_(kt)+jp; 437 417 } 438 418 else … … 463 443 int i; 464 444 for(i = 0; i < NTheta_; i++) 465 if(k < TNphi_ [i+1]) break;445 if(k < TNphi_(i+1)) break; 466 446 467 447 // indice kt de tranche … … 470 450 471 451 // indice jp de pixel 472 if (fgzn) jp= TNphi_ [i+1]-k-1;473 else jp= k-TNphi_ [i];452 if (fgzn) jp= TNphi_(i+1)-k-1; 453 else jp= k-TNphi_(i); 474 454 } 475 455 //++ … … 502 482 // Creation des vecteurs contenant : 503 483 // Les valeurs limites de theta (une valeur de plus que le nombre de bandes...) 504 Theta_= new double[m+1]; 484 // Theta_= new double[m+1]; 485 Theta_.ReSize(m+1); 505 486 506 487 // Le nombre de pixels en phi de chacune des bandes en theta 507 NPhi_ = new int_4[m]; 488 // NPhi_ = new int_4[m]; 489 NPhi_.ReSize(m); 508 490 509 491 // Le nombre/Deuxpi total des pixels contenus dans les bandes de z superieur a une 510 492 // bande donnee (mTPphi[m] contient le nombre de pixels total de l'hemisphere) 511 TNphi_= new int_4[m+1]; 493 // TNphi_= new int_4[m+1]; 494 TNphi_.ReSize(m+1); 512 495 513 496 // Calcul du nombre total de pixels dans chaque bande pour optimiser … … 515 498 516 499 //calotte polaire 517 TNphi_ [0]= 0;518 NPhi_ [0]= 1;500 TNphi_(0)= 0; 501 NPhi_(0) = 1; 519 502 520 503 //bandes jusqu'a l'equateur 521 504 for(j = 1; j < m; j++) 522 505 { 523 TNphi_ [j]= TNphi_[j-1]+NPhi_[j-1];524 NPhi_ [j]= (int_4)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ;506 TNphi_(j)= TNphi_(j-1)+NPhi_(j-1); 507 NPhi_(j) = (int_4)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ; 525 508 } 526 509 527 510 // Nombre total de pixels sur l'hemisphere 528 ntotpix = TNphi_ [m-1]+NPhi_[m-1];529 TNphi_ [m]= ntotpix;511 ntotpix = TNphi_(m-1)+NPhi_(m-1); 512 TNphi_(m)= ntotpix; 530 513 // et sur la sphere entiere 531 514 NPix_= 2*ntotpix; … … 548 531 for(j=0; j <= m; j++) 549 532 { 550 Theta_ [j]= acos(1.-(double)TNphi_[j]*omeg2pi);533 Theta_(j)= acos(1.-(double)TNphi_(j)*omeg2pi); 551 534 } 552 535 } … … 566 549 if(index < 0 || index >= NbThetaSlices()) 567 550 { 568 // THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 569 cout << " SphereThetaPhi::GetThetaSlice : Pixel index out of range" <<endl; 570 THROW(rangeCheckErr); 551 throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range"); 571 552 } 572 553 … … 587 568 } 588 569 589 template <class T> 590 void SphereThetaPhi<T>::setmNPhi(int_4* array, int_4 m) 591 //remplit le tableau contenant le nombre de pixels en phi de chacune des bandes en theta 592 // 593 { 594 NPhi_= new int_4[m]; 595 for(int k = 0; k < m; k++) NPhi_[k]= array[k]; 596 } 597 598 template <class T> 599 void SphereThetaPhi<T>::setmTNphi(int_4* array, int_4 m) 600 //remplit le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes 601 // 602 { 603 TNphi_= new int_4[m]; 604 for(int k = 0; k < m; k++) TNphi_[k]= array[k]; 605 } 606 607 template <class T> 608 void SphereThetaPhi<T>::setmTheta(double* array, int_4 m) 609 //remplit le tableau contenant les valeurs limites de theta 610 // 611 { 612 Theta_= new double[m]; 613 for(int k = 0; k < m; k++) Theta_[k]= array[k]; 614 } 570 //++ 571 template <class T> 572 void SphereThetaPhi<T>::GetThetaSlice(int_4 index,double& theta, double& phi0,TVector<int>& pixelIndices, TVector<T>& value) const 573 574 // For a theta-slice with index 'index', return : 575 // the corresponding "theta" 576 // the corresponding "phi" for first pixel of the slice 577 // a vector containing the indices of the pixels of the slice 578 // (equally distributed in phi) 579 // a vector containing the corresponding values of pixels 580 //-- 581 582 { 583 584 if(index < 0 || index >= NbThetaSlices()) 585 { 586 throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range"); 587 588 } 589 590 int iring= Index(index,0); 591 int lring = NPhi(index); 592 593 pixelIndices.ReSize(lring); 594 value.ReSize(lring); 595 double Te= 0.; 596 double Fi= 0.; 597 for(int kk = 0; kk < lring; kk++) 598 { 599 pixelIndices(kk)=kk+iring ; 600 value(kk)= PixVal(kk+iring); 601 } 602 PixThetaPhi(iring,theta,phi0); 603 } 604 605 615 606 616 607 … … 629 620 { 630 621 if(i%5 == 0) os << endl; 631 os << NPhi_ [i]<<", ";622 os << NPhi_(i) <<", "; 632 623 } 633 624 os << endl; … … 637 628 { 638 629 if(i%5 == 0) os << endl; 639 os << Theta_ [i]<<", ";630 os << Theta_(i) <<", "; 640 631 } 641 632 os << endl; … … 645 636 { 646 637 if(i%5 == 0) os << endl; 647 os << TNphi_ [i]<<", ";638 os << TNphi_(i) <<", "; 648 639 } 649 640 os << endl; … … 675 666 { 676 667 dobj= new SphereThetaPhi<T>; 677 // dobj->DataBlock().SetTemp(true);678 668 dobj->pixels_.SetTemp(true); 679 669 ownobj= true; … … 685 675 { 686 676 dobj= new SphereThetaPhi<T>(obj, true); 687 // dobj->DataBlock().SetTemp(true);688 677 dobj->pixels_.SetTemp(true); 689 678 ownobj= true; … … 716 705 { 717 706 dobj= new SphereThetaPhi<T>; 718 // dobj->DataBlock().SetTemp(true);719 707 dobj->pixels_.SetTemp(true); 720 708 ownobj= true; 721 709 } 722 710 711 // On lit les 3 premiers uint_8 712 uint_8 itab[3]; 713 is.Get(itab, 3); 723 714 // Let's Read the SphereCoordSys object -- ATTENTIOn - $CHECK$ 724 715 FIO_SphereCoordSys fio_scs( dobj->GetCoordSys()); … … 742 733 is.GetR8(mOmeg); 743 734 dobj->setParameters(mNPix, mOmeg, mNTheta); 744 745 int_4* mNphi= new int_4[mNTheta]; 746 is.GetI4s(mNphi, mNTheta); 747 dobj->setmNPhi(mNphi, mNTheta); 748 delete [] mNphi; 749 750 int_4* mTNphi= new int_4[mNTheta+1]; 751 is.GetI4s(mTNphi, mNTheta+1); 752 dobj->setmTNphi(mTNphi, mNTheta+1); 753 delete [] mTNphi; 754 755 double* mTheta= new double[mNTheta+1]; 756 is.GetR8s(mTheta, mNTheta+1); 757 dobj->setmTheta(mTheta, mNTheta+1); 758 delete [] mTheta; 759 760 // On lit le DataBlock; 761 //FIO_NDataBlock<T> fio_nd(&dobj->DataBlock()); 735 FIO_NDataBlock<int_4> fio_nd_nphi(&dobj->NPhi_); 736 fio_nd_nphi.Read(is); 737 FIO_NDataBlock<int_4> fio_nd_Tnphi(&dobj->TNphi_); 738 fio_nd_Tnphi.Read(is); 739 FIO_NDataBlock<r_8> fio_nd_Theta(&dobj->Theta_); 740 fio_nd_Theta.Read(is); 741 762 742 FIO_NDataBlock<T> fio_nd(&dobj->pixels_); 763 743 fio_nd.Read(is); 764 // is >> dobj->DataBlock();765 744 } 766 745 … … 775 754 } 776 755 756 // On ecrit 3 uint_8 757 // 0 : Numero de version, 1 : Size index, 2 reserve a l 758 uint_8 itab[3]; 759 itab[0] = 1; 760 itab[1] = dobj->SizeIndex(); 761 itab[2] = 0; 762 os.Put(itab, 3); 777 763 // Let's write the SphereCoordSys object 778 764 FIO_SphereCoordSys fio_scs( dobj->GetCoordSys()); … … 798 784 os.PutI4(mNPix); 799 785 os.PutR8(dobj->PixSolAngle()); 800 os.PutI4s(dobj->getmNPhi() , mNTheta); 801 os.PutI4s(dobj->getmTNphi(), mNTheta+1); 802 os.PutR8s(dobj->getmTheta(), mNTheta+1); 803 // On ecrit le datablock 804 //FIO_NDataBlock<T> fio_nd(&dobj->DataBlock()); 786 FIO_NDataBlock<int_4> fio_nd_nphi(&dobj->NPhi_); 787 fio_nd_nphi.Write(os); 788 FIO_NDataBlock<int_4> fio_nd_Tnphi(&dobj->TNphi_); 789 fio_nd_Tnphi.Write(os); 790 FIO_NDataBlock<r_8> fio_nd_Theta(&dobj->Theta_); 791 fio_nd_Theta.Write(os); 805 792 FIO_NDataBlock<T> fio_nd(&dobj->pixels_); 806 793 fio_nd.Write(os); 807 // os << dobj->DataBlock();808 794 } 809 795 -
trunk/SophyaLib/Samba/spherethetaphi.h
r708 r726 41 41 virtual ~SphereThetaPhi(); 42 42 43 /*! Setting blockdata to temporary (see ndatablock documentation) */ 44 inline virtual void SetTemp(bool temp=false) const {pixels_.SetTemp(temp);}; 45 43 46 // ------------ Definition of PixelMap abstract methods - 44 47 … … 94 97 /* Nombre de tranches en theta */ 95 98 /*! Return number of theta-slices on the sphere */ 96 int_4 NbThetaSlices() const;99 uint_4 NbThetaSlices() const; 97 100 98 101 /* Nombre de pixels en phi de la tranche d'indice kt */ … … 140 143 void GetThetaSlice(int_4 index,double& theta,TVector<double>& phi,TVector<T>& value) const; 141 144 142 145 /*! For a theta-slice with index 'index', return : 146 147 the corresponding "theta" 148 149 the corresponding "phi" for first pixel of the slice 150 151 a vector containing indices of the pixels of the slice 152 153 (equally distributed in phi) 154 155 a vector containing the corresponding values of pixels 156 */ 157 void GetThetaSlice(int_4 index,double& theta, double& phi0,TVector<int>& pixelIndices, TVector<T>& value) const ; 143 158 144 159 … … 150 165 // ------------- méthodes internes ---------------------- 151 166 void InitNul(); 152 void Clear();153 167 inline void setParameters(int nbpix, double omega, int nbThetaIndex) 154 168 { … … 157 171 NTheta_= nbThetaIndex; 158 172 } 159 void setmNPhi(int* array, int m);160 void setmTNphi(int* array, int m);161 void setmTheta(double* array, int m);162 /*retourne l'adresse du tableau contenant le nombre de pixels en phi de chacune des bandes en theta */163 inline const int* getmNPhi() const { return(NPhi_); }164 165 /* retourne le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes */166 inline const int* getmTNphi() const { return(TNphi_); }167 168 /* retourne le tableau contenant les valeurs limites de theta */169 inline const double* getmTheta() const { return(Theta_); }170 173 171 174 // ------------- variables internes --------------------- … … 173 176 int_4 NPix_; // nombre total de pixels 174 177 double Omega_; // angle solide constant pour chaque pixel 175 int_4* NPhi_; // tableau donnant, pour chaque bande en theta, le nombre de176 //pixels selon phi177 int_4*TNphi_;178 double*Theta_;179 NDataBlock<T> pixels_;178 NDataBlock<int_4> NPhi_; // tableau donnant, pour chaque bande en theta, 179 //le nombre de pixels selon phi 180 NDataBlock<int_4> TNphi_; 181 NDataBlock<r_8> Theta_; 182 NDataBlock<T> pixels_; 180 183 }; 181 184
Note:
See TracChangeset
for help on using the changeset viewer.