[843] | 1 | #include "machdefs.h"
|
---|
| 2 | #include <math.h>
|
---|
| 3 | #include <complex>
|
---|
| 4 |
|
---|
| 5 | #include "pexceptions.h"
|
---|
| 6 | #include "fiondblock.h"
|
---|
| 7 | #include "spherehealpix.h"
|
---|
| 8 | #include "strutil.h"
|
---|
[1196] | 9 |
|
---|
[843] | 10 | extern "C"
|
---|
| 11 | {
|
---|
| 12 | #include <stdio.h>
|
---|
| 13 | #include <stdlib.h>
|
---|
| 14 | #include <unistd.h>
|
---|
| 15 | }
|
---|
| 16 |
|
---|
[1195] | 17 | using namespace SOPHYA;
|
---|
[843] | 18 |
|
---|
[1217] | 19 | /*!
|
---|
| 20 | \class SOPHYA::SphereHEALPix
|
---|
[843] | 21 |
|
---|
[1217] | 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 | */
|
---|
| 57 |
|
---|
[843] | 58 | /* --Methode-- */
|
---|
| 59 |
|
---|
| 60 | template<class T>
|
---|
[979] | 61 | SphereHEALPix<T>::SphereHEALPix() : pixels_(), sliceBeginIndex_(),
|
---|
| 62 | sliceLenght_()
|
---|
[843] | 63 |
|
---|
[1217] | 64 |
|
---|
[843] | 65 | {
|
---|
| 66 | InitNul();
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[1217] | 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 |
|
---|
[843] | 78 | template<class T>
|
---|
[853] | 79 | SphereHEALPix<T>::SphereHEALPix(int_4 m)
|
---|
[843] | 80 |
|
---|
| 81 | {
|
---|
| 82 |
|
---|
| 83 | if(m <= 0 || m > 8192)
|
---|
| 84 | {
|
---|
[853] | 85 | cout << "SphereHEALPix : m hors bornes [0,8192], m= " << m << endl;
|
---|
| 86 | throw RangeCheckError("SphereHEALPix<T>::SphereHEALPix() - Out of bound nside (< 8192)!");
|
---|
[843] | 87 | }
|
---|
| 88 | // verifier que m est une puissance de deux
|
---|
| 89 | int x= m;
|
---|
| 90 | while(x%2 == 0) x/=2;
|
---|
| 91 | if(x != 1)
|
---|
| 92 | {
|
---|
[853] | 93 | cout<<"SphereHEALPix: m doit etre une puissance de deux, m= "<<m<<endl;
|
---|
| 94 | throw ParmError("SphereHEALPix<T>::SphereHEALPix() - nside != 2^n !");
|
---|
[843] | 95 | }
|
---|
| 96 | InitNul();
|
---|
| 97 | Pixelize(m);
|
---|
| 98 | SetThetaSlices();
|
---|
| 99 | }
|
---|
| 100 | //++
|
---|
| 101 | template<class T>
|
---|
[853] | 102 | SphereHEALPix<T>::SphereHEALPix(const SphereHEALPix<T>& s, bool share)
|
---|
[843] | 103 | : pixels_(s.pixels_, share), sliceBeginIndex_(s.sliceBeginIndex_, share),
|
---|
| 104 | sliceLenght_(s.sliceLenght_, share)
|
---|
| 105 | // copy constructor
|
---|
| 106 | //--
|
---|
| 107 | {
|
---|
| 108 | nSide_= s.nSide_;
|
---|
| 109 | nPix_ = s.nPix_;
|
---|
| 110 | omeg_ = s.omeg_;
|
---|
[979] | 111 | if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
|
---|
[843] | 112 | }
|
---|
[906] | 113 | //++
|
---|
| 114 | template<class T>
|
---|
| 115 | SphereHEALPix<T>::SphereHEALPix(const SphereHEALPix<T>& s)
|
---|
| 116 | : pixels_(s.pixels_), sliceBeginIndex_(s.sliceBeginIndex_),
|
---|
| 117 | sliceLenght_(s.sliceLenght_)
|
---|
| 118 | // copy constructor
|
---|
| 119 | //--
|
---|
| 120 | {
|
---|
| 121 | nSide_= s.nSide_;
|
---|
| 122 | nPix_ = s.nPix_;
|
---|
| 123 | omeg_ = s.omeg_;
|
---|
[979] | 124 | if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
|
---|
| 125 | // CloneOrShare(s);
|
---|
[906] | 126 | }
|
---|
| 127 |
|
---|
[1419] | 128 | //! Clone if \b a is not temporary, share if temporary
|
---|
| 129 | /*! \sa NDataBlock::CloneOrShare(const NDataBlock<T>&) */
|
---|
[892] | 130 | template<class T>
|
---|
| 131 | void SphereHEALPix<T>::CloneOrShare(const SphereHEALPix<T>& a)
|
---|
| 132 | {
|
---|
[979] | 133 | nSide_= a.nSide_;
|
---|
| 134 | nPix_ = a.nPix_;
|
---|
| 135 | omeg_ = a.omeg_;
|
---|
[892] | 136 | pixels_.CloneOrShare(a.pixels_);
|
---|
| 137 | sliceBeginIndex_.CloneOrShare(a.sliceBeginIndex_);
|
---|
| 138 | sliceLenght_.CloneOrShare(a.sliceLenght_);
|
---|
[1419] | 139 | if (mInfo_) {delete mInfo_; mInfo_ = NULL;}
|
---|
| 140 | if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
|
---|
| 141 | }
|
---|
[979] | 142 |
|
---|
[1419] | 143 | //! Share data with a
|
---|
| 144 | template<class T>
|
---|
| 145 | void SphereHEALPix<T>::Share(const SphereHEALPix<T>& a)
|
---|
| 146 | {
|
---|
| 147 | nSide_= a.nSide_;
|
---|
| 148 | nPix_ = a.nPix_;
|
---|
| 149 | omeg_ = a.omeg_;
|
---|
| 150 | pixels_.Share(a.pixels_);
|
---|
| 151 | sliceBeginIndex_.Share(a.sliceBeginIndex_);
|
---|
| 152 | sliceLenght_.Share(a.sliceLenght_);
|
---|
| 153 | if (mInfo_) {delete mInfo_; mInfo_ = NULL;}
|
---|
| 154 | if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
|
---|
[892] | 155 | }
|
---|
| 156 |
|
---|
[979] | 157 | ////////////////////////// methodes de copie/share
|
---|
[892] | 158 | template<class T>
|
---|
| 159 | SphereHEALPix<T>& SphereHEALPix<T>::Set(const SphereHEALPix<T>& a)
|
---|
[980] | 160 | {
|
---|
[892] | 161 | if (this != &a)
|
---|
| 162 | {
|
---|
[980] | 163 |
|
---|
| 164 | if (a.NbPixels() < 1)
|
---|
[1419] | 165 | throw RangeCheckError("SphereHEALPix<T>::Set(a ) - SphereHEALPix a not allocated ! ");
|
---|
[980] | 166 | if (NbPixels() < 1) CloneOrShare(a);
|
---|
| 167 | else CopyElt(a);
|
---|
| 168 |
|
---|
| 169 |
|
---|
| 170 | if (mInfo_) delete mInfo_;
|
---|
| 171 | mInfo_ = NULL;
|
---|
| 172 | if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
|
---|
[892] | 173 | }
|
---|
| 174 | return(*this);
|
---|
[980] | 175 | }
|
---|
[892] | 176 |
|
---|
[979] | 177 | template<class T>
|
---|
| 178 | SphereHEALPix<T>& SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>& a)
|
---|
| 179 | {
|
---|
| 180 | if (NbPixels() < 1)
|
---|
[1419] | 181 | throw RangeCheckError("SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>& ) - Not Allocated SphereHEALPix ! ");
|
---|
[979] | 182 | if (NbPixels() != a.NbPixels())
|
---|
[980] | 183 | throw(SzMismatchError("SphereHEALPix<T>::CopyElt(const SphereHEALPix<T>&) SizeMismatch")) ;
|
---|
[979] | 184 | nSide_= a.nSide_;
|
---|
| 185 | nPix_ = a.nPix_;
|
---|
| 186 | omeg_ = a.omeg_;
|
---|
| 187 | int k;
|
---|
| 188 | for (k=0; k< nPix_; k++) pixels_(k) = a.pixels_(k);
|
---|
| 189 | for (k=0; k< a.sliceBeginIndex_.Size(); k++) sliceBeginIndex_(k) = a.sliceBeginIndex_(k);
|
---|
| 190 | for (k=0; k< a.sliceLenght_.Size(); k++) sliceLenght_(k) = a.sliceLenght_(k);
|
---|
| 191 | return(*this);
|
---|
| 192 | }
|
---|
[1419] | 193 |
|
---|
| 194 |
|
---|
| 195 |
|
---|
[843] | 196 | //++
|
---|
| 197 | // Titre Destructor
|
---|
| 198 | //--
|
---|
| 199 | //++
|
---|
| 200 | template<class T>
|
---|
[853] | 201 | SphereHEALPix<T>::~SphereHEALPix()
|
---|
[843] | 202 |
|
---|
| 203 | //--
|
---|
| 204 | {
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | //++
|
---|
| 208 | // Titre Public Methods
|
---|
| 209 | //--
|
---|
| 210 |
|
---|
[1217] | 211 | /*! \fn void SOPHYA::SphereHEALPix::Resize(int_4 m)
|
---|
| 212 | \param <m> "nside" of the Gorski algorithm
|
---|
| 213 |
|
---|
| 214 | The total number of pixels will be Npix = 12*nside**2
|
---|
| 215 |
|
---|
| 216 | nside MUST be a power of 2 (<= 8192)
|
---|
| 217 | */
|
---|
[843] | 218 | template<class T>
|
---|
[853] | 219 | void SphereHEALPix<T>::Resize(int_4 m)
|
---|
[843] | 220 |
|
---|
[1217] | 221 |
|
---|
[843] | 222 | {
|
---|
| 223 | if (m<=0 || m> 8192) {
|
---|
[853] | 224 | cout << "SphereHEALPix : m hors bornes [0,8192], m= " << m << endl;
|
---|
[843] | 225 | exit(1);
|
---|
| 226 | }
|
---|
| 227 | // verifier que m est une puissance de deux
|
---|
| 228 | int x= m;
|
---|
| 229 | while (x%2==0) x/=2;
|
---|
| 230 | if(x != 1)
|
---|
| 231 | {
|
---|
[853] | 232 | cout<<"SphereHEALPix: m doit etre une puissance de deux, m= "<<m<<endl;
|
---|
[843] | 233 | exit(1);
|
---|
| 234 | }
|
---|
| 235 | InitNul();
|
---|
| 236 | Pixelize(m);
|
---|
| 237 | SetThetaSlices();
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | template<class T>
|
---|
[853] | 241 | void SphereHEALPix<T>::Pixelize( int_4 m)
|
---|
[843] | 242 |
|
---|
| 243 | // prépare la pixelisation Gorski (m a la même signification
|
---|
| 244 | // que pour le constructeur)
|
---|
| 245 | //
|
---|
| 246 | //
|
---|
| 247 | {
|
---|
| 248 | // On memorise les arguments d'appel
|
---|
| 249 | nSide_= m;
|
---|
| 250 |
|
---|
| 251 | // Nombre total de pixels sur la sphere entiere
|
---|
| 252 | nPix_= 12*nSide_*nSide_;
|
---|
| 253 |
|
---|
| 254 | // pour le moment les tableaux qui suivent seront ranges dans l'ordre
|
---|
| 255 | // de l'indexation GORSKY "RING"
|
---|
| 256 | // on pourra ulterieurement changer de strategie et tirer profit
|
---|
| 257 | // de la dualite d'indexation GORSKY (RING et NEST) : tout dependra
|
---|
| 258 | // de pourquoi c'est faire
|
---|
| 259 |
|
---|
| 260 | // Creation et initialisation du vecteur des contenus des pixels
|
---|
| 261 | pixels_.ReSize(nPix_);
|
---|
| 262 | pixels_.Reset();
|
---|
| 263 |
|
---|
| 264 | // solid angle per pixel
|
---|
| 265 | omeg_= 4.0*Pi/nPix_;
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 | template<class T>
|
---|
[853] | 269 | void SphereHEALPix<T>::InitNul()
|
---|
[843] | 270 | //
|
---|
| 271 | // initialise à zéro les variables de classe
|
---|
| 272 | {
|
---|
| 273 | nSide_= 0;
|
---|
| 274 | nPix_ = 0;
|
---|
| 275 | omeg_ = 0.;
|
---|
| 276 | // pixels_.Reset(); - Il ne faut pas mettre les pixels a zero si share !
|
---|
| 277 | }
|
---|
| 278 |
|
---|
| 279 | /* --Methode-- */
|
---|
[1217] | 280 | /* Nombre de pixels du decoupage */
|
---|
| 281 | /*! \fn int_4 SOPHYA::SphereHEALPix::NbPixels() const
|
---|
| 282 |
|
---|
| 283 | Return number of pixels of the splitting
|
---|
| 284 | */
|
---|
[843] | 285 | template<class T>
|
---|
[853] | 286 | int_4 SphereHEALPix<T>::NbPixels() const
|
---|
[843] | 287 | {
|
---|
| 288 | return(nPix_);
|
---|
| 289 | }
|
---|
| 290 |
|
---|
[1217] | 291 |
|
---|
| 292 | /*! \fn uint_4 SOPHYA::SphereHEALPix::NbThetaSlices() const
|
---|
| 293 |
|
---|
| 294 | \return number of slices in theta direction on the sphere
|
---|
| 295 | */
|
---|
[843] | 296 | template<class T>
|
---|
[853] | 297 | uint_4 SphereHEALPix<T>::NbThetaSlices() const
|
---|
[843] | 298 | {
|
---|
| 299 | uint_4 nbslices = uint_4(4*nSide_-1);
|
---|
| 300 | if (nSide_<=0)
|
---|
| 301 | {
|
---|
| 302 | nbslices = 0;
|
---|
| 303 | throw PException(" sphere not pixelized, NbSlice=0 ");
|
---|
| 304 | }
|
---|
| 305 | return nbslices;
|
---|
| 306 | }
|
---|
| 307 |
|
---|
[1217] | 308 | /*! \fn void SOPHYA::SphereHEALPix::GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const
|
---|
| 309 |
|
---|
| 310 | For a theta-slice with index 'index', return :
|
---|
| 311 |
|
---|
| 312 | the corresponding "theta"
|
---|
| 313 |
|
---|
| 314 | a vector containing the phi's of the pixels of the slice
|
---|
| 315 |
|
---|
| 316 | a vector containing the corresponding values of pixels
|
---|
| 317 | */
|
---|
[843] | 318 | template<class T>
|
---|
[853] | 319 | void SphereHEALPix<T>::GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const
|
---|
[843] | 320 |
|
---|
| 321 | {
|
---|
| 322 |
|
---|
| 323 | if (index<0 || index >= NbThetaSlices())
|
---|
| 324 | {
|
---|
[853] | 325 | cout << " SphereHEALPix::GetThetaSlice : Pixel index out of range" <<endl;
|
---|
| 326 | throw RangeCheckError(" SphereHEALPix::GetThetaSlice : Pixel index out of range");
|
---|
[843] | 327 | }
|
---|
| 328 |
|
---|
| 329 |
|
---|
| 330 | int_4 iring= sliceBeginIndex_(index);
|
---|
| 331 | int_4 lring = sliceLenght_(index);
|
---|
| 332 |
|
---|
| 333 | phi.ReSize(lring);
|
---|
| 334 | value.ReSize(lring);
|
---|
| 335 |
|
---|
| 336 | double TH= 0.;
|
---|
| 337 | double FI= 0.;
|
---|
| 338 | for(int_4 kk = 0; kk < lring;kk++)
|
---|
| 339 | {
|
---|
| 340 | PixThetaPhi(kk+iring,TH,FI);
|
---|
| 341 | phi(kk)= FI;
|
---|
| 342 | value(kk)= PixVal(kk+iring);
|
---|
| 343 | }
|
---|
| 344 | theta= TH;
|
---|
| 345 | }
|
---|
[1217] | 346 | /*! \fn void SOPHYA::SphereHEALPix::GetThetaSlice(int_4 sliceIndex,r_8& theta, r_8& phi0, TVector<int_4>& pixelIndices,TVector<T>& value) const
|
---|
[843] | 347 |
|
---|
[1217] | 348 | For a theta-slice with index 'index', return :
|
---|
| 349 |
|
---|
| 350 | the corresponding "theta"
|
---|
| 351 |
|
---|
| 352 | the corresponding "phi" for first pixel of the slice
|
---|
| 353 |
|
---|
| 354 | a vector containing indices of the pixels of the slice
|
---|
| 355 |
|
---|
| 356 | (equally distributed in phi)
|
---|
| 357 |
|
---|
| 358 | a vector containing the corresponding values of pixels
|
---|
| 359 | */
|
---|
| 360 |
|
---|
[843] | 361 | template<class T>
|
---|
[853] | 362 | void SphereHEALPix<T>::GetThetaSlice(int_4 sliceIndex,r_8& theta, r_8& phi0, TVector<int_4>& pixelIndices,TVector<T>& value) const
|
---|
[843] | 363 |
|
---|
| 364 | {
|
---|
| 365 |
|
---|
| 366 | if (sliceIndex<0 || sliceIndex >= NbThetaSlices())
|
---|
| 367 | {
|
---|
[853] | 368 | cout << " SphereHEALPix::GetThetaSlice : Pixel index out of range" <<endl;
|
---|
| 369 | throw RangeCheckError(" SphereHEALPix::GetThetaSlice : Pixel index out of range");
|
---|
[843] | 370 | }
|
---|
| 371 | int_4 iring= sliceBeginIndex_(sliceIndex);
|
---|
| 372 | int_4 lring = sliceLenght_(sliceIndex);
|
---|
| 373 | pixelIndices.ReSize(lring);
|
---|
| 374 | value.ReSize(lring);
|
---|
| 375 |
|
---|
| 376 | for(int_4 kk = 0; kk < lring;kk++)
|
---|
| 377 | {
|
---|
| 378 | pixelIndices(kk)= kk+iring;
|
---|
| 379 | value(kk)= PixVal(kk+iring);
|
---|
| 380 | }
|
---|
| 381 | PixThetaPhi(iring, theta, phi0);
|
---|
| 382 | }
|
---|
[1217] | 383 |
|
---|
[843] | 384 | template<class T>
|
---|
[853] | 385 | void SphereHEALPix<T>::SetThetaSlices()
|
---|
[843] | 386 | {
|
---|
| 387 | sliceBeginIndex_.ReSize(4*nSide_-1);
|
---|
| 388 | sliceLenght_.ReSize(4*nSide_-1);
|
---|
[965] | 389 | int sliceIndex;
|
---|
| 390 | for (sliceIndex=0; sliceIndex< nSide_-1; sliceIndex++)
|
---|
[843] | 391 | {
|
---|
| 392 | sliceBeginIndex_(sliceIndex) = 2*sliceIndex*(sliceIndex+1);
|
---|
| 393 | sliceLenght_(sliceIndex) = 4*(sliceIndex+1);
|
---|
| 394 | }
|
---|
[965] | 395 | for (sliceIndex= nSide_-1; sliceIndex< 3*nSide_; sliceIndex++)
|
---|
[843] | 396 | {
|
---|
| 397 | sliceBeginIndex_(sliceIndex) = 2*nSide_*(2*sliceIndex-nSide_+1);
|
---|
| 398 | sliceLenght_(sliceIndex) = 4*nSide_;
|
---|
| 399 | }
|
---|
[965] | 400 | for (sliceIndex= 3*nSide_; sliceIndex< 4*nSide_-1; sliceIndex++)
|
---|
[843] | 401 | {
|
---|
| 402 | int_4 nc= 4*nSide_-1-sliceIndex;
|
---|
| 403 | sliceBeginIndex_(sliceIndex) = nPix_-2*nc*(nc+1);
|
---|
| 404 | sliceLenght_(sliceIndex) = 4*nc;
|
---|
| 405 | }
|
---|
| 406 | }
|
---|
| 407 |
|
---|
[1217] | 408 |
|
---|
| 409 | /*! \fn T& SOPHYA::SphereHEALPix::PixVal(int_4 k)
|
---|
| 410 |
|
---|
| 411 | \return value of pixel with "RING" index k
|
---|
| 412 | */
|
---|
[843] | 413 | template<class T>
|
---|
[853] | 414 | T& SphereHEALPix<T>::PixVal(int_4 k)
|
---|
[843] | 415 |
|
---|
| 416 | {
|
---|
| 417 | if((k < 0) || (k >= nPix_))
|
---|
| 418 | {
|
---|
[853] | 419 | throw RangeCheckError("SphereHEALPix::PIxVal Pixel index out of range");
|
---|
[843] | 420 | }
|
---|
| 421 | return pixels_(k);
|
---|
| 422 | }
|
---|
| 423 |
|
---|
[1217] | 424 | /*! \fn T const& SOPHYA::SphereHEALPix::PixVal(int_4 k) const
|
---|
| 425 |
|
---|
| 426 | \return value of pixel with "RING" index k
|
---|
| 427 | */
|
---|
[843] | 428 | template<class T>
|
---|
[853] | 429 | T const& SphereHEALPix<T>::PixVal(int_4 k) const
|
---|
[843] | 430 |
|
---|
| 431 | {
|
---|
| 432 | if((k < 0) || (k >= nPix_))
|
---|
| 433 | {
|
---|
[853] | 434 | throw RangeCheckError("SphereHEALPix::PIxVal Pixel index out of range");
|
---|
[843] | 435 | }
|
---|
| 436 | return *(pixels_.Data()+k);
|
---|
| 437 | }
|
---|
| 438 |
|
---|
[1217] | 439 | /*! \fn T& SOPHYA::SphereHEALPix::PixValNest(int_4 k)
|
---|
| 440 |
|
---|
| 441 | \return value of pixel with "NESTED" index k
|
---|
| 442 | */
|
---|
[843] | 443 | template<class T>
|
---|
[853] | 444 | T& SphereHEALPix<T>::PixValNest(int_4 k)
|
---|
[843] | 445 |
|
---|
| 446 | //--
|
---|
| 447 | {
|
---|
| 448 | if((k < 0) || (k >= nPix_))
|
---|
| 449 | {
|
---|
[853] | 450 | throw RangeCheckError("SphereHEALPix::PIxValNest Pixel index out of range");
|
---|
[843] | 451 | }
|
---|
| 452 | return pixels_(nest2ring(nSide_,k));
|
---|
| 453 | }
|
---|
| 454 |
|
---|
[1217] | 455 | /*! \fn T const& SOPHYA::SphereHEALPix::PixValNest(int_4 k) const
|
---|
| 456 |
|
---|
| 457 | \return value of pixel with "NESTED" index k
|
---|
| 458 | */
|
---|
| 459 |
|
---|
[843] | 460 | template<class T>
|
---|
[853] | 461 | T const& SphereHEALPix<T>::PixValNest(int_4 k) const
|
---|
[843] | 462 |
|
---|
| 463 | {
|
---|
| 464 | if((k < 0) || (k >= nPix_))
|
---|
| 465 | {
|
---|
[853] | 466 | throw RangeCheckError("SphereHEALPix::PIxValNest Pixel index out of range");
|
---|
[843] | 467 | }
|
---|
| 468 | int_4 pix= nest2ring(nSide_,k);
|
---|
| 469 | return *(pixels_.Data()+pix);
|
---|
| 470 | }
|
---|
| 471 |
|
---|
[1217] | 472 | /*! \fn bool SOPHYA::SphereHEALPix::ContainsSph(double theta, double phi) const
|
---|
| 473 |
|
---|
| 474 | \return true if teta,phi in map
|
---|
| 475 | */
|
---|
[843] | 476 | template<class T>
|
---|
[1217] | 477 | bool SphereHEALPix<T>::ContainsSph(double theta, double phi) const
|
---|
[843] | 478 | {
|
---|
| 479 | return(true);
|
---|
| 480 | }
|
---|
| 481 |
|
---|
[1217] | 482 | /*! \fn int_4 SOPHYA::SphereHEALPix::PixIndexSph(double theta,double phi) const
|
---|
| 483 |
|
---|
| 484 | \return "RING" index of the pixel corresponding to direction (theta, phi).
|
---|
| 485 | */
|
---|
[843] | 486 | template<class T>
|
---|
[853] | 487 | int_4 SphereHEALPix<T>::PixIndexSph(double theta,double phi) const
|
---|
[843] | 488 |
|
---|
| 489 | {
|
---|
| 490 | return ang2pix_ring(nSide_,theta,phi);
|
---|
| 491 | }
|
---|
| 492 |
|
---|
[1217] | 493 | /*! \fn int_4 SOPHYA::SphereHEALPix::PixIndexSphNest(double theta,double phi) const
|
---|
| 494 |
|
---|
| 495 | \return "NESTED" index of the pixel corresponding to direction (theta, phi).
|
---|
| 496 | */
|
---|
[843] | 497 | template<class T>
|
---|
[853] | 498 | int_4 SphereHEALPix<T>::PixIndexSphNest(double theta,double phi) const
|
---|
[843] | 499 |
|
---|
| 500 | {
|
---|
| 501 | return ang2pix_nest(nSide_,theta,phi);
|
---|
| 502 | }
|
---|
| 503 |
|
---|
| 504 |
|
---|
| 505 | /* --Methode-- */
|
---|
[1217] | 506 | /*! \fn void SOPHYA::SphereHEALPix::PixThetaPhi(int_4 k,double& theta,double& phi) const
|
---|
| 507 | \return (theta,phi) coordinates of middle of pixel with "RING" index k
|
---|
| 508 | */
|
---|
[843] | 509 | template<class T>
|
---|
[853] | 510 | void SphereHEALPix<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const
|
---|
[843] | 511 | {
|
---|
| 512 | pix2ang_ring(nSide_,k,theta,phi);
|
---|
| 513 | }
|
---|
| 514 |
|
---|
[1217] | 515 | /*! \fn T SOPHYA::SphereHEALPix::SetPixels(T v)
|
---|
| 516 |
|
---|
| 517 | Set all pixels to value v
|
---|
| 518 | */
|
---|
[843] | 519 | template <class T>
|
---|
[853] | 520 | T SphereHEALPix<T>::SetPixels(T v)
|
---|
[843] | 521 | {
|
---|
| 522 | pixels_.Reset(v);
|
---|
| 523 | return(v);
|
---|
| 524 | }
|
---|
| 525 |
|
---|
| 526 |
|
---|
[1217] | 527 |
|
---|
| 528 | /*! \fn void SOPHYA::SphereHEALPix::PixThetaPhiNest(int_4 k,double& theta,double& phi) const
|
---|
| 529 |
|
---|
| 530 | \return (theta,phi) coordinates of middle of pixel with "NESTED" index k
|
---|
| 531 | */
|
---|
[843] | 532 | template<class T>
|
---|
[853] | 533 | void SphereHEALPix<T>::PixThetaPhiNest(int_4 k,double& theta,double& phi) const
|
---|
[843] | 534 |
|
---|
| 535 | {
|
---|
| 536 | pix2ang_nest(nSide_,k,theta,phi);
|
---|
| 537 | }
|
---|
| 538 |
|
---|
[1217] | 539 |
|
---|
| 540 | /*! \fn int_4 SOPHYA::SphereHEALPix::NestToRing(int_4 k) const
|
---|
| 541 |
|
---|
| 542 | translation from NESTED index into RING index
|
---|
| 543 | */
|
---|
[843] | 544 | template<class T>
|
---|
[853] | 545 | int_4 SphereHEALPix<T>::NestToRing(int_4 k) const
|
---|
[843] | 546 |
|
---|
| 547 | {
|
---|
| 548 | return nest2ring(nSide_,k);
|
---|
| 549 | }
|
---|
| 550 |
|
---|
[1217] | 551 |
|
---|
| 552 | /*! \fn int_4 SOPHYA::SphereHEALPix::RingToNest(int_4 k) const
|
---|
| 553 |
|
---|
| 554 | translation from RING index into NESTED index
|
---|
| 555 | */
|
---|
[843] | 556 | template<class T>
|
---|
[853] | 557 | int_4 SphereHEALPix<T>::RingToNest(int_4 k) const
|
---|
[843] | 558 | {
|
---|
| 559 | return ring2nest(nSide_,k);
|
---|
| 560 | }
|
---|
| 561 |
|
---|
[1419] | 562 | // ...... Operations de calcul ......
|
---|
[843] | 563 |
|
---|
[1419] | 564 | //! Fill a SphereHEALPix with a constant value \b a
|
---|
[843] | 565 | template <class T>
|
---|
[1419] | 566 | SphereHEALPix<T>& SphereHEALPix<T>::SetT(T a)
|
---|
| 567 | {
|
---|
| 568 | if (NbPixels() < 1)
|
---|
| 569 | throw RangeCheckError("SphereHEALPix<T>::SetT(T ) - SphereHEALPix not dimensionned ! ");
|
---|
| 570 | pixels_ = a;
|
---|
| 571 | return (*this);
|
---|
| 572 | }
|
---|
| 573 |
|
---|
| 574 | /*! Add a constant value \b x to a SphereHEALPix */
|
---|
| 575 | template <class T>
|
---|
| 576 | SphereHEALPix<T>& SphereHEALPix<T>::Add(T a)
|
---|
| 577 | {
|
---|
| 578 | if (NbPixels() < 1)
|
---|
| 579 | throw RangeCheckError("SphereHEALPix<T>::Add(T ) - SphereHEALPix not dimensionned ! ");
|
---|
| 580 | pixels_ += a;
|
---|
| 581 | return (*this);
|
---|
| 582 | }
|
---|
| 583 |
|
---|
| 584 | /*! Substract a constant value \b a to a SphereHEALPix */
|
---|
| 585 | template <class T>
|
---|
[1624] | 586 | SphereHEALPix<T>& SphereHEALPix<T>::Sub(T a,bool fginv)
|
---|
[1419] | 587 | {
|
---|
| 588 | if (NbPixels() < 1)
|
---|
| 589 | throw RangeCheckError("SphereHEALPix<T>::Sub(T ) - SphereHEALPix not dimensionned ! ");
|
---|
[1624] | 590 | pixels_.Sub(a,fginv);
|
---|
[1419] | 591 | return (*this);
|
---|
| 592 | }
|
---|
| 593 |
|
---|
| 594 | /*! multiply a SphereHEALPix by a constant value \b a */
|
---|
| 595 | template <class T>
|
---|
| 596 | SphereHEALPix<T>& SphereHEALPix<T>::Mul(T a)
|
---|
| 597 | {
|
---|
| 598 | if (NbPixels() < 1)
|
---|
| 599 | throw RangeCheckError("SphereHEALPix<T>::Mul(T ) - SphereHEALPix not dimensionned ! ");
|
---|
| 600 | pixels_ *= a;
|
---|
| 601 | return (*this);
|
---|
| 602 | }
|
---|
| 603 |
|
---|
| 604 | /*! divide a SphereHEALPix by a constant value \b a */
|
---|
| 605 | template <class T>
|
---|
| 606 | SphereHEALPix<T>& SphereHEALPix<T>::Div(T a)
|
---|
| 607 | {
|
---|
| 608 | if (NbPixels() < 1)
|
---|
| 609 | throw RangeCheckError("SphereHEALPix<T>::Div(T ) - SphereHEALPix not dimensionned ! ");
|
---|
| 610 | pixels_ /= a;
|
---|
| 611 | return (*this);
|
---|
| 612 | }
|
---|
| 613 |
|
---|
| 614 | // >>>> Operations avec 2nd membre de type SphereHEALPix
|
---|
| 615 | //! Add two SphereHEALPix
|
---|
| 616 |
|
---|
| 617 | template <class T>
|
---|
| 618 | SphereHEALPix<T>& SphereHEALPix<T>::AddElt(const SphereHEALPix<T>& a)
|
---|
| 619 | {
|
---|
| 620 | if (NbPixels() != a.NbPixels() )
|
---|
| 621 | {
|
---|
| 622 | throw(SzMismatchError("SphereHEALPix<T>::AddElt(const SphereHEALPix<T>&) SizeMismatch")) ;
|
---|
| 623 | }
|
---|
| 624 | pixels_ += a.pixels_;
|
---|
| 625 | return (*this);
|
---|
| 626 | }
|
---|
| 627 |
|
---|
| 628 | //! Substract two SphereHEALPix
|
---|
| 629 | template <class T>
|
---|
| 630 | SphereHEALPix<T>& SphereHEALPix<T>::SubElt(const SphereHEALPix<T>& a)
|
---|
| 631 | {
|
---|
| 632 | if (NbPixels() != a.NbPixels() )
|
---|
| 633 | {
|
---|
| 634 | throw(SzMismatchError("SphereHEALPix<T>::SubElt(const SphereHEALPix<T>&) SizeMismatch")) ;
|
---|
| 635 | }
|
---|
| 636 | pixels_ -= a.pixels_;
|
---|
| 637 | return (*this);
|
---|
| 638 | }
|
---|
| 639 |
|
---|
| 640 | //! Multiply two SphereHEALPix (elements by elements)
|
---|
| 641 | template <class T>
|
---|
| 642 | SphereHEALPix<T>& SphereHEALPix<T>::MulElt(const SphereHEALPix<T>& a)
|
---|
| 643 | {
|
---|
| 644 | if (NbPixels() != a.NbPixels() )
|
---|
| 645 | {
|
---|
[1551] | 646 | throw(SzMismatchError("SphereHEALPix<T>::MulElt(const SphereHEALPix<T>&) SizeMismatch")) ;
|
---|
[1419] | 647 | }
|
---|
| 648 | pixels_ *= a.pixels_;
|
---|
| 649 | return (*this);
|
---|
| 650 | }
|
---|
| 651 |
|
---|
[1551] | 652 | //! Divide two SphereHEALPix (elements by elements) - No protection for divide by 0
|
---|
| 653 | template <class T>
|
---|
| 654 | SphereHEALPix<T>& SphereHEALPix<T>::DivElt(const SphereHEALPix<T>& a)
|
---|
| 655 | {
|
---|
| 656 | if (NbPixels() != a.NbPixels() )
|
---|
| 657 | {
|
---|
| 658 | throw(SzMismatchError("SphereHEALPix<T>::DivElt(const SphereHEALPix<T>&) SizeMismatch")) ;
|
---|
| 659 | }
|
---|
| 660 | pixels_ /= a.pixels_;
|
---|
| 661 | return (*this);
|
---|
| 662 | }
|
---|
[1419] | 663 |
|
---|
| 664 |
|
---|
| 665 |
|
---|
[1551] | 666 |
|
---|
[1419] | 667 | template <class T>
|
---|
[853] | 668 | void SphereHEALPix<T>::print(ostream& os) const
|
---|
[843] | 669 | {
|
---|
| 670 | if(mInfo_) os << " DVList Info= " << *mInfo_ << endl;
|
---|
| 671 | //
|
---|
| 672 | os << " nSide_ = " << nSide_ << endl;
|
---|
| 673 | os << " nPix_ = " << nPix_ << endl;
|
---|
| 674 | os << " omeg_ = " << omeg_ << endl;
|
---|
| 675 |
|
---|
| 676 | os << " content of pixels : ";
|
---|
| 677 | for(int i=0; i < nPix_; i++)
|
---|
| 678 | {
|
---|
| 679 | if(i%5 == 0) os << endl;
|
---|
| 680 | os << pixels_(i) <<", ";
|
---|
| 681 | }
|
---|
| 682 | os << endl;
|
---|
| 683 |
|
---|
| 684 |
|
---|
| 685 | }
|
---|
| 686 |
|
---|
| 687 |
|
---|
| 688 |
|
---|
| 689 | //*******************************************************************
|
---|
| 690 |
|
---|
| 691 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
[853] | 692 | #pragma define_template SphereHEALPix<uint_2>
|
---|
[1304] | 693 | #pragma define_template SphereHEALPix<int_4>
|
---|
[853] | 694 | #pragma define_template SphereHEALPix<r_8>
|
---|
| 695 | #pragma define_template SphereHEALPix<r_4>
|
---|
| 696 | #pragma define_template SphereHEALPix< complex<r_4> >
|
---|
| 697 | #pragma define_template SphereHEALPix< complex<r_8> >
|
---|
[843] | 698 | #endif
|
---|
| 699 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
|
---|
[853] | 700 | template class SphereHEALPix<uint_2>;
|
---|
[1304] | 701 | template class SphereHEALPix<int_4>;
|
---|
[853] | 702 | template class SphereHEALPix<r_8>;
|
---|
| 703 | template class SphereHEALPix<r_4>;
|
---|
| 704 | template class SphereHEALPix< complex<r_4> >;
|
---|
| 705 | template class SphereHEALPix< complex<r_8> >;
|
---|
[843] | 706 | #endif
|
---|
| 707 |
|
---|