Changeset 1217 in Sophya for trunk/SophyaLib/SkyMap/spherehealpix.cc
- Timestamp:
- Oct 3, 2000, 10:19:18 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/SkyMap/spherehealpix.cc
r1196 r1217 17 17 using namespace SOPHYA; 18 18 19 //******************************************************************* 20 //++ 21 // Class SphereHEALPix 22 // 23 // include SphereHealpix.h strutil.h 24 // 25 // Pixelisation Gorski 26 // 27 // 28 //| ----------------------------------------------------------------------- 29 //| version 0.8.2 Aug97 TAC Eric Hivon, Kris Gorski 30 //| ----------------------------------------------------------------------- 31 // 32 // the sphere is split in 12 diamond-faces containing nside**2 pixels each 33 // 34 // the numbering of the pixels (in the nested scheme) is similar to 35 // quad-cube 36 // In each face the first pixel is in the lowest corner of the diamond 37 // 38 // the faces are (x,y) coordinate on each face 39 //| . . . . <--- North Pole 40 //| / \ / \ / \ / \ ^ ^ 41 //| . 0 . 1 . 2 . 3 . <--- z = 2/3 \ / 42 //| \ / \ / \ / \ / y \ / x 43 //| 4 . 5 . 6 . 7 . 4 <--- equator \ / 44 //| / \ / \ / \ / \ \/ 45 //| . 8 . 9 .10 .11 . <--- z = -2/3 (0,0) : lowest corner 46 //| \ / \ / \ / \ / 47 //| . . . . <--- South Pole 48 //| 49 // phi:0 2Pi 50 // 51 // in the ring scheme pixels are numbered along the parallels 52 // the first parallel is the one closest to the north pole and so on 53 // on each parallel, pixels are numbered starting from the one closest 54 // to phi = 0 55 // 56 // nside MUST be a power of 2 (<= 8192) 57 //-- 58 //++ 59 // 60 // Links Parents 61 // 62 // SphericalMap 63 //-- 19 /*! 20 \class SOPHYA::SphereHEALPix 21 22 ******************************************************************* 23 Pixelisation Gorski 24 25 \verbatim 26 27 ----------------------------------------------------------------------- 28 version 0.8.2 Aug97 TAC Eric Hivon, Kris Gorski 29 ----------------------------------------------------------------------- 30 31 the sphere is split in 12 diamond-faces containing nside**2 pixels each 32 the numbering of the pixels (in the nested scheme) is similar to 33 quad-cube 34 In each face the first pixel is in the lowest corner of the diamond 35 the faces are (x,y) coordinate on each face 36 37 . . . . <--- North Pole 38 / \ / \ / \ / \ ^ ^ 39 . 0 . 1 . 2 . 3 . <--- z = 2/3 \ / 40 \ / \ / \ / \ / y \ / x 41 4 . 5 . 6 . 7 . 4 <--- equator \ / 42 / \ / \ / \ / \ \/ 43 . 8 . 9 .10 .11 . <--- z = -2/3 (0,0) : lowest corner 44 \ / \ / \ / \ / 45 . . . . <--- South Pole 46 \endverbatim 47 phi:0 2Pi 48 49 in the ring scheme pixels are numbered along the parallels 50 the first parallel is the one closest to the north pole and so on 51 on each parallel, pixels are numbered starting from the one closest 52 to phi = 0 53 54 nside MUST be a power of 2 (<= 8192) 55 56 */ 64 57 65 58 /* --Methode-- */ 66 //++67 // Titre Constructors68 //--69 //++70 59 71 60 template<class T> … … 73 62 sliceLenght_() 74 63 75 //-- 64 76 65 { 77 66 InitNul(); 78 // SetTemp(false); 79 } 80 81 //++ 67 } 68 69 /*! \fn SOPHYA::SphereHEALPix::SphereHEALPix(int_4 m) 70 71 \param <m> : "nside" of the Healpix algorithm 72 73 The total number of pixels will be Npix = 12*nside**2 74 75 nside MUST be a power of 2 (<= 8192) 76 */ 77 82 78 template<class T> 83 79 SphereHEALPix<T>::SphereHEALPix(int_4 m) 84 80 85 // m is the "nside" of the Gorski algorithm86 //87 // The total number of pixels will be Npix = 12*nside**288 //89 // nside MUST be a power of 2 (<= 8192)90 //--91 81 { 92 82 … … 202 192 //-- 203 193 204 //++ 194 /*! \fn void SOPHYA::SphereHEALPix::Resize(int_4 m) 195 \param <m> "nside" of the Gorski algorithm 196 197 The total number of pixels will be Npix = 12*nside**2 198 199 nside MUST be a power of 2 (<= 8192) 200 */ 205 201 template<class T> 206 202 void SphereHEALPix<T>::Resize(int_4 m) 207 203 208 // m is the "nside" of the Gorski algorithm 209 // 210 // The total number of pixels will be Npix = 12*nside**2 211 // 212 // nside MUST be a power of 2 (<= 8192) 213 //-- 204 214 205 { 215 206 if (m<=0 || m> 8192) { … … 270 261 271 262 /* --Methode-- */ 272 //++ 263 /* Nombre de pixels du decoupage */ 264 /*! \fn int_4 SOPHYA::SphereHEALPix::NbPixels() const 265 266 Return number of pixels of the splitting 267 */ 273 268 template<class T> 274 269 int_4 SphereHEALPix<T>::NbPixels() const 275 276 // Retourne le nombre de pixels du découpage277 //--278 270 { 279 271 return(nPix_); 280 272 } 281 273 282 //++ 274 275 /*! \fn uint_4 SOPHYA::SphereHEALPix::NbThetaSlices() const 276 277 \return number of slices in theta direction on the sphere 278 */ 283 279 template<class T> 284 280 uint_4 SphereHEALPix<T>::NbThetaSlices() const 285 286 // Return number of slices in theta direction on the sphere287 //--288 281 { 289 282 uint_4 nbslices = uint_4(4*nSide_-1); … … 296 289 } 297 290 298 //++ 291 /*! \fn void SOPHYA::SphereHEALPix::GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const 292 293 For a theta-slice with index 'index', return : 294 295 the corresponding "theta" 296 297 a vector containing the phi's of the pixels of the slice 298 299 a vector containing the corresponding values of pixels 300 */ 299 301 template<class T> 300 302 void SphereHEALPix<T>::GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const 301 303 302 // For a theta-slice with index 'index', return :303 //304 // the corresponding "theta"305 //306 // a vector containing the phi's of the pixels of the slice307 //308 // a vector containing the corresponding values of pixels309 //310 //--311 304 { 312 305 313 306 if (index<0 || index >= NbThetaSlices()) 314 307 { 315 // THROW(out_of_range("SphereHEALPix::PIxVal Pixel index out of range"));316 308 cout << " SphereHEALPix::GetThetaSlice : Pixel index out of range" <<endl; 317 309 throw RangeCheckError(" SphereHEALPix::GetThetaSlice : Pixel index out of range"); … … 335 327 theta= TH; 336 328 } 337 //++ 338 //++ 329 /*! \fn void SOPHYA::SphereHEALPix::GetThetaSlice(int_4 sliceIndex,r_8& theta, r_8& phi0, TVector<int_4>& pixelIndices,TVector<T>& value) const 330 331 For a theta-slice with index 'index', return : 332 333 the corresponding "theta" 334 335 the corresponding "phi" for first pixel of the slice 336 337 a vector containing indices of the pixels of the slice 338 339 (equally distributed in phi) 340 341 a vector containing the corresponding values of pixels 342 */ 339 343 340 344 template<class T> 341 345 void SphereHEALPix<T>::GetThetaSlice(int_4 sliceIndex,r_8& theta, r_8& phi0, TVector<int_4>& pixelIndices,TVector<T>& value) const 342 346 343 // For a theta-slice with index 'sliceIndex', return :344 //345 // the corresponding "theta"346 // the corresponding "phi" for first pixel of the slice347 //348 // a vector containing the indices of the pixels of the slice349 // (equally distributed in phi)350 //351 // a vector containing the corresponding values of pixels352 //353 //--354 347 { 355 348 356 349 if (sliceIndex<0 || sliceIndex >= NbThetaSlices()) 357 350 { 358 // THROW(out_of_range("SphereHEALPix::PIxVal Pixel index out of range"));359 351 cout << " SphereHEALPix::GetThetaSlice : Pixel index out of range" <<endl; 360 352 throw RangeCheckError(" SphereHEALPix::GetThetaSlice : Pixel index out of range"); … … 372 364 PixThetaPhi(iring, theta, phi0); 373 365 } 374 //++ 366 375 367 template<class T> 376 368 void SphereHEALPix<T>::SetThetaSlices() 377 378 //--379 369 { 380 370 sliceBeginIndex_.ReSize(4*nSide_-1); … … 399 389 } 400 390 401 /* --Methode-- */ 402 //++ 391 392 /*! \fn T& SOPHYA::SphereHEALPix::PixVal(int_4 k) 393 394 \return value of pixel with "RING" index k 395 */ 403 396 template<class T> 404 397 T& SphereHEALPix<T>::PixVal(int_4 k) 405 398 406 // Return value of pixel with "RING" index k407 //--408 399 { 409 400 if((k < 0) || (k >= nPix_)) … … 414 405 } 415 406 416 /* --Methode-- */ 417 //++ 407 /*! \fn T const& SOPHYA::SphereHEALPix::PixVal(int_4 k) const 408 409 \return value of pixel with "RING" index k 410 */ 418 411 template<class T> 419 412 T const& SphereHEALPix<T>::PixVal(int_4 k) const 420 413 421 // Return value of pixel with "RING" index k422 //--423 414 { 424 415 if((k < 0) || (k >= nPix_)) … … 429 420 } 430 421 431 //++ 422 /*! \fn T& SOPHYA::SphereHEALPix::PixValNest(int_4 k) 423 424 \return value of pixel with "NESTED" index k 425 */ 432 426 template<class T> 433 427 T& SphereHEALPix<T>::PixValNest(int_4 k) 434 428 435 // Return value of pixel with "NESTED" index k436 429 //-- 437 430 { … … 442 435 return pixels_(nest2ring(nSide_,k)); 443 436 } 444 //++ 437 438 /*! \fn T const& SOPHYA::SphereHEALPix::PixValNest(int_4 k) const 439 440 \return value of pixel with "NESTED" index k 441 */ 445 442 446 443 template<class T> 447 444 T const& SphereHEALPix<T>::PixValNest(int_4 k) const 448 445 449 // Return value of pixel with "NESTED" index k450 //--451 446 { 452 447 if((k < 0) || (k >= nPix_)) … … 458 453 } 459 454 455 /*! \fn bool SOPHYA::SphereHEALPix::ContainsSph(double theta, double phi) const 456 457 \return true if teta,phi in map 458 */ 459 template<class T> 460 bool SphereHEALPix<T>::ContainsSph(double theta, double phi) const 461 { 462 return(true); 463 } 464 465 /*! \fn int_4 SOPHYA::SphereHEALPix::PixIndexSph(double theta,double phi) const 466 467 \return "RING" index of the pixel corresponding to direction (theta, phi). 468 */ 469 template<class T> 470 int_4 SphereHEALPix<T>::PixIndexSph(double theta,double phi) const 471 472 { 473 return ang2pix_ring(nSide_,theta,phi); 474 } 475 476 /*! \fn int_4 SOPHYA::SphereHEALPix::PixIndexSphNest(double theta,double phi) const 477 478 \return "NESTED" index of the pixel corresponding to direction (theta, phi). 479 */ 480 template<class T> 481 int_4 SphereHEALPix<T>::PixIndexSphNest(double theta,double phi) const 482 483 { 484 return ang2pix_nest(nSide_,theta,phi); 485 } 486 487 460 488 /* --Methode-- */ 461 //++ 462 template<class T> 463 bool SphereHEALPix<T>::ContainsSph(double /*theta*/, double /*phi*/) const 464 //-- 465 { 466 return(true); 467 } 468 469 /* --Methode-- */ 470 //++ 471 template<class T> 472 int_4 SphereHEALPix<T>::PixIndexSph(double theta,double phi) const 473 474 // Return "RING" index of the pixel corresponding to 475 // direction (theta, phi). 476 //-- 477 { 478 return ang2pix_ring(nSide_,theta,phi); 479 } 480 481 //++ 482 template<class T> 483 int_4 SphereHEALPix<T>::PixIndexSphNest(double theta,double phi) const 484 485 // Return "NESTED" index of the pixel corresponding to 486 // direction (theta, phi). 487 //-- 488 { 489 return ang2pix_nest(nSide_,theta,phi); 490 } 491 492 493 /* --Methode-- */ 494 //++ 489 /*! \fn void SOPHYA::SphereHEALPix::PixThetaPhi(int_4 k,double& theta,double& phi) const 490 \return (theta,phi) coordinates of middle of pixel with "RING" index k 491 */ 495 492 template<class T> 496 493 void SphereHEALPix<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const 497 498 // Return (theta,phi) coordinates of middle of pixel with "RING" index k499 //--500 494 { 501 495 pix2ang_ring(nSide_,k,theta,phi); 502 496 } 503 497 498 /*! \fn T SOPHYA::SphereHEALPix::SetPixels(T v) 499 500 Set all pixels to value v 501 */ 504 502 template <class T> 505 503 T SphereHEALPix<T>::SetPixels(T v) … … 509 507 } 510 508 511 //++ 512 template<class T> 513 double SphereHEALPix<T>::PixSolAngle(int_4 /*dummy*/) const 514 // Pixel Solid angle (steradians) 515 // All the pixels have the same solid angle. The dummy argument is 516 // for compatibility with eventual pixelizations which would not 517 // fulfil this requirement. 518 //-- 519 { 520 return omeg_; 521 } 522 523 //++ 509 510 511 /*! \fn void SOPHYA::SphereHEALPix::PixThetaPhiNest(int_4 k,double& theta,double& phi) const 512 513 \return (theta,phi) coordinates of middle of pixel with "NESTED" index k 514 */ 524 515 template<class T> 525 516 void SphereHEALPix<T>::PixThetaPhiNest(int_4 k,double& theta,double& phi) const 526 517 527 // Return (theta,phi) coordinates of middle of pixel with "NESTED" index k528 //--529 518 { 530 519 pix2ang_nest(nSide_,k,theta,phi); 531 520 } 532 521 533 //++ 522 523 /*! \fn int_4 SOPHYA::SphereHEALPix::NestToRing(int_4 k) const 524 525 translation from NESTED index into RING index 526 */ 534 527 template<class T> 535 528 int_4 SphereHEALPix<T>::NestToRing(int_4 k) const 536 529 537 // translation from NESTED index into RING index538 //539 //--540 530 { 541 531 return nest2ring(nSide_,k); 542 532 } 543 533 544 //++ 534 535 /*! \fn int_4 SOPHYA::SphereHEALPix::RingToNest(int_4 k) const 536 537 translation from RING index into NESTED index 538 */ 545 539 template<class T> 546 540 int_4 SphereHEALPix<T>::RingToNest(int_4 k) const 547 //548 // translation from RING index into NESTED index549 //550 //--551 541 { 552 542 return ring2nest(nSide_,k); … … 571 561 os << endl; 572 562 573 os << endl;574 //const PIXELS_XY& PXY= PIXELS_XY::instance();575 576 //os << endl; os << " contenu des tableaux conversions "<<endl;577 //for(int i=0; i < 5; i++)578 // {579 // os<<PXY.pix2x_(i)<<", "<<PXY.pix2y_(i)<<", "<<PXY.x2pix_(i)<<", "<<PXY.y2pix_(i)<<endl;580 // }581 os << endl;582 563 583 564 }
Note:
See TracChangeset
for help on using the changeset viewer.