| 1 | #include "sopnamsp.h"
 | 
|---|
| 2 | #include "spherethetaphi.h"
 | 
|---|
| 3 | #include "smathconst.h"
 | 
|---|
| 4 | #include <complex>
 | 
|---|
| 5 | #include "fiondblock.h"
 | 
|---|
| 6 | #include <iostream>
 | 
|---|
| 7 | 
 | 
|---|
| 8 | 
 | 
|---|
| 9 | /*!
 | 
|---|
| 10 |   \class SOPHYA::SphereThetaPhi
 | 
|---|
| 11 |   \ingroup SkyMap
 | 
|---|
| 12 | 
 | 
|---|
| 13 |   \brief Spherical map with equal latitude (iso-theta) rings 
 | 
|---|
| 14 | 
 | 
|---|
| 15 | 
 | 
|---|
| 16 |   Class implementing spherical maps, with equal latitude (iso-theta) rings 
 | 
|---|
| 17 |   pixelisation scheme - with template data types (double, float, complex, ...)
 | 
|---|
| 18 | 
 | 
|---|
| 19 |     sphere splitted with respect to theta, phi : each hemisphere is 
 | 
|---|
| 20 |     splitted into (m-1) parallels (equator does not enter into account).
 | 
|---|
| 21 |     This operation defines m slices, each of which is splitted into 
 | 
|---|
| 22 |     equidistant meridians. This splitting is realized in such a way that 
 | 
|---|
| 23 |     all pixels have the same area and are as square as possible.
 | 
|---|
| 24 | 
 | 
|---|
| 25 |     One begins with the hemisphere with positive z, starting from the pole
 | 
|---|
| 26 |     toward the equator. The first pixel is the polar cap ; it is circular
 | 
|---|
| 27 |     and centered on theta=0. 
 | 
|---|
| 28 | */
 | 
|---|
| 29 | 
 | 
|---|
| 30 | //***************************************************************
 | 
|---|
| 31 | //++ 
 | 
|---|
| 32 | // Class        SphereThetaPhi
 | 
|---|
| 33 | // 
 | 
|---|
| 34 | //
 | 
|---|
| 35 | // include      spherethetaphi.h 
 | 
|---|
| 36 | //--
 | 
|---|
| 37 | //++
 | 
|---|
| 38 | //
 | 
|---|
| 39 | // Links        Parents
 | 
|---|
| 40 | //
 | 
|---|
| 41 | //    SphericalMap 
 | 
|---|
| 42 | //-- 
 | 
|---|
| 43 | 
 | 
|---|
| 44 | /* --Methode-- */
 | 
|---|
| 45 | //++
 | 
|---|
| 46 | // Titre        Constructors
 | 
|---|
| 47 | //--
 | 
|---|
| 48 | //++
 | 
|---|
| 49 | 
 | 
|---|
| 50 | template <class T>
 | 
|---|
| 51 | SphereThetaPhi<T>::SphereThetaPhi()
 | 
|---|
| 52 |   : NPhi_(), TNphi_(), Theta_(), pixels_() 
 | 
|---|
| 53 | 
 | 
|---|
| 54 | //--
 | 
|---|
| 55 | {
 | 
|---|
| 56 |   InitNul();
 | 
|---|
| 57 | }
 | 
|---|
| 58 | 
 | 
|---|
| 59 | 
 | 
|---|
| 60 | /* --Methode-- */
 | 
|---|
| 61 | 
 | 
|---|
| 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 | */
 | 
|---|
| 67 | template <class T>
 | 
|---|
| 68 | SphereThetaPhi<T>::SphereThetaPhi(int_4 m)
 | 
|---|
| 69 | {
 | 
|---|
| 70 |   InitNul();
 | 
|---|
| 71 |   Pixelize(m);
 | 
|---|
| 72 | }
 | 
|---|
| 73 | 
 | 
|---|
| 74 | //! Copy constructor (shares the pixel data if share==true) 
 | 
|---|
| 75 | template <class T>
 | 
|---|
| 76 | SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s, bool share)
 | 
|---|
| 77 |   : NPhi_(s.NPhi_, share), TNphi_(s.TNphi_, share), Theta_(s.Theta_, share),
 | 
|---|
| 78 |     pixels_(s.pixels_ , share) 
 | 
|---|
| 79 | {
 | 
|---|
| 80 | 
 | 
|---|
| 81 |   NTheta_= s.NTheta_;
 | 
|---|
| 82 |   NPix_  = s.NPix_;
 | 
|---|
| 83 |   Omega_ = s.Omega_;
 | 
|---|
| 84 |   if(s.mInfo_) this->mInfo_= new DVList(*s.mInfo_);
 | 
|---|
| 85 | }
 | 
|---|
| 86 | 
 | 
|---|
| 87 | //! Copy constructor (shares the pixel data)
 | 
|---|
| 88 | template <class T>
 | 
|---|
| 89 | SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s)
 | 
|---|
| 90 |   : NPhi_(s.NPhi_), TNphi_(s.TNphi_), Theta_(s.Theta_), pixels_(s.pixels_) 
 | 
|---|
| 91 | {
 | 
|---|
| 92 | 
 | 
|---|
| 93 |   NTheta_= s.NTheta_;
 | 
|---|
| 94 |   NPix_  = s.NPix_;
 | 
|---|
| 95 |   Omega_ = s.Omega_;
 | 
|---|
| 96 |   if(s.mInfo_) this->mInfo_= new DVList(*s.mInfo_);
 | 
|---|
| 97 | }
 | 
|---|
| 98 | 
 | 
|---|
| 99 | //++
 | 
|---|
| 100 | // Titre        Destructor
 | 
|---|
| 101 | //--
 | 
|---|
| 102 | //++
 | 
|---|
| 103 | template <class T>
 | 
|---|
| 104 | SphereThetaPhi<T>::~SphereThetaPhi()
 | 
|---|
| 105 | 
 | 
|---|
| 106 | //--
 | 
|---|
| 107 | {}
 | 
|---|
| 108 | 
 | 
|---|
| 109 | template <class T>
 | 
|---|
| 110 | void SphereThetaPhi<T>::InitNul()
 | 
|---|
| 111 | //
 | 
|---|
| 112 | {
 | 
|---|
| 113 |   NTheta_= 0;
 | 
|---|
| 114 |   NPix_  = 0;
 | 
|---|
| 115 | //  pixels_.Reset();  Pas de reset par InitNul (en cas de share) - Reza 20/11/99 $CHECK$
 | 
|---|
| 116 | }
 | 
|---|
| 117 | 
 | 
|---|
| 118 | 
 | 
|---|
| 119 | //!   re-pixelize the sphere if (m > 0) 
 | 
|---|
| 120 | template <class T>
 | 
|---|
| 121 | void SphereThetaPhi<T>::Resize(int_4 m)
 | 
