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