Changeset 473 in Sophya
- Timestamp:
- Oct 18, 1999, 4:37:44 PM (26 years ago)
- Location:
- trunk/SophyaLib/Samba
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/Samba/localmap.cc
r470 r473 89 89 //++ 90 90 template<class T> 91 LocalMap<T>::LocalMap(int _4 nx, int_4ny) : nSzX_(nx), nSzY_(ny)91 LocalMap<T>::LocalMap(int nx, int ny) : nSzX_(nx), nSzY_(ny) 92 92 // 93 93 // Constructeur … … 155 155 //++ 156 156 template<class T> 157 void LocalMap<T>::ReSize(int _4 nx, int_4ny)157 void LocalMap<T>::ReSize(int nx, int ny) 158 158 // 159 159 // Redimensionne l'espace de stokage des pixels … … 175 175 //++ 176 176 template<class T> 177 int _4LocalMap<T>::NbPixels() const177 int LocalMap<T>::NbPixels() const 178 178 // 179 179 // Retourne le nombre de pixels du découpage … … 185 185 //++ 186 186 template<class T> 187 T& LocalMap<T>::PixVal(int _4k)187 T& LocalMap<T>::PixVal(int k) 188 188 // 189 189 // Retourne la valeur du contenu du pixel d'indice k … … 203 203 204 204 template<class T> 205 T const& LocalMap<T>::PixVal(int _4k) const205 T const& LocalMap<T>::PixVal(int k) const 206 206 // 207 207 // Retourne la valeur du contenu du pixel d'indice k … … 220 220 //++ 221 221 template<class T> 222 int _4 LocalMap<T>::PixIndexSph(float theta, floatphi) const222 int LocalMap<T>::PixIndexSph(double theta,double phi) const 223 223 // 224 224 // Retourne l'indice du pixel vers lequel pointe une direction définie par … … 234 234 235 235 // theta et phi en coordonnees relatives (on se ramene a une situation par rapport au plan de reference) 236 float theta_aux=theta;237 float phi_aux=phi;236 double theta_aux= theta; 237 double phi_aux = phi; 238 238 UserToReference(theta_aux, phi_aux); 239 239 240 240 // coordonnees dans le plan local en unites de pixels 241 floatx,y;242 AngleProjToPix(theta_aux, 243 244 floatxmin= -x0_-0.5;245 floatxmax= xmin+nSzX_;246 if((x > 247 floatxcurrent= xmin;241 double x,y; 242 AngleProjToPix(theta_aux,phi_aux, x, y); 243 244 double xmin= -x0_-0.5; 245 double xmax= xmin+nSzX_; 246 if((x > xmax) || (x < xmin)) return(-1); 247 double xcurrent= xmin; 248 248 for(i = 0; i < nSzX_; i++ ) 249 249 { … … 251 251 if( x < xcurrent ) break; 252 252 } 253 floatymin= -y0_-0.5;254 floatymax= ymin+nSzY_;253 double ymin= -y0_-0.5; 254 double ymax= ymin+nSzY_; 255 255 if((y > ymax) || (y < ymin)) return(-1); 256 floatycurrent= ymin;256 double ycurrent= ymin; 257 257 for(j = 0; j < nSzY_; j++ ) 258 258 { … … 265 265 //++ 266 266 template<class T> 267 void LocalMap<T>::PixThetaPhi(int _4 k, float& theta, float& phi) const267 void LocalMap<T>::PixThetaPhi(int k,double& theta,double& phi) const 268 268 // 269 269 // Retourne les coordonnées (theta,phi) du milieu du pixel d'indice k … … 279 279 Getij(k,i,j); 280 280 281 float X= float(i-x0_);282 float Y= float(j-y0_);281 double X= double(i-x0_); 282 double Y= double(j-y0_); 283 283 // situation de ce pixel dans le plan de reference 284 floatx= X*cos_angle_-Y*sin_angle_;285 floaty= X*sin_angle_+Y* cos_angle_;284 double x= X*cos_angle_-Y*sin_angle_; 285 double y= X*sin_angle_+Y* cos_angle_; 286 286 // projection sur la sphere 287 287 PixProjToAngle(x, y, theta, phi); … … 292 292 //++ 293 293 template<class T> 294 r_8 LocalMap<T>::PixSolAngle(int_4k) const294 double LocalMap<T>::PixSolAngle(int k) const 295 295 // 296 296 // Pixel Solid angle (steradians) … … 301 301 int i,j; 302 302 Getij(k,i,j); 303 float X= float(i-x0_); 304 float Y= float(j-y0_); 305 float XR= X+float(i)*0.5; 306 float XL= X-float(i)*0.5; 307 float YU= Y+float(j)*0.5; 308 float YL= Y-float(j)*0.5; 303 double X= double(i-x0_); 304 double Y= double(j-y0_); 305 double XR= X+double(i)*0.5; 306 double XL= X-double(i)*0.5; 307 double YU= Y+double(j)*0.5; 308 double YL= Y-double(j)*0.5; 309 309 310 // situation dans le plan de reference 310 float x0= XL*cos_angle_-YL*sin_angle_; 311 float y0= XL*sin_angle_+YL*cos_angle_; 312 float xa= XR*cos_angle_-YL*sin_angle_; 313 float ya= XR*sin_angle_+YL*cos_angle_; 314 float xb= XL*cos_angle_-YU*sin_angle_; 315 float yb= XL*sin_angle_+YU*cos_angle_; 311 double x0= XL*cos_angle_-YL*sin_angle_; 312 double y0= XL*sin_angle_+YL*cos_angle_; 313 double xa= XR*cos_angle_-YL*sin_angle_; 314 double ya= XR*sin_angle_+YL*cos_angle_; 315 double xb= XL*cos_angle_-YU*sin_angle_; 316 double yb= XL*sin_angle_+YU*cos_angle_; 317 316 318 // projection sur la sphere 317 float tet0,phi0,teta,phia,tetb,phib; 318 PixProjToAngle(x0, y0, tet0, phi0); 319 PixProjToAngle(xa, ya, teta, phia); 320 PixProjToAngle(xb, yb, tetb, phib); 319 double thet0,phi0,theta,phia,thetb,phib; 320 PixProjToAngle(x0, y0, thet0, phi0); 321 PixProjToAngle(xa, ya, theta, phia); 322 PixProjToAngle(xb, yb, thetb, phib); 323 321 324 // angle solide 322 floatsol= fabs((xa-x0)*(yb-y0)-(xb-x0)*(ya-y0));323 return r_8(sol);324 } 325 326 //++ 327 template<class T> 328 void LocalMap<T>::SetOrigin(float theta0, float phi0, floatangle)325 double sol= fabs((xa-x0)*(yb-y0)-(xb-x0)*(ya-y0)); 326 return sol; 327 } 328 329 //++ 330 template<class T> 331 void LocalMap<T>::SetOrigin(double theta0,double phi0,double angle) 329 332 // 330 333 // Fixe la repere de reference ( angles en degres) 331 334 //-- 332 335 { 333 theta0_= (double)theta0;334 phi0_ = (double)phi0;335 angle_ = (double)angle;336 theta0_= theta0; 337 phi0_ = phi0; 338 angle_ = angle; 336 339 x0_= nSzX_/2; 337 340 y0_= nSzY_/2; 338 cos_angle_= cos df(angle);339 sin_angle_= sin df(angle);341 cos_angle_= cos(angle*Pi/180.); 342 sin_angle_= sin(angle*Pi/180.); 340 343 originFlag_= true; 341 344 cout << " LocalMap:: set origin 1 done" << endl; … … 344 347 //++ 345 348 template<class T> 346 void LocalMap<T>::SetOrigin(float theta0, float phi0, int_4 x0, int_4 y0, floatangle)349 void LocalMap<T>::SetOrigin(double theta0,double phi0,int x0,int y0,double angle) 347 350 // 348 351 // Fixe le repere de reference (angles en degres) 349 352 //-- 350 353 { 351 theta0_= (double)theta0;352 phi0_ = (double)phi0;353 angle_ = (double)angle;354 theta0_= theta0; 355 phi0_ = phi0; 356 angle_ = angle; 354 357 x0_= x0; 355 358 y0_= y0; 356 cos_angle_= cos df(angle);357 sin_angle_= sin df(angle);359 cos_angle_= cos(angle*Pi/180.); 360 sin_angle_= sin(angle*Pi/180.); 358 361 originFlag_= true; 359 362 cout << " LocalMap:: set origin 2 done" << endl; … … 362 365 //++ 363 366 template<class T> 364 void LocalMap<T>::SetSize( float angleX, floatangleY)367 void LocalMap<T>::SetSize(double angleX,double angleY) 365 368 // 366 369 // Fixe l'extension de la carte (angles en degres) 367 370 //-- 368 371 { 369 angleX_= (double)angleX; 370 angleY_= (double)angleY; 371 372 //tgAngleX_= T(tan(angleX*Pi/360.)); 373 //tgAngleY_= T(tan(angleY*Pi/360.)); 374 372 angleX_= angleX; 373 angleY_= angleY; 375 374 376 375 // tangente de la moitie de l'ouverture angulaire totale 377 tgAngleX_= tan d(0.5*angleX_);378 tgAngleY_= tan d(0.5*angleY_);376 tgAngleX_= tan(0.5*angleX_*Pi/180.); 377 tgAngleY_= tan(0.5*angleY_*Pi/180.); 379 378 380 379 extensFlag_= true; … … 391 390 for(int m = 0; m < nPix_; m++) 392 391 { 393 floattheta,phi;392 double theta,phi; 394 393 PixThetaPhi(m,theta,phi); 395 394 sphere(theta,phi)= pixels_(m); … … 400 399 //++ 401 400 template<class T> 402 void LocalMap<T>::Getij(int k, int& i,int& j) const401 void LocalMap<T>::Getij(int k,int& i,int& j) const 403 402 // 404 403 //-- … … 411 410 //++ 412 411 template<class T> 413 void LocalMap<T>::ReferenceToUser( float &theta, float &phi) const412 void LocalMap<T>::ReferenceToUser(double& theta,double& phi) const 414 413 // 415 414 // -- 416 415 { 417 if(theta > (r_4)Pi || theta < 0. || phi < 0. || phi >= 2*(r_4)Pi) 418 { 419 //cout << " LocalMap::ReferenceToUser : exceptions a mettre en place" <<endl; 420 // THROW(out_of_range("LocalMap::PIxVal Pixel index out of range")); 416 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) 417 { 421 418 throw "LocalMap::ReferenceToUser (theta,phi) out of range"; 422 419 } 423 420 424 //cout << " ReferenceToUser entree, t= " << theta << " phi= " << phi << endl; 425 theta= (r_4)theta0_*Pi/180.+theta-(r_4)Pi*0.5; 421 theta= theta0_*Pi/180.+theta-Pi*0.5; 426 422 if(theta < 0.) 427 423 { 428 424 theta= -theta; 429 phi += (r_4)Pi;425 phi += Pi; 430 426 } 431 427 else 432 428 { 433 if(theta > (r_4)Pi)429 if(theta > Pi) 434 430 { 435 theta= 2.* (r_4)Pi-theta;436 phi += (r_4)Pi;431 theta= 2.*Pi-theta; 432 phi += Pi; 437 433 } 438 434 } 439 435 440 phi= (r_4)phi0_*Pi/180.+phi;441 while(phi >= 2.* (r_4)Pi) phi-=2.*(r_4)Pi;442 443 if(theta > (r_4)Pi || theta < 0. || phi < 0. || phi >= 2*(r_4)Pi)436 phi= phi0_*Pi/180.+phi; 437 while(phi >= 2.*Pi) phi-= 2.*Pi; 438 439 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) 444 440 { 445 441 cout << " LocalMap::ReferenceToUser : erreur bizarre dans le transfert a la carte utilisateur " << endl; … … 447 443 exit(0); 448 444 } 449 //cout << " ReferenceToUser sortie, t= " << theta << " phi= " << phi << endl; 450 } 451 452 //++ 453 template<class T> 454 void LocalMap<T>::UserToReference(float &theta, float &phi) const 445 } 446 447 //++ 448 template<class T> 449 void LocalMap<T>::UserToReference(double& theta,double& phi) const 455 450 // 456 451 // -- 457 452 { 458 if(theta > (r_4)Pi || theta < 0. || phi<0. || phi >= 2*(r_4)Pi)459 { 460 cout << " LocalMap::UserToReference : exceptionsa mettre en place" <<endl;461 // 453 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) 454 { 455 cout<<" LocalMap::UserToReference: exceptions a mettre en place" <<endl; 456 // THROW(out_of_range("LocalMap::PIxVal Pixel index out of range")); 462 457 throw "LocalMap::UserToReference (theta,phi) out of range"; 463 458 } 464 459 465 float phi1=phi-(r_4)phi0_*Pi/180.;466 if(phi1 < 0.) phi1+= 2.*(r_4)Pi;467 468 float theta1= theta-(r_4)theta0_*Pi/180.+(r_4)Pi*0.5;460 double phi1= phi-phi0_*Pi/180.; 461 if(phi1 < 0.) phi1+= 2.*Pi; 462 463 double theta1= theta-theta0_*Pi/180.+Pi*0.5; 469 464 if(theta1 < 0.) 470 465 { 471 466 theta= -theta1; 472 phi1+= (r_4)Pi;467 phi1+= Pi; 473 468 } 474 469 else 475 470 { 476 if(theta1 > (r_4)Pi)471 if(theta1 > Pi) 477 472 { 478 theta= 2.* (r_4)Pi-theta1;479 phi1+= (r_4)Pi;473 theta= 2.*Pi-theta1; 474 phi1+= Pi; 480 475 } 481 476 } 482 477 483 while(phi1 >= 2.* (r_4)Pi) phi1-=2.*(r_4)Pi;478 while(phi1 >= 2.*Pi) phi1-= 2.*Pi; 484 479 phi= phi1; 485 if(theta > (r_4)Pi || theta < 0. || phi < 0. || phi >= 2*(r_4)Pi)480 if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi) 486 481 { 487 482 cout << " LocalMap::UserToReference : erreur bizarre dans le transfert a la carte de reference " << endl; … … 493 488 //++ 494 489 template<class T> 495 void LocalMap<T>::PixProjToAngle( float x, float y, float& theta, float& phi) const496 // 497 // (x,y) representent les coordonnees en unites de pixels d'un point DANS 490 void LocalMap<T>::PixProjToAngle(double x,double y,double& theta,double& phi) const 491 // 492 // (x,y) representent les coordonnees en unites de pixels d'un point DANS LE PLAN DE REFERENCE. 498 493 // On recupere (theta,phi) par rapport au repere "absolu" theta=pi/2 et phi=0. 499 494 //-- 500 495 { 501 theta= (r_4)Pi*0.5-atan(2*y*tgAngleY_/(float)nSzY_);502 phi= atan2(2 *x*tgAngleX_,(float)nSzX_);496 theta= Pi*0.5-atan(2.*y*tgAngleY_/(double)nSzY_); 497 phi= atan2(2.*x*tgAngleX_,(double)nSzX_); 503 498 if(phi < 0.) phi += DeuxPi; 504 499 } … … 506 501 //++ 507 502 template<class T> 508 void LocalMap<T>::AngleProjToPix( float theta, float phi, float& x, float& y) const503 void LocalMap<T>::AngleProjToPix(double theta,double phi,double& x,double& y) const 509 504 // 510 505 // (theta,phi) par rapport au repere "absolu" theta=pi/2,phi=0. On recupere … … 512 507 //-- 513 508 { 514 if(phi >= (r_4)Pi) phi-= DeuxPi;509 if(phi >= Pi) phi-= DeuxPi; 515 510 // y=0.5*mSzY_*cot(theta)/tgAngleY_; $CHECK-REZA-04/99$ 516 511 y= 0.5*nSzY_/tan(theta)/tgAngleY_; // ? cot = 1/tan ? … … 606 601 } 607 602 608 int _4nSzX;603 int nSzX; 609 604 is.GetI4(nSzX); 610 605 dobj->setSize_x(nSzX); 611 606 612 int _4nSzY;607 int nSzY; 613 608 is.GetI4(nSzY); 614 609 dobj->setSize_y(nSzY); 615 610 616 int _4nPix;611 int nPix; 617 612 is.GetI4(nPix); 618 613 dobj->setNbPixels(nPix); … … 624 619 { 625 620 cout<<" ReadSelf:: local mapping"<<endl; 626 int _4x0, y0;627 floattheta, phi, angle;621 int x0, y0; 622 double theta, phi, angle; 628 623 is.GetI4(x0); 629 624 is.GetI4(y0); 630 is.GetR 4(theta);631 is.GetR 4(phi);632 is.GetR 4(angle);625 is.GetR8(theta); 626 is.GetR8(phi); 627 is.GetR8(angle); 633 628 dobj->SetOrigin(theta, phi, x0, y0, angle); 634 629 635 floatangleX, angleY;636 is.GetR 4(angleX);637 is.GetR 4(angleY);630 double angleX, angleY; 631 is.GetR8(angleX); 632 is.GetR8(angleY); 638 633 dobj->SetSize(angleX, angleY); 639 634 } … … 657 652 658 653 char strg[256]; 659 int _4nSzX= dobj->Size_x();660 int _4nSzY= dobj->Size_y();661 int _4nPix= dobj->NbPixels();654 int nSzX= dobj->Size_x(); 655 int nSzY= dobj->Size_y(); 656 int nPix= dobj->NbPixels(); 662 657 663 658 if(dobj->ptrInfo()) … … 681 676 string ss("local mapping is done"); 682 677 os.PutStr(ss); 683 int _4x0, y0;684 floattheta, phi, angle;678 int x0, y0; 679 double theta, phi, angle; 685 680 dobj->Origin(theta, phi, x0, y0, angle); 686 681 os.PutI4(x0); 687 682 os.PutI4(y0); 688 os.PutR 4(theta);689 os.PutR 4(phi);690 os.PutR 4(angle);691 692 floatangleX, angleY;683 os.PutR8(theta); 684 os.PutR8(phi); 685 os.PutR8(angle); 686 687 double angleX, angleY; 693 688 dobj->Aperture(angleX, angleY); 694 os.PutR 4(angleX);695 os.PutR 4(angleY);689 os.PutR8(angleX); 690 os.PutR8(angleY); 696 691 } 697 692 else -
trunk/SophyaLib/Samba/localmap.h
r470 r473 42 42 43 43 LocalMap(); 44 LocalMap(int _4 nx, int_4ny);44 LocalMap(int nx, int ny); 45 45 LocalMap(const LocalMap<T>& lm); 46 46 virtual ~LocalMap(); … … 48 48 // ---------- Overloading of () to access pixel number k ---- 49 49 50 inline T& operator()(int _4k) {return(PixVal(k));}51 inline T const& operator()(int _4k) const {return(PixVal(k));}50 inline T& operator()(int k) {return(PixVal(k));} 51 inline T const& operator()(int k) const {return(PixVal(k));} 52 52 inline T& operator()(int ix, int iy) {return PixVal(iy*nSzX_+ix);}; 53 53 inline T const& operator()(int ix, int iy) const {return PixVal(iy*nSzX_+ix);}; … … 56 56 57 57 /* return/set the number of pixels */ 58 virtual int _4NbPixels() const;59 inline void setNbPixels(int _4n) {nPix_= n;}58 virtual int NbPixels() const; 59 inline void setNbPixels(int n) {nPix_= n;} 60 60 61 61 /* return the value of pixel number k */ 62 virtual T& PixVal(int _4k);63 virtual T const& PixVal(int _4k) const;62 virtual T& PixVal(int k); 63 virtual T const& PixVal(int k) const; 64 64 65 65 /* return the index of pixel at (theta,phi) */ 66 virtual int _4 PixIndexSph(float theta, floatphi) const;66 virtual int PixIndexSph(double theta,double phi) const; 67 67 68 68 /* return the spherical coordinates of center of pixel number k */ 69 virtual void PixThetaPhi(int _4 k, float& theta, float& phi) const;69 virtual void PixThetaPhi(int k,double& theta,double& phi) const; 70 70 71 71 /* return the Pixel Solid angle (steradians) */ 72 virtual r_8 PixSolAngle(int_4k) const;72 virtual double PixSolAngle(int k) const; 73 73 74 74 // ---------- Specific methods ------------------------------ 75 75 76 void ReSize(int _4 nx, int_4ny);76 void ReSize(int nx, int ny); 77 77 78 78 inline virtual char* TypeOfMap() const {return "LOCAL";}; 79 79 80 80 /* Origin (with angle between x axis and phi axis, in degrees) x0,y0 the default: middle of map*/ 81 virtual void SetOrigin( float theta=90., float phi=0., floatangle=0.);82 virtual void SetOrigin( float theta,float phi,int_4 x0,int_4 y0,floatangle=0.);81 virtual void SetOrigin(double theta=90.,double phi=0.,double angle=0.); 82 virtual void SetOrigin(double theta,double phi,int x0,int y0,double angle=0.); 83 83 84 84 /* Pixel size (degres) */ 85 virtual void SetSize( float angleX, floatangleY);85 virtual void SetSize(double angleX,double angleY); 86 86 87 87 /* Check to see if the local mapping is done */ … … 95 95 96 96 /* provides a integer characterizing the pixelization refinement (here : number of pixels) */ 97 inline virtual int _4SizeIndex() const {return(nPix_);}98 inline int _4Size_x() const {return nSzX_;}99 inline void setSize_x(int _4n) {nSzX_= n;}100 inline int _4Size_y() const {return nSzY_;}101 inline void setSize_y(int _4n) {nSzY_= n;}97 inline virtual int SizeIndex() const {return(nPix_);} 98 inline int Size_x() const {return nSzX_;} 99 inline void setSize_x(int n) {nSzX_= n;} 100 inline int Size_y() const {return nSzY_;} 101 inline void setSize_y(int n) {nSzY_= n;} 102 102 103 inline void Origin( float& theta, float& phi,int& x0, int& y0, float& angle) const {theta= (float)theta0_; phi= (float)phi0_; x0= x0_; y0= y0_;angle= (float)angle_;}103 inline void Origin(double& theta,double& phi,int& x0,int& y0,double& angle) const {theta= theta0_; phi= phi0_; x0= x0_; y0= y0_;angle= angle_;} 104 104 105 inline void Aperture( float& anglex, float& angley) const {anglex= (float)angleX_; angley= (float)angleY_;}105 inline void Aperture(double& anglex,double& angley) const {anglex= angleX_; angley= angleY_;} 106 106 107 107 /* retourne le pointeur vers/remplit le vecteur des contenus des pixels */ 108 108 inline const NDataBlock<T>* getDataBlock() const {return (&pixels_);} 109 inline void setDataBlock(T* data, int _4n) {pixels_.FillFrom(n,data);}109 inline void setDataBlock(T* data, int n) {pixels_.FillFrom(n,data);} 110 110 111 111 /* impression */ … … 117 117 118 118 void InitNul(); 119 void Getij(int k, int& i,int& j) const;120 void ReferenceToUser( float &theta, float &phi) const;121 void UserToReference( float &theta, float &phi) const;122 void PixProjToAngle( float x, float y,float &theta, float &phi) const;123 void AngleProjToPix( float theta, float phi, float& x, float& y) const;119 void Getij(int k,int& i,int& j) const; 120 void ReferenceToUser(double& theta,double& phi) const; 121 void UserToReference(double& theta,double& phi) const; 122 void PixProjToAngle(double x,double y,double& theta,double& phi) const; 123 void AngleProjToPix(double theta,double phi,double& x,double& y) const; 124 124 125 125 // ---------- Variables internes ---------------------------- 126 126 127 int _4nSzX_;128 int _4nSzY_;129 int _4nPix_;127 int nSzX_; 128 int nSzY_; 129 int nPix_; 130 130 bool originFlag_; 131 131 bool extensFlag_; 132 int _4x0_;133 int _4y0_;134 r_8theta0_;135 r_8phi0_;136 r_8angle_;137 r_4cos_angle_;138 r_4sin_angle_;139 r_8angleX_;140 r_8angleY_;141 r_8tgAngleX_;142 r_8tgAngleY_;132 int x0_; 133 int y0_; 134 double theta0_; 135 double phi0_; 136 double angle_; 137 double cos_angle_; 138 double sin_angle_; 139 double angleX_; 140 double angleY_; 141 double tgAngleX_; 142 double tgAngleY_; 143 143 NDataBlock<T> pixels_; 144 144 }; -
trunk/SophyaLib/Samba/pixelmap.h
r470 r473 25 25 26 26 // Number of pixels 27 virtual int _4NbPixels() const=0;27 virtual int NbPixels() const=0; 28 28 29 29 // Value of pixel number k 30 virtual T& PixVal(int _4k)=0;31 virtual T const& PixVal(int _4k) const=0;30 virtual T& PixVal(int k)=0; 31 virtual T const& PixVal(int k) const=0; 32 32 33 33 // Index of pixel at (theta,phi) 34 virtual int _4 PixIndexSph(float theta, floatphi) const=0;34 virtual int PixIndexSph(double theta, double phi) const=0; 35 35 36 36 // Value of pixel number at (theta,phi) 37 virtual T& PixValSph( float theta, floatphi)37 virtual T& PixValSph(double theta, double phi) 38 38 {return PixVal(PixIndexSph(theta,phi));} 39 virtual T const& PixValSph( float theta, floatphi) const39 virtual T const& PixValSph(double theta, double phi) const 40 40 {return PixVal(PixIndexSph(theta,phi));} 41 41 42 42 // Spherical coordinates of center of pixel number k 43 virtual void PixThetaPhi(int _4 k, float& theta, float& phi) const=0;43 virtual void PixThetaPhi(int k, double& theta, double& phi) const=0; 44 44 45 45 // provides a integer characterizing the pixelization refinement 46 46 // (depending of the type of the map) 47 virtual int _4SizeIndex() const=0;47 virtual int SizeIndex() const=0; 48 48 virtual char* TypeOfMap() const =0; 49 49 50 50 // Pixel (steradians) 51 virtual r_8 PixSolAngle(int_4k) const =0;51 virtual double PixSolAngle(int k) const =0; 52 52 53 53 // Overloading of () to access pixel number k. 54 inline T& operator()(int _4k) {return(PixVal(k));}55 inline T const& operator()(int _4k) const {return(PixVal(k));}54 inline T& operator()(int k) {return(PixVal(k));} 55 inline T const& operator()(int k) const {return(PixVal(k));} 56 56 57 // Note : no overloading of ( float,float) to access pixel (theta,phi).58 // overloading of ( float,float) in SphericalMap57 // Note : no overloading of (double,double) to access pixel (theta,phi). 58 // overloading of (double,double) in SphericalMap 59 59 // overloading of (int,int) in CartesianMap 60 60 -
trunk/SophyaLib/Samba/spheregorski.cc
r470 r473 1 //2 1 #include "spheregorski.h" 3 2 #include "strutil.h" … … 14 13 extern "C" 15 14 { 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*);15 void anafast_(int&,int&,int&,double&,float*,float*,float*,float*,float*,float*,float*); 16 void synfast_(int&,int&,int&,int&,float&,float*,float*,float*,double*,double*,double*,double*,double*,float*); 18 17 } 19 18 20 19 //******************************************************************* 21 20 // Class PIXELS_XY 22 // 23 // 21 // Construction des tableaux necessaires a la traduction des indices RING en 22 // indices NESTED (ou l'inverse) 24 23 //******************************************************************* 25 24 … … 57 56 c one breaks up the pixel number by even and odd bits 58 57 ================================================== 59 58 */ 60 59 // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur 61 60 // (16/12/98) … … 101 100 c ix + iy in {0, 128**2 -1} 102 101 ================================================= 103 102 */ 104 103 // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur 105 104 // (16/12/98) … … 196 195 //++ 197 196 template<class T> 198 SphereGorski<T>::SphereGorski(int _4m)197 SphereGorski<T>::SphereGorski(int m) 199 198 200 199 // Constructeur : m est la variable nside de l'algorithme de Gorski … … 211 210 } 212 211 // verifier que m est une puissance de deux 213 int _4 x=m;212 int x= m; 214 213 while(x%2 == 0) x/=2; 215 214 if(x != 1) … … 261 260 //++ 262 261 template<class T> 263 void SphereGorski<T>::Resize(int _4m)262 void SphereGorski<T>::Resize(int m) 264 263 265 264 // m est la variable nside de l'algorithme de Gorski … … 273 272 } 274 273 // verifier que m est une puissance de deux 275 int _4 x=m;274 int x= m; 276 275 while (x%2==0) x/=2; 277 276 if(x != 1) … … 285 284 286 285 template<class T> 287 void SphereGorski<T>::Pixelize( int _4m)286 void SphereGorski<T>::Pixelize( int m) 288 287 289 288 // prépare la pixelisation Gorski (m a la même signification … … 294 293 { 295 294 // On memorise les arguments d'appel 296 nSide_ 295 nSide_= m; 297 296 298 297 // Nombre total de pixels sur la sphere entiere 299 nPix_= 12*nSide_*nSide_;298 nPix_= 12*nSide_*nSide_; 300 299 301 300 // pour le moment les tableaux qui suivent seront ranges dans l'ordre … … 310 309 311 310 // solid angle per pixel 312 omeg_= 4 *Pi/nPix_;311 omeg_= 4.0*Pi/nPix_; 313 312 } 314 313 … … 335 334 //++ 336 335 template<class T> 337 int _4SphereGorski<T>::NbPixels() const336 int SphereGorski<T>::NbPixels() const 338 337 339 338 // Retourne le nombre de pixels du découpage … … 345 344 //++ 346 345 template<class T> 347 int _4SphereGorski<T>::NbThetaSlices() const346 int SphereGorski<T>::NbThetaSlices() const 348 347 349 348 // Retourne le nombre de tranches en theta sur la sphere 350 349 //-- 351 350 { 352 return int _4(4*nSide_-1);353 } 354 355 //++ 356 template<class T> 357 void SphereGorski<T>::GetThetaSlice(int_4 index, r_4& theta, TVector<float>& phi,TVector<T>& value) const351 return int(4*nSide_-1); 352 } 353 354 //++ 355 template<class T> 356 void SphereGorski<T>::GetThetaSlice(int index,double& theta,TVector<double>& phi,TVector<T>& value) const 358 357 359 358 // Retourne, pour la tranche en theta d'indice 'index' le theta … … 372 371 } 373 372 374 int _4iring= 0;373 int iring= 0; 375 374 int lring = 0; 376 375 if(index < nSide_-1) … … 393 392 phi.ReSize(lring); 394 393 value.ReSize(lring); 395 float TH=0.;396 float F =0.;394 double TH= 0.; 395 double FI= 0.; 397 396 for(int kk = 0; kk < lring;kk++) 398 397 { 399 PixThetaPhi(kk+iring,TH,F );400 phi(kk)= F ;398 PixThetaPhi(kk+iring,TH,FI); 399 phi(kk)= FI; 401 400 value(kk)= PixVal(kk+iring); 402 401 } … … 407 406 //++ 408 407 template<class T> 409 T& SphereGorski<T>::PixVal(int _4k)408 T& SphereGorski<T>::PixVal(int k) 410 409 411 410 // Retourne la valeur du contenu du pixel d'indice "RING" k … … 424 423 //++ 425 424 template<class T> 426 T const& SphereGorski<T>::PixVal(int _4k) const425 T const& SphereGorski<T>::PixVal(int k) const 427 426 428 427 // Retourne la valeur du contenu du pixel d'indice "RING" k … … 440 439 //++ 441 440 template<class T> 442 T& SphereGorski<T>::PixValNest(int _4k)441 T& SphereGorski<T>::PixValNest(int k) 443 442 444 443 // Retourne la valeur du contenu du pixel d'indice "NESTED" k … … 456 455 457 456 template<class T> 458 T const& SphereGorski<T>::PixValNest(int _4k) const457 T const& SphereGorski<T>::PixValNest(int k) const 459 458 460 459 // Retourne la valeur du contenu du pixel d'indice "NESTED" k … … 467 466 THROW(rangeCheckErr); 468 467 } 469 int _4pix= nest2ring(nSide_,k);468 int pix= nest2ring(nSide_,k); 470 469 return *(pixels_.Data()+pix); 471 470 } … … 474 473 //++ 475 474 template<class T> 476 int _4 SphereGorski<T>::PixIndexSph(r_4 theta, r_4phi) const475 int SphereGorski<T>::PixIndexSph(double theta,double phi) const 477 476 478 477 // Retourne l'indice "RING" du pixel vers lequel pointe une direction … … 480 479 //-- 481 480 { 482 return ang2pix_ring(nSide_, double(theta),double(phi));483 } 484 485 //++ 486 template<class T> 487 int _4 SphereGorski<T>::PixIndexSphNest(r_4 theta, r_4phi) const481 return ang2pix_ring(nSide_,theta,phi); 482 } 483 484 //++ 485 template<class T> 486 int SphereGorski<T>::PixIndexSphNest(double theta,double phi) const 488 487 489 488 // Retourne l'indice NESTED" du pixel vers lequel pointe une direction … … 491 490 //-- 492 491 { 493 return ang2pix_nest(nSide_, double(theta),double(phi));492 return ang2pix_nest(nSide_,theta,phi); 494 493 } 495 494 … … 498 497 //++ 499 498 template<class T> 500 void SphereGorski<T>::PixThetaPhi(int_4 k, r_4& teta, r_4& phi) const 501 502 // Retourne les coordonnées (teta,phi) du milieu du pixel d'indice "RING" k 503 //-- 504 { 505 double t; 506 double p; 507 pix2ang_ring(nSide_,k, t, p); 508 teta= (r_4)t; 509 phi = (r_4)p; 510 } 511 512 //++ 513 template<class T> 514 r_8 SphereGorski<T>::PixSolAngle(int_4 dummy) const 499 void SphereGorski<T>::PixThetaPhi(int k,double& theta,double& phi) const 500 501 // Retourne les coordonnées (theta,phi) du milieu du pixel d'indice "RING" k 502 //-- 503 { 504 pix2ang_ring(nSide_,k,theta,phi); 505 } 506 507 //++ 508 template<class T> 509 double SphereGorski<T>::PixSolAngle(int dummy) const 515 510 // Pixel Solid angle (steradians) 516 511 // All the pixels have the same solid angle. The dummy argument is … … 524 519 //++ 525 520 template<class T> 526 void SphereGorski<T>::PixThetaPhiNest(int _4 k, float& teta, float& phi)const527 528 // Retourne les coordonnées (t eta,phi) du milieu du pixel d'indice521 void SphereGorski<T>::PixThetaPhiNest(int k,double& theta,double& phi) const 522 523 // Retourne les coordonnées (theta,phi) du milieu du pixel d'indice 529 524 // NESTED k 530 525 //-- 531 526 { 532 double t; 533 double p; 534 pix2ang_nest(nSide_, k, t, p); 535 teta= (r_4)t; 536 phi = (r_4)p; 537 } 538 539 //++ 540 template<class T> 541 int_4 SphereGorski<T>::NestToRing(int_4 k) const 527 pix2ang_nest(nSide_,k,theta,phi); 528 } 529 530 //++ 531 template<class T> 532 int SphereGorski<T>::NestToRing(int k) const 542 533 543 534 // conversion d'index NESTD en un index RING … … 550 541 //++ 551 542 template<class T> 552 int _4 SphereGorski<T>::RingToNest(int_4k) const543 int SphereGorski<T>::RingToNest(int k) const 553 544 // 554 545 // conversion d'index RING en un index NESTED … … 687 678 688 679 template<class T> 689 int SphereGorski<T>::nest2ring(int nside, int ipnest) const { 680 int SphereGorski<T>::nest2ring(int nside, int ipnest) const 681 { 690 682 /* 691 683 ==================================================== … … 694 686 c conversion from NESTED to RING pixel number 695 687 ==================================================== 696 688 */ 697 689 // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur 698 690 // (16/12/98) … … 776 768 c conversion from RING to NESTED pixel number 777 769 ================================================== 778 770 */ 779 771 // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur 780 772 // (16/12/98) … … 884 876 c corresponding to angles theta and phi 885 877 c================================================== 886 878 */ 887 879 // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur 888 880 // (16/12/98) … … 968 960 c for every resolution 969 961 ================================================== 970 962 */ 971 963 // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur 972 964 // (16/12/98) … … 1004 996 ifp = jp / ns_max;// ! in {0,4} 1005 997 ifm = jm / ns_max; 1006 if( ifp==ifm ) face_num = (int)fmod(ifp,4) + 4; //then 998 if( ifp==ifm ) face_num = (int)fmod(ifp,4) + 4; //then ! faces 4 to 7 1007 999 else if( ifp<ifm ) face_num = (int)fmod(ifp,4); // (half-)faces 0 to 3 1008 1000 else face_num = (int)fmod(ifm,4) + 8;//! (half-)faces 8 to 11 … … 1053 1045 c for a parameter nside 1054 1046 =================================================== 1055 1047 */ 1056 1048 // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur 1057 1049 // (16/12/98) … … 1123 1115 c for a parameter nside 1124 1116 ================================================== 1125 1117 */ 1126 1118 // tranlated from FORTRAN (Gorski) to C, by B. Revenu, revised Guy Le Meur 1127 1119 // (16/12/98) … … 1227 1219 1228 1220 template<class T> 1229 void SphereGorski<T>::getParafast(int _4& nlmax,int_4& nmmax,int_4& iseed,float& fwhm,float& quadr,float& cut) const1221 void SphereGorski<T>::getParafast(int& nlmax,int& nmmax,int& iseed,float& fwhm,float& quadr,float& cut) const 1230 1222 { 1231 1223 nlmax= nlmax_; … … 1238 1230 1239 1231 template<class T> 1240 void SphereGorski<T>::setParafast(int _4 nlmax,int_4 nmmax,int_4iseed,float fwhm,float quadr,float cut,char* filename)1232 void SphereGorski<T>::setParafast(int nlmax,int nmmax,int iseed,float fwhm,float quadr,float cut,char* filename) 1241 1233 { 1242 1234 nlmax_= nlmax; … … 1348 1340 } 1349 1341 1350 int _4nSide;1342 int nSide; 1351 1343 is.GetI4(nSide); 1352 1344 dobj->setSizeIndex(nSide); 1353 1345 1354 int _4nPix;1346 int nPix; 1355 1347 is.GetI4(nPix); 1356 1348 dobj->setNbPixels(nPix); 1357 1349 1358 r_8Omega;1350 double Omega; 1359 1351 is.GetR8(Omega); 1360 1352 dobj->setPixSolAngle(Omega); … … 1365 1357 delete [] pixels; 1366 1358 1367 int _4nlmax,nmmax,iseed;1359 int nlmax,nmmax,iseed; 1368 1360 is.GetI4(nlmax); 1369 1361 is.GetI4(nmmax); … … 1393 1385 1394 1386 char strg[256]; 1395 int _4nSide= dobj->SizeIndex();1396 int _4nPix = dobj->NbPixels();1387 int nSide= dobj->SizeIndex(); 1388 int nPix = dobj->NbPixels(); 1397 1389 1398 1390 if(dobj->ptrInfo()) … … 1414 1406 PIOSWriteArray(os,(dobj->getDataBlock())->Data(), nPix); 1415 1407 1416 int _4nlmax,nmmax,iseed;1408 int nlmax,nmmax,iseed; 1417 1409 float fwhm,quadr,cut; 1418 1410 dobj->getParafast(nlmax,nmmax,iseed,fwhm,quadr,cut); -
trunk/SophyaLib/Samba/spheregorski.h
r470 r473 32 32 33 33 SphereGorski(); 34 SphereGorski(int _4m);34 SphereGorski(int m); 35 35 SphereGorski(const SphereGorski<T>& s); 36 36 virtual ~SphereGorski(); … … 39 39 40 40 /* Nombre de pixels du decoupage */ 41 virtual int _4NbPixels() const;42 inline void setNbPixels(int _4n) {nPix_= n;}41 virtual int NbPixels() const; 42 inline void setNbPixels(int n) {nPix_= n;} 43 43 44 44 /* Valeur du contenu du pixel d'indice "RING" k */ 45 virtual T& PixVal(int _4k);46 virtual T const& PixVal(int _4k) const;45 virtual T& PixVal(int k); 46 virtual T const& PixVal(int k) const; 47 47 48 48 /* Nombre de tranches en theta */ 49 int _4NbThetaSlices() const;50 void GetThetaSlice(int _4 index,r_4& theta,TVector<float>& phi,TVector<T>& value) const;49 int NbThetaSlices() const; 50 void GetThetaSlice(int index,double& theta,TVector<double>& phi,TVector<T>& value) const; 51 51 52 52 /* Indice "RING" du pixel vers lequel pointe une direction definie par 53 53 ses coordonnees spheriques */ 54 virtual int _4 PixIndexSph(float theta, floatphi) const;54 virtual int PixIndexSph(double theta,double phi) const; 55 55 56 56 /* Coordonnees spheriques du milieu du pixel d'indice "RING" k */ 57 virtual void PixThetaPhi(int _4 k, float& teta, float& phi) const;57 virtual void PixThetaPhi(int k,double& theta,double& phi) const; 58 58 59 59 /* Pixel Solid angle (steradians) */ 60 virtual r_8 PixSolAngle(int_4dummy) const;61 inline void setPixSolAngle( r_8x) {omeg_= x;}60 virtual double PixSolAngle(int dummy) const; 61 inline void setPixSolAngle(double x) {omeg_= x;} 62 62 63 63 // --------------- Specific methods 64 64 65 virtual void Resize(int _4m);65 virtual void Resize(int m); 66 66 67 67 inline virtual char* TypeOfMap() const {return "RING";}; 68 68 69 /* Valeur du contenu du pixel d'indice "NEST" k 70 virtual T& PixValNest(int _4k);71 virtual T const& PixValNest(int _4k) const;69 /* Valeur du contenu du pixel d'indice "NEST" k */ 70 virtual T& PixValNest(int k); 71 virtual T const& PixValNest(int k) const; 72 72 73 73 /* Indice "NEST" du pixel vers lequel pointe une direction definie par 74 74 ses coordonnees spheriques */ 75 virtual int _4 PixIndexSphNest(float theta, floatphi) const;75 virtual int PixIndexSphNest(double theta,double phi) const; 76 76 77 77 /* Coordonnees spheriques du milieu du pixel d'indice "NEST" k */ 78 virtual void PixThetaPhiNest(int _4 k, float& teta, float& phi) const;78 virtual void PixThetaPhiNest(int k,double& theta,double& phi) const; 79 79 80 80 /* algorithme de pixelisation */ 81 void Pixelize(int _4);81 void Pixelize(int); 82 82 83 83 /* convertit index nested en ring */ 84 int _4 NestToRing(int_4) const;84 int NestToRing(int) const; 85 85 86 86 /* convertit index ring en nested" */ 87 int _4 RingToNest(int_4) const;87 int RingToNest(int) const; 88 88 89 /* 89 /* analyse en harmoniques spheriques des valeurs des pixels de la 90 90 sphere : appel du module anafast (Gorski-Hivon) */ 91 91 //void anharm(int, float, float*); … … 97 97 98 98 /* retourne/fixe la valeur du parametre Gorski */ 99 inline virtual int _4SizeIndex() const {return(nSide_);}100 inline void setSizeIndex(int _4n) {nSide_= n;}99 inline virtual int SizeIndex() const {return(nSide_);} 100 inline void setSizeIndex(int n) {nSide_= n;} 101 101 102 102 /* retourne les pointeurs /remplit les tableaux */ 103 103 inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); } 104 inline void setDataBlock(T* data, int_4m) { pixels_.FillFrom(m,data); }104 inline void setDataBlock(T* data,int m) { pixels_.FillFrom(m,data); } 105 105 106 106 /* retourne/fixe les parametres des modules anafast et synfast */ 107 void getParafast(int _4& nlmax,int_4& nmmax,int_4& iseed,float& fwhm,float& quadr,float& cut) const;108 void setParafast(int _4 nlmax,int_4 nmmax,int_4iseed,float fwhm,float quadr,float cut,char* filename);107 void getParafast(int& nlmax,int& nmmax,int& iseed,float& fwhm,float& quadr,float& cut) const; 108 void setParafast(int nlmax,int nmmax,int iseed,float fwhm,float quadr,float cut,char* filename); 109 109 110 110 /* retourne/fixe le nom du fichier qui contient le spectre de puissance */ … … 119 119 void InitNul(); 120 120 121 int nest2ring(int nside, 122 int ring2nest(int nside, 121 int nest2ring(int nside,int ipnest) const; 122 int ring2nest(int nside,int ipring) const; 123 123 124 int ang2pix_ring(int nside, double theta,double phi) const;125 int ang2pix_nest(int nside, double theta,double phi) const;126 void pix2ang_ring(int nside, int ipix, double& theta,double& phi) const;127 void pix2ang_nest(int nside, int ipix, double& theta,double& phi) const;124 int ang2pix_ring(int nside,double theta,double phi) const; 125 int ang2pix_nest(int nside,double theta,double phi) const; 126 void pix2ang_ring(int nside,int ipix,double& theta,double& phi) const; 127 void pix2ang_nest(int nside,int ipix,double& theta,double& phi) const; 128 128 129 129 // ------------- variables internes ----------------------- 130 int _4nSide_;131 int _4nPix_;132 r_8omeg_;130 int nSide_; 131 int nPix_; 132 double omeg_; 133 133 134 134 NDataBlock<T> pixels_; -
trunk/SophyaLib/Samba/spherethetaphi.cc
r470 r473 87 87 //++ 88 88 template <class T> 89 SphereThetaPhi<T>::SphereThetaPhi(int _4m)89 SphereThetaPhi<T>::SphereThetaPhi(int m) 90 90 91 91 // Constructeur : m est le nombre de bandes en theta sur un hémisphère … … 105 105 NTheta_= s.NTheta_; 106 106 NPix_ = s.NPix_; 107 NPhi_ = new int _4[NTheta_];108 Theta_ = new r_4[NTheta_+1];109 TNphi_ = new int _4[NTheta_+1];107 NPhi_ = new int[NTheta_]; 108 Theta_ = new double[NTheta_+1]; 109 TNphi_ = new int[NTheta_+1]; 110 110 for(int k = 0; k < NTheta_; k++) 111 111 { … … 161 161 //++ 162 162 template <class T> 163 void SphereThetaPhi<T>::Resize(int _4m)163 void SphereThetaPhi<T>::Resize(int m) 164 164 // re-pixelize the sphere 165 165 //-- … … 172 172 //++ 173 173 template <class T> 174 int _4SphereThetaPhi<T>::NbPixels() const174 int SphereThetaPhi<T>::NbPixels() const 175 175 176 176 // Retourne le nombre de pixels du découpage … … 183 183 //++ 184 184 template <class T> 185 T& SphereThetaPhi<T>::PixVal(int _4k)185 T& SphereThetaPhi<T>::PixVal(int k) 186 186 187 187 // Retourne la valeur du contenu du pixel d'indice k … … 190 190 if((k < 0) || (k >= NPix_)) 191 191 { 192 // THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 192 //THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 193 cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl; 194 THROW(rangeCheckErr); 195 } 196 return pixels_(k); 197 } 198 199 //++ 200 template <class T> 201 T const& SphereThetaPhi<T>::PixVal(int k) const 202 203 // Retourne la valeur du contenu du pixel d'indice k 204 //-- 205 { 206 if((k < 0) || (k >= NPix_)) 207 { 193 208 cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl; 194 THROW(rangeCheckErr); 195 } 196 return pixels_(k); 197 } 198 199 //++ 200 template <class T> 201 T const& SphereThetaPhi<T>::PixVal(int_4 k) const 202 203 // Retourne la valeur du contenu du pixel d'indice k 204 //-- 205 { 206 if((k < 0) || (k >= NPix_)) 207 { 208 cout << " SphereThetaPhi::PIxVal : exceptions a mettre en place" <<endl; 209 // THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 209 //THROW(out_of_range("SphereThetaPhi::PIxVal Pixel index out of range")); 210 210 throw "SphereThetaPhi::PIxVal Pixel index out of range"; 211 211 } … … 216 216 //++ 217 217 template <class T> 218 int _4 SphereThetaPhi<T>::PixIndexSph(r_4 theta, r_4phi) const219 220 // 218 int SphereThetaPhi<T>::PixIndexSph(double theta, double phi) const 219 220 // Retourne l'indice du pixel vers lequel pointe une direction définie par 221 221 // ses coordonnées sphériques 222 222 //-- 223 223 { 224 r_4dphi;225 int _4i,j,k;224 double dphi; 225 int i,j,k; 226 226 bool fgzn = false; 227 227 228 if( (theta > (r_4)Pi) || (theta < 0. )) return(-1);229 if( (phi < 0.) || (phi > DeuxPi) )return(-1);230 if( theta > (r_4)Pi*0.5) { fgzn = true; theta = Pi-theta;}228 if((theta > Pi) || (theta < 0.)) return(-1); 229 if((phi < 0.) || (phi > DeuxPi)) return(-1); 230 if(theta > Pi*0.5) {fgzn = true; theta = Pi-theta;} 231 231 232 232 // La bande d'indice kt est limitée par les valeurs de theta contenues dans … … 235 235 if( theta < Theta_[i] ) break; 236 236 237 dphi= (r_4)DeuxPi/(r_4)NPhi_[i-1];238 239 if (fgzn) k= NPix_-TNphi_[i]+(int _4)(phi/dphi);240 else k= TNphi_[i-1]+(int _4)(phi/dphi);237 dphi= DeuxPi/(double)NPhi_[i-1]; 238 239 if (fgzn) k= NPix_-TNphi_[i]+(int)(phi/dphi); 240 else k= TNphi_[i-1]+(int)(phi/dphi); 241 241 return(k); 242 242 } … … 245 245 //++ 246 246 template <class T> 247 void SphereThetaPhi<T>::PixThetaPhi(int _4 k, r_4& theta, r_4& phi) const247 void SphereThetaPhi<T>::PixThetaPhi(int k,double& theta,double& phi) const 248 248 249 249 // Retourne les coordonnées (theta,phi) du milieu du pixel d'indice k 250 250 //-- 251 251 { 252 int _4i;252 int i; 253 253 bool fgzn = false; 254 254 255 if( (k < 0) || (k >= NPix_) ) {theta = -99999.; phi = -99999.;return; }256 if( k >= NPix_/2) {fgzn = true; k = NPix_-1-k;}255 if((k < 0) || (k >= NPix_)) {theta = -99999.; phi = -99999.; return; } 256 if( k >= NPix_/2) {fgzn = true; k = NPix_-1-k;} 257 257 258 258 // recupère l'indice i de la tranche qui contient le pixel k … … 266 266 // angle phi 267 267 k -= TNphi_[i]; 268 phi= (r_4)DeuxPi/(r_4)NPhi_[i]*(r_4)(k+.5);268 phi= DeuxPi/(double)NPhi_[i]*(double)(k+.5); 269 269 if (fgzn) phi= DeuxPi-phi; 270 270 } … … 272 272 //++ 273 273 template <class T> 274 r_8 SphereThetaPhi<T>::PixSolAngle(int_4dummy) const274 double SphereThetaPhi<T>::PixSolAngle(int dummy) const 275 275 276 276 // Pixel Solid angle (steradians) … … 286 286 //++ 287 287 template <class T> 288 void SphereThetaPhi<T>::Limits(int _4 k, r_4& tetMin, r_4& tetMax, r_4& phiMin, r_4& phiMax)288 void SphereThetaPhi<T>::Limits(int k,double& tetMin,double& tetMax,double& phiMin,double& phiMax) 289 289 290 290 // Retourne les valeurs de theta et phi limitant le pixel d'indice k 291 291 //-- 292 292 { 293 int _4j;294 r_4dphi;293 int j; 294 double dphi; 295 295 bool fgzn= false; 296 296 297 if( (k< 0) || (k >= NPix_)) {297 if((k < 0) || (k >= NPix_)) { 298 298 tetMin= -99999.; 299 299 phiMin= -99999.; … … 304 304 305 305 // si on se trouve dans l'hémisphère Sud 306 if( k >= NPix_/2) {306 if(k >= NPix_/2) { 307 307 fgzn= true; 308 308 k= NPix_-1-k; … … 312 312 int i; 313 313 for( i=0; i< NTheta_; i++ ) 314 if( k< TNphi_[i+1]) break;314 if(k < TNphi_[i+1]) break; 315 315 316 316 // valeurs limites de theta dans l'hemisphere Nord … … 328 328 // indice j de discretisation ( phi= j*dphi ) 329 329 j= k-TNphi_[i]; 330 dphi= (r_4)DeuxPi/(r_4)NPhi_[i];330 dphi= DeuxPi/(double)NPhi_[i]; 331 331 332 332 // valeurs limites de phi 333 phiMin= dphi*( r_4)(j);334 phiMax= dphi*( r_4)(j+1);333 phiMin= dphi*(double)(j); 334 phiMax= dphi*(double)(j+1); 335 335 return; 336 336 } … … 339 339 //++ 340 340 template <class T> 341 int _4SphereThetaPhi<T>::NbThetaSlices() const341 int SphereThetaPhi<T>::NbThetaSlices() const 342 342 343 343 // Retourne le nombre de tranches en theta sur la sphere 344 344 //-- 345 345 { 346 int _4nbslices;346 int nbslices; 347 347 nbslices= 2*NTheta_; 348 348 return(nbslices); … … 352 352 //++ 353 353 template <class T> 354 int _4 SphereThetaPhi<T>::NPhi(int_4kt) const354 int SphereThetaPhi<T>::NPhi(int kt) const 355 355 356 356 // Retourne le nombre de pixels en phi de la tranche kt 357 357 //-- 358 358 { 359 int _4nbpix;359 int nbpix; 360 360 // verification 361 if( (kt< 0) || (kt>= 2*NTheta_)) return(-1);361 if((kt < 0) || (kt >= 2*NTheta_)) return(-1); 362 362 363 363 // si on se trouve dans l'hemisphere Sud 364 if( kt >= NTheta_) {364 if(kt >= NTheta_) { 365 365 kt= 2*NTheta_-1-kt; 366 366 } … … 375 375 //++ 376 376 template <class T> 377 void SphereThetaPhi<T>::Theta(int _4 kt,r_4& tetMin,r_4& tetMax)377 void SphereThetaPhi<T>::Theta(int kt,double& tetMin,double& tetMax) 378 378 379 379 // Retourne les valeurs de theta limitant la tranche kt … … 407 407 //++ 408 408 template <class T> 409 void SphereThetaPhi<T>::Phi(int _4 kt,int_4 jp,r_4& phiMin,r_4& phiMax)409 void SphereThetaPhi<T>::Phi(int kt,int jp,double& phiMin,double& phiMax) 410 410 411 411 // Retourne les valeurs de phi limitant le pixel jp de la tranche kt … … 413 413 { 414 414 // verification 415 if( (kt< 0) || (kt>= 2*NTheta_)) {415 if((kt < 0) || (kt >= 2*NTheta_)) { 416 416 phiMin= -99999.; 417 417 phiMax= -99999.; … … 420 420 421 421 // si on se trouve dans l'hemisphere Sud 422 if( kt >= NTheta_) kt= 2*NTheta_-1-kt;422 if(kt >= NTheta_) kt= 2*NTheta_-1-kt; 423 423 424 424 // verifie si la tranche kt contient au moins jp pixels … … 429 429 } 430 430 431 r_4 dphi= (r_4)DeuxPi/(r_4)NPhi_[kt];432 phiMin= dphi*( r_4)(jp);433 phiMax= dphi*( r_4)(jp+1);431 double dphi= DeuxPi/(double)NPhi_[kt]; 432 phiMin= dphi*(double)(jp); 433 phiMax= dphi*(double)(jp+1); 434 434 return; 435 435 } … … 438 438 //++ 439 439 template <class T> 440 int _4 SphereThetaPhi<T>::Index(int_4 kt,int_4jp) const440 int SphereThetaPhi<T>::Index(int kt,int jp) const 441 441 442 442 // Retourne l'indice du pixel d'indice jp dans la tranche kt 443 443 //-- 444 444 { 445 int _4k;445 int k; 446 446 bool fgzn= false; 447 447 448 448 // si on se trouve dans l'hemisphere Sud 449 if( kt >= NTheta_) {449 if(kt >= NTheta_) { 450 450 fgzn= true; 451 451 kt= 2*NTheta_-1-kt; … … 471 471 //++ 472 472 template <class T> 473 void SphereThetaPhi<T>::ThetaPhiIndex(int _4 k,int_4& kt,int_4& jp)473 void SphereThetaPhi<T>::ThetaPhiIndex(int k,int& kt,int& jp) 474 474 475 475 // Retourne les indices kt et jp du pixel d'indice k … … 478 478 bool fgzn= false; 479 479 // si on se trouve dans l'hemisphere Sud 480 if( k >= NPix_/2 ) { 481 fgzn= true; 482 k= NPix_-1-k; 483 } 480 if(k >= NPix_/2) 481 { 482 fgzn= true; 483 k= NPix_-1-k; 484 } 484 485 485 486 // on recupere l'indice kt de la tranche qui contient le pixel k 486 487 int i; 487 for( i=0; i< NTheta_; i++)488 if( k< TNphi_[i+1]) break;488 for(i = 0; i < NTheta_; i++) 489 if(k < TNphi_[i+1]) break; 489 490 490 491 // indice kt de tranche … … 494 495 // indice jp de pixel 495 496 if (fgzn) jp= TNphi_[i+1]-k-1; 496 else jp= k-TNphi_[i]; 497 498 } 499 //++ 500 template <class T> 501 void SphereThetaPhi<T>::Pixelize( int_4 m) 497 else jp= k-TNphi_[i]; 498 } 499 //++ 500 template <class T> 501 void SphereThetaPhi<T>::Pixelize(int m) 502 502 503 503 // effectue le découpage en pixels (m et pet ont la même signification … … 511 511 //-- 512 512 { 513 int _4ntotpix,i,j;513 int ntotpix,i,j; 514 514 515 515 // Decodage et controle des arguments d'appel : … … 524 524 // Creation des vecteurs contenant : 525 525 // Les valeurs limites de theta (une valeur de plus que le nombre de bandes...) 526 Theta_= new r_4[m+1];526 Theta_= new double[m+1]; 527 527 528 528 // Le nombre de pixels en phi de chacune des bandes en theta 529 NPhi_ = new int _4[m];529 NPhi_ = new int[m]; 530 530 531 531 // Le nombre/Deuxpi total des pixels contenus dans les bandes de z superieur a une 532 532 // bande donnee (mTPphi[m] contient le nombre de pixels total de l'hemisphere) 533 TNphi_= new int _4[m+1];533 TNphi_= new int[m+1]; 534 534 535 535 // Calcul du nombre total de pixels dans chaque bande pour optimiser … … 544 544 { 545 545 TNphi_[j]= TNphi_[j-1]+NPhi_[j-1]; 546 NPhi_[j] = (int _4)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ;546 NPhi_[j] = (int)(.5+4.*(double)(m-.5)*sin(Pi*(double)j/(double)(2.*m-1.))) ; 547 547 } 548 548 … … 576 576 //++ 577 577 template <class T> 578 void SphereThetaPhi<T>::GetThetaSlice(int_4 index, r_4& theta, TVector<float>& phi, TVector<T>& value) const578 void SphereThetaPhi<T>::GetThetaSlice(int index,double& theta, TVector<double>& phi, TVector<T>& value) const 579 579 580 580 // Retourne, pour la tranche en theta d'indice 'index' le theta … … 594 594 } 595 595 596 int _4iring= Index(index,0);597 int _4bid = this->NPhi(index);596 int iring= Index(index,0); 597 int bid = this->NPhi(index); 598 598 int lring = bid; 599 599 cout << " iring= " << iring << " lring= " << lring << endl; … … 601 601 phi.ReSize(lring); 602 602 value.ReSize(lring); 603 floatTe= 0.;604 floatFi= 0.;603 double Te= 0.; 604 double Fi= 0.; 605 605 for(int kk = 0; kk < lring; kk++) 606 606 { … … 613 613 614 614 template <class T> 615 void SphereThetaPhi<T>::setmNPhi(int _4* array, int_4m)616 //remplit 615 void SphereThetaPhi<T>::setmNPhi(int* array, int m) 616 //remplit le tableau contenant le nombre de pixels en phi de chacune des bandes en theta 617 617 //-- 618 618 { 619 NPhi_= new int _4[m];619 NPhi_= new int[m]; 620 620 for(int k = 0; k < m; k++) NPhi_[k]= array[k]; 621 621 } 622 622 623 623 template <class T> 624 void SphereThetaPhi<T>::setmTNphi(int _4* array, int_4m)624 void SphereThetaPhi<T>::setmTNphi(int* array, int m) 625 625 //remplit le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes 626 626 //-- 627 627 { 628 TNphi_= new int _4[m];628 TNphi_= new int[m]; 629 629 for(int k = 0; k < m; k++) TNphi_[k]= array[k]; 630 630 } 631 631 632 632 template <class T> 633 void SphereThetaPhi<T>::setmTheta( r_4* array, int_4m)633 void SphereThetaPhi<T>::setmTheta(double* array, int m) 634 634 //remplit le tableau contenant les valeurs limites de theta 635 635 //-- 636 636 { 637 Theta_= new r_4[m];637 Theta_= new double[m]; 638 638 for(int k = 0; k < m; k++) Theta_[k]= array[k]; 639 639 } 640 640 641 641 template <class T> 642 void SphereThetaPhi<T>::setDataBlock(T* data, int _4m)642 void SphereThetaPhi<T>::setDataBlock(T* data, int m) 643 643 // remplit le vecteur des contenus des pixels 644 644 { … … 755 755 } 756 756 757 int _4mNTheta;757 int mNTheta; 758 758 is.GetI4(mNTheta); 759 759 dobj->setSizeIndex(mNTheta); 760 760 761 int _4mNPix;761 int mNPix; 762 762 is.GetI4(mNPix); 763 763 dobj->setNbPixels(mNPix); 764 764 765 r_8mOmeg;765 double mOmeg; 766 766 is.GetR8(mOmeg); 767 767 dobj->setPixSolAngle(mOmeg); 768 768 769 int _4* mNphi= new int_4[mNTheta];769 int* mNphi= new int[mNTheta]; 770 770 is.GetI4s(mNphi, mNTheta); 771 771 dobj->setmNPhi(mNphi, mNTheta); 772 772 delete [] mNphi; 773 773 774 int _4* mTNphi= new int_4[mNTheta+1];774 int* mTNphi= new int[mNTheta+1]; 775 775 is.GetI4s(mTNphi, mNTheta+1); 776 776 dobj->setmTNphi(mTNphi, mNTheta+1); 777 777 delete [] mTNphi; 778 778 779 r_4* mTheta= new r_4[mNTheta+1];780 is.GetR 4s(mTheta, mNTheta+1);779 double* mTheta= new double[mNTheta+1]; 780 is.GetR8s(mTheta, mNTheta+1); 781 781 dobj->setmTheta(mTheta, mNTheta+1); 782 782 delete [] mTheta; 783 783 784 784 T* mPixels= new T[mNPix]; 785 //is.Get(mPixels, mNPix);786 785 PIOSReadArray(is, mPixels, mNPix); 787 786 dobj->setDataBlock(mPixels, mNPix); … … 801 800 802 801 char strg[256]; 803 int _4mNTheta= dobj->SizeIndex();804 int _4mNPix = dobj->NbPixels();802 int mNTheta= dobj->SizeIndex(); 803 int mNPix = dobj->NbPixels(); 805 804 806 805 if(dobj->ptrInfo()) … … 821 820 os.PutI4s(dobj->getmNPhi() , mNTheta); 822 821 os.PutI4s(dobj->getmTNphi(), mNTheta+1); 823 os.PutR 4s(dobj->getmTheta(), mNTheta+1);822 os.PutR8s(dobj->getmTheta(), mNTheta+1); 824 823 //os.Put((dobj->getDataBlock())->Data(), mNPix); 825 824 PIOSWriteArray(os,(dobj->getDataBlock())->Data(), mNPix); -
trunk/SophyaLib/Samba/spherethetaphi.h
r470 r473 18 18 19 19 SphereThetaPhi(); 20 SphereThetaPhi(int _4m);20 SphereThetaPhi(int m); 21 21 SphereThetaPhi(char* flnm); 22 22 SphereThetaPhi(const SphereThetaPhi<T>& s); … … 26 26 27 27 /* retourne/fixe le nombre de pixels */ 28 virtual int _4NbPixels() const;29 inline void setNbPixels(int _4nbpix) { NPix_= nbpix; }28 virtual int NbPixels() const; 29 inline void setNbPixels(int nbpix) { NPix_= nbpix; } 30 30 31 31 /* retourne la valeur du pixel d'indice k */ 32 virtual T& PixVal(int _4k);33 virtual T const& PixVal(int _4k) const;32 virtual T& PixVal(int k); 33 virtual T const& PixVal(int k) const; 34 34 35 35 /* retourne l'indice du pixel a (theta,phi) */ 36 virtual int _4 PixIndexSph(float theta, floatphi) const;36 virtual int PixIndexSph(double theta, double phi) const; 37 37 38 38 /* retourne les coordonnees Spheriques du centre du pixel d'indice k */ 39 virtual void PixThetaPhi(int _4 k, float& theta, float& phi) const;39 virtual void PixThetaPhi(int k, double& theta, double& phi) const; 40 40 41 41 /* retourne/fixe l'angle Solide de Pixel (steradians) */ 42 virtual r_8 PixSolAngle(int_4dummy) const;43 inline void setPixSolAngle( r_8omega) { Omega_= omega; }42 virtual double PixSolAngle(int dummy) const; 43 inline void setPixSolAngle(double omega) { Omega_= omega; } 44 44 45 45 /* retourne/fixe la valeur du parametre de decoupage m */ 46 inline virtual int _4SizeIndex() const { return( NTheta_); }47 inline void setSizeIndex(int _4nbindex) { NTheta_= nbindex; }46 inline virtual int SizeIndex() const { return( NTheta_); } 47 inline void setSizeIndex(int nbindex) { NTheta_= nbindex; } 48 48 49 49 // ------------- Specific methods ---------------------- 50 50 51 virtual void Resize(int _4m);51 virtual void Resize(int m); 52 52 53 53 inline virtual char* TypeOfMap() const {return "TETAFI";}; 54 54 55 /* Valeurs de theta des paralleles et phi des meridiens limitant 56 virtual void Limits(int _4 k,float& tet1,float& tet2,float& phi1,float& phi2);55 /* Valeurs de theta des paralleles et phi des meridiens limitant le pixel d'indice k */ 56 virtual void Limits(int k,double& th1,double& th2,double& phi1,double& phi2); 57 57 58 58 /* Nombre de tranches en theta */ 59 int _4NbThetaSlices() const;59 int NbThetaSlices() const; 60 60 61 61 /* Nombre de pixels en phi de la tranche d'indice kt */ 62 int _4 NPhi(int_4kt) const;62 int NPhi(int kt) const; 63 63 64 64 /* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */ 65 65 /* de la tranche d'indice kt */ 66 void Theta(int _4 kt, float& t1, float& t2);66 void Theta(int kt, double& t1, double& t2); 67 67 68 68 /* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */ 69 69 /* dans la tranche d'indice kt */ 70 void Phi(int _4 kt, int_4 jp, float& p1, float& p2);70 void Phi(int kt, int jp, double& p1, double& p2); 71 71 72 72 /* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt */ 73 int _4 Index(int_4 kt, int_4jp) const;73 int Index(int kt, int jp) const; 74 74 75 75 /* Indice kt de la tranche et indice jp du pixel d'indice k */ 76 void ThetaPhiIndex(int _4 k,int_4& kt,int_4& jp);76 void ThetaPhiIndex(int k,int& kt,int& jp); 77 77 78 void Pixelize(int _4);78 void Pixelize(int); 79 79 80 void GetThetaSlice(int _4 index,r_4& theta,TVector<float>& phi,TVector<T>& value) const;80 void GetThetaSlice(int index,double& theta,TVector<double>& phi,TVector<T>& value) const; 81 81 82 82 /*retourne le tableau contenant le nombre de pixels en phi de chacune des bandes en theta */ 83 inline const int _4* getmNPhi() const { return(NPhi_); }84 void setmNPhi(int _4* array, int_4m);83 inline const int* getmNPhi() const { return(NPhi_); } 84 void setmNPhi(int* array, int m); 85 85 86 86 /* retourne/remplit le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes */ 87 inline const int _4* getmTNphi() const { return(TNphi_); }88 void setmTNphi(int _4* array, int_4m);87 inline const int* getmTNphi() const { return(TNphi_); } 88 void setmTNphi(int* array, int m); 89 89 90 90 /* retourne/remplit le tableau contenant les valeurs limites de theta */ 91 inline const r_4* getmTheta() const { return(Theta_); }92 void setmTheta( r_4* array, int_4m);91 inline const double* getmTheta() const { return(Theta_); } 92 void setmTheta(double* array, int m); 93 93 94 94 /* retourne le pointeur vers/remplit le vecteur des contenus des pixels */ 95 95 inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); } 96 void setDataBlock(T* data, int _4m);96 void setDataBlock(T* data, int m); 97 97 98 98 /* impression */ … … 106 106 107 107 // ------------- variables internes --------------------- 108 int _4NTheta_;109 int _4NPix_;110 r_8Omega_;111 int _4* NPhi_;112 int _4* TNphi_;113 r_4* Theta_;108 int NTheta_; 109 int NPix_; 110 double Omega_; 111 int* NPhi_; 112 int* TNphi_; 113 double* Theta_; 114 114 NDataBlock<T> pixels_; 115 115 }; -
trunk/SophyaLib/Samba/sphericalmap.h
r470 r473 27 27 28 28 // Overloading of () to access pixel number k. 29 inline T& operator()(int _4k) {return(PixVal(k));}30 inline T const& operator()(int _4k) const {return(PixVal(k));}31 inline T& operator()( float theta,floatphi) {return(PixValSph(theta,phi));};32 inline T const& operator()( float theta,floatphi) const {return(PixValSph(theta,phi));};29 inline T& operator()(int k) {return(PixVal(k));} 30 inline T const& operator()(int k) const {return(PixVal(k));} 31 inline T& operator()(double theta,double phi) {return(PixValSph(theta,phi));}; 32 inline T const& operator()(double theta,double phi) const {return(PixValSph(theta,phi));}; 33 33 34 34 // index characterizing the size pixelization : m for SphereThetaPhi 35 35 // nside for Gorski sphere... 36 virtual void Resize(int _4m)=0;37 virtual int _4NbThetaSlices() const=0;38 virtual void GetThetaSlice(int _4 index, r_4& theta, TVector<float>& phi, TVector<T>& value) const=0;36 virtual void Resize(int m)=0; 37 virtual int NbThetaSlices() const=0; 38 virtual void GetThetaSlice(int index,double& theta, TVector<double>& phi, TVector<T>& value) const=0; 39 39 }; 40 40 #endif
Note:
See TracChangeset
for help on using the changeset viewer.