|---|
| 122 | {
 | 
|---|
| 123 |   if ((m <= 0) && (NTheta_ > 0) ) {
 | 
|---|
| 124 |     cout << "SphereThetaPhi<T>::Resize(m) with m<=0 - NOT resized" << endl;
 | 
|---|
| 125 |     return;
 | 
|---|
| 126 |   }
 | 
|---|
| 127 |   InitNul();
 | 
|---|
| 128 |   Pixelize(m);
 | 
|---|
| 129 | }
 | 
|---|
| 130 | 
 | 
|---|
| 131 | //! Clone or share the SphereThetaPhi object \b a
 | 
|---|
| 132 | template<class T>
 | 
|---|
| 133 | void  SphereThetaPhi<T>::CloneOrShare(const  SphereThetaPhi<T>& a)
 | 
|---|
| 134 | {
 | 
|---|
| 135 | 
 | 
|---|
| 136 |   NTheta_= a.NTheta_;
 | 
|---|
| 137 |   NPix_  = a.NPix_;
 | 
|---|
| 138 |   Omega_ = a.Omega_;
 | 
|---|
| 139 |   NPhi_.CloneOrShare(a.NPhi_);
 | 
|---|
| 140 |   TNphi_.CloneOrShare(a.TNphi_);
 | 
|---|
| 141 |   Theta_.CloneOrShare(a.Theta_);
 | 
|---|
| 142 |   pixels_.CloneOrShare(a.pixels_);
 | 
|---|
| 143 |   if (this->mInfo_) {delete this->mInfo_; this->mInfo_ = NULL;}
 | 
|---|
| 144 |   if (a.mInfo_) this->mInfo_ = new DVList(*(a.mInfo_));
 | 
|---|
| 145 | }
 | 
|---|
| 146 | //! Share the pixel data with object \b a
 | 
|---|
| 147 | template<class T>
 | 
|---|
| 148 | void  SphereThetaPhi<T>::Share(const  SphereThetaPhi<T>& a)
 | 
|---|
| 149 | {
 | 
|---|
| 150 | 
 | 
|---|
| 151 |   NTheta_= a.NTheta_;
 | 
|---|
| 152 |   NPix_  = a.NPix_;
 | 
|---|
| 153 |   Omega_ = a.Omega_;
 | 
|---|
| 154 |   NPhi_.Share(a.NPhi_);
 | 
|---|
| 155 |   TNphi_.Share(a.TNphi_);
 | 
|---|
| 156 |   Theta_.Share(a.Theta_);
 | 
|---|
| 157 |   pixels_.Share(a.pixels_);
 | 
|---|
| 158 |   if (this->mInfo_) {delete this->mInfo_; this->mInfo_ = NULL;}
 | 
|---|
| 159 |   if (a.mInfo_) this->mInfo_ = new DVList(*(a.mInfo_));
 | 
|---|
| 160 | }
 | 
|---|
| 161 | 
 | 
|---|
| 162 | ////////////////////////// methodes de copie/share
 | 
|---|
| 163 | //! Perform data copy or shares the data 
 | 
|---|
| 164 | template<class T>
 | 
|---|
| 165 | SphereThetaPhi<T>& SphereThetaPhi<T>::Set(const SphereThetaPhi<T>& a)
 | 
|---|
| 166 | {
 | 
|---|
| 167 |   if (this != &a) 
 | 
|---|
| 168 |     { 
 | 
|---|
| 169 |       
 | 
|---|
| 170 |       
 | 
|---|
| 171 |       if (a.NbPixels() < 1) 
 | 
|---|
| 172 |         throw RangeCheckError("SphereThetaPhi<T>::Set(a ) - Array a not allocated ! ");
 | 
|---|
| 173 |       if (NbPixels() < 1) CloneOrShare(a);
 | 
|---|
| 174 |       else CopyElt(a);
 | 
|---|
| 175 |       if (this->mInfo_) delete this->mInfo_;
 | 
|---|
| 176 |       this->mInfo_ = NULL;
 | 
|---|
| 177 |       if (a.mInfo_) this->mInfo_ = new DVList(*(a.mInfo_));
 | 
|---|
| 178 |     }
 | 
|---|
| 179 |   return(*this);
 | 
|---|
| 180 | }
 | 
|---|
| 181 | 
 | 
|---|
| 182 | //! Perform data copy or shares the data 
 | 
|---|
| 183 | template<class T>
 | 
|---|
| 184 | SphereThetaPhi<T>& SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>& a)
 | 
|---|
| 185 | {
 | 
|---|
| 186 |   if (NbPixels() < 1) 
 | 
|---|
| 187 |     throw RangeCheckError("SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>& )  - Not Allocated Array ! ");
 | 
|---|
| 188 |   if (NbPixels() != a.NbPixels()) 
 | 
|---|
| 189 |     throw(SzMismatchError("SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>&) SizeMismatch")) ;
 | 
|---|
| 190 | 
 | 
|---|
| 191 |   NTheta_= a.NTheta_;
 | 
|---|
| 192 |   NPix_  = a.NPix_;
 | 
|---|
| 193 |   Omega_ = a.Omega_;
 | 
|---|
| 194 |   for (int_4 k=0; k< NPix_; k++) pixels_(k) = a.pixels_(k);
 | 
|---|
| 195 |   for (size_t k=0; k< a.NPhi_.Size(); k++) NPhi_(k) = a.NPhi_(k);
 | 
|---|
| 196 |   for (size_t k=0; k< a.TNphi_.Size(); k++) TNphi_(k) = a.TNphi_(k);
 | 
|---|
| 197 |   for (size_t k=0; k< a.Theta_.Size(); k++) Theta_(k) = a.Theta_(k);
 | 
|---|
| 198 |   return(*this);
 | 
|---|
| 199 | 
 | 
|---|
| 200 | }
 | 
|---|
| 201 | 
 | 
|---|
| 202 | /* --Methode-- */
 | 
|---|
| 203 | //!    Return total number of pixels 
 | 
|---|
| 204 | template <class T>
 | 
|---|
| 205 | int_4 SphereThetaPhi<T>::NbPixels() const
 | 
|---|
| 206 | {
 | 
|---|
| 207 |   return(NPix_);
 | 
|---|
| 208 | }
 | 
|---|
| 209 | 
 | 
|---|
| 210 | /* --Methode-- */
 | 
|---|
| 211 | //!    Return value of pixel with index k
 | 
|---|
| 212 | template <class T>
 | 
|---|
| 213 | T& SphereThetaPhi<T>::PixVal(int_4 k)
 | 
|---|
| 214 | {
 | 
|---|
| 215 |   if((k < 0) || (k >= NPix_)) 
 | 
|---|
| 216 |     {
 | 
|---|
| 217 |       throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range");
 | 
|---|
| 218 |     }
 | 
|---|
| 219 |   return pixels_(k);
 | 
|---|
| 220 | }
 | 
|---|
| 221 | 
 | 
|---|
| 222 | //!    Return value of pixel with index k
 | 
|---|
| 223 | template <class T>
 | 
|---|
| 224 | T const& SphereThetaPhi<T>::PixVal(int_4 k) const
 | 
