Changeset 2960 in Sophya
- Timestamp:
- Jun 1, 2006, 4:35:47 PM (19 years ago)
- Location:
- trunk/SophyaLib/SkyMap
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SkyMap/spherehealpix.cc
r2885 r2960 28 28 29 29 \verbatim 30 30 Adapted from : 31 31 ----------------------------------------------------------------------- 32 32 version 0.8.2 Aug97 TAC Eric Hivon, Kris Gorski … … 84 84 85 85 { 86 87 if(m <= 0 || m > 8192)88 {89 cout << "SphereHEALPix : m hors bornes [0,8192], m= " << m << endl;90 throw RangeCheckError("SphereHEALPix<T>::SphereHEALPix() - Out of bound nside (< 8192)!");91 }92 // verifier que m est une puissance de deux93 int x= m;94 while(x%2 == 0) x/=2;95 if(x != 1)96 {97 cout<<"SphereHEALPix: m doit etre une puissance de deux, m= "<<m<<endl;98 throw ParmError("SphereHEALPix<T>::SphereHEALPix() - nside != 2^n !");99 }100 86 InitNul(); 101 87 Pixelize(m); 102 88 SetThetaSlices(); 103 89 } 104 // ++90 //! Copy constructor 105 91 template<class T> 106 92 SphereHEALPix<T>::SphereHEALPix(const SphereHEALPix<T>& s, bool share) 107 93 : pixels_(s.pixels_, share), sliceBeginIndex_(s.sliceBeginIndex_, share), 108 94 sliceLenght_(s.sliceLenght_, share) 109 // copy constructor110 95 //-- 111 96 { … … 214 199 215 200 /*! \fn void SOPHYA::SphereHEALPix::Resize(int_4 m) 216 \param <m> "nside" of the Gorskialgorithm201 \param <m> "nside" of the HEALPix algorithm 217 202 218 203 The total number of pixels will be Npix = 12*nside**2 … … 225 210 226 211 { 212 if ((m <= 0 && nSide_ > 0)) { 213 cout << "SphereHEALPix<T>::Resize(m) with m<=0, NOT resized" << endl; 214 return; 215 } 216 InitNul(); 217 Pixelize(m); 218 SetThetaSlices(); 219 } 220 221 template<class T> 222 void SphereHEALPix<T>::Pixelize( int_4 m) 223 224 // prépare la pixelisation Gorski (m a la même signification 225 // que pour le constructeur) 226 // 227 // 228 { 227 229 if (m<=0 || m> 8192) { 228 cout << "SphereHEALPix : m hors bornes [0,8192], m= " << m<< endl;229 exit(1);230 cout << "SphereHEALPix<T>::Pixelize() m=" << m <<" out of range [0,8192]" << endl; 231 throw ParmError("SphereHEALPix<T>::Pixelize() m out of range"); 230 232 } 231 233 // verifier que m est une puissance de deux 232 234 int x= m; 233 235 while (x%2==0) x/=2; 234 if(x != 1) 235 { 236 cout<<"SphereHEALPix: m doit etre une puissance de deux, m= "<<m<<endl; 237 exit(1); 238 } 239 InitNul(); 240 Pixelize(m); 241 SetThetaSlices(); 242 } 243 244 template<class T> 245 void SphereHEALPix<T>::Pixelize( int_4 m) 246 247 // prépare la pixelisation Gorski (m a la même signification 248 // que pour le constructeur) 249 // 250 // 251 { 236 if(x != 1) { 237 cout << "SphereHEALPix<T>::Pixelize() m=" << m << " != 2^n " << endl; 238 throw ParmError("SphereHEALPix<T>::Pixelize() m!=2^n"); 239 } 240 252 241 // On memorise les arguments d'appel 253 242 nSide_= m; -
trunk/SophyaLib/SkyMap/spherethetaphi.cc
r2885 r2960 60 60 /* --Methode-- */ 61 61 62 //++ 62 /*! 63 \brief Constructor with specification of number of slices (in a hemisphere) 64 \param m is the number of slices in theta on an hemisphere (the polar cap 65 forms the first slice). 66 */ 63 67 template <class T> 64 68 SphereThetaPhi<T>::SphereThetaPhi(int_4 m) 65 66 // m is the number of slices in theta on an hemisphere (the polar cap67 // forms the first slice).68 //--69 69 { 70 70 InitNul(); … … 72 72 } 73 73 74 //! Copy constructor (shares the pixel data if share==true) 74 75 template <class T> 75 76 SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s, bool share) … … 84 85 } 85 86 87 //! Copy constructor (shares the pixel data) 86 88 template <class T> 87 89 SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s) … … 105 107 {} 106 108 107 //++108 // Titre Public Méthods109 //--110 109 template <class T> 111 110 void SphereThetaPhi<T>::InitNul() … … 118 117 119 118 120 // ++119 //! re-pixelize the sphere if (m > 0) 121 120 template <class T> 122 121 void SphereThetaPhi<T>::Resize(int_4 m) 123 // re-pixelize the sphere 124 //-- 125 { 122 { 123 if ((m <= 0) && (NTheta_ > 0) ) { 124 cout << "SphereThetaPhi<T>::Resize(m) with m<=0 - NOT resized" << endl; 125 return; 126 } 126 127 InitNul(); 127 128 Pixelize(m); 128 129 } 129 130 131 //! Clone or share the SphereThetaPhi object \b a 130 132 template<class T> 131 133 void SphereThetaPhi<T>::CloneOrShare(const SphereThetaPhi<T>& a) … … 142 144 if (a.mInfo_) this->mInfo_ = new DVList(*(a.mInfo_)); 143 145 } 146 //! Share the pixel data with object \b a 144 147 template<class T> 145 148 void SphereThetaPhi<T>::Share(const SphereThetaPhi<T>& a) … … 158 161 159 162 ////////////////////////// methodes de copie/share 163 //! Perform data copy or shares the data 160 164 template<class T> 161 165 SphereThetaPhi<T>& SphereThetaPhi<T>::Set(const SphereThetaPhi<T>& a) … … 176 180 } 177 181 182 //! Perform data copy or shares the data 178 183 template<class T> 179 184 SphereThetaPhi<T>& SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>& a) … … 197 202 198 203 /* --Methode-- */ 199 // ++204 //! Return total number of pixels 200 205 template <class T> 201 206 int_4 SphereThetaPhi<T>::NbPixels() const 202 203 // Return total number of pixels204 //--205 207 { 206 208 return(NPix_); … … 208 210 209 211 /* --Methode-- */ 210 // ++212 //! Return value of pixel with index k 211 213 template <class T> 212 214 T& SphereThetaPhi<T>::PixVal(int_4 k) 213 214 // Return value of pixel with index k215 //--216 215 { 217 216 if((k < 0) || (k >= NPix_)) … … 222 221 } 223 222 224 // ++223 //! Return value of pixel with index k 225 224 template <class T> 226 225 T const& SphereThetaPhi<T>::PixVal(int_4 k) const 227 228 // Return value of pixel with index k229 //--230 226 { 231 227 if((k < 0) || (k >= NPix_)) … … 237 233 238 234 /* --Methode-- */ 239 // ++235 //! Return true if teta,phi in map 240 236 template <class T> 241 237 bool SphereThetaPhi<T>::ContainsSph(double /*theta*/, double /*phi*/) const 242 //--243 238 { 244 239 return(true); … … 246 241 247 242 /* --Methode-- */ 248 // ++243 //! Return index of the pixel corresponding to direction (theta, phi). 249 244 template <class T> 250 245 int_4 SphereThetaPhi<T>::PixIndexSph(double theta, double phi) const 251 252 // Return index of the pixel corresponding to253 // direction (theta, phi).254 //--255 246 { 256 247 double dphi; … … 275 266 276 267 /* --Methode-- */ 277 // ++268 //! Return (theta,phi) coordinates of middle of pixel with index k 278 269 template <class T> 279 270 void SphereThetaPhi<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const 280 281 // Return (theta,phi) coordinates of middle of pixel with index k282 //--283 271 { 284 272 int i; … … 302 290 } 303 291 292 //! Setting pixel values to a constant 304 293 template <class T> 305 294 T SphereThetaPhi<T>::SetPixels(T v) … … 309 298 } 310 299 311 //++ 300 /*! 301 \brief Pixel Solid angle (steradians) 302 All the pixels have the same solid angle. The dummy argument is 303 for compatibility with eventual pixelizations which would not 304 fulfil this requirement. 305 */ 312 306 template <class T> 313 307 double SphereThetaPhi<T>::PixSolAngle(int_4 /*dummy*/) const 314 308 315 // Pixel Solid angle (steradians)316 // All the pixels have the same solid angle. The dummy argument is317 // for compatibility with eventual pixelizations which would not318 // fulfil this requirement.319 //--320 309 { 321 310 return Omega_; … … 323 312 324 313 /* --Methode-- */ 325 // ++314 //! Return values of theta,phi which limit the pixel with index k 326 315 template <class T> 327 316 void SphereThetaPhi<T>::Limits(int_4 k,double& tetMin,double& tetMax,double& phiMin,double& phiMax) 328 329 // Return values of theta,phi which limit the pixel with index k330 //--331 317 { 332 318 int j; … … 376 362 377 363 /* --Methode-- */ 378 // ++364 //! Return number of theta-slices on the sphere 379 365 template <class T> 380 366 uint_4 SphereThetaPhi<T>::NbThetaSlices() const 381 382 // Return number of theta-slices on the sphere383 //--384 367 { 385 368 if (NTheta_<=0) … … 391 374 392 375 /* --Methode-- */ 393 // ++376 //! Return number of pixels along the phi-direction of the kt-th slice 394 377 template <class T> 395 378 int_4 SphereThetaPhi<T>::NPhi(int_4 kt) const 396 397 // Return number of pixels in phi-direction of the kt-th slice398 //--399 379 { 400 380 int nbpix; … … 414 394 415 395 /* --Methode-- */ 416 // ++396 //! Return theta values which limit the slice kt 417 397 template <class T> 418 398 void SphereThetaPhi<T>::Theta(int_4 kt,double& tetMin,double& tetMax) 419 420 // Return theta values which limit the slice kt421 //--422 399 { 423 400 bool fgzn= false; … … 446 423 447 424 /* --Methode-- */ 448 // ++425 //! Return values of phi which limit the jp-th pixel of the kt-th slice 449 426 template <class T> 450 427 void SphereThetaPhi<T>::Phi(int_4 kt,int_4 jp,double& phiMin,double& phiMax) 451 452 // Return values of phi which limit the jp-th pixel of the kt-th slice453 //--454 428 { 455 429 // verification … … 477 451 478 452 /* --Methode-- */ 479 // ++453 //! Return pixel index with sequence index jp in the slice kt 480 454 template <class T> 481 455 int_4 SphereThetaPhi<T>::Index(int_4 kt,int_4 jp) const 482 483 // Return pixel index with sequence index jp in the slice kt484 //--485 456 { 486 457 int k; … … 510 481 511 482 /* --Methode-- */ 512 // ++483 //! Return indices kt (theta) and jp (phi) of pixel with index k 513 484 template <class T> 514 485 void SphereThetaPhi<T>::ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp) 515 516 // Return indices kt (theta) and jp (phi) of pixel with index k517 //--518 486 { 519 487 bool fgzn= false; … … 538 506 else jp= k-TNphi_(i); 539 507 } 540 //++ 508 /*! 509 \brief achieve the splitting into pixels 510 m has the same signification as for the constructor 511 512 Each theta-slice of the north hemisphere will be spitted starting f 513 from phi=0 ... 514 515 South hemisphere is scanned in the same direction according to phi 516 and from equator to the pole (the pixel following the last one of 517 the slice closest to the equator with z>0, is the pixel with lowest 518 phi of the slice closest of the equator with z<0). 519 */ 541 520 template <class T> 542 521 void SphereThetaPhi<T>::Pixelize(int_4 m) 543 522 544 // achieve the splitting into pixels (m has the same signification545 // as for the constructor)546 //547 // Each theta-slice of the north hemisphere will be spitted starting f548 // from phi=0 ...549 //550 // South hemisphere is scanned in the same direction according to phi551 // and from equator to the pole (the pixel following the last one of552 // the slice closest to the equator with z>0, is the pixel with lowest553 // phi of the slice closest of the equator with z<0).554 523 //-- 555 524 { … … 557 526 558 527 // Decodage et controle des arguments d'appel : 559 // au moins 2 et au plus 16384bandes d'un hemisphere en theta528 // au moins 2 et au plus 524288 bandes d'un hemisphere en theta 560 529 if (m < 2) m = 2; 561 if (m > 16384) m = 16384;530 if (m > 524288) m = 524288; 562 531 563 532 // On memorise les arguments d'appel … … 623 592 } 624 593 625 //++ 594 595 /*! 596 \brief return a Theta slice information 597 For a theta-slice with index 'index', return : 598 the corresponding "theta" 599 a vector containing the phi's of the pixels of the slice 600 a vector containing the corresponding values of pixels 601 */ 626 602 template <class T> 627 603 void SphereThetaPhi<T>::GetThetaSlice(int_4 index,r_8& theta, TVector<r_8>& phi, TVector<T>& value) const 628 629 // For a theta-slice with index 'index', return :630 // the corresponding "theta"631 // a vector containing the phi's of the pixels of the slice632 // a vector containing the corresponding values of pixels633 //--634 604 635 605 { … … 656 626 } 657 627 658 //++ 628 /* 629 \brief return information on a theta slice 630 For a theta-slice with index 'index', return : 631 the corresponding "theta" 632 the corresponding "phi" for first pixel of the slice 633 a vector containing the indices of the pixels of the slice 634 (equally distributed in phi) 635 a vector containing the corresponding values of pixels 636 */ 659 637 template <class T> 660 638 void SphereThetaPhi<T>::GetThetaSlice(int_4 index,r_8& theta, r_8& phi0,TVector<int_4>& pixelIndices, TVector<T>& value) const 661 662 // For a theta-slice with index 'index', return :663 // the corresponding "theta"664 // the corresponding "phi" for first pixel of the slice665 // a vector containing the indices of the pixels of the slice666 // (equally distributed in phi)667 // a vector containing the corresponding values of pixels668 //--669 639 670 640 { -
trunk/SophyaLib/SkyMap/spherethetaphi.h
r2433 r2960 21 21 22 22 // ***************** Class SphereThetaPhi ***************************** 23 /*! sphere splitted with respect to theta, phi : each hemisphere is24 splitted into (m-1) parallels (equator does not enter into account).25 This operation defines m slices, each of which is splitted into26 equidistant meridians. This splitting is realized in such a way that27 all pixels have the same area and are as square as possible.28 29 One begins with the hemisphere with positive z, starting from the pole30 toward the equator. The first pixel is the polar cap ; it is circular31 and centered on theta=0.32 */33 23 template <class T> 34 24 class SphereThetaPhi : public SphericalMap<T> … … 38 28 39 29 SphereThetaPhi(); 40 /*! m is the number of slices in theta on an hemisphere (the polar cap41 forms the first slice).42 pet is a dummy parameter at the moment.43 */44 30 SphereThetaPhi(int_4 m); 45 31 SphereThetaPhi(const SphereThetaPhi<T>& s, bool share); … … 68 54 69 55 /* retourne le nombre de pixels */ 70 /*! Return total number of pixels */71 56 virtual int_4 NbPixels() const; 72 57 73 58 /* retourne la valeur du pixel d'indice k */ 74 /*! Return value of pixel with index k */75 59 virtual T& PixVal(int_4 k); 76 60 virtual T const& PixVal(int_4 k) const; … … 83 67 84 68 /* retourne les coordonnees Spheriques du centre du pixel d'indice k */ 85 /*! Return (theta,phi) coordinates of middle of pixel with index k */86 69 virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const; 87 70 88 /* !Setting pixel values to a constant */71 /* Setting pixel values to a constant */ 89 72 virtual T SetPixels(T v); 90 73 91 74 /* retourne/fixe l'angle Solide de Pixel (steradians) */ 92 /*! Pixel Solid angle (steradians)93 94 All the pixels have the same solid angle. The dummy argument is95 for compatibility with eventual pixelizations which would not96 fulfil this requirement.97 */98 75 virtual double PixSolAngle(int_4 dummy=0) const; 99 76 100 77 /* retourne/fixe la valeur du parametre de decoupage m */ 78 //! Return the pixelisation parameter (number of slices in a hemisphere) 101 79 inline virtual int_4 SizeIndex() const { return( NTheta_); } 102 80 103 81 /* Acces to the DataBlock */ 82 //! Acces to the pixel data NDataBlock<T> object 104 83 inline NDataBlock<T>& DataBlock() {return pixels_;} 84 //! Acces to the pixel data NDataBlock<T> object (const version) 105 85 inline const NDataBlock<T>& DataBlock() const {return pixels_;} 106 86 107 87 // ------------- Specific methods ---------------------- 108 88 109 /*! re-pixelize the sphere */110 89 virtual void Resize(int_4 m); 111 90 … … 117 96 118 97 /* Nombre de tranches en theta */ 119 /* !Return number of theta-slices on the sphere */98 /* Return number of theta-slices on the sphere */ 120 99 uint_4 NbThetaSlices() const; 121 100 … … 125 104 /* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */ 126 105 /* de la tranche d'indice kt */ 127 /*! Return theta values which limit the slice kt */128 106 void Theta(int_4 kt, double& t1, double& t2); 129 107 130 108 /* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */ 131 109 /* dans la tranche d'indice kt */ 132 /*! Return values of phi which limit the jp-th pixel of the kt-th slice */133 110 void Phi(int_4 kt, int_4 jp, double& p1, double& p2); 134 111 … … 138 115 139 116 /* Indice kt de la tranche et indice jp du pixel d'indice k */ 140 /*! Return indices kt (theta) and jp (phi) of pixel with index k */141 117 void ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp); 142 118 143 /*! achieve the splitting into pixels (m has the same signification144 as for the constructor)145 146 Each theta-slice of the north hemisphere will be spitted starting f147 from phi=0 ...148 149 South hemisphere is scanned in the same direction according to phi150 and from equator to the pole (the pixel following the last one of151 the slice closest to the equator with z>0, is the pixel with lowest152 phi of the slice closest of the equator with z<0).153 */154 119 void Pixelize(int_4); 155 120 156 /*! For a theta-slice with index 'index', return :157 158 the corresponding "theta"159 160 a vector containing the phi's of the pixels of the slice161 162 a vector containing the corresponding values of pixels163 */164 121 virtual void GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const; 165 166 /*! For a theta-slice with index 'index', return :167 168 the corresponding "theta"169 170 the corresponding "phi" for first pixel of the slice171 172 a vector containing indices of the pixels of the slice173 174 (equally distributed in phi)175 176 a vector containing the corresponding values of pixels177 */178 122 virtual void GetThetaSlice(int_4 index, r_8& theta, r_8& phi0,TVector<int_4>& pixelIndices, TVector<T>& value) const ; 179 123 180 124 181 / * impression */125 //! ASCII dump (print) of the pixel map 182 126 void print(ostream& os) const; 183 127 … … 331 275 inline SphereThetaPhi<T> operator - (const SphereThetaPhi<T>& a,const SphereThetaPhi<T>& b) 332 276 { SphereThetaPhi<T> result; result.SetTemp(true); 333 if (b.IsTemp()) { result.Share(b); result.SubElt(a, true); } 334 else { result.CloneOrShare(a); result.SubElt(b); } 277 result.CloneOrShare(a); result.SubElt(b); 335 278 return result; } 336 279
Note:
See TracChangeset
for help on using the changeset viewer.