source: Sophya/trunk/SophyaLib/SkyMap/spherehealpix.cc@ 2978

Last change on this file since 2978 was 2978, checked in by ansari, 19 years ago

1/ Mise en place de la prise en charge du schema de pixelisation NESTED dans
SphereHEALPix<T>
2/ petites corrections sur PixelMap<T> et cartes speheriques

Reza 21/06/2006

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