|---|
| 225 | {
 | 
|---|
| 226 |   if((k < 0) || (k >= NPix_)) 
 | 
|---|
| 227 |     {
 | 
|---|
| 228 |        throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range");
 | 
|---|
| 229 |     } 
 | 
|---|
| 230 |   return *(pixels_.Data()+k);
 | 
|---|
| 231 | }
 | 
|---|
| 232 | 
 | 
|---|
| 233 | /* --Methode-- */
 | 
|---|
| 234 | //! Return true if teta,phi in map  
 | 
|---|
| 235 | template <class T>
 | 
|---|
| 236 | bool SphereThetaPhi<T>::ContainsSph(double /*theta*/, double /*phi*/) const
 | 
|---|
| 237 | {
 | 
|---|
| 238 |   return(true);
 | 
|---|
| 239 | }
 | 
|---|
| 240 | 
 | 
|---|
| 241 | /* --Methode-- */
 | 
|---|
| 242 | //!    Return index of the pixel corresponding to direction (theta, phi).
 | 
|---|
| 243 | template <class T>
 | 
|---|
| 244 | int_4 SphereThetaPhi<T>::PixIndexSph(double theta, double phi) const
 | 
|---|
| 245 | {
 | 
|---|
| 246 |   double dphi;
 | 
|---|
| 247 |   int_4 i,k;
 | 
|---|
| 248 |   bool fgzn = false;
 | 
|---|
| 249 | 
 | 
|---|
| 250 |   if((theta > Pi) || (theta < 0.)) return(-1);
 | 
|---|
| 251 |   if((phi < 0.) || (phi > DeuxPi)) return(-1);
 | 
|---|
| 252 |   if(theta > Pi*0.5) {fgzn = true; theta = Pi-theta;}
 | 
|---|
| 253 |   
 | 
|---|
| 254 |   // La bande d'indice kt est limitée par les valeurs de theta contenues dans
 | 
|---|
| 255 |   // Theta_[kt] et Theta_[kt+1]
 | 
|---|
| 256 |   for( i=1; i< NTheta_; i++ ) 
 | 
|---|
| 257 |     if( theta < Theta_(i) ) break;
 | 
|---|
| 258 |   
 | 
|---|
| 259 |   dphi= DeuxPi/(double)NPhi_(i-1);
 | 
|---|
| 260 |   
 | 
|---|
| 261 |   if (fgzn)  k= NPix_-TNphi_(i)+(int_4)(phi/dphi);
 | 
|---|
| 262 |   else k= TNphi_(i-1)+(int_4)(phi/dphi); 
 | 
|---|
| 263 |   return(k);
 | 
|---|
| 264 | }
 | 
|---|
| 265 | 
 | 
|---|
| 266 | /* --Methode-- */
 | 
|---|
| 267 | //!   Return (theta,phi) coordinates of middle of  pixel with  index k
 | 
|---|
| 268 | template <class T>
 | 
|---|
| 269 | void SphereThetaPhi<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const
 | 
|---|
| 270 | {
 | 
|---|
| 271 |   int_4 i; 
 | 
|---|
| 272 |   bool fgzn = false;
 | 
|---|
| 273 |   
 | 
|---|
| 274 |   if((k < 0) || (k >= NPix_)) {theta = -99999.; phi = -99999.; return; }
 | 
|---|
| 275 |   if( k >= NPix_/2)  {fgzn = true; k = NPix_-1-k;}
 | 
|---|
| 276 | 
 | 
|---|
| 277 |   // recupère l'indice i de la tranche qui contient le pixel k
 | 
|---|
| 278 |   for( i=0; i< NTheta_; i++ ) 
 | 
|---|
| 279 |     if( k < TNphi_(i+1) ) break;
 | 
|---|
| 280 | 
 | 
|---|
| 281 |   // angle theta
 | 
|---|
| 282 |   theta= 0.5*(Theta_(i)+Theta_(i+1));
 | 
|---|
| 283 |   if (fgzn) theta= Pi-theta;
 | 
|---|
| 284 |   
 | 
|---|
| 285 |   // angle phi
 | 
|---|
| 286 |   k -= TNphi_(i);
 | 
|---|
| 287 |   phi= DeuxPi/(double)NPhi_(i)*(double)(k+.5);
 | 
|---|
| 288 |   if (fgzn) phi= DeuxPi-phi;
 | 
|---|
| 289 | }
 | 
|---|
| 290 | 
 | 
|---|
| 291 | //! Setting pixel values to a constant 
 | 
|---|
| 292 | template <class T>
 | 
|---|
| 293 | T SphereThetaPhi<T>::SetPixels(T v)
 | 
|---|
| 294 | {
 | 
|---|
| 295 | pixels_.Reset(v);
 | 
|---|
| 296 | return(v);
 | 
|---|
| 297 | }
 | 
|---|
| 298 | 
 | 
|---|
| 299 | /*!
 | 
|---|
| 300 |   \brief Pixel Solid angle  (steradians)
 | 
|---|
| 301 |   All the pixels have the same solid angle. The dummy argument is
 | 
|---|
| 302 |   for compatibility with eventual pixelizations which would not 
 | 
|---|
| 303 |   fulfil this requirement.
 | 
|---|
| 304 | */
 | 
|---|
| 305 | template <class T>
 | 
|---|
| 306 | double SphereThetaPhi<T>::PixSolAngle(int_4 /*dummy*/) const
 | 
|---|
| 307 | 
 | 
|---|
| 308 | {
 | 
|---|
| 309 |   return Omega_;
 | 
|---|
| 310 | }
 | 
|---|
| 311 | 
 | 
|---|
| 312 | /* --Methode-- */
 | 
|---|
| 313 | //!   Return values of theta,phi which limit the pixel with  index k
 | 
|---|
| 314 | template <class T>
 | 
|---|
| 315 | void SphereThetaPhi<T>::Limits(int_4 k,double& tetMin,double& tetMax,double& phiMin,double& phiMax) 
 | 
