[228] | 1 | //
|
---|
| 2 | #include "spheregorski.h"
|
---|
| 3 | #include "strutil.h"
|
---|
[470] | 4 | #include <complex>
|
---|
| 5 | #include "piocmplx.h"
|
---|
| 6 |
|
---|
| 7 | extern "C"
|
---|
| 8 | {
|
---|
[228] | 9 | #include <stdio.h>
|
---|
| 10 | #include <stdlib.h>
|
---|
| 11 | #include <unistd.h>
|
---|
| 12 | }
|
---|
| 13 |
|
---|
[470] | 14 | extern "C"
|
---|
| 15 | {
|
---|
| 16 | void anafast_(int&, int&, int&,double&,float*,float*,float*,float*,float*,float*,float*);
|
---|
| 17 | void synfast_(int&, int&, int&,int&, float&,float*,float*,float*,double*, double*,double*,double*,double*,float*);
|
---|
| 18 | }
|
---|
[228] | 19 |
|
---|
[470] | 20 | //*******************************************************************
|
---|
| 21 | // Class PIXELS_XY
|
---|
| 22 | // Construction des tableaux necessaires a la traduction des indices RING en
|
---|
| 23 | // indices NESTED (ou l'inverse)
|
---|
| 24 | //*******************************************************************
|
---|
| 25 |
|
---|
| 26 | PIXELS_XY::PIXELS_XY()
|
---|
| 27 | {
|
---|
| 28 | cout << " appel du constructeur PIXELS_XY " <<endl;
|
---|
| 29 | pix2x_.ReSize(1024);
|
---|
| 30 | pix2x_.Reset();
|
---|
| 31 | pix2y_.ReSize(1024);
|
---|
| 32 | pix2y_.Reset();
|
---|
| 33 | x2pix_.ReSize(128);
|
---|
| 34 | x2pix_.Reset();
|
---|
| 35 | y2pix_.ReSize(128);
|
---|
| 36 | y2pix_.Reset();
|
---|
| 37 | mk_pix2xy();
|
---|
| 38 | mk_xy2pix();
|
---|
[228] | 39 | }
|
---|
[470] | 40 |
|
---|
| 41 | PIXELS_XY& PIXELS_XY::instance()
|
---|
| 42 | {
|
---|
| 43 | static PIXELS_XY single;
|
---|
| 44 | return (single);
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | void PIXELS_XY::mk_pix2xy()
|
---|
| 48 | {
|
---|
| 49 | /*
|
---|
| 50 | ==================================================
|
---|
| 51 | subroutine mk_pix2xy
|
---|
| 52 | ==================================================
|
---|
| 53 | c constructs the array giving x and y in the face from pixel number
|
---|
| 54 | c for the nested (quad-cube like) ordering of pixels
|
---|
| 55 | c
|
---|
| 56 | c the bits corresponding to x and y are interleaved in the pixel number
|
---|
| 57 | c one breaks up the pixel number by even and odd bits
|
---|
| 58 | ==================================================
|
---|
| 59 | */
|
---|
| 60 | // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
|
---|
| 61 | // (16/12/98)
|
---|
| 62 |
|
---|
| 63 | int kpix, jpix, IX, IY, IP, ID;
|
---|
| 64 |
|
---|
| 65 | for(kpix = 0; kpix < 1024; kpix++)
|
---|
| 66 | {
|
---|
| 67 | jpix = kpix;
|
---|
| 68 | IX = 0;
|
---|
| 69 | IY = 0;
|
---|
| 70 | IP = 1 ;// ! bit position (in x and y)
|
---|
| 71 | while( jpix!=0 )
|
---|
| 72 | { // ! go through all the bits
|
---|
| 73 | ID=jpix%2;// ! bit value (in kpix), goes in ix
|
---|
| 74 | jpix = jpix/2;
|
---|
| 75 | IX = ID*IP+IX;
|
---|
| 76 |
|
---|
| 77 | ID=jpix%2;// ! bit value (in kpix), goes in iy
|
---|
| 78 | jpix = jpix/2;
|
---|
| 79 | IY = ID*IP+IY;
|
---|
| 80 |
|
---|
| 81 | IP = 2*IP;// ! next bit (in x and y)
|
---|
| 82 | }
|
---|
| 83 | pix2x_(kpix) = IX;// ! in 0,31
|
---|
| 84 | pix2y_(kpix) = IY;// ! in 0,31
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | void PIXELS_XY::mk_xy2pix()
|
---|
| 89 | {
|
---|
| 90 | /*
|
---|
| 91 | =================================================
|
---|
| 92 | subroutine mk_xy2pix
|
---|
| 93 | =================================================
|
---|
| 94 | c sets the array giving the number of the pixel lying in (x,y)
|
---|
| 95 | c x and y are in {1,128}
|
---|
| 96 | c the pixel number is in {0,128**2-1}
|
---|
| 97 | c
|
---|
| 98 | c if i-1 = sum_p=0 b_p * 2^p
|
---|
| 99 | c then ix = sum_p=0 b_p * 4^p
|
---|
| 100 | c iy = 2*ix
|
---|
| 101 | c ix + iy in {0, 128**2 -1}
|
---|
| 102 | =================================================
|
---|
| 103 | */
|
---|
| 104 | // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
|
---|
| 105 | // (16/12/98)
|
---|
| 106 |
|
---|
| 107 | int K,IP,I,J,ID;
|
---|
| 108 | for(I = 1; I <= 128; I++)
|
---|
| 109 | {
|
---|
| 110 | J = I-1;// !pixel numbers
|
---|
| 111 | K = 0;//
|
---|
| 112 | IP = 1;//
|
---|
| 113 | truc : if( J==0 )
|
---|
| 114 | {
|
---|
| 115 | x2pix_(I-1) = K;
|
---|
| 116 | y2pix_(I-1) = 2*K;
|
---|
| 117 | }
|
---|
| 118 | else
|
---|
| 119 | {
|
---|
| 120 | ID = (int)fmod(J,2);
|
---|
| 121 | J = J/2;
|
---|
| 122 | K = IP*ID+K;
|
---|
| 123 | IP = IP*4;
|
---|
| 124 | goto truc;
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[228] | 129 | //*******************************************************************
|
---|
| 130 | //++
|
---|
| 131 | // Class SphereGorski
|
---|
| 132 | //
|
---|
| 133 | // include spheregorski.h strutil.h
|
---|
| 134 | //
|
---|
| 135 | // Pixelisation Gorski
|
---|
| 136 | //
|
---|
| 137 | //
|
---|
| 138 | //| -----------------------------------------------------------------------
|
---|
| 139 | //| version 0.8.2 Aug97 TAC Eric Hivon, Kris Gorski
|
---|
| 140 | //| -----------------------------------------------------------------------
|
---|
| 141 | //
|
---|
| 142 | // the sphere is split in 12 diamond-faces containing nside**2 pixels each
|
---|
| 143 | //
|
---|
| 144 | // the numbering of the pixels (in the nested scheme) is similar to
|
---|
| 145 | // quad-cube
|
---|
| 146 | // In each face the first pixel is in the lowest corner of the diamond
|
---|
| 147 | //
|
---|
| 148 | // the faces are (x,y) coordinate on each face
|
---|
| 149 | //| . . . . <--- North Pole
|
---|
| 150 | //| / \ / \ / \ / \ ^ ^
|
---|
| 151 | //| . 0 . 1 . 2 . 3 . <--- z = 2/3 \ /
|
---|
| 152 | //| \ / \ / \ / \ / y \ / x
|
---|
| 153 | //| 4 . 5 . 6 . 7 . 4 <--- equator \ /
|
---|
| 154 | //| / \ / \ / \ / \ \/
|
---|
| 155 | //| . 8 . 9 .10 .11 . <--- z = -2/3 (0,0) : lowest corner
|
---|
| 156 | //| \ / \ / \ / \ /
|
---|
| 157 | //| . . . . <--- South Pole
|
---|
| 158 | //|
|
---|
| 159 | // phi:0 2Pi
|
---|
| 160 | //
|
---|
| 161 | // in the ring scheme pixels are numbered along the parallels
|
---|
| 162 | // the first parallel is the one closest to the north pole and so on
|
---|
| 163 | // on each parallel, pixels are numbered starting from the one closest
|
---|
| 164 | // to phi = 0
|
---|
| 165 | //
|
---|
| 166 | // nside DOIT OBLIGATOIREMENT ETRE UNE PUISSANCE DE 2 (<= 8192)
|
---|
| 167 | //--
|
---|
| 168 | //++
|
---|
| 169 | //
|
---|
| 170 | // Links Parents
|
---|
| 171 | //
|
---|
| 172 | // SphericalMap
|
---|
| 173 | //--
|
---|
| 174 | //++
|
---|
| 175 | //
|
---|
| 176 | // Links Descendants
|
---|
| 177 | //
|
---|
| 178 | //
|
---|
| 179 | //--
|
---|
| 180 |
|
---|
| 181 | /* --Methode-- */
|
---|
| 182 | //++
|
---|
| 183 | // Titre Constructeurs
|
---|
| 184 | //--
|
---|
| 185 | //++
|
---|
| 186 |
|
---|
[470] | 187 | template<class T>
|
---|
| 188 | SphereGorski<T>::SphereGorski()
|
---|
[228] | 189 |
|
---|
| 190 | //--
|
---|
| 191 | {
|
---|
[470] | 192 | cout<<" appel du constructeur SphereGorski ()" <<endl;
|
---|
[228] | 193 | InitNul();
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | //++
|
---|
[470] | 197 | template<class T>
|
---|
| 198 | SphereGorski<T>::SphereGorski(int_4 m)
|
---|
[228] | 199 |
|
---|
| 200 | // Constructeur : m est la variable nside de l'algorithme de Gorski
|
---|
| 201 | // le nombre total de pixels sera Npix = 12*nside**2
|
---|
| 202 | // m DOIT OBLIGATOIREMENT ETRE UNE PUISSANCE DE 2 (<= 8192)
|
---|
| 203 | //--
|
---|
| 204 | {
|
---|
[470] | 205 | cout<<" appel du constructeur SphereGorski (m)" <<endl;
|
---|
| 206 |
|
---|
| 207 | if(m <= 0 || m > 8192)
|
---|
| 208 | {
|
---|
| 209 | cout << "SphereGorski : m hors bornes [0,8192], m= " << m << endl;
|
---|
| 210 | exit(1);
|
---|
| 211 | }
|
---|
| 212 | // verifier que m est une puissance de deux
|
---|
[228] | 213 | int_4 x=m;
|
---|
[470] | 214 | while(x%2 == 0) x/=2;
|
---|
| 215 | if(x != 1)
|
---|
| 216 | {
|
---|
| 217 | cout<<"SphereGorski: m doit etre une puissance de deux, m= "<<m<<endl;
|
---|
| 218 | exit(1);
|
---|
| 219 | }
|
---|
[228] | 220 | InitNul();
|
---|
| 221 | Pixelize(m);
|
---|
| 222 | }
|
---|
| 223 |
|
---|
[470] | 224 | template<class T>
|
---|
| 225 | SphereGorski<T>::SphereGorski(const SphereGorski<T>& s)
|
---|
| 226 | {
|
---|
| 227 | cout << " constructeur de recopie " << endl;
|
---|
| 228 | if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
|
---|
[228] | 229 |
|
---|
[470] | 230 | nSide_= s.nSide_;
|
---|
| 231 | nPix_ = s.nPix_;
|
---|
| 232 | omeg_ = s.omeg_;
|
---|
[228] | 233 |
|
---|
[470] | 234 | pixels_= s.pixels_;
|
---|
[228] | 235 |
|
---|
[470] | 236 | nlmax_= s.nlmax_;
|
---|
| 237 | nmmax_= s.nmmax_;
|
---|
| 238 | iseed_= s.iseed_;
|
---|
| 239 | fwhm_ = s.fwhm_;
|
---|
| 240 | quadrupole_ = s.quadrupole_;
|
---|
| 241 | sym_cut_deg_= s.sym_cut_deg_;
|
---|
| 242 | strcpy(powFile_,s.powFile_);
|
---|
| 243 | }
|
---|
[228] | 244 |
|
---|
| 245 | //++
|
---|
| 246 | // Titre Destructeur
|
---|
| 247 | //--
|
---|
| 248 | //++
|
---|
[470] | 249 | template<class T>
|
---|
| 250 | SphereGorski<T>::~SphereGorski()
|
---|
[228] | 251 |
|
---|
| 252 | //--
|
---|
| 253 | {
|
---|
[470] | 254 | InitNul();
|
---|
[228] | 255 | }
|
---|
| 256 |
|
---|
| 257 | //++
|
---|
| 258 | // Titre Méthodes
|
---|
| 259 | //--
|
---|
| 260 |
|
---|
[470] | 261 | //++
|
---|
| 262 | template<class T>
|
---|
| 263 | void SphereGorski<T>::Resize(int_4 m)
|
---|
[228] | 264 |
|
---|
[470] | 265 | // m est la variable nside de l'algorithme de Gorski
|
---|
| 266 | // le nombre total de pixels sera Npix = 12*nside**2
|
---|
| 267 | // m DOIT OBLIGATOIREMENT ETRE UNE PUISSANCE DE 2 (<= 8192)
|
---|
| 268 | //--
|
---|
| 269 | {
|
---|
| 270 | if (m<=0 || m> 8192) {
|
---|
| 271 | cout << "SphereGorski : m hors bornes [0,8192], m= " << m << endl;
|
---|
| 272 | exit(1);
|
---|
| 273 | }
|
---|
| 274 | // verifier que m est une puissance de deux
|
---|
| 275 | int_4 x=m;
|
---|
| 276 | while (x%2==0) x/=2;
|
---|
| 277 | if(x != 1)
|
---|
| 278 | {
|
---|
| 279 | cout<<"SphereGorski: m doit etre une puissance de deux, m= "<<m<<endl;
|
---|
| 280 | exit(1);
|
---|
| 281 | }
|
---|
| 282 | InitNul();
|
---|
| 283 | Pixelize(m);
|
---|
| 284 | }
|
---|
[228] | 285 |
|
---|
[470] | 286 | template<class T>
|
---|
| 287 | void SphereGorski<T>::Pixelize( int_4 m)
|
---|
[228] | 288 |
|
---|
| 289 | // prépare la pixelisation Gorski (m a la même signification
|
---|
| 290 | // que pour le constructeur)
|
---|
| 291 | //
|
---|
| 292 | //
|
---|
| 293 | //--
|
---|
| 294 | {
|
---|
| 295 | // On memorise les arguments d'appel
|
---|
| 296 | nSide_ = m;
|
---|
[470] | 297 |
|
---|
[228] | 298 | // Nombre total de pixels sur la sphere entiere
|
---|
| 299 | nPix_=12*nSide_*nSide_;
|
---|
| 300 |
|
---|
[470] | 301 | // pour le moment les tableaux qui suivent seront ranges dans l'ordre
|
---|
| 302 | // de l'indexation GORSKY "RING"
|
---|
| 303 | // on pourra ulterieurement changer de strategie et tirer profit
|
---|
| 304 | // de la dualite d'indexation GORSKY (RING et NEST) : tout dependra
|
---|
| 305 | // de pourquoi c'est faire
|
---|
[228] | 306 |
|
---|
| 307 | // Creation et initialisation du vecteur des contenus des pixels
|
---|
[470] | 308 | pixels_.ReSize(nPix_);
|
---|
| 309 | pixels_.Reset();
|
---|
[228] | 310 |
|
---|
| 311 | // solid angle per pixel
|
---|
[470] | 312 | omeg_= 4*Pi/nPix_;
|
---|
[228] | 313 | }
|
---|
| 314 |
|
---|
[470] | 315 | template<class T>
|
---|
| 316 | void SphereGorski<T>::InitNul()
|
---|
[228] | 317 | //
|
---|
| 318 | // initialise à zéro les variables de classe
|
---|
| 319 | {
|
---|
[470] | 320 | nSide_= 0;
|
---|
| 321 | nPix_ = 0;
|
---|
| 322 | omeg_ = 0.;
|
---|
| 323 | pixels_.Reset();
|
---|
[228] | 324 |
|
---|
[470] | 325 | nlmax_= 0;
|
---|
| 326 | nmmax_= 0;
|
---|
| 327 | iseed_= 0;
|
---|
| 328 | fwhm_ = 0.;
|
---|
| 329 | quadrupole_ = 0.;
|
---|
| 330 | sym_cut_deg_= 0.;
|
---|
| 331 | for(int k = 0; k < 128; k++) powFile_[k]=' ';
|
---|
[228] | 332 | }
|
---|
| 333 |
|
---|
| 334 | /* --Methode-- */
|
---|
| 335 | //++
|
---|
[470] | 336 | template<class T>
|
---|
| 337 | int_4 SphereGorski<T>::NbPixels() const
|
---|
[228] | 338 |
|
---|
| 339 | // Retourne le nombre de pixels du découpage
|
---|
| 340 | //--
|
---|
[470] | 341 | {
|
---|
[228] | 342 | return(nPix_);
|
---|
| 343 | }
|
---|
| 344 |
|
---|
| 345 | //++
|
---|
[470] | 346 | template<class T>
|
---|
| 347 | int_4 SphereGorski<T>::NbThetaSlices() const
|
---|
[228] | 348 |
|
---|
| 349 | // Retourne le nombre de tranches en theta sur la sphere
|
---|
| 350 | //--
|
---|
[470] | 351 | {
|
---|
| 352 | return int_4(4*nSide_-1);
|
---|
| 353 | }
|
---|
[228] | 354 |
|
---|
| 355 | //++
|
---|
[470] | 356 | template<class T>
|
---|
| 357 | void SphereGorski<T>::GetThetaSlice(int_4 index, r_4& theta, TVector<float>& phi, TVector<T>& value) const
|
---|
[228] | 358 |
|
---|
| 359 | // Retourne, pour la tranche en theta d'indice 'index' le theta
|
---|
| 360 | // correspondant, un vecteur (Peida) contenant les phi des pixels de
|
---|
| 361 | // la tranche, un vecteur (Peida) contenant les valeurs de pixel
|
---|
| 362 | // correspondantes
|
---|
| 363 | //--
|
---|
| 364 | {
|
---|
[470] | 365 | cout << "entree GetThetaSlice, couche no " << index << endl;
|
---|
[228] | 366 |
|
---|
[470] | 367 | if (index<0 || index > NbThetaSlices())
|
---|
| 368 | {
|
---|
| 369 | // THROW(out_of_range("SphereGorski::PIxVal Pixel index out of range"));
|
---|
| 370 | cout << " SphereGorski::GetThetaSlice : exceptions a mettre en place" <<endl;
|
---|
| 371 | THROW(rangeCheckErr);
|
---|
| 372 | }
|
---|
[228] | 373 |
|
---|
[470] | 374 | int_4 iring= 0;
|
---|
| 375 | int lring = 0;
|
---|
| 376 | if(index < nSide_-1)
|
---|
| 377 | {
|
---|
| 378 | iring= 2*index*(index+1);
|
---|
| 379 | lring= 4*(index+1);
|
---|
| 380 | }
|
---|
| 381 | else if(index < 3*nSide_)
|
---|
| 382 | {
|
---|
| 383 | iring= 2*nSide_*(2*index-nSide_+1);
|
---|
| 384 | lring= 4*nSide_;
|
---|
| 385 | }
|
---|
| 386 | else
|
---|
| 387 | {
|
---|
| 388 | int nc= 4*nSide_-1-index;
|
---|
| 389 | iring = nPix_-2*nc*(nc+1);
|
---|
| 390 | lring = 4*nc;
|
---|
| 391 | }
|
---|
| 392 |
|
---|
| 393 | phi.ReSize(lring);
|
---|
| 394 | value.ReSize(lring);
|
---|
| 395 | float TH=0.;
|
---|
| 396 | float F =0.;
|
---|
| 397 | for(int kk = 0; kk < lring;kk++)
|
---|
| 398 | {
|
---|
| 399 | PixThetaPhi(kk+iring,TH,F);
|
---|
| 400 | phi(kk)= F;
|
---|
| 401 | value(kk)= PixVal(kk+iring);
|
---|
| 402 | }
|
---|
| 403 | theta= TH;
|
---|
[228] | 404 | }
|
---|
| 405 |
|
---|
| 406 | /* --Methode-- */
|
---|
| 407 | //++
|
---|
[470] | 408 | template<class T>
|
---|
| 409 | T& SphereGorski<T>::PixVal(int_4 k)
|
---|
[228] | 410 |
|
---|
| 411 | // Retourne la valeur du contenu du pixel d'indice "RING" k
|
---|
| 412 | //--
|
---|
| 413 | {
|
---|
[470] | 414 | if((k < 0) || (k >= nPix_))
|
---|
| 415 | {
|
---|
| 416 | // THROW(out_of_range("SphereGorski::PIxVal Pixel index out of range"));
|
---|
| 417 | cout << " SphereGorski::PIxVal : exceptions a mettre en place" <<endl;
|
---|
| 418 | THROW(rangeCheckErr);
|
---|
| 419 | }
|
---|
| 420 | return pixels_(k);
|
---|
[228] | 421 | }
|
---|
| 422 |
|
---|
| 423 | /* --Methode-- */
|
---|
| 424 | //++
|
---|
[470] | 425 | template<class T>
|
---|
| 426 | T const& SphereGorski<T>::PixVal(int_4 k) const
|
---|
[228] | 427 |
|
---|
| 428 | // Retourne la valeur du contenu du pixel d'indice "RING" k
|
---|
| 429 | //--
|
---|
| 430 | {
|
---|
[470] | 431 | if((k < 0) || (k >= nPix_))
|
---|
| 432 | {
|
---|
| 433 | //THROW(out_of_range("SphereGorski::PIxVal Pixel index out of range"));
|
---|
| 434 | cout << " SphereGorski::PIxVal : exceptions a mettre en place" <<endl;
|
---|
| 435 | THROW(rangeCheckErr);
|
---|
| 436 | }
|
---|
| 437 | return *(pixels_.Data()+k);
|
---|
[228] | 438 | }
|
---|
| 439 |
|
---|
| 440 | //++
|
---|
[470] | 441 | template<class T>
|
---|
| 442 | T& SphereGorski<T>::PixValNest(int_4 k)
|
---|
[228] | 443 |
|
---|
| 444 | // Retourne la valeur du contenu du pixel d'indice "NESTED" k
|
---|
| 445 | //--
|
---|
| 446 | {
|
---|
[470] | 447 | if((k < 0) || (k >= nPix_))
|
---|
| 448 | {
|
---|
| 449 | //THROW(out_of_range("SphereGorski::PIxValNest Pixel index out of range"));
|
---|
| 450 | cout<<" SphereGorski::PIxValNest : exceptions a mettre en place" <<endl;
|
---|
| 451 | THROW(rangeCheckErr);
|
---|
| 452 | }
|
---|
| 453 | return pixels_(nest2ring(nSide_,k));
|
---|
[228] | 454 | }
|
---|
| 455 | //++
|
---|
| 456 |
|
---|
[470] | 457 | template<class T>
|
---|
| 458 | T const& SphereGorski<T>::PixValNest(int_4 k) const
|
---|
[228] | 459 |
|
---|
| 460 | // Retourne la valeur du contenu du pixel d'indice "NESTED" k
|
---|
| 461 | //--
|
---|
| 462 | {
|
---|
[470] | 463 | if((k < 0) || (k >= nPix_))
|
---|
| 464 | {
|
---|
| 465 | //THROW(out_of_range("SphereGorski::PIxValNest Pixel index out of range"));
|
---|
| 466 | cout<<" SphereGorski::PIxValNest : exceptions a mettre en place" <<endl;
|
---|
| 467 | THROW(rangeCheckErr);
|
---|
[228] | 468 | }
|
---|
[470] | 469 | int_4 pix= nest2ring(nSide_,k);
|
---|
| 470 | return *(pixels_.Data()+pix);
|
---|
[228] | 471 | }
|
---|
| 472 |
|
---|
| 473 | /* --Methode-- */
|
---|
| 474 | //++
|
---|
[470] | 475 | template<class T>
|
---|
| 476 | int_4 SphereGorski<T>::PixIndexSph(r_4 theta, r_4 phi) const
|
---|
[228] | 477 |
|
---|
| 478 | // Retourne l'indice "RING" du pixel vers lequel pointe une direction
|
---|
| 479 | // définie par ses coordonnées sphériques
|
---|
| 480 | //--
|
---|
| 481 | {
|
---|
[470] | 482 | return ang2pix_ring(nSide_,double(theta),double(phi));
|
---|
[228] | 483 | }
|
---|
| 484 |
|
---|
| 485 | //++
|
---|
[470] | 486 | template<class T>
|
---|
| 487 | int_4 SphereGorski<T>::PixIndexSphNest(r_4 theta, r_4 phi) const
|
---|
[228] | 488 |
|
---|
| 489 | // Retourne l'indice NESTED" du pixel vers lequel pointe une direction
|
---|
| 490 | // définie par ses coordonnées sphériques
|
---|
| 491 | //--
|
---|
| 492 | {
|
---|
[470] | 493 | return ang2pix_nest(nSide_,double(theta),double(phi));
|
---|
[228] | 494 | }
|
---|
| 495 |
|
---|
| 496 |
|
---|
| 497 | /* --Methode-- */
|
---|
| 498 | //++
|
---|
[470] | 499 | template<class T>
|
---|
| 500 | void SphereGorski<T>::PixThetaPhi(int_4 k, r_4& teta, r_4& phi) const
|
---|
[228] | 501 |
|
---|
| 502 | // Retourne les coordonnées (teta,phi) du milieu du pixel d'indice "RING" k
|
---|
| 503 | //--
|
---|
| 504 | {
|
---|
| 505 | double t;
|
---|
| 506 | double p;
|
---|
[470] | 507 | pix2ang_ring(nSide_,k, t, p);
|
---|
| 508 | teta= (r_4)t;
|
---|
| 509 | phi = (r_4)p;
|
---|
[228] | 510 | }
|
---|
| 511 |
|
---|
| 512 | //++
|
---|
[470] | 513 | template<class T>
|
---|
| 514 | r_8 SphereGorski<T>::PixSolAngle(int_4 dummy) const
|
---|
[228] | 515 | // Pixel Solid angle (steradians)
|
---|
| 516 | // All the pixels have the same solid angle. The dummy argument is
|
---|
| 517 | // for compatibility with eventual pixelizations which would not
|
---|
| 518 | // fulfil this requirement.
|
---|
| 519 | //--
|
---|
| 520 | {
|
---|
| 521 | return omeg_;
|
---|
| 522 | }
|
---|
| 523 |
|
---|
| 524 | //++
|
---|
[470] | 525 | template<class T>
|
---|
| 526 | void SphereGorski<T>::PixThetaPhiNest(int_4 k, float& teta, float& phi) const
|
---|
[228] | 527 |
|
---|
| 528 | // Retourne les coordonnées (teta,phi) du milieu du pixel d'indice
|
---|
| 529 | // NESTED k
|
---|
| 530 | //--
|
---|
| 531 | {
|
---|
| 532 | double t;
|
---|
| 533 | double p;
|
---|
| 534 | pix2ang_nest(nSide_, k, t, p);
|
---|
[470] | 535 | teta= (r_4)t;
|
---|
| 536 | phi = (r_4)p;
|
---|
[228] | 537 | }
|
---|
| 538 |
|
---|
| 539 | //++
|
---|
[470] | 540 | template<class T>
|
---|
| 541 | int_4 SphereGorski<T>::NestToRing(int_4 k) const
|
---|
[228] | 542 |
|
---|
| 543 | // conversion d'index NESTD en un index RING
|
---|
| 544 | //
|
---|
| 545 | //--
|
---|
| 546 | {
|
---|
| 547 | return nest2ring(nSide_,k);
|
---|
| 548 | }
|
---|
[470] | 549 |
|
---|
[228] | 550 | //++
|
---|
[470] | 551 | template<class T>
|
---|
| 552 | int_4 SphereGorski<T>::RingToNest(int_4 k) const
|
---|
[228] | 553 | //
|
---|
| 554 | // conversion d'index RING en un index NESTED
|
---|
| 555 | //
|
---|
| 556 | //--
|
---|
| 557 | {
|
---|
| 558 | return ring2nest(nSide_,k);
|
---|
| 559 | }
|
---|
[470] | 560 |
|
---|
| 561 | /*
|
---|
[228] | 562 | //++
|
---|
[470] | 563 | template<class T>
|
---|
| 564 | void SphereGorski<T>::anharm(int nlmax, float sym_c,float* powspec)
|
---|
[228] | 565 | //
|
---|
| 566 | // analyse en harmoniques spheriques des valeurs des pixels de la
|
---|
| 567 | // sphere : appel du module anafast (Gorski-Hivon)
|
---|
| 568 | //
|
---|
| 569 | // "nlmax" : multipole maximum, nlmax <= 2*nsmax (cf. Nyquist)
|
---|
| 570 | //
|
---|
| 571 | // "sym c" : coupure symetrique autour de l'equateur (degres)
|
---|
| 572 | //
|
---|
| 573 | // "powspec" : tableau resultat (a reserver avant l'appel) de C(l)
|
---|
| 574 | // (spectre de puissance)
|
---|
| 575 | //
|
---|
| 576 | //--
|
---|
| 577 | //
|
---|
| 578 | // Pb a resoudre : dans cette classe les valeurs de pixel sont "double"
|
---|
| 579 | // dans anafast le tableau correspondant est "float"
|
---|
| 580 | // pour l'instant on duplique les tableaux, il faudra decider quelque chose
|
---|
| 581 | //
|
---|
| 582 | {
|
---|
[470] | 583 | if (nlmax > 2*nSide_) {
|
---|
| 584 | cout << " anharm : nlmax= " << nlmax <<
|
---|
| 585 | " doit etre <= 2*nsmax (cf. Nyquist), soit :" << 2*nSide_ << endl;
|
---|
| 586 | exit(1);
|
---|
[228] | 587 | }
|
---|
| 588 | else {
|
---|
| 589 | nlmax_=nlmax;
|
---|
| 590 | nmmax_=nlmax_;
|
---|
| 591 | }
|
---|
| 592 | sym_cut_deg_=sym_c;
|
---|
| 593 | float* map=new float[nPix_];
|
---|
[470] | 594 | for (int k=0; k<nPix_; k++) map[k]=(float)pixels_(k);
|
---|
[228] | 595 | int nsmax=nSide_;
|
---|
| 596 | int nmmax=nmmax_;
|
---|
| 597 | double sc=(double)sym_cut_deg_;
|
---|
| 598 | float* alm_T=new float[2*(nlmax+1)*(nmmax+1)];
|
---|
| 599 | if (powspec==NULL) {
|
---|
| 600 |
|
---|
| 601 | cout <<
|
---|
| 602 | " anharm : un tableau de C_l doit etre alloue avant appel " << endl;
|
---|
| 603 | exit(1);
|
---|
| 604 | }
|
---|
| 605 | float* phas_n=new float[2*(nmmax+1)];
|
---|
| 606 | float* phas_s=new float[2*(nmmax+1)];
|
---|
| 607 | float* dataw =new float[16*nsmax];
|
---|
| 608 | float* work =new float[16*nsmax];
|
---|
| 609 |
|
---|
| 610 | anafast_(nsmax,nlmax,nmmax,sc,map,alm_T, powspec,phas_n,phas_s,dataw,work);
|
---|
| 611 | quadrupole_=powspec[2];
|
---|
| 612 | delete [] map;
|
---|
| 613 | delete [] alm_T;
|
---|
| 614 | delete [] phas_n;
|
---|
| 615 | delete [] phas_s;
|
---|
| 616 | delete [] dataw;
|
---|
[470] | 617 | delete [] work;
|
---|
[228] | 618 | }
|
---|
[470] | 619 | */
|
---|
[228] | 620 |
|
---|
[470] | 621 | /*
|
---|
[228] | 622 | //++
|
---|
[470] | 623 | template<class T>
|
---|
| 624 | void SphereGorski<T>::synharm(int nlmax, int iseed,float fwhm, float* powspec)
|
---|
[228] | 625 | //
|
---|
| 626 | // synthese des valeurs des pixels de la sphere par l'intermediaire
|
---|
| 627 | // des coefficients en harmoniques spheriques reconstitues apartir d'un
|
---|
| 628 | // spectre en puissance : appel du module synfast (Gorski-Hivon)
|
---|
| 629 | //
|
---|
| 630 | // powspec est un tableau (a fournir) de C(l) (spectre de puissance)
|
---|
| 631 | // Ce tableau doit contenir les valeur de C(l) par ordre
|
---|
| 632 | // SEQUENTIEL de l (de l=0 a l=nlmax). IL SERA MODIFIE PAR L'ALGORITHME
|
---|
| 633 | //
|
---|
| 634 | // nlmax : multipole maximum (nlmax <= 2*nsmax (cf. Nyquist)
|
---|
| 635 | // iseed : initialisation generation aleatoire (negatif, suggere : -1)
|
---|
| 636 | // fwhm : largeur totale a mi-hauteur (minutes d'arc, >=0, ex: 5)
|
---|
| 637 | //--
|
---|
| 638 | // Pb a resoudre : dans cette classe les valeurs de pixel sont "double"
|
---|
| 639 | // dans anafast le tableau correspondant est "float"
|
---|
| 640 | // pour l'instant on duplique les tableaux, il faudra decider quelque chose
|
---|
| 641 |
|
---|
| 642 | {
|
---|
| 643 | if (nlmax > 2*nSide_) {
|
---|
| 644 | cout << " sphereGorski::synharm: nlmax= " << nlmax <<
|
---|
| 645 | " doit etre <= 2*nsmax (cf. Nyquist), soit : " << 2*nSide_ << endl;
|
---|
| 646 | exit(1);
|
---|
| 647 | }
|
---|
| 648 | else {
|
---|
| 649 | nlmax_=nlmax;
|
---|
| 650 | nmmax_=nlmax_;
|
---|
| 651 | quadrupole_=powspec[2];
|
---|
| 652 | }
|
---|
| 653 | if (powspec==NULL) {
|
---|
| 654 |
|
---|
| 655 | cout <<
|
---|
| 656 | "sphereGorski::synharm : un tableau de C_l doit etre alloue avant appel"
|
---|
| 657 | << endl;
|
---|
| 658 | exit(1);
|
---|
| 659 | }
|
---|
| 660 | iseed_=iseed;
|
---|
| 661 | fwhm_ =fwhm;
|
---|
| 662 | float* map=new float[nPix_];
|
---|
| 663 | int nsmax=nSide_;
|
---|
| 664 | int nmmax=nmmax_;
|
---|
[470] | 665 | float* alm_T=new float[2*(nlmax+1)*(nmmax+1)];
|
---|
[228] | 666 |
|
---|
[470] | 667 | // tableaux de travail
|
---|
[228] | 668 | double* b_north=new double[2*(2*nmmax+1)];
|
---|
| 669 | double* b_south=new double[2*(2*nmmax+1)];
|
---|
| 670 | double* bw=new double[2*4*nsmax];
|
---|
| 671 | double* data=new double[2*4*nsmax];
|
---|
| 672 | double* work=new double[2*4*nsmax];
|
---|
| 673 | float* lread=new float[nlmax+1];
|
---|
| 674 | synfast_(nsmax,nlmax,nmmax,iseed,fwhm, map,alm_T, powspec,
|
---|
| 675 | b_north,b_south,bw,data,work,lread);
|
---|
[470] | 676 | for (int k=0; k<nPix_; k++) pixels_(k) = (T)map[k];
|
---|
[228] | 677 | delete [] map;
|
---|
| 678 | delete [] alm_T;
|
---|
| 679 | delete [] b_north;
|
---|
| 680 | delete [] b_south;
|
---|
| 681 | delete [] bw;
|
---|
| 682 | delete [] data;
|
---|
| 683 | delete [] work;
|
---|
| 684 | delete [] lread;
|
---|
| 685 | }
|
---|
[470] | 686 | */
|
---|
[228] | 687 |
|
---|
[470] | 688 | template<class T>
|
---|
| 689 | int SphereGorski<T>::nest2ring(int nside, int ipnest) const {
|
---|
[228] | 690 | /*
|
---|
[470] | 691 | ====================================================
|
---|
[228] | 692 | subroutine nest2ring(nside, ipnest, ipring)
|
---|
[470] | 693 | ====================================================
|
---|
[228] | 694 | c conversion from NESTED to RING pixel number
|
---|
[470] | 695 | ====================================================
|
---|
| 696 | */
|
---|
[228] | 697 | // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
|
---|
| 698 | // (16/12/98)
|
---|
[470] | 699 |
|
---|
| 700 | const PIXELS_XY& PXY= PIXELS_XY::instance();
|
---|
[228] | 701 |
|
---|
[470] | 702 | int npix, npface, face_num, ncap, n_before;
|
---|
| 703 | int ipf, ip_low, ip_trunc, ip_med, ip_hi;
|
---|
| 704 | int ix, iy, jrt, jr, nr, jpt, jp, kshift, nl4;
|
---|
| 705 | int ns_max=8192;
|
---|
| 706 | int jrll[12]={2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};
|
---|
| 707 | int jpll[12]={1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7};
|
---|
| 708 |
|
---|
| 709 | if( nside<1 || nside>ns_max ) {
|
---|
| 710 | cout << "nside out of range" << endl;
|
---|
| 711 | exit(0);
|
---|
| 712 | }
|
---|
| 713 | npix = 12 * nside* nside;
|
---|
| 714 | if( ipnest<0 || ipnest>npix-1 ) {
|
---|
| 715 | cout << "ipnest out of range" << endl;
|
---|
| 716 | exit(0);
|
---|
| 717 | }
|
---|
[228] | 718 |
|
---|
[470] | 719 | ncap = 2* nside*( nside-1);// ! number of points in the North Polar cap
|
---|
| 720 | nl4 = 4* nside;
|
---|
| 721 |
|
---|
| 722 | //c finds the face, and the number in the face
|
---|
| 723 | npface = nside* nside;
|
---|
| 724 | //cccccc ip = ipnest - 1 ! in {0,npix-1}
|
---|
| 725 |
|
---|
| 726 | face_num = ipnest/npface;// ! face number in {0,11}
|
---|
| 727 | ipf =ipnest%npface;// ! pixel number in the face {0,npface-1}
|
---|
| 728 | //c finds the x,y on the face (starting from the lowest corner)
|
---|
| 729 | //c from the pixel number
|
---|
| 730 | ip_low=ipf%1024; // ! content of the last 10 bits
|
---|
| 731 | ip_trunc = ipf/1024; // ! truncation of the last 10 bits
|
---|
| 732 | ip_med=ip_trunc%1024; // ! content of the next 10 bits
|
---|
| 733 | ip_hi = ip_trunc/1024;// ! content of the high weight 10 bits
|
---|
| 734 |
|
---|
| 735 | ix = 1024*PXY.pix2x_(ip_hi)+32*PXY.pix2x_(ip_med)+PXY.pix2x_(ip_low);
|
---|
| 736 | iy = 1024*PXY.pix2y_(ip_hi)+32*PXY.pix2y_(ip_med)+PXY.pix2y_(ip_low);
|
---|
| 737 |
|
---|
| 738 | //c transforms this in (horizontal, vertical) coordinates
|
---|
| 739 | jrt = ix + iy;// ! 'vertical' in {0,2*(nside-1)}
|
---|
| 740 | jpt = ix - iy;// ! 'horizontal' in {-nside+1,nside-1}
|
---|
| 741 |
|
---|
| 742 | //c computes the z coordinate on the sphere
|
---|
| 743 | // jr = jrll[face_num+1]*nside - jrt - 1;// ! ring number in {1,4*nside-1}
|
---|
| 744 | jr = jrll[face_num]*nside - jrt - 1;
|
---|
| 745 | nr = nside;// ! equatorial region (the most frequent)
|
---|
| 746 | n_before = ncap + nl4 * (jr - nside);
|
---|
| 747 | kshift=(jr - nside)%2;
|
---|
| 748 | if( jr<nside ) {//then ! north pole region
|
---|
| 749 | nr = jr;
|
---|
| 750 | n_before = 2 * nr * (nr - 1);
|
---|
| 751 | kshift = 0;
|
---|
| 752 | }
|
---|
| 753 | else if( jr>3*nside ) {//then ! south pole region
|
---|
| 754 | nr = nl4 - jr;
|
---|
| 755 | n_before = npix - 2 * (nr + 1) * nr;
|
---|
| 756 | kshift = 0;
|
---|
| 757 | }
|
---|
| 758 |
|
---|
| 759 | //c computes the phi coordinate on the sphere, in [0,2Pi]
|
---|
| 760 | jp = (jpll[face_num]*nr + jpt + 1 + kshift)/2;// ! 'phi' number in the ring in {1,4*nr}
|
---|
| 761 |
|
---|
| 762 | if( jp>nl4 ) jp = jp - nl4;
|
---|
| 763 | if( jp<1 ) jp = jp + nl4;
|
---|
| 764 |
|
---|
| 765 | int aux=n_before + jp - 1;
|
---|
| 766 | return (n_before + jp - 1);// ! in {0, npix-1}
|
---|
[228] | 767 | }
|
---|
| 768 |
|
---|
[470] | 769 | template<class T>
|
---|
| 770 | int SphereGorski<T>::ring2nest(int nside, int ipring) const
|
---|
| 771 | {
|
---|
[228] | 772 | /*
|
---|
[470] | 773 | ==================================================
|
---|
[228] | 774 | subroutine ring2nest(nside, ipring, ipnest)
|
---|
[470] | 775 | ==================================================
|
---|
[228] | 776 | c conversion from RING to NESTED pixel number
|
---|
[470] | 777 | ==================================================
|
---|
[228] | 778 | */
|
---|
| 779 | // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
|
---|
| 780 | // (16/12/98)
|
---|
| 781 |
|
---|
[470] | 782 | const PIXELS_XY& PXY= PIXELS_XY::instance();
|
---|
| 783 |
|
---|
[228] | 784 | double fihip, hip;
|
---|
| 785 | int npix, nl2, nl4, ncap, ip, iphi, ipt, ipring1;
|
---|
| 786 | int kshift, face_num, nr;
|
---|
| 787 | int irn, ire, irm, irs, irt, ifm , ifp;
|
---|
| 788 | int ix, iy, ix_low, ix_hi, iy_low, iy_hi, ipf;
|
---|
| 789 | int ns_max(8192);
|
---|
| 790 |
|
---|
| 791 | // coordinate of the lowest corner of each face
|
---|
| 792 | int jrll[12]={2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};// ! in unit of nside
|
---|
| 793 | int jpll[12]={1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7};//! in unit of nside/2
|
---|
| 794 |
|
---|
| 795 | if( nside<1 || nside>ns_max ) {
|
---|
| 796 | cout << "nside out of range" << endl;
|
---|
| 797 | exit(0);
|
---|
| 798 | }
|
---|
| 799 | npix = 12 * nside*nside;
|
---|
| 800 | if( ipring<0 || ipring>npix-1 ) {
|
---|
| 801 | cout << "ipring out of range" << endl;
|
---|
| 802 | exit(0);
|
---|
| 803 | }
|
---|
| 804 |
|
---|
| 805 | nl2 = 2*nside;
|
---|
| 806 | nl4 = 4*nside;
|
---|
| 807 | npix = 12*nside*nside;// ! total number of points
|
---|
| 808 | ncap = 2*nside*(nside-1);// ! points in each polar cap, =0 for nside =1
|
---|
| 809 | ipring1 = ipring + 1;
|
---|
| 810 |
|
---|
| 811 | //c finds the ring number, the position of the ring and the face number
|
---|
| 812 | if( ipring1<=ncap ) {//then
|
---|
| 813 |
|
---|
| 814 | hip = ipring1/2.;
|
---|
| 815 | fihip = (int)floor ( hip );
|
---|
| 816 | irn = (int)floor( sqrt( hip - sqrt(fihip) ) ) + 1;// ! counted from North pole
|
---|
| 817 | iphi = ipring1 - 2*irn*(irn - 1);
|
---|
| 818 |
|
---|
| 819 | kshift = 0;
|
---|
| 820 | nr = irn ;// ! 1/4 of the number of points on the current ring
|
---|
| 821 | face_num = (iphi-1) / irn;// ! in {0,3}
|
---|
| 822 | }
|
---|
| 823 | else if( ipring1<=nl2*(5*nside+1) ) {//then
|
---|
| 824 |
|
---|
| 825 | ip = ipring1 - ncap - 1;
|
---|
| 826 | irn = (int)floor( ip / nl4 ) + nside;// ! counted from North pole
|
---|
| 827 | iphi = (int)fmod(ip,nl4) + 1;
|
---|
| 828 |
|
---|
| 829 | kshift = (int)fmod(irn+nside,2);// ! 1 if irn+nside is odd, 0 otherwise
|
---|
| 830 | nr = nside;
|
---|
| 831 | ire = irn - nside + 1;// ! in {1, 2*nside +1}
|
---|
| 832 | irm = nl2 + 2 - ire;
|
---|
| 833 | ifm = (iphi - ire/2 + nside -1) / nside;// ! face boundary
|
---|
| 834 | ifp = (iphi - irm/2 + nside -1) / nside;
|
---|
| 835 | if( ifp==ifm ) {//then ! faces 4 to 7
|
---|
| 836 | face_num = (int)fmod(ifp,4) + 4;
|
---|
| 837 | }
|
---|
| 838 | else if( ifp + 1==ifm ) {//then ! (half-)faces 0 to 3
|
---|
| 839 | face_num = ifp;
|
---|
| 840 | }
|
---|
| 841 | else if( ifp - 1==ifm ) {//then ! (half-)faces 8 to 11
|
---|
| 842 | face_num = ifp + 7;
|
---|
| 843 | }
|
---|
| 844 | }
|
---|
| 845 | else {
|
---|
| 846 |
|
---|
| 847 | ip = npix - ipring1 + 1;
|
---|
| 848 | hip = ip/2.;
|
---|
| 849 | fihip = floor ( hip );
|
---|
| 850 | irs = (int)floor( sqrt( hip - sqrt(fihip) ) ) + 1;// ! counted from South pole
|
---|
| 851 | iphi = 4*irs + 1 - (ip - 2*irs*(irs-1));
|
---|
| 852 |
|
---|
| 853 | kshift = 0;
|
---|
| 854 | nr = irs;
|
---|
| 855 | irn = nl4 - irs;
|
---|
| 856 | face_num = (iphi-1) / irs + 8;// ! in {8,11}
|
---|
| 857 | }
|
---|
| 858 |
|
---|
| 859 | //c finds the (x,y) on the face
|
---|
| 860 | irt = irn - jrll[face_num]*nside + 1;// ! in {-nside+1,0}
|
---|
| 861 | ipt = 2*iphi - jpll[face_num]*nr - kshift - 1;// ! in {-nside+1,nside-1}
|
---|
| 862 |
|
---|
| 863 |
|
---|
| 864 | if( ipt>=nl2 ) ipt = ipt - 8*nside;// ! for the face #4
|
---|
| 865 |
|
---|
| 866 | ix = (ipt - irt ) / 2;
|
---|
| 867 | iy = -(ipt + irt ) / 2;
|
---|
| 868 |
|
---|
| 869 | ix_low = (int)fmod(ix,128);
|
---|
| 870 | ix_hi = ix/128;
|
---|
| 871 | iy_low = (int)fmod(iy,128);
|
---|
| 872 | iy_hi = iy/128;
|
---|
[470] | 873 | ipf=(PXY.x2pix_(ix_hi)+PXY.y2pix_(iy_hi))*(128*128)+(PXY.x2pix_(ix_low)+PXY.y2pix_(iy_low));
|
---|
[228] | 874 |
|
---|
| 875 | return (ipf + face_num* nside *nside);// ! in {0, 12*nside**2 - 1}
|
---|
| 876 | }
|
---|
| 877 |
|
---|
[470] | 878 | template<class T>
|
---|
| 879 | int SphereGorski<T>::ang2pix_ring(int nside, double theta, double phi) const
|
---|
| 880 | {
|
---|
[228] | 881 | /*
|
---|
[470] | 882 | ==================================================
|
---|
[228] | 883 | c gives the pixel number ipix (RING)
|
---|
| 884 | c corresponding to angles theta and phi
|
---|
[470] | 885 | c==================================================
|
---|
| 886 | */
|
---|
[228] | 887 | // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
|
---|
| 888 | // (16/12/98)
|
---|
| 889 |
|
---|
| 890 | int nl2, nl4, ncap, npix, jp, jm, ipix1;
|
---|
| 891 | double z, za, tt, tp, tmp;
|
---|
| 892 | int ir, ip, kshift;
|
---|
| 893 |
|
---|
| 894 | double piover2(Pi/2.);
|
---|
| 895 | double twopi(2.*Pi);
|
---|
| 896 | double z0(2./3.);
|
---|
| 897 | int ns_max(8192);
|
---|
| 898 |
|
---|
| 899 | if( nside<1 || nside>ns_max ) {
|
---|
| 900 | cout << "nside out of range" << endl;
|
---|
| 901 | exit(0);
|
---|
| 902 | }
|
---|
| 903 |
|
---|
| 904 | if( theta<0. || theta>Pi) {
|
---|
| 905 | cout << "theta out of range" << endl;
|
---|
| 906 | exit(0);
|
---|
| 907 | }
|
---|
| 908 |
|
---|
| 909 | z = cos(theta);
|
---|
| 910 | za = fabs(z);
|
---|
| 911 | if( phi >= twopi) phi = phi - twopi;
|
---|
| 912 | if (phi < 0.) phi = phi + twopi;
|
---|
| 913 | tt = phi / piover2;// ! in [0,4)
|
---|
| 914 |
|
---|
| 915 | nl2 = 2*nside;
|
---|
| 916 | nl4 = 4*nside;
|
---|
| 917 | ncap = nl2*(nside-1);// ! number of pixels in the north polar cap
|
---|
| 918 | npix = 12*nside*nside;
|
---|
| 919 |
|
---|
| 920 | if( za <= z0 ) {
|
---|
| 921 |
|
---|
| 922 | jp = (int)floor(nside*(0.5 + tt - z*0.75));// ! index of ascending edge line
|
---|
| 923 | jm = (int)floor(nside*(0.5 + tt + z*0.75));// ! index of descending edge line
|
---|
| 924 |
|
---|
| 925 | ir = nside + 1 + jp - jm;// ! in {1,2n+1} (ring number counted from z=2/3)
|
---|
| 926 | kshift = 0;
|
---|
| 927 | if (fmod(ir,2)==0.) kshift = 1;// ! kshift=1 if ir even, 0 otherwise
|
---|
| 928 |
|
---|
| 929 | ip = (int)floor( ( jp+jm - nside + kshift + 1 ) / 2 ) + 1;// ! in {1,4n}
|
---|
| 930 | if( ip>nl4 ) ip = ip - nl4;
|
---|
| 931 |
|
---|
| 932 | ipix1 = ncap + nl4*(ir-1) + ip ;
|
---|
| 933 | }
|
---|
| 934 | else {
|
---|
| 935 |
|
---|
| 936 | tp = tt - floor(tt);// !MOD(tt,1.d0)
|
---|
| 937 | tmp = sqrt( 3.*(1. - za) );
|
---|
| 938 |
|
---|
| 939 | jp = (int)floor( nside * tp * tmp );// ! increasing edge line index
|
---|
| 940 | jm = (int)floor( nside * (1. - tp) * tmp );// ! decreasing edge line index
|
---|
| 941 |
|
---|
| 942 | ir = jp + jm + 1;// ! ring number counted from the closest pole
|
---|
| 943 | ip = (int)floor( tt * ir ) + 1;// ! in {1,4*ir}
|
---|
| 944 | if( ip>4*ir ) ip = ip - 4*ir;
|
---|
| 945 |
|
---|
| 946 | ipix1 = 2*ir*(ir-1) + ip;
|
---|
| 947 | if( z<=0. ) {
|
---|
| 948 | ipix1 = npix - 2*ir*(ir+1) + ip;
|
---|
| 949 | }
|
---|
| 950 | }
|
---|
| 951 | return (ipix1 - 1);// ! in {0, npix-1}
|
---|
| 952 | }
|
---|
| 953 |
|
---|
[470] | 954 | template<class T>
|
---|
| 955 | int SphereGorski<T>::ang2pix_nest(int nside, double theta, double phi) const
|
---|
| 956 | {
|
---|
[228] | 957 | /*
|
---|
[470] | 958 | ==================================================
|
---|
[228] | 959 | subroutine ang2pix_nest(nside, theta, phi, ipix)
|
---|
[470] | 960 | ==================================================
|
---|
[228] | 961 | c gives the pixel number ipix (NESTED)
|
---|
| 962 | c corresponding to angles theta and phi
|
---|
| 963 | c
|
---|
| 964 | c the computation is made to the highest resolution available (nside=8192)
|
---|
| 965 | c and then degraded to that required (by integer division)
|
---|
| 966 | c this doesn't cost more, and it makes sure
|
---|
| 967 | c that the treatement of round-off will be consistent
|
---|
| 968 | c for every resolution
|
---|
[470] | 969 | ==================================================
|
---|
| 970 | */
|
---|
[228] | 971 | // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
|
---|
| 972 | // (16/12/98)
|
---|
[470] | 973 |
|
---|
| 974 | const PIXELS_XY& PXY= PIXELS_XY::instance();
|
---|
| 975 |
|
---|
| 976 | double z, za, z0, tt, tp, tmp;
|
---|
| 977 | int face_num,jp,jm;
|
---|
| 978 | int ifp, ifm;
|
---|
| 979 | int ix, iy, ix_low, ix_hi, iy_low, iy_hi, ipf, ntt;
|
---|
| 980 | double piover2(Pi/2.), twopi(2.*Pi);
|
---|
| 981 | int ns_max(8192);
|
---|
| 982 |
|
---|
| 983 | if( nside<1 || nside>ns_max ) {
|
---|
| 984 | cout << "nside out of range" << endl;
|
---|
| 985 | exit(0);
|
---|
| 986 | }
|
---|
| 987 | if( theta<0 || theta>Pi ) {
|
---|
| 988 | cout << "theta out of range" << endl;
|
---|
| 989 | exit(0);
|
---|
| 990 | }
|
---|
| 991 | z = cos(theta);
|
---|
| 992 | za = fabs(z);
|
---|
| 993 | z0 = 2./3.;
|
---|
| 994 | if( phi>=twopi ) phi = phi - twopi;
|
---|
| 995 | if( phi<0. ) phi = phi + twopi;
|
---|
| 996 | tt = phi / piover2;// ! in [0,4[
|
---|
| 997 | if( za<=z0 ) { // then ! equatorial region
|
---|
[228] | 998 |
|
---|
[470] | 999 | //(the index of edge lines increase when the longitude=phi goes up)
|
---|
| 1000 | jp = (int)floor(ns_max*(0.5 + tt - z*0.75));// ! ascending edge line index
|
---|
| 1001 | jm = (int)floor(ns_max*(0.5 + tt + z*0.75));// ! descending edge line index
|
---|
| 1002 |
|
---|
| 1003 | //c finds the face
|
---|
| 1004 | ifp = jp / ns_max;// ! in {0,4}
|
---|
| 1005 | ifm = jm / ns_max;
|
---|
| 1006 | if( ifp==ifm ) face_num = (int)fmod(ifp,4) + 4; //then ! faces 4 to 7
|
---|
| 1007 | else if( ifp<ifm ) face_num = (int)fmod(ifp,4); // (half-)faces 0 to 3
|
---|
| 1008 | else face_num = (int)fmod(ifm,4) + 8;//! (half-)faces 8 to 11
|
---|
| 1009 |
|
---|
| 1010 | ix = (int)fmod(jm, ns_max);
|
---|
| 1011 | iy = ns_max - (int)fmod(jp, ns_max) - 1;
|
---|
| 1012 | }
|
---|
| 1013 | else { //! polar region, za > 2/3
|
---|
| 1014 |
|
---|
| 1015 | ntt = (int)floor(tt);
|
---|
| 1016 | if( ntt>=4 ) ntt = 3;
|
---|
| 1017 | tp = tt - ntt;
|
---|
| 1018 | tmp = sqrt( 3.*(1. - za) );// ! in ]0,1]
|
---|
| 1019 |
|
---|
| 1020 | //(the index of edge lines increase when distance from the closest pole goes up)
|
---|
| 1021 | jp = (int)floor(ns_max*tp*tmp); // ! line going toward the pole as phi increases
|
---|
| 1022 | jm = (int)floor(ns_max*(1.-tp)*tmp); // ! that one goes away of the closest pole
|
---|
| 1023 | jp = (int)min(ns_max-1, jp);// ! for points too close to the boundary
|
---|
| 1024 | jm = (int)min(ns_max-1, jm);
|
---|
| 1025 |
|
---|
| 1026 | // finds the face and pixel's (x,y)
|
---|
| 1027 | if( z>=0 ) {
|
---|
| 1028 | face_num = ntt;// ! in {0,3}
|
---|
| 1029 | ix = ns_max - jm - 1;
|
---|
| 1030 | iy = ns_max - jp - 1;
|
---|
| 1031 | }
|
---|
| 1032 | else {
|
---|
| 1033 | face_num = ntt + 8;// ! in {8,11}
|
---|
| 1034 | ix = jp;
|
---|
| 1035 | iy = jm;
|
---|
| 1036 | }
|
---|
| 1037 | }
|
---|
| 1038 |
|
---|
| 1039 | ix_low = (int)fmod(ix,128);
|
---|
| 1040 | ix_hi = ix/128;
|
---|
| 1041 | iy_low = (int)fmod(iy,128);
|
---|
| 1042 | iy_hi = iy/128;
|
---|
| 1043 | ipf= (PXY.x2pix_(ix_hi)+PXY.y2pix_(iy_hi))*(128*128)+(PXY.x2pix_(ix_low)+PXY.y2pix_(iy_low));
|
---|
| 1044 | ipf = ipf / pow(ns_max/nside,2);// ! in {0, nside**2 - 1}
|
---|
| 1045 | return ( ipf + face_num*pow(nside,2));// ! in {0, 12*nside**2 - 1}
|
---|
[228] | 1046 | }
|
---|
| 1047 |
|
---|
[470] | 1048 | template<class T>
|
---|
| 1049 | void SphereGorski<T>::pix2ang_ring(int nside,int ipix,double& theta,double& phi) const {
|
---|
[228] | 1050 | /*
|
---|
[470] | 1051 | ===================================================
|
---|
[228] | 1052 | c gives theta and phi corresponding to pixel ipix (RING)
|
---|
| 1053 | c for a parameter nside
|
---|
[470] | 1054 | ===================================================
|
---|
| 1055 | */
|
---|
[228] | 1056 | // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
|
---|
| 1057 | // (16/12/98)
|
---|
| 1058 |
|
---|
| 1059 | int nl2, nl4, npix, ncap, iring, iphi, ip, ipix1;
|
---|
| 1060 | double fact1, fact2, fodd, hip, fihip;
|
---|
| 1061 |
|
---|
| 1062 | int ns_max(8192);
|
---|
| 1063 |
|
---|
| 1064 | if( nside<1 || nside>ns_max ) {
|
---|
| 1065 | cout << "nside out of range" << endl;
|
---|
| 1066 | exit(0);
|
---|
| 1067 | }
|
---|
| 1068 | npix = 12*nside*nside; // ! total number of points
|
---|
| 1069 | if( ipix<0 || ipix>npix-1 ) {
|
---|
| 1070 | cout << "ipix out of range" << endl;
|
---|
| 1071 | exit(0);
|
---|
| 1072 | }
|
---|
| 1073 |
|
---|
| 1074 | ipix1 = ipix + 1; // in {1, npix}
|
---|
| 1075 | nl2 = 2*nside;
|
---|
| 1076 | nl4 = 4*nside;
|
---|
| 1077 | ncap = 2*nside*(nside-1);// ! points in each polar cap, =0 for nside =1
|
---|
| 1078 | fact1 = 1.5*nside;
|
---|
| 1079 | fact2 = 3.0*nside*nside;
|
---|
| 1080 |
|
---|
| 1081 | if( ipix1 <= ncap ) { //! North Polar cap -------------
|
---|
| 1082 |
|
---|
| 1083 | hip = ipix1/2.;
|
---|
| 1084 | fihip = floor(hip);
|
---|
| 1085 | iring = (int)floor( sqrt( hip - sqrt(fihip) ) ) + 1;// ! counted from North pole
|
---|
| 1086 | iphi = ipix1 - 2*iring*(iring - 1);
|
---|
| 1087 |
|
---|
| 1088 | theta = acos( 1. - iring*iring / fact2 );
|
---|
| 1089 | phi = (1.*iphi - 0.5) * Pi/(2.*iring);
|
---|
| 1090 | // cout << theta << " " << phi << endl;
|
---|
| 1091 | }
|
---|
| 1092 | else if( ipix1 <= nl2*(5*nside+1) ) {//then ! Equatorial region ------
|
---|
| 1093 |
|
---|
| 1094 | ip = ipix1 - ncap - 1;
|
---|
| 1095 | iring = (int)floor( ip / nl4 ) + nside;// ! counted from North pole
|
---|
| 1096 | iphi = (int)fmod(ip,nl4) + 1;
|
---|
| 1097 |
|
---|
| 1098 | fodd = 0.5 * (1 + fmod((double)(iring+nside),2));// ! 1 if iring+nside is odd, 1/2 otherwise
|
---|
| 1099 | theta = acos( (nl2 - iring) / fact1 );
|
---|
| 1100 | phi = (1.*iphi - fodd) * Pi /(2.*nside);
|
---|
| 1101 | }
|
---|
| 1102 | else {//! South Polar cap -----------------------------------
|
---|
| 1103 |
|
---|
| 1104 | ip = npix - ipix1 + 1;
|
---|
| 1105 | hip = ip/2.;
|
---|
| 1106 | fihip = 1.*hip;
|
---|
| 1107 | iring = (int)floor( sqrt( hip - sqrt(fihip) ) ) + 1;// ! counted from South pole
|
---|
| 1108 | iphi = (int)(4.*iring + 1 - (ip - 2.*iring*(iring-1)));
|
---|
| 1109 |
|
---|
| 1110 | theta = acos( -1. + iring*iring / fact2 );
|
---|
| 1111 | phi = (1.*iphi - 0.5) * Pi/(2.*iring);
|
---|
| 1112 | // cout << theta << " " << phi << endl;
|
---|
| 1113 | }
|
---|
| 1114 | }
|
---|
| 1115 |
|
---|
[470] | 1116 | template<class T>
|
---|
| 1117 | void SphereGorski<T>::pix2ang_nest(int nside,int ipix,double& theta,double& phi) const {
|
---|
[228] | 1118 | /*
|
---|
[470] | 1119 | ==================================================
|
---|
[228] | 1120 | subroutine pix2ang_nest(nside, ipix, theta, phi)
|
---|
[470] | 1121 | ==================================================
|
---|
[228] | 1122 | c gives theta and phi corresponding to pixel ipix (NESTED)
|
---|
| 1123 | c for a parameter nside
|
---|
[470] | 1124 | ==================================================
|
---|
| 1125 | */
|
---|
[228] | 1126 | // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur
|
---|
| 1127 | // (16/12/98)
|
---|
[470] | 1128 |
|
---|
| 1129 | const PIXELS_XY& PXY= PIXELS_XY::instance();
|
---|
[228] | 1130 |
|
---|
[470] | 1131 | int npix, npface, face_num;
|
---|
| 1132 | int ipf, ip_low, ip_trunc, ip_med, ip_hi;
|
---|
| 1133 | int ix, iy, jrt, jr, nr, jpt, jp, kshift, nl4;
|
---|
| 1134 | double z, fn, fact1, fact2;
|
---|
| 1135 | double piover2(Pi/2.);
|
---|
| 1136 | int ns_max(8192);
|
---|
| 1137 |
|
---|
| 1138 | // ! coordinate of the lowest corner of each face
|
---|
| 1139 | int jrll[12]={2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4};//! in unit of nside
|
---|
| 1140 | int jpll[12]={1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7};// ! in unit of nside/2
|
---|
| 1141 |
|
---|
| 1142 | if( nside<1 || nside>ns_max ) {
|
---|
| 1143 | cout << "nside out of range" << endl;
|
---|
| 1144 | exit(0);
|
---|
| 1145 | }
|
---|
| 1146 | npix = 12 * nside*nside;
|
---|
| 1147 | if( ipix<0 || ipix>npix-1 ) {
|
---|
| 1148 | cout << "ipix out of range" << endl;
|
---|
| 1149 | exit(0);
|
---|
| 1150 | }
|
---|
| 1151 |
|
---|
| 1152 | fn = 1.*nside;
|
---|
| 1153 | fact1 = 1./(3.*fn*fn);
|
---|
| 1154 | fact2 = 2./(3.*fn);
|
---|
| 1155 | nl4 = 4*nside;
|
---|
[228] | 1156 |
|
---|
[470] | 1157 | //c finds the face, and the number in the face
|
---|
| 1158 | npface = nside*nside;
|
---|
| 1159 |
|
---|
| 1160 | face_num = ipix/npface;// ! face number in {0,11}
|
---|
| 1161 | ipf = (int)fmod(ipix,npface);// ! pixel number in the face {0,npface-1}
|
---|
| 1162 |
|
---|
| 1163 | //c finds the x,y on the face (starting from the lowest corner)
|
---|
| 1164 | //c from the pixel number
|
---|
| 1165 | ip_low = (int)fmod(ipf,1024);// ! content of the last 10 bits
|
---|
| 1166 | ip_trunc = ipf/1024 ;// ! truncation of the last 10 bits
|
---|
| 1167 | ip_med = (int)fmod(ip_trunc,1024);// ! content of the next 10 bits
|
---|
| 1168 | ip_hi = ip_trunc/1024 ;//! content of the high weight 10 bits
|
---|
| 1169 |
|
---|
| 1170 | ix = 1024*PXY.pix2x_(ip_hi)+32*PXY.pix2x_(ip_med)+PXY.pix2x_(ip_low);
|
---|
| 1171 | iy = 1024*PXY.pix2y_(ip_hi)+32*PXY.pix2y_(ip_med)+PXY.pix2y_(ip_low);
|
---|
| 1172 |
|
---|
| 1173 | //c transforms this in (horizontal, vertical) coordinates
|
---|
| 1174 | jrt = ix + iy;// ! 'vertical' in {0,2*(nside-1)}
|
---|
| 1175 | jpt = ix - iy;// ! 'horizontal' in {-nside+1,nside-1}
|
---|
| 1176 |
|
---|
| 1177 | //c computes the z coordinate on the sphere
|
---|
| 1178 | // jr = jrll[face_num+1]*nside - jrt - 1;// ! ring number in {1,4*nside-1}
|
---|
| 1179 | jr = jrll[face_num]*nside - jrt - 1;
|
---|
| 1180 | nr = nside;// ! equatorial region (the most frequent)
|
---|
| 1181 | z = (2*nside-jr)*fact2;
|
---|
| 1182 | kshift = (int)fmod(jr - nside, 2);
|
---|
| 1183 | if( jr<nside ) { //then ! north pole region
|
---|
| 1184 | nr = jr;
|
---|
| 1185 | z = 1. - nr*nr*fact1;
|
---|
| 1186 | kshift = 0;
|
---|
| 1187 | }
|
---|
| 1188 | else {
|
---|
| 1189 | if( jr>3*nside ) {// then ! south pole region
|
---|
| 1190 | nr = nl4 - jr;
|
---|
| 1191 | z = - 1. + nr*nr*fact1;
|
---|
| 1192 | kshift = 0;
|
---|
| 1193 | }
|
---|
| 1194 | }
|
---|
| 1195 | theta = acos(z);
|
---|
| 1196 |
|
---|
| 1197 | //c computes the phi coordinate on the sphere, in [0,2Pi]
|
---|
| 1198 | // jp = (jpll[face_num+1]*nr + jpt + 1 + kshift)/2;// ! 'phi' number in the ring in {1,4*nr}
|
---|
| 1199 | jp = (jpll[face_num]*nr + jpt + 1 + kshift)/2;
|
---|
| 1200 | if( jp>nl4 ) jp = jp - nl4;
|
---|
| 1201 | if( jp<1 ) jp = jp + nl4;
|
---|
| 1202 | phi = (jp - (kshift+1)*0.5) * (piover2 / nr);
|
---|
| 1203 | }
|
---|
[228] | 1204 |
|
---|
[470] | 1205 | // retourne le nom du fichier qui contient le spectre de puissance
|
---|
| 1206 | template<class T>
|
---|
| 1207 | void SphereGorski<T>::powfile(char filename[]) const
|
---|
| 1208 | {
|
---|
| 1209 | bool status = false;
|
---|
| 1210 | for (int k=0; k< 128; k++)
|
---|
| 1211 | {
|
---|
| 1212 | if( powFile_[k] != ' ' )
|
---|
| 1213 | {
|
---|
| 1214 | status = true;
|
---|
| 1215 | break;
|
---|
| 1216 | }
|
---|
| 1217 | }
|
---|
| 1218 | if ( status )
|
---|
| 1219 | {
|
---|
| 1220 | strcpy(filename,powFile_);
|
---|
| 1221 | }
|
---|
| 1222 | else
|
---|
| 1223 | {
|
---|
| 1224 | strcpy(filename,"no file");
|
---|
| 1225 | }
|
---|
| 1226 | }
|
---|
[228] | 1227 |
|
---|
[470] | 1228 | template<class T>
|
---|
| 1229 | void SphereGorski<T>::getParafast(int_4& nlmax,int_4& nmmax,int_4& iseed,float& fwhm,float& quadr,float& cut) const
|
---|
| 1230 | {
|
---|
| 1231 | nlmax= nlmax_;
|
---|
| 1232 | nmmax= nmmax_;
|
---|
| 1233 | iseed= iseed_;
|
---|
| 1234 | fwhm = fwhm_;
|
---|
| 1235 | quadr= quadrupole_;
|
---|
| 1236 | cut = sym_cut_deg_;
|
---|
| 1237 | }
|
---|
[228] | 1238 |
|
---|
[470] | 1239 | template<class T>
|
---|
| 1240 | void SphereGorski<T>::setParafast(int_4 nlmax,int_4 nmmax,int_4 iseed,float fwhm,float quadr,float cut,char* filename)
|
---|
| 1241 | {
|
---|
| 1242 | nlmax_= nlmax;
|
---|
| 1243 | nmmax_= nmmax;
|
---|
| 1244 | iseed_= iseed;
|
---|
| 1245 | fwhm_ = fwhm;
|
---|
| 1246 | quadrupole_ = quadr;
|
---|
| 1247 | sym_cut_deg_= cut;
|
---|
| 1248 | strcpy(powFile_,filename);
|
---|
| 1249 | }
|
---|
[228] | 1250 |
|
---|
[470] | 1251 | template <class T>
|
---|
| 1252 | void SphereGorski<T>::print(ostream& os) const
|
---|
| 1253 | {
|
---|
| 1254 | if(mInfo_) os << " DVList Info= " << *mInfo_ << endl;
|
---|
| 1255 | //
|
---|
| 1256 | os << " nSide_ = " << nSide_ << endl;
|
---|
| 1257 | os << " nPix_ = " << nPix_ << endl;
|
---|
| 1258 | os << " omeg_ = " << omeg_ << endl;
|
---|
[228] | 1259 |
|
---|
[470] | 1260 | os << " contenu de pixels : ";
|
---|
| 1261 | for(int i=0; i < nPix_; i++)
|
---|
| 1262 | {
|
---|
| 1263 | if(i%5 == 0) os << endl;
|
---|
| 1264 | os << pixels_(i) <<", ";
|
---|
| 1265 | }
|
---|
| 1266 | os << endl;
|
---|
[228] | 1267 |
|
---|
[470] | 1268 | os << endl;
|
---|
| 1269 | const PIXELS_XY& PXY= PIXELS_XY::instance();
|
---|
[228] | 1270 |
|
---|
[470] | 1271 | os << endl; os << " contenu des tableaux conversions "<<endl;
|
---|
| 1272 | for(int i=0; i < 5; i++)
|
---|
| 1273 | {
|
---|
| 1274 | os<<PXY.pix2x_(i)<<", "<<PXY.pix2y_(i)<<", "<<PXY.x2pix_(i)<<", "<<PXY.y2pix_(i)<<endl;
|
---|
| 1275 | }
|
---|
| 1276 | os << endl;
|
---|
[228] | 1277 |
|
---|
[470] | 1278 | os << " les parametres des modules anafast et synfast " <<endl;
|
---|
| 1279 | os << " nlmax, nmmax & iseed= " <<nlmax_<<", "<<nmmax_<<", "<<iseed_<<endl;
|
---|
| 1280 | os << " fwhm, quadr & cut = "<<fwhm_<<", "<<quadrupole_<<", "<<sym_cut_deg_<<endl;
|
---|
| 1281 | os << " powfile= " << powFile_<<endl;
|
---|
[228] | 1282 | }
|
---|
| 1283 |
|
---|
[470] | 1284 | //*******************************************************************
|
---|
| 1285 | // Class FIO_SphereGorski<T>
|
---|
| 1286 | // Les objets delegues pour la gestion de persistance
|
---|
| 1287 | //*******************************************************************
|
---|
[228] | 1288 |
|
---|
[470] | 1289 | template <class T>
|
---|
| 1290 | FIO_SphereGorski<T>::FIO_SphereGorski()
|
---|
| 1291 | {
|
---|
| 1292 | dobj= new SphereGorski<T>;
|
---|
| 1293 | ownobj= true;
|
---|
| 1294 | }
|
---|
[228] | 1295 |
|
---|
[470] | 1296 | template <class T>
|
---|
| 1297 | FIO_SphereGorski<T>::FIO_SphereGorski(string const& filename)
|
---|
| 1298 | {
|
---|
| 1299 | dobj= new SphereGorski<T>;
|
---|
| 1300 | ownobj= true;
|
---|
| 1301 | Read(filename);
|
---|
| 1302 | }
|
---|
[228] | 1303 |
|
---|
[470] | 1304 | template <class T>
|
---|
| 1305 | FIO_SphereGorski<T>::FIO_SphereGorski(const SphereGorski<T>& obj)
|
---|
| 1306 | {
|
---|
| 1307 | dobj= new SphereGorski<T>(obj);
|
---|
| 1308 | ownobj= true;
|
---|
| 1309 | }
|
---|
[228] | 1310 |
|
---|
[470] | 1311 | template <class T>
|
---|
| 1312 | FIO_SphereGorski<T>::FIO_SphereGorski(SphereGorski<T>* obj)
|
---|
| 1313 | {
|
---|
| 1314 | dobj= obj;
|
---|
| 1315 | ownobj= false;
|
---|
| 1316 | }
|
---|
[228] | 1317 |
|
---|
[470] | 1318 | template <class T>
|
---|
| 1319 | FIO_SphereGorski<T>::~FIO_SphereGorski()
|
---|
| 1320 | {
|
---|
| 1321 | if (ownobj && dobj) delete dobj;
|
---|
| 1322 | }
|
---|
[228] | 1323 |
|
---|
[470] | 1324 | template <class T>
|
---|
| 1325 | AnyDataObj* FIO_SphereGorski<T>::DataObj()
|
---|
| 1326 | {
|
---|
| 1327 | return(dobj);
|
---|
| 1328 | }
|
---|
[228] | 1329 |
|
---|
[470] | 1330 | template <class T>
|
---|
| 1331 | void FIO_SphereGorski<T>::ReadSelf(PInPersist& is)
|
---|
| 1332 | {
|
---|
| 1333 | cout << " FIO_SphereGorski:: ReadSelf " << endl;
|
---|
[228] | 1334 |
|
---|
[470] | 1335 | if(dobj == NULL)
|
---|
| 1336 | {
|
---|
| 1337 | dobj= new SphereGorski<T>;
|
---|
| 1338 | }
|
---|
[228] | 1339 |
|
---|
[470] | 1340 | // Pour savoir s'il y avait un DVList Info associe
|
---|
| 1341 | char strg[256];
|
---|
| 1342 | is.GetLine(strg, 255);
|
---|
| 1343 | bool hadinfo= false;
|
---|
| 1344 | if(strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo= true;
|
---|
| 1345 | if(hadinfo)
|
---|
| 1346 | { // Lecture eventuelle du DVList Info
|
---|
| 1347 | is >> dobj->Info();
|
---|
| 1348 | }
|
---|
[228] | 1349 |
|
---|
[470] | 1350 | int_4 nSide;
|
---|
| 1351 | is.GetI4(nSide);
|
---|
| 1352 | dobj->setSizeIndex(nSide);
|
---|
| 1353 |
|
---|
| 1354 | int_4 nPix;
|
---|
| 1355 | is.GetI4(nPix);
|
---|
| 1356 | dobj->setNbPixels(nPix);
|
---|
| 1357 |
|
---|
| 1358 | r_8 Omega;
|
---|
| 1359 | is.GetR8(Omega);
|
---|
| 1360 | dobj->setPixSolAngle(Omega);
|
---|
| 1361 |
|
---|
| 1362 | T* pixels= new T[nPix];
|
---|
| 1363 | PIOSReadArray(is, pixels, nPix);
|
---|
| 1364 | dobj->setDataBlock(pixels, nPix);
|
---|
| 1365 | delete [] pixels;
|
---|
| 1366 |
|
---|
| 1367 | int_4 nlmax,nmmax,iseed;
|
---|
| 1368 | is.GetI4(nlmax);
|
---|
| 1369 | is.GetI4(nmmax);
|
---|
| 1370 | is.GetI4(iseed);
|
---|
| 1371 |
|
---|
| 1372 | float fwhm,quadr,cut;
|
---|
| 1373 | is.GetR4(fwhm);
|
---|
| 1374 | is.GetR4(quadr);
|
---|
| 1375 | is.GetR4(cut);
|
---|
| 1376 |
|
---|
| 1377 | char powfl[128];
|
---|
| 1378 | is.GetLine(powfl, 127);
|
---|
| 1379 |
|
---|
| 1380 | dobj->setParafast(nlmax,nmmax,iseed,fwhm,quadr,cut,powfl);
|
---|
[228] | 1381 | }
|
---|
| 1382 |
|
---|
[470] | 1383 | template <class T>
|
---|
| 1384 | void FIO_SphereGorski<T>::WriteSelf(POutPersist& os) const
|
---|
| 1385 | {
|
---|
| 1386 | cout << " FIO_SphereGorski:: WriteSelf " << endl;
|
---|
[228] | 1387 |
|
---|
[470] | 1388 | if(dobj == NULL)
|
---|
| 1389 | {
|
---|
| 1390 | cout << " WriteSelf:: dobj= null " << endl;
|
---|
| 1391 | return;
|
---|
| 1392 | }
|
---|
[228] | 1393 |
|
---|
[470] | 1394 | char strg[256];
|
---|
| 1395 | int_4 nSide= dobj->SizeIndex();
|
---|
| 1396 | int_4 nPix = dobj->NbPixels();
|
---|
| 1397 |
|
---|
| 1398 | if(dobj->ptrInfo())
|
---|
| 1399 | {
|
---|
| 1400 | sprintf(strg,"SphereGorski: NSide=%6d NPix=%9d HasInfo",nSide,nPix);
|
---|
| 1401 | os.PutLine(strg);
|
---|
| 1402 | os << dobj->Info();
|
---|
| 1403 | }
|
---|
| 1404 | else
|
---|
| 1405 | {
|
---|
| 1406 | sprintf(strg,"SphereGorski: NSide=%6d NPix=%9d ",nSide,nPix);
|
---|
| 1407 | os.PutLine(strg);
|
---|
| 1408 | }
|
---|
| 1409 |
|
---|
| 1410 | os.PutI4(nSide);
|
---|
| 1411 | os.PutI4(nPix);
|
---|
| 1412 | os.PutR8(dobj->PixSolAngle(0));
|
---|
| 1413 |
|
---|
| 1414 | PIOSWriteArray(os,(dobj->getDataBlock())->Data(), nPix);
|
---|
| 1415 |
|
---|
| 1416 | int_4 nlmax,nmmax,iseed;
|
---|
| 1417 | float fwhm,quadr,cut;
|
---|
| 1418 | dobj->getParafast(nlmax,nmmax,iseed,fwhm,quadr,cut);
|
---|
| 1419 | os.PutI4(nlmax);
|
---|
| 1420 | os.PutI4(nmmax);
|
---|
| 1421 | os.PutI4(iseed);
|
---|
| 1422 | os.PutR4(fwhm);
|
---|
| 1423 | os.PutR4(quadr);
|
---|
| 1424 | os.PutR4(cut);
|
---|
| 1425 |
|
---|
| 1426 | char powfl[128];
|
---|
| 1427 | dobj->powfile(powfl);
|
---|
| 1428 | os.PutLine(powfl);
|
---|
| 1429 | }
|
---|
| 1430 |
|
---|
| 1431 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
| 1432 | #pragma define_template SphereGorski<double>
|
---|
| 1433 | #pragma define_template SphereGorski<float>
|
---|
| 1434 | #pragma define_template SphereGorski< complex<float> >
|
---|
| 1435 | #pragma define_template SphereGorski< complex<double> >
|
---|
| 1436 | #pragma define_template FIO_SphereGorski<double>
|
---|
| 1437 | #pragma define_template FIO_SphereGorski<float>
|
---|
| 1438 | #pragma define_template FIO_SphereGorski< complex<float> >
|
---|
| 1439 | #pragma define_template FIO_SphereGorski< complex<double> >
|
---|
| 1440 | #endif
|
---|
| 1441 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
|
---|
| 1442 | template class SphereGorski<double>;
|
---|
| 1443 | template class SphereGorski<float>;
|
---|
| 1444 | template class SphereGorski< complex<float> >;
|
---|
| 1445 | template class SphereGorski< complex<double> >;
|
---|
| 1446 | template class FIO_SphereGorski<double>;
|
---|
| 1447 | template class FIO_SphereGorski<float>;
|
---|
| 1448 | template class FIO_SphereGorski< complex<float> >;
|
---|
| 1449 | template class FIO_SphereGorski< complex<double> >;
|
---|
| 1450 | #endif
|
---|
| 1451 |
|
---|