Changeset 473 in Sophya for trunk/SophyaLib/Samba/spherethetaphi.cc
- Timestamp:
- Oct 18, 1999, 4:37:44 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Samba/spherethetaphi.cc
r470 r473 87 87 //++ 88 88 template <class T> 89 SphereThetaPhi<T>::SphereThetaPhi(int _4m)89 SphereThetaPhi<T>::SphereThetaPhi(int m) 90 90 91 91 // Constructeur : m est le nombre de bandes en theta sur un hémisphère … … 105 105 NTheta_= s.NTheta_; 106 106 NPix_ = s.NPix_; 107 NPhi_ = new int _4[NTheta_];108 Theta_ = new r_4[NTheta_+1];109 TNphi_ = new int _4[NTheta_+1];107 NPhi_ = new int[NTheta_]; 108 Theta_ = new double[NTheta_+1]; 109 TNphi_ = new int[NTheta_+1]; 110 110 for(int k = 0; k < NTheta_; k++) 111 111 { … … 161 161 //++ 162 162 template <class T> 163 void SphereThetaPhi<T>::Resize(int _4m)163 void SphereThetaPhi<T>::Resize(int m) 164 164 // re-pixelize the sphere 165 165 //-- … … 172 172 //++ 173 173 template <class T> 174 int _4SphereThetaPhi<T>::NbPixels() const174 int SphereThetaPhi<T>::NbPixels() const 175 175 176 176 // Retourne le nombre de pixels du découpage … … 183 183 //++ 184 184 template <class T> 185 T& SphereThetaPhi<T>::PixVal(int _4k)185 T& SphereThetaPhi<T>::PixVal(int k) 186 186 187 187 // Retourne la valeur du contenu du pixel d'indice k … … 190 190 if((k < 0) || (k >= NPix_)) 191 191 { 192 // THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 192 //THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 193 cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl; 194 THROW(rangeCheckErr); 195 } 196 return pixels_(k); 197 } 198 199 //++ 200 template <class T> 201 T const& SphereThetaPhi<T>::PixVal(int k) const 202 203 // Retourne la valeur du contenu du pixel d'indice k 204 //-- 205 { 206 if((k < 0) || (k >= NPix_)) 207 { 193 208 cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl; 194 THROW(rangeCheckErr); 195 } 196 return pixels_(k); 197 } 198 199 //++ 200 template <class T> 201 T const& SphereThetaPhi<T>::PixVal(int_4 k) const 202 203 // Retourne la valeur du contenu du pixel d'indice k 204 //-- 205 { 206 if((k < 0) || (k >= NPix_)) 207 { 208 cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl; 209 // THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 209 //THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 210 210 throw "SphereThetaPhi::PIxVal Pixel index out of range"; 211 211 } … … 216 216 //++ 217 217 template <class T> 218 int _4 SphereThetaPhi<T>::PixIndexSph(r_4 theta, r_4phi) const219 220 // 218 int SphereThetaPhi<T>::PixIndexSph(double theta, double phi) const 219 220 // Retourne l'indice du pixel vers lequel pointe une direction définie par 221 221 // ses coordonnées sphériques 222 222 //-- 223 223 { 224 r_4dphi;225 int _4i,j,k;224 double dphi; 225 int i,j,k; 226 226 bool fgzn = false; 227 227 228 if( (theta > (r_4)Pi) || (theta < 0. )) return(-1);229 if( (phi < 0.) || (phi > DeuxPi) )return(-1);230 if( theta > (r_4)Pi*0.5) { fgzn = true; theta = Pi-theta;}228 if((theta > Pi) || (theta < 0.)) return(-1); 229 if((phi < 0.) || (phi > DeuxPi)) return(-1); 230 if(theta > Pi*0.5) {fgzn = true; theta = Pi-theta;} 231 231 232 232 // La bande d'indice kt est limitée par les valeurs de theta contenues dans … … 235 235 if( theta < Theta_[i] ) break; 236 236 237 dphi= (r_4)DeuxPi/(r_4)NPhi_[i-1];238 239 if (fgzn) k= NPix_-TNphi_[i]+(int _4)(phi/dphi);240 else k= TNphi_[i-1]+(int _4)(phi/dphi);237 dphi= DeuxPi/(double)NPhi_[i-1]; 238 239 if (fgzn) k= NPix_-TNphi_[i]+(int)(phi/dphi); 240 else k= TNphi_[i-1]+(int)(phi/dphi); 241 241 return(k); 242 242 } … … 245 245 //++ 246 246 template <class T> 247 void SphereThetaPhi<T>::PixThetaPhi(int _4 k, r_4& theta, r_4& phi) const247 void SphereThetaPhi<T>::PixThetaPhi(int k,double& theta,double& phi) const 248 248 249 249 // Retourne les coordonnées (theta,phi) du milieu du pixel d'indice k 250 250 //-- 251 251 { 252 int _4i;252 int i; 253 253 bool fgzn = false; 254 254 255 if( (k < 0) || (k >= NPix_) ) {theta = -99999.; phi = -99999.;return; }256 if( k >= NPix_/2) {fgzn = true; k = NPix_-1-k;}255 if((k < 0) || (k >= NPix_)) {theta = -99999.; phi = -99999.; return; } 256 if( k >= NPix_/2) {fgzn = true; k = NPix_-1-k;} 257 257 258 258 // recupère l'indice i de la tranche qui contient le pixel k … … 266 266 // angle phi 267 267 k -= TNphi_[i]; 268 phi= (r_4)DeuxPi/(r_4)NPhi_[i]*(r_4)(k+.5);268 phi= DeuxPi/(double)NPhi_[i]*(double)(k+.5); 269 269 if (fgzn) phi= DeuxPi-phi; 270 270 } … … 272 272 //++ 273 273 template <class T> 274 r_8 SphereThetaPhi<T>::PixSolAngle(int_4dummy) const274 double SphereThetaPhi<T>::PixSolAngle(int dummy) const 275 275 276 276 // Pixel Solid angle (steradians) … … 286 286 //++ 287 287 template <class T> 288 void SphereThetaPhi<T>::Limits(int _4 k, r_4& tetMin, r_4& tetMax, r_4& phiMin, r_4& phiMax)288 void SphereThetaPhi<T>::Limits(int k,double& tetMin,double& tetMax,double& phiMin,double& phiMax) 289 289 290 290 // Retourne les valeurs de theta et phi limitant le pixel d'indice k 291 291 //-- 292 292 { 293 int _4j;294 r_4dphi;293 int j; 294 double dphi; 295 295 bool fgzn= false; 296 296 297 if( (k< 0) || (k >= NPix_)) {297 if((k < 0) || (k >= NPix_)) { 298 298 tetMin= -99999.; 299 299 phiMin= -99999.; … … 304 304 305 305 // si on se trouve dans l'hémisphère Sud 306 if( k >= NPix_/2) {306 if(k >= NPix_/2) { 307 307 fgzn= true; 308 308 k= NPix_-1-k; … … 312 312 int i; 313 313 for( i=0; i< NTheta_; i++ ) 314 if( k< TNphi_[i+1]) break;314 if(k < TNphi_[i+1]) break; 315 315 316 316 // valeurs limites de theta dans l'hemisphere Nord … … 328 328 // indice j de discretisation ( phi= j*dphi ) 329 329 j= k-TNphi_[i]; 330 dphi= (r_4)DeuxPi/(r_4)NPhi_[i];330 dphi= DeuxPi/(double)NPhi_[i]; 331 331 332 332 // valeurs limites de phi 333 phiMin= dphi*( r_4)(j);334 phiMax= dphi*( r_4)(j+1);333 phiMin= dphi*(double)(j); 334 phiMax= dphi*(double)(j+1); 335 335 return; 336 336 } … … 339 339 //++ 340 340 template <class T> 341 int _4SphereThetaPhi<T>::NbThetaSlices() const341 int SphereThetaPhi<T>::NbThetaSlices() const 342 342 343 343 // Retourne le nombre de tranches en theta sur la sphere 344 344 //-- 345 345 { 346 int _4nbslices;346 int nbslices; 347 347 nbslices= 2*NTheta_; 348 348 return(nbslices); … … 352 352 //++ 353 353 template <class T> 354 int _4 SphereThetaPhi<T>::NPhi(int_4kt) const354 int SphereThetaPhi<T>::NPhi(int kt) const 355 355 356 356 // Retourne le nombre de pixels en phi de la tranche kt 357 357 //-- 358 358 { 359 int _4nbpix;359 int nbpix; 360 360 // verification 361 if( (kt< 0) || (kt>= 2*NTheta_)) return(-1);361 if((kt < 0) || (kt >= 2*NTheta_)) return(-1); 362 362 363 363 // si on se trouve dans l'hemisphere Sud 364 if( kt >= NTheta_) {364 if(kt >= NTheta_) { 365 365 kt= 2*NTheta_-1-kt; 366 366 } … … 375 375 //++ 376 376 template <class T> 377 void SphereThetaPhi<T>::Theta(int _4 kt,r_4& tetMin,r_4& tetMax)377 void SphereThetaPhi<T>::Theta(int kt,double& tetMin,double& tetMax) 378 378 379 379 // Retourne les valeurs de theta limitant la tranche kt … … 407 407 //++ 408 408 template <class T> 409 void SphereThetaPhi<T>::Phi(int _4 kt,int_4 jp,r_4& phiMin,r_4& phiMax)409 void SphereThetaPhi<T>::Phi(int kt,int jp,double& phiMin,double& phiMax) 410 410 411 411 // Retourne les valeurs de phi limitant le pixel jp de la tranche kt … … 413 413 { 414 414 // verification 415 if( (kt< 0) || (kt>= 2*NTheta_)) {415 if((kt < 0) || (kt >= 2*NTheta_)) { 416 416 phiMin= -99999.; 417 417 phiMax= -99999.; … … 420 420 421 421 // si on se trouve dans l'hemisphere Sud 422 if( kt >= NTheta_) kt= 2*NTheta_-1-kt;422 if(kt >= NTheta_) kt= 2*NTheta_-1-kt; 423 423 424 424 // verifie si la tranche kt contient au moins jp pixels … … 429 429 } 430 430 431 r_4 dphi= (r_4)DeuxPi/(r_4)NPhi_[kt];432 phiMin= dphi*( r_4)(jp);433 phiMax= dphi*( r_4)(jp+1);431 double dphi= DeuxPi/(double)NPhi_[kt]; 432 phiMin= dphi*(double)(jp); 433 phiMax= dphi*(double)(jp+1); 434 434 return; 435 435 } … … 438 438 //++ 439 439 template <class T> 440 int _4 SphereThetaPhi<T>::Index(int_4 kt,int_4jp) const440 int SphereThetaPhi<T>::Index(int kt,int jp) const 441 441 442 442 // Retourne l'indice du pixel d'indice jp dans la tranche kt 443 443 //-- 444 444 { 445 int _4k;445 int k; 446 446 bool fgzn= false; 447 447 448 448 // si on se trouve dans l'hemisphere Sud 449 if( kt >= NTheta_) {449 if(kt >= NTheta_) { 450 450 fgzn= true; 451 451 kt= 2*NTheta_-1-kt; … … 471 471 //++ 472 472 template <class T> 473 void SphereThetaPhi<T>::ThetaPhiIndex(int _4 k,int_4& kt,int_4& jp)473 void SphereThetaPhi<T>::ThetaPhiIndex(int k,int& kt,int& jp) 474 474 475 475 // Retourne les indices kt et jp du pixel d'indice k … … 478 478 bool fgzn= false; 479 479 // si on se trouve dans l'hemisphere Sud 480 if( k >= NPix_/2 ) { 481 fgzn= true; 482 k= NPix_-1-k; 483 } 480 if(k >= NPix_/2) 481 { 482 fgzn= true; 483 k= NPix_-1-k; 484 } 484 485 485 486 // on recupere l'indice kt de la tranche qui contient le pixel k 486 487 int i; 487 for( i=0; i< NTheta_; i++)488 if( k< TNphi_[i+1]) break;488 for(i = 0; i < NTheta_; i++) 489 if(k < TNphi_[i+1]) break; 489 490 490 491 // indice kt de tranche … … 494 495 // indice jp de pixel 495 496 if (fgzn) jp= TNphi_[i+1]-k-1; 496 else jp= k-TNphi_[i]; 497 498 } 499 //++ 500 template <class T> 501 void SphereThetaPhi<T>::Pixelize( int_4 m) 497 else jp= k-TNphi_[i]; 498 } 499 //++ 500 template <class T> 501 void SphereThetaPhi<T>::Pixelize(int m) 502 502 503 503 // effectue le découpage en pixels (m et pet ont la même signification … … 511 511 //-- 512 512 { 513 int _4ntotpix,i,j;513 int ntotpix,i,j; 514 514 515 515 // Decodage et controle des arguments d'appel : … … 524 524 // Creation des vecteurs contenant : 525 525 // Les valeurs limites de theta (une valeur de plus que le nombre de bandes...) 526 Theta_= new r_4[m+1];526 Theta_= new double[m+1]; 527 527 528 528 // Le nombre de pixels en phi de chacune des bandes en theta 529 NPhi_ = new int _4[m];529 NPhi_ = new int[m]; 530 530 531 531 // Le nombre/Deuxpi total des pixels contenus dans les bandes de z superieur a une 532 532 // bande donnee (mTPphi[m] contient le nombre de pixels total de l'hemisphere) 533 TNphi_= new int _4[m+1];533 TNphi_= new int[m+1]; 534 534 535 535 // Calcul du nombre total de pixels dans chaque bande pour optimiser … … 544 544 { 545 545 TNphi_[j]= TNphi_[j-1]+NPhi_[j-1]; 546 NPhi_[j] = (int _4)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ;546 NPhi_[j] = (int)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ; 547 547 } 548 548 … … 576 576 //++ 577 577 template <class T> 578 void SphereThetaPhi<T>::GetThetaSlice(int_4 index, r_4& theta, TVector<float>& phi, TVector<T>& value) const578 void SphereThetaPhi<T>::GetThetaSlice(int index,double& theta, TVector<double>& phi, TVector<T>& value) const 579 579 580 580 // Retourne, pour la tranche en theta d'indice 'index' le theta … … 594 594 } 595 595 596 int _4iring= Index(index,0);597 int _4bid = this->NPhi(index);596 int iring= Index(index,0); 597 int bid = this->NPhi(index); 598 598 int lring = bid; 599 599 cout << " iring= " << iring << " lring= " << lring << endl; … … 601 601 phi.ReSize(lring); 602 602 value.ReSize(lring); 603 floatTe= 0.;604 floatFi= 0.;603 double Te= 0.; 604 double Fi= 0.; 605 605 for(int kk = 0; kk < lring; kk++) 606 606 { … … 613 613 614 614 template <class T> 615 void SphereThetaPhi<T>::setmNPhi(int _4* array, int_4m)616 //remplit 615 void SphereThetaPhi<T>::setmNPhi(int* array, int m) 616 //remplit le tableau contenant le nombre de pixels en phi de chacune des bandes en theta 617 617 //-- 618 618 { 619 NPhi_= new int _4[m];619 NPhi_= new int[m]; 620 620 for(int k = 0; k < m; k++) NPhi_[k]= array[k]; 621 621 } 622 622 623 623 template <class T> 624 void SphereThetaPhi<T>::setmTNphi(int _4* array, int_4m)624 void SphereThetaPhi<T>::setmTNphi(int* array, int m) 625 625 //remplit le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes 626 626 //-- 627 627 { 628 TNphi_= new int _4[m];628 TNphi_= new int[m]; 629 629 for(int k = 0; k < m; k++) TNphi_[k]= array[k]; 630 630 } 631 631 632 632 template <class T> 633 void SphereThetaPhi<T>::setmTheta( r_4* array, int_4m)633 void SphereThetaPhi<T>::setmTheta(double* array, int m) 634 634 //remplit le tableau contenant les valeurs limites de theta 635 635 //-- 636 636 { 637 Theta_= new r_4[m];637 Theta_= new double[m]; 638 638 for(int k = 0; k < m; k++) Theta_[k]= array[k]; 639 639 } 640 640 641 641 template <class T> 642 void SphereThetaPhi<T>::setDataBlock(T* data, int _4m)642 void SphereThetaPhi<T>::setDataBlock(T* data, int m) 643 643 // remplit le vecteur des contenus des pixels 644 644 { … … 755 755 } 756 756 757 int _4mNTheta;757 int mNTheta; 758 758 is.GetI4(mNTheta); 759 759 dobj->setSizeIndex(mNTheta); 760 760 761 int _4mNPix;761 int mNPix; 762 762 is.GetI4(mNPix); 763 763 dobj->setNbPixels(mNPix); 764 764 765 r_8mOmeg;765 double mOmeg; 766 766 is.GetR8(mOmeg); 767 767 dobj->setPixSolAngle(mOmeg); 768 768 769 int _4* mNphi= new int_4[mNTheta];769 int* mNphi= new int[mNTheta]; 770 770 is.GetI4s(mNphi, mNTheta); 771 771 dobj->setmNPhi(mNphi, mNTheta); 772 772 delete [] mNphi; 773 773 774 int _4* mTNphi= new int_4[mNTheta+1];774 int* mTNphi= new int[mNTheta+1]; 775 775 is.GetI4s(mTNphi, mNTheta+1); 776 776 dobj->setmTNphi(mTNphi, mNTheta+1); 777 777 delete [] mTNphi; 778 778 779 r_4* mTheta= new r_4[mNTheta+1];780 is.GetR 4s(mTheta, mNTheta+1);779 double* mTheta= new double[mNTheta+1]; 780 is.GetR8s(mTheta, mNTheta+1); 781 781 dobj->setmTheta(mTheta, mNTheta+1); 782 782 delete [] mTheta; 783 783 784 784 T* mPixels= new T[mNPix]; 785 //is.Get(mPixels, mNPix);786 785 PIOSReadArray(is, mPixels, mNPix); 787 786 dobj->setDataBlock(mPixels, mNPix); … … 801 800 802 801 char strg[256]; 803 int _4mNTheta= dobj->SizeIndex();804 int _4mNPix = dobj->NbPixels();802 int mNTheta= dobj->SizeIndex(); 803 int mNPix = dobj->NbPixels(); 805 804 806 805 if(dobj->ptrInfo()) … … 821 820 os.PutI4s(dobj->getmNPhi() , mNTheta); 822 821 os.PutI4s(dobj->getmTNphi(), mNTheta+1); 823 os.PutR 4s(dobj->getmTheta(), mNTheta+1);822 os.PutR8s(dobj->getmTheta(), mNTheta+1); 824 823 //os.Put((dobj->getDataBlock())->Data(), mNPix); 825 824 PIOSWriteArray(os,(dobj->getDataBlock())->Data(), mNPix);
Note:
See TracChangeset
for help on using the changeset viewer.