|---|
| 316 |   {
 | 
|---|
| 317 |   int_4 j;
 | 
|---|
| 318 |   double dphi;
 | 
|---|
| 319 |   bool fgzn= false;
 | 
|---|
| 320 |   
 | 
|---|
| 321 |   if((k < 0) || (k >= NPix_)) {
 | 
|---|
| 322 |     tetMin= -99999.; 
 | 
|---|
| 323 |     phiMin= -99999.;  
 | 
|---|
| 324 |     tetMax= -99999.; 
 | 
|---|
| 325 |     phiMax= -99999.;  
 | 
|---|
| 326 |     return;
 | 
|---|
| 327 |   }
 | 
|---|
| 328 |   
 | 
|---|
| 329 |   // si on se trouve dans l'hémisphère Sud
 | 
|---|
| 330 |   if(k >= NPix_/2) { 
 | 
|---|
| 331 |     fgzn= true; 
 | 
|---|
| 332 |     k= NPix_-1-k; 
 | 
|---|
| 333 |   }
 | 
|---|
| 334 |   
 | 
|---|
| 335 |   // on recupere l'indice i de la tranche qui contient le pixel k
 | 
|---|
| 336 |   int_4 i;
 | 
|---|
| 337 |   for( i=0; i< NTheta_; i++ ) 
 | 
|---|
| 338 |     if(k < TNphi_(i+1)) break;
 | 
|---|
| 339 |   
 | 
|---|
| 340 |   // valeurs limites de theta dans l'hemisphere Nord
 | 
|---|
| 341 |   tetMin= Theta_(i);
 | 
|---|
| 342 |   tetMax= Theta_(i+1);
 | 
|---|
| 343 |   // valeurs limites de theta dans l'hemisphere Sud
 | 
|---|
| 344 |   if (fgzn) {
 | 
|---|
| 345 |     tetMin= Pi - Theta_(i+1);
 | 
|---|
| 346 |     tetMax= Pi - Theta_(i);
 | 
|---|
| 347 |   }
 | 
|---|
| 348 |   
 | 
|---|
| 349 |   // pixel correspondant dans l'hemisphere Nord
 | 
|---|
| 350 |   if (fgzn) k= TNphi_(i+1)-k+TNphi_(i)-1;
 | 
|---|
| 351 |   
 | 
|---|
| 352 |   // indice j de discretisation ( phi= j*dphi )
 | 
|---|
| 353 |   j= k-TNphi_(i);
 | 
|---|
| 354 |   dphi= DeuxPi/(double)NPhi_(i);
 | 
|---|
| 355 |   
 | 
|---|
| 356 |   // valeurs limites de phi 
 | 
|---|
| 357 |   phiMin= dphi*(double)(j);
 | 
|---|
| 358 |   phiMax= dphi*(double)(j+1);
 | 
|---|
| 359 |   return;
 | 
|---|
| 360 | }
 | 
|---|
| 361 | 
 | 
|---|
| 362 | /* --Methode-- */
 | 
|---|
| 363 | //!    Return number of theta-slices on the sphere
 | 
|---|
| 364 | template <class T>
 | 
|---|
| 365 | uint_4 SphereThetaPhi<T>::NbThetaSlices() const
 | 
|---|
| 366 | {
 | 
|---|
| 367 |   if (NTheta_<=0) 
 | 
|---|
| 368 |     {
 | 
|---|
| 369 |       throw PException(" sphere not pixelized, NbSlice=0 ");
 | 
|---|
| 370 |     }
 | 
|---|
| 371 |   return( 2*NTheta_);
 | 
|---|
| 372 | }
 | 
|---|
| 373 | 
 | 
|---|
| 374 | /* --Methode-- */
 | 
|---|
| 375 | //!    Return number of pixels along the phi-direction of the kt-th slice
 | 
|---|
| 376 | template <class T>
 | 
|---|
| 377 | int_4 SphereThetaPhi<T>::NPhi(int_4 kt) const
 | 
|---|
| 378 | {
 | 
|---|
| 379 |   int_4 nbpix;  
 | 
|---|
| 380 |   // verification
 | 
|---|
| 381 |   if((kt < 0) || (kt >= 2*NTheta_)) return(-1);
 | 
|---|
| 382 |   
 | 
|---|
| 383 |   // si on se trouve dans l'hemisphere Sud
 | 
|---|
| 384 |   if(kt >= NTheta_) {
 | 
|---|
| 385 |     kt= 2*NTheta_-1-kt; 
 | 
|---|
| 386 |   }
 | 
|---|
| 387 |   
 | 
|---|
| 388 |   // nombre de pixels
 | 
|---|
| 389 |   nbpix= NPhi_(kt);
 | 
|---|
| 390 |   return(nbpix);
 | 
|---|
| 391 | }
 | 
|---|
| 392 | 
 | 
|---|
| 393 | 
 | 
|---|
| 394 | /* --Methode-- */
 | 
|---|
| 395 | //!    Return  theta values which limit the slice kt
 | 
|---|
| 396 | template <class T>
 | 
|---|
| 397 | void SphereThetaPhi<T>::Theta(int_4 kt,double& tetMin,double& tetMax) const 
 | 
|---|
| 398 | {
 | 
|---|
| 399 |   bool fgzn= false;
 | 
|---|
| 400 |   // verification
 | 
|---|
| 401 |   if( (kt< 0) || (kt>= 2*NTheta_) ) {
 | 
|---|
| 402 |     tetMin= -99999.; 
 | 
|---|
| 403 |     tetMax= -99999.; 
 | 
|---|
| 404 |     return;
 | 
|---|
| 405 |   }
 | 
|---|
| 406 | 
 | 
|---|
| 407 |   // si on se trouve dans l'hemisphere Sud
 | 
|---|
| 408 |   if( kt >= NTheta_ ) {
 | 
|---|
| 409 |     fgzn= true;
 | 
|---|
| 410 |     kt= 2*NTheta_-1-kt; 
 | 
|---|
| 411 |   }
 | 
|---|
| 412 |   
 | 
|---|
| 413 |   // valeurs limites de theta dans l'hemisphere Nord
 | 
|---|
| 414 |   tetMin= Theta_(kt);
 | 
|---|
| 415 |   tetMax= Theta_(kt+1);
 | 
|---|
| 416 |   // valeurs limites de theta dans l'hemisphere Sud
 | 
|---|
| 417 |   if (fgzn) {
 | 
|---|
| 418 |     tetMin= Pi - Theta_(kt+1);
 | 
|---|
| 419 |     tetMax= Pi - Theta_(kt);
 | 
|---|
| 420 |   }  
 | 
|---|
| 421 | }
 | 
|---|
| 422 | 
 | 
|---|
| 423 | /* --Methode-- */
 | 
|---|
| 424 | //!   Return values of phi which limit the jp-th pixel of the kt-th slice
 | 
|---|
| 425 | template <class T>
 | 
|---|
| 426 | void SphereThetaPhi<T>::Phi(int_4 kt,int_4 jp,double& phiMin,double& phiMax) const 
 | 
|---|
| 427 | {
 | 
|---|
| 428 |   // verification
 | 
|---|
| 429 |   if((kt < 0) || (kt >= 2*NTheta_)) {
 | 
|---|
| 430 |     phiMin= -99999.; 
 | 
|---|
| 431 |     phiMax= -99999.; 
 | 
|---|
| 432 |     return;
 | 
|---|
| 433 |   }
 | 
|---|
| 434 |   
 | 
|---|
| 435 |   // si on se trouve dans l'hemisphere Sud
 | 
|---|
| 436 |   if(kt >= NTheta_) kt= 2*NTheta_-1-kt;
 | 
|---|
| 437 |   
 | 
|---|
| 438 |   // verifie si la tranche kt contient au moins jp pixels
 | 
|---|
| 439 |   if( (jp< 0) || (jp >= NPhi_(kt)) ) {
 | 
|---|
| 440 |     phiMin= -88888.; 
 | 
|---|
| 441 |     phiMax= -88888.; 
 | 
|---|
| 442 |     return;
 | 
|---|
| 443 |   }
 | 
|---|
| 444 |   
 | 
|---|
| 445 |   double dphi= DeuxPi/(double)NPhi_(kt);
 | 
|---|
| 446 |   phiMin= dphi*(double)(jp);
 | 
|---|
| 447 |   phiMax= dphi*(double)(jp+1);
 | 
|---|
| 448 |   return;
 | 
|---|
| 449 | }
 | 
