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