|---|
| 450 | 
 | 
|---|
| 451 | /* --Methode-- */
 | 
|---|
| 452 | //!    Return pixel index  with sequence index jp in the slice kt 
 | 
|---|
| 453 | template <class T>
 | 
|---|
| 454 | int_4 SphereThetaPhi<T>::Index(int_4 kt,int_4 jp) const
 | 
|---|
| 455 | {
 | 
|---|
| 456 |   int_4 k;
 | 
|---|
| 457 |   bool fgzn= false;
 | 
|---|
| 458 |   
 | 
|---|
| 459 |   // si on se trouve dans l'hemisphere Sud
 | 
|---|
| 460 |   if(kt >= NTheta_) {
 | 
|---|
| 461 |     fgzn= true; 
 | 
|---|
| 462 |     kt= 2*NTheta_-1-kt;
 | 
|---|
| 463 |   }
 | 
|---|
| 464 |   
 | 
|---|
| 465 |   // si la tranche kt contient au moins i pixels
 | 
|---|
| 466 |   if( (jp>=0) && (jp<NPhi_(kt)) ) 
 | 
|---|
| 467 |     {
 | 
|---|
| 468 |       // dans l'hemisphere Sud
 | 
|---|
| 469 |       if (fgzn) k= NPix_-TNphi_(kt+1)+jp;
 | 
|---|
| 470 |       // dans l'hemisphere Nord
 | 
|---|
| 471 |       else k= TNphi_(kt)+jp;
 | 
|---|
| 472 |     }
 | 
|---|
| 473 |   else
 | 
|---|
| 474 |     {
 | 
|---|
| 475 |       k= 9999;
 | 
|---|
| 476 |       printf("\n la tranche %d ne contient pas un pixel de rang %d",kt,jp);
 | 
|---|
| 477 |     }
 | 
|---|
| 478 |   return(k);
 | 
|---|
| 479 | }
 | 
|---|
| 480 | 
 | 
|---|
| 481 | /* --Methode-- */
 | 
|---|
| 482 | //!    Return indices kt (theta) and jp (phi) of  pixel with index k
 | 
|---|
| 483 | template <class T>
 | 
|---|
| 484 | void SphereThetaPhi<T>::ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp) 
 | 
|---|
| 485 | {
 | 
|---|
| 486 |   bool fgzn= false;  
 | 
|---|
| 487 |   // si on se trouve dans l'hemisphere Sud
 | 
|---|
| 488 |   if(k >= NPix_/2) 
 | 
|---|
| 489 |     { 
 | 
|---|
| 490 |       fgzn= true; 
 | 
|---|
| 491 |       k= NPix_-1-k; 
 | 
|---|
| 492 |     }
 | 
|---|
| 493 |   
 | 
|---|
| 494 |   // on recupere l'indice kt de la tranche qui contient le pixel k
 | 
|---|
| 495 |   int_4 i;
 | 
|---|
| 496 |   for(i = 0; i < NTheta_; i++) 
 | 
|---|
| 497 |     if(k < TNphi_(i+1)) break;
 | 
|---|
| 498 |   
 | 
|---|
| 499 |   // indice  kt de tranche
 | 
|---|
| 500 |   if (fgzn) kt= 2*NTheta_-1-i;
 | 
|---|
| 501 |   else kt= i;
 | 
|---|
| 502 |   
 | 
|---|
| 503 |   // indice jp de pixel
 | 
|---|
| 504 |   if (fgzn) jp= TNphi_(i+1)-k-1;
 | 
|---|
| 505 |   else jp= k-TNphi_(i);  
 | 
|---|
| 506 | }
 | 
|---|
| 507 | /*!
 | 
|---|
| 508 |   \brief achieve the splitting into pixels 
 | 
|---|
| 509 |   m has the same signification as for the constructor
 | 
|---|
| 510 |   
 | 
|---|
| 511 |   Each theta-slice of the north hemisphere will be spitted starting f
 | 
|---|
| 512 |   from  phi=0 ...
 | 
|---|
| 513 |   
 | 
|---|
| 514 |   South hemisphere is scanned in the same direction according to phi
 | 
|---|
| 515 |   and from equator to the pole (the pixel following the last one of
 | 
|---|
| 516 |   the slice closest to the equator with z>0, is the pixel with lowest 
 | 
|---|
| 517 |   phi of the slice closest of the equator with z<0).
 | 
|---|
| 518 | */
 | 
|---|
| 519 | template <class T>
 | 
|---|
| 520 | void  SphereThetaPhi<T>::Pixelize(int_4 m) 
 | 
|---|
| 521 | 
 | 
|---|
| 522 | //--
 | 
|---|
| 523 | {
 | 
|---|
| 524 |   int_4 ntotpix,j;
 | 
|---|
| 525 |   
 | 
|---|
| 526 |   // Decodage et controle des arguments d'appel :
 | 
|---|
| 527 |   // au moins 2 et au plus 524288 bandes d'un hemisphere en theta
 | 
|---|
| 528 |   if (m < 2) m = 2;
 | 
|---|
| 529 |   if (m > 524288) m = 524288;
 | 
|---|
| 530 |   
 | 
|---|
| 531 |   // On memorise les arguments d'appel
 | 
|---|
| 532 |   NTheta_ = m;  
 | 
|---|
| 533 |   
 | 
|---|
| 534 |   // On commence par decouper l'hemisphere z>0.
 | 
|---|
| 535 |   // Creation des vecteurs contenant :
 | 
|---|
| 536 |   // Les valeurs limites de theta (une valeur de plus que le nombre de bandes...)
 | 
|---|
| 537 |   //  Theta_= new double[m+1];
 | 
|---|
| 538 |   Theta_.ReSize(m+1);
 | 
|---|
| 539 |   
 | 
|---|
| 540 |   // Le nombre de pixels en phi de chacune des bandes en theta
 | 
|---|
| 541 |   //  NPhi_ = new int_4[m];
 | 
|---|
| 542 |   // une taille de m suffit, mais je mets m+1 pour que les 3 tableaux aient 
 | 
|---|
| 543 |   // la meme taille pour une manipulation plus faciles par la librairie 
 | 
|---|
| 544 |   // cfitsio -- GLM (13-04-00)
 | 
|---|
| 545 |   NPhi_.ReSize(m+1);
 | 
|---|
| 546 |   
 | 
|---|
| 547 |   // Le nombre/Deuxpi total des pixels contenus dans les bandes de z superieur a une
 | 
|---|
| 548 |   // bande donnee (mTPphi[m] contient le nombre de pixels total de l'hemisphere)
 | 
|---|
| 549 |   //  TNphi_= new int_4[m+1];
 | 
|---|
| 550 |     TNphi_.ReSize(m+1);
 | 
|---|
| 551 |   
 | 
|---|
| 552 |   // Calcul du nombre total de pixels dans chaque bande pour optimiser
 | 
|---|
| 553 |   // le rapport largeur/hauteur des pixels 
 | 
|---|
| 554 |   
 | 
|---|
| 555 |   //calotte polaire
 | 
|---|
| 556 |   TNphi_(0)= 0;
 | 
|---|
| 557 |   NPhi_(0) = 1;
 | 
|---|
| 558 |   
 | 
|---|
| 559 |   //bandes jusqu'a l'equateur
 | 
|---|
| 560 |   for(j = 1; j < m; j++) 
 | 
|---|
| 561 |     {
 | 
|---|
| 562 |       TNphi_(j)= TNphi_(j-1)+NPhi_(j-1);
 | 
|---|
| 563 |       NPhi_(j) = (int_4)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ;
 | 
|---|
| 564 |     }
 | 
|---|
| 565 |   
 | 
|---|
| 566 |   // Nombre total de pixels sur l'hemisphere
 | 
|---|
| 567 |   ntotpix  = TNphi_(m-1)+NPhi_(m-1);
 | 
|---|
| 568 |   TNphi_(m)= ntotpix;
 | 
|---|
| 569 |   // et sur la sphere entiere
 | 
|---|
| 570 |   NPix_= 2*ntotpix;
 | 
|---|
| 571 |   
 | 
|---|
| 572 |   // Creation et initialisation du vecteur des contenus des pixels 
 | 
|---|
| 573 |   pixels_.ReSize(NPix_);
 | 
|---|
| 574 |   pixels_.Reset();
 | 
|---|
| 575 | 
 | 
|---|
| 576 |   // Determination des limites des bandes en theta :
 | 
|---|
| 577 |   // omeg est l'angle solide couvert par chaque pixel,
 | 
|---|
| 578 |   // une bande donnee kt couvre un angle solide NPhi_[kt]*omeg
 | 
|---|
| 579 |   // egal a 2* Pi*(cos Theta_[kt]-cos Theta_[kt+1]). De meme, l'angle solide 
 | 
|---|
| 580 |   //de la
 | 
|---|
| 581 |   // calotte allant du pole a la limite haute de la bande kt vaut
 | 
|---|
| 582 |   // 2* Pi*(1.-cos Theta_[kt+1])= TNphi_[kt]*omeg...
 | 
|---|
| 583 |   
 | 
|---|
| 584 |   double omeg2pi= 1./(double)ntotpix;
 | 
|---|
| 585 |   Omega_ = omeg2pi*DeuxPi;
 | 
|---|
| 586 |   
 | 
|---|
| 587 |   for(j=0; j <= m; j++) 
 | 
|---|
| 588 |     {
 | 
|---|
| 589 |       Theta_(j)= acos(1.-(double)TNphi_(j)*omeg2pi);
 | 
|---|
| 590 |     }
 | 
|---|
| 591 | }
 | 
|---|
| 592 | 
 | 
|---|
| 593 | //! Return the theta angle for slice defined by \b index
 | 
|---|
| 594 | template <class T>
 | 
|---|
| 595 | r_8 SphereThetaPhi<T>::ThetaOfSlice(int_4 index) const
 | 
|---|
| 596 | {
 | 
|---|
| 597 |   if(index < 0 || index >= 2*NTheta_) 
 | 
|---|
| 598 |     throw RangeCheckError("SphereThetaPhi::ThetaOfSlice() index out of range"); 
 | 
|---|
| 599 |   double tet1, tet2;
 | 
|---|
| 600 |   Theta(index, tet1, tet2); 
 | 
|---|
| 601 |   return 0.5*(tet1+tet2);  
 | 
|---|
| 602 | }
 | 
|---|
| 603 | 
 | 
|---|
| 604 | //! Return true : All theta slices have a symmetric slice at Pi-Theta in SphereThetaPhi
 | 
|---|
| 605 | template <class T>
 | 
|---|
| 606 | bool SphereThetaPhi<T>::HasSymThetaSlice() const 
 | 
|---|
| 607 | {
 | 
|---|
| 608 |   return true;
 | 
|---|
| 609 | }
 | 
|---|
| 610 | //! Return the slice index for the symmetric slice at theta=Pi-ThetaOfSlice(idx) 
 | 
|---|
| 611 | template <class T>
 | 
|---|
| 612 | int_4 SphereThetaPhi<T>::GetSymThetaSliceIndex(int_4 idx) const
 | 
|---|
| 613 | {
 | 
|---|
| 614 |   if(idx < 0 || idx >= (int_4)NbThetaSlices()) 
 | 
|---|
| 615 |     throw RangeCheckError("SphereThetaPhi::GetSymThetaSliceIndex index out of range"); 
 | 
|---|
| 616 |   return (NbThetaSlices()-1-idx);
 | 
|---|
| 617 | }
 | 
|---|
| 618 | 
 | 
|---|
| 619 | /*!    
 | 
|---|
| 620 |   \brief return a Theta slice information
 | 
|---|
| 621 |   For a theta-slice with index 'index', return : 
 | 
|---|
| 622 |   the corresponding "theta" 
 | 
|---|
| 623 |   a vector containing the phi's of the pixels of the slice
 | 
|---|
| 624 |   a vector containing the corresponding values of pixels 
 | 
|---|
| 625 | */
 | 
|---|
| 626 | template <class T>
 | 
|---|
| 627 | void SphereThetaPhi<T>::GetThetaSlice(int_4 index,r_8& theta, TVector<r_8>& phi, TVector<T>& value) const 
 | 
|---|
| 628 | 
 | 
|---|
| 629 | {
 | 
|---|
| 630 | 
 | 
|---|
| 631 |   if(index < 0 || index >= (int_4)NbThetaSlices()) 
 | 
|---|
| 632 |     throw RangeCheckError("SphereThetaPhi::GetThetaSlice(idx...) index out of range"); 
 | 
|---|
| 633 |     
 | 
|---|
| 634 | 
 | 
|---|
| 635 |   int_4 iring= Index(index,0);
 | 
|---|
| 636 |   int_4 lring  = NPhi(index);
 | 
|---|
| 637 | 
 | 
|---|
| 638 |   phi.ReSize(lring);
 | 
|---|
| 639 |   value.ReSize(lring);
 | 
|---|
| 640 |   double Te= 0.;
 | 
|---|
| 641 |   double Fi= 0.;
 | 
|---|
| 642 |   PixThetaPhi(iring,Te,Fi);
 | 
|---|
| 643 |   double DFi = DeuxPi/(double)NPhi(index);
 | 
|---|
| 644 |   for(int_4 kk = 0; kk < lring; kk++)   {
 | 
|---|
| 645 |     value(kk)= pixels_(kk+iring);
 | 
|---|
| 646 |     phi(kk)= Fi;
 | 
|---|
| 647 |     Fi += DFi;
 | 
|---|
| 648 |   }
 | 
|---|
| 649 |   theta= Te;
 | 
|---|
| 650 | }
 | 
|---|
| 651 | 
 | 
|---|
| 652 | /*
 | 
|---|
| 653 |   \brief return information on a theta slice 
 | 
|---|
| 654 |   For a theta-slice with index 'index', return : 
 | 
|---|
| 655 |   the corresponding "theta" 
 | 
|---|
| 656 |   the corresponding "phi" for first pixel of the slice 
 | 
|---|
| 657 |   a vector containing the indices of the pixels of the slice
 | 
|---|
| 658 |   (equally distributed in phi)
 | 
|---|
| 659 |   a vector containing the corresponding values of pixels 
 | 
|---|
| 660 | */
 | 
|---|
| 661 | template <class T>
 | 
|---|
| 662 | void SphereThetaPhi<T>::GetThetaSlice(int_4 index,r_8& theta, r_8& phi0,TVector<int_4>& pixelIndices, TVector<T>& value) const 
 | 
|---|
| 663 | 
 | 
|---|
| 664 | {
 | 
|---|
| 665 | 
 | 
|---|
| 666 |   if(index < 0 || index >= (int_4)NbThetaSlices()) 
 | 
|---|
| 667 |     throw RangeCheckError("SphereThetaPhi::GetThetaSlice(idx...)  idx out of range"); 
 | 
|---|
| 668 | 
 | 
|---|
| 669 |   int_4 iring= Index(index,0);
 | 
|---|
| 670 |   int_4 lring  = NPhi(index);
 | 
|---|
| 671 | 
 | 
|---|
| 672 |   pixelIndices.ReSize(lring);
 | 
|---|
| 673 |   value.ReSize(lring);
 | 
|---|
| 674 |   for(int_4 kk = 0; kk < lring; kk++)  {
 | 
|---|
| 675 |     pixelIndices(kk)=kk+iring ;
 | 
|---|
| 676 |     value(kk)= pixels_(kk+iring);
 | 
|---|
| 677 |   }
 | 
|---|
| 678 |   PixThetaPhi(iring,theta,phi0);
 | 
|---|
| 679 | }
 | 
|---|
| 680 | 
 | 
|---|
| 681 | //! return a pointer to the specified slice pixel data
 | 
|---|
| 682 | template <class T>
 | 
|---|
| 683 | T* SphereThetaPhi<T>::GetThetaSliceDataPtr(int_4 index)
 | 
|---|
| 684 | {
 | 
|---|
| 685 |   if(index < 0 || index >= (int_4)NbThetaSlices()) 
 | 
|---|
| 686 |     throw RangeCheckError("SphereThetaPhi::GetThetaSliceDataPtr(idx)  idx out of range"); 
 | 
|---|
| 687 |   return pixels_.Begin()+Index(index,0);
 | 
|---|
| 688 | }
 | 
|---|
| 689 | 
 | 
|---|
| 690 | 
 | 
|---|
| 691 | template <class T>
 | 
|---|
| 692 | void SphereThetaPhi<T>::print(ostream& os) const
 | 
|---|
| 693 | {
 | 
|---|
| 694 |   this->Show(os);
 | 
|---|
| 695 |   os << "SphereThetaPhi<T> NTheta_= " << NTheta_ << " NPix_    = " << NPix_ 
 | 
|---|
| 696 |      << " Omega_  =  " << Omega_   << endl;
 | 
|---|
| 697 |   if(this->mInfo_) os << "  DVList Info= " << *(this->mInfo_) << endl;
 | 
|---|
| 698 | 
 | 
|---|
| 699 |   os << "... NPhi_ Values : ";
 | 
|---|
| 700 |   int_4 i;
 | 
|---|
| 701 |   for(i=0; i < NTheta_; i++)
 | 
|---|
| 702 |     {
 | 
|---|
| 703 |       if(i%5 == 0) os << endl;
 | 
|---|
| 704 |       os << NPhi_(i) <<", ";
 | 
|---|
| 705 |     }
 | 
|---|
| 706 |   os << endl;
 | 
|---|
| 707 | 
 | 
|---|
| 708 |   os << "... Theta_ Values : ";
 | 
|---|
| 709 |   for(i=0; i < NTheta_+1; i++)
 | 
|---|
| 710 |     {
 | 
|---|
| 711 |       if(i%5 == 0) os << endl;
 | 
|---|
| 712 |       os << Theta_(i) <<", ";
 | 
|---|
| 713 |     }
 | 
|---|
| 714 |   os << endl;
 | 
|---|
| 715 | 
 | 
|---|
| 716 |   os << "... TNphi_ Values : ";
 | 
|---|
| 717 |   for(i=0; i < NTheta_+1; i++)
 | 
|---|
| 718 |     {
 | 
|---|
| 719 |       if(i%5 == 0) os << endl;
 | 
|---|
| 720 |       os << TNphi_(i) <<", ";
 | 
|---|
| 721 |     }
 | 
|---|
| 722 |   os << endl;
 | 
|---|
| 723 | 
 | 
|---|
| 724 |   os << "... Pixel Values : ";
 | 
|---|
| 725 |   for(i=0; i < NPix_; i++)
 | 
|---|
| 726 |     {
 | 
|---|
| 727 |       if(i%5 == 0) os << endl;
 | 
|---|
| 728 |       os <<  pixels_(i) <<", ";
 | 
|---|
| 729 |     }
 | 
|---|
| 730 |   os << endl;
 | 
|---|
| 731 | }
 | 
|---|
| 732 | 
 | 
|---|
| 733 | //   ...... Operations de calcul  ......
 | 
|---|
| 734 | 
 | 
|---|
| 735 | 
 | 
|---|
| 736 | //! Fill a SphereThetaPhi with a constant value \b a
 | 
|---|
| 737 | template <class T>
 | 
|---|
| 738 | SphereThetaPhi<T>& SphereThetaPhi<T>::SetT(T a) 
 | 
|---|
| 739 | {
 | 
|---|
| 740 |   if (NbPixels() < 1) 
 | 
|---|
| 741 |     throw RangeCheckError("SphereThetaPhi<T>::SetT(T )  - SphereThetaPhi not dimensionned ! ");
 | 
|---|
| 742 |   pixels_ = a;
 | 
|---|
| 743 |   return (*this);
 | 
|---|
| 744 | }
 | 
|---|
| 745 | 
 | 
|---|
| 746 | /*! Add a constant value \b x to a SphereThetaPhi */
 | 
|---|
| 747 | template <class T>
 | 
|---|
| 748 | SphereThetaPhi<T>& SphereThetaPhi<T>::Add(T a)
 | 
|---|
| 749 |  {
 | 
|---|
| 750 |   if (NbPixels()< 1) 
 | 
|---|
| 751 |     throw RangeCheckError("SphereThetaPhi<T>::Add(T )  - SphereThetaPhi not dimensionned ! ");
 | 
|---|
| 752 |   pixels_ += a; 
 | 
|---|
| 753 |   return (*this);
 | 
|---|
| 754 | }
 | 
|---|
| 755 | 
 | 
|---|
| 756 | /*! Substract a constant value \b a to a SphereThetaPhi */
 | 
|---|
| 757 | template <class T>
 | 
|---|
| 758 | SphereThetaPhi<T>& SphereThetaPhi<T>::Sub(T a,bool fginv) 
 | 
|---|
| 759 | {
 | 
|---|
| 760 |   if (NbPixels()< 1) 
 | 
|---|
| 761 |     throw RangeCheckError("SphereThetaPhi<T>::Sub(T )  - SphereThetaPhi not dimensionned ! ");
 | 
|---|
| 762 |   pixels_.Sub(a,fginv); 
 | 
|---|
| 763 |   return (*this);
 | 
|---|
| 764 | } 
 | 
|---|
| 765 | 
 | 
|---|
| 766 | /*! multiply a SphereThetaPhi by a constant value \b a */
 | 
|---|
| 767 | template <class T>
 | 
|---|
| 768 | SphereThetaPhi<T>& SphereThetaPhi<T>::Mul(T a) 
 | 
|---|
| 769 | {
 | 
|---|
| 770 |   if (NbPixels()< 1) 
 | 
|---|
| 771 |     throw RangeCheckError("SphereThetaPhi<T>::Mul(T )  - SphereThetaPhi not dimensionned ! ");
 | 
|---|
| 772 |   pixels_ *= a; 
 | 
|---|
| 773 |   return (*this);
 | 
|---|
| 774 | }
 | 
|---|
| 775 | 
 | 
|---|
| 776 | /*! divide a SphereThetaPhi by a constant value \b a */
 | 
|---|
| 777 | template <class T>
 | 
|---|
| 778 | SphereThetaPhi<T>& SphereThetaPhi<T>::Div(T a) 
 | 
|---|
| 779 | {
 | 
|---|
| 780 |   if (NbPixels()< 1) 
 | 
|---|
| 781 |     throw RangeCheckError("SphereThetaPhi<T>::Div(T )  - SphereThetaPhi not dimensionned ! ");
 | 
|---|
| 782 |   pixels_ /= a; 
 | 
|---|
| 783 |   return (*this);
 | 
|---|
| 784 | } 
 | 
|---|
| 785 | 
 | 
|---|
| 786 | //  >>>> Operations avec 2nd membre de type SphereThetaPhi
 | 
|---|
| 787 | //! Add two SphereThetaPhi
 | 
|---|
| 788 | 
 | 
|---|
| 789 | template <class T>
 | 
|---|
| 790 | SphereThetaPhi<T>& SphereThetaPhi<T>::AddElt(const SphereThetaPhi<T>& a)
 | 
|---|
| 791 | {
 | 
|---|
| 792 |   if (NbPixels()!= a.NbPixels())
 | 
|---|
| 793 |     {
 | 
|---|
| 794 |     throw(SzMismatchError("SphereThetaPhi<T>::AddElt(const SphereThetaPhi<T>&) SizeMismatch")) ;
 | 
|---|
| 795 |     }
 | 
|---|
| 796 |   pixels_ += a.pixels_;
 | 
|---|
| 797 |   return (*this);
 | 
|---|
| 798 | }
 | 
|---|
| 799 | 
 | 
|---|
| 800 | //! Substract two SphereThetaPhi
 | 
|---|
| 801 | template <class T>
 | 
|---|
| 802 | SphereThetaPhi<T>& SphereThetaPhi<T>::SubElt(const SphereThetaPhi<T>& a)
 | 
|---|
| 803 | {
 | 
|---|
| 804 |   if (NbPixels()!= a.NbPixels())
 | 
|---|
| 805 |     {
 | 
|---|
| 806 |     throw(SzMismatchError("SphereThetaPhi<T>::SubElt(const SphereThetaPhi<T>&) SizeMismatch")) ;
 | 
|---|
| 807 |     }
 | 
|---|
| 808 |   pixels_ -= a.pixels_;
 | 
|---|
| 809 |   return (*this);
 | 
|---|
| 810 | }
 | 
|---|
| 811 | 
 | 
|---|
| 812 | //! Multiply two SphereThetaPhi (elements by elements)
 | 
|---|
| 813 | template <class T>
 | 
|---|
| 814 | SphereThetaPhi<T>& SphereThetaPhi<T>::MulElt(const SphereThetaPhi<T>& a)
 | 
|---|
| 815 | {
 | 
|---|
| 816 |   if (NbPixels()!= a.NbPixels())
 | 
|---|
| 817 |     {
 | 
|---|
| 818 |     throw(SzMismatchError("SphereThetaPhi<T>::MulElt(const SphereThetaPhi<T>&) SizeMismatch")) ;
 | 
|---|
| 819 |     }
 | 
|---|
| 820 |   pixels_ *= a.pixels_;
 | 
|---|
| 821 |   return (*this);
 | 
|---|
| 822 | }
 | 
|---|
| 823 | 
 | 
|---|
| 824 | //! Divide two SphereThetaPhi (elements by elements) - No protection for divide by 0
 | 
|---|
| 825 | template <class T>
 | 
|---|
| 826 | SphereThetaPhi<T>& SphereThetaPhi<T>::DivElt(const SphereThetaPhi<T>& a)
 | 
|---|
| 827 | {
 | 
|---|
| 828 |   if (NbPixels()!= a.NbPixels())
 | 
|---|
| 829 |     {
 | 
|---|
| 830 |     throw(SzMismatchError("SphereThetaPhi<T>::DivElt(const SphereThetaPhi<T>&) SizeMismatch")) ;
 | 
|---|
| 831 |     }
 | 
|---|
| 832 |   pixels_ /= a.pixels_;
 | 
|---|
| 833 |   return (*this);
 | 
|---|
| 834 | }
 | 
|---|
| 835 | 
 | 
|---|
| 836 | 
 | 
|---|
| 837 | 
 | 
|---|
| 838 | #ifdef __CXX_PRAGMA_TEMPLATES__
 | 
|---|
| 839 | #pragma define_template SphereThetaPhi<int_4>
 | 
|---|
| 840 | #pragma define_template SphereThetaPhi<r_8>
 | 
|---|
| 841 | #pragma define_template SphereThetaPhi<r_4>
 | 
|---|
| 842 | #pragma define_template SphereThetaPhi< complex<r_4> >
 | 
|---|
| 843 | #pragma define_template SphereThetaPhi< complex<r_8> >
 | 
|---|
| 844 | #endif
 | 
|---|
| 845 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
 | 
|---|
| 846 | namespace SOPHYA {
 | 
|---|
| 847 | template class SphereThetaPhi<int_4>;
 | 
|---|
| 848 | template class SphereThetaPhi<r_8>;
 | 
|---|
| 849 | template class SphereThetaPhi<r_4>;
 | 
|---|
| 850 | template class SphereThetaPhi< complex<r_4> >;
 | 
|---|
| 851 | template class SphereThetaPhi< complex<r_8> >;
 | 
|---|
| 852 | }
 | 
|---|
| 853 | #endif
 | 
|---|