Changeset 2985 in Sophya


Ignore:
Timestamp:
Jun 21, 2006, 5:55:29 PM (19 years ago)
Author:
ansari
Message:

1/ Suite codage HEALPix-NEST , test avec transforme Ylm OK
2/ Petites modifs et corrections diverses (ajout SizeIndex2Resol() par exemple)

Reza 21 Juin 2006

Location:
trunk/SophyaLib/SkyMap
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SkyMap/HEALPixUtils.cc

    r2973 r2985  
    707707  return m;
    708708
     709
     710//! return the pixel resolution for a given size index (nside)
     711double HEALPix::SizeIndexToResol(int_4 m)
     712{
     713  double res = 4.*M_PI/(double)(12*m*m);
     714  return sqrt(res);
     715
  • trunk/SophyaLib/SkyMap/HEALPixUtils.h

    r2973 r2985  
    2525  static inline int_4  ResolToNSide(double res)
    2626  { return   ResolToSizeIndex(res); }
     27  static double SizeIndexToResol(int_4 m); 
     28  static inline double  NSideToResol(int_4 m)
     29  { return  SizeIndexToResol(m); }
    2730};
    2831
  • trunk/SophyaLib/SkyMap/sphereecp.h

    r2978 r2985  
    2626static inline int_4 ResolToSizeIndex(double res)
    2727  { return (int_4)((M_PI/res)+0.5); }
     28//! return the pixel resolution (in radian) for the size index \b m
     29static inline double  SizeIndexToResol(int_4 m)
     30  { return  (M_PI/(double)m); }
    2831
    2932  // Constructeur par defaut
  • trunk/SophyaLib/SkyMap/spherehealpix.cc

    r2978 r2985  
    178178  omeg_ = a.omeg_;
    179179  int k;
    180   if (fgring_ != a.fgring_)
     180  if (fgring_ == a.fgring_)
    181181    for (k=0; k< nPix_; k++) pixels_(k) = a.pixels_(k);
    182182  else {
     
    359359      value(kk)= pixels_(kk+iring);
    360360    }
     361    PixThetaPhi(iring, theta, FI);
    361362  }
    362363  else {  // NESTED pixelisation scheme
     
    367368      value(kk)= pixels_(kkn);
    368369    }
    369   }
    370   theta= TH;
     370    PixThetaPhi(ring2nest(nSide_,iring), theta, FI);   
     371  }
     372  //  theta= TH;
    371373}
    372374/*! \fn void SOPHYA::SphereHEALPix::GetThetaSlice(int_4 sliceIndex,r_8& theta, r_8& phi0, TVector<int_4>& pixelIndices,TVector<T>& value) const
     
    422424  sliceBeginIndex_.ReSize(4*nSide_-1);
    423425  sliceLenght_.ReSize(4*nSide_-1);
    424   int sliceIndex;
    425   for (sliceIndex=0; sliceIndex<  nSide_-1; sliceIndex++)
    426     {
    427       sliceBeginIndex_(sliceIndex)  = 2*sliceIndex*(sliceIndex+1);
    428       sliceLenght_(sliceIndex) = 4*(sliceIndex+1);
    429     }
    430   for (sliceIndex= nSide_-1; sliceIndex<  3*nSide_; sliceIndex++)
    431     {
    432       sliceBeginIndex_(sliceIndex)  = 2*nSide_*(2*sliceIndex-nSide_+1);
    433       sliceLenght_(sliceIndex) = 4*nSide_;
    434     }
    435   for (sliceIndex= 3*nSide_; sliceIndex< 4*nSide_-1; sliceIndex++)
    436     {
    437       int_4 nc= 4*nSide_-1-sliceIndex;
    438       sliceBeginIndex_(sliceIndex)  = nPix_-2*nc*(nc+1);
    439       sliceLenght_(sliceIndex) = 4*nc;
    440     }
     426  int_4 sliceIndex;
     427  int_4 offp = 0;
     428  for (sliceIndex=0; sliceIndex<  nSide_-1; sliceIndex++)  {
     429    //      sliceBeginIndex_(sliceIndex)  = 2*sliceIndex*(sliceIndex+1);     
     430    sliceBeginIndex_(sliceIndex)  = offp;
     431    sliceLenght_(sliceIndex) = 4*(sliceIndex+1);
     432    offp += sliceLenght_(sliceIndex);
     433  }
     434  for (sliceIndex= nSide_-1; sliceIndex<  3*nSide_; sliceIndex++)  {
     435    //      sliceBeginIndex_(sliceIndex)  = 2*nSide_*(2*sliceIndex-nSide_+1);
     436    sliceBeginIndex_(sliceIndex)  = offp;
     437    sliceLenght_(sliceIndex) = 4*nSide_;
     438    offp += sliceLenght_(sliceIndex);
     439  }
     440  for (sliceIndex= 3*nSide_; sliceIndex< 4*nSide_-1; sliceIndex++) {
     441    int_4 nc= 4*nSide_-1-sliceIndex;
     442      //      sliceBeginIndex_(sliceIndex)  = nPix_-2*nc*(nc+1);
     443    sliceBeginIndex_(sliceIndex)  = offp;
     444    sliceLenght_(sliceIndex) = 4*nc;
     445    offp += sliceLenght_(sliceIndex);   
     446  }
    441447}
    442448
     
    463469}
    464470
    465 /*! \fn T& SOPHYA::SphereHEALPix::PixValNest(int_4 k)
    466 
    467    \return value of  pixel with "NESTED" index k
    468 
    469 template<class T>
    470 T& SphereHEALPix<T>::PixValNest(int_4 k)
    471 
    472 //--
    473 {
    474   if((k < 0) || (k >= nPix_))
    475     {
    476       throw RangeCheckError("SphereHEALPix::PIxValNest Pixel index out of range");
    477     }
    478   return pixels_(nest2ring(nSide_,k));
    479 }
    480 */
    481 /*!  \fn T const& SOPHYA::SphereHEALPix::PixValNest(int_4 k) const
    482 
    483   \return value of  pixel with "NESTED" index k
    484 
    485 template<class T>
    486 T const& SphereHEALPix<T>::PixValNest(int_4 k) const
    487 
    488 {
    489   if((k < 0) || (k >= nPix_))
    490     {
    491       throw RangeCheckError("SphereHEALPix::PIxValNest Pixel index out of range");
    492   }
    493   int_4 pix= nest2ring(nSide_,k);
    494   return *(pixels_.Data()+pix);
    495 }
    496 */
    497471
    498472/*! \fn bool SOPHYA::SphereHEALPix::ContainsSph(double theta, double phi) const
     
    518492}
    519493
    520 /*! \fn int_4 SOPHYA::SphereHEALPix::PixIndexSphNest(double theta,double phi) const
    521 
    522  \return "NESTED" index of the pixel corresponding to direction (theta, phi).
    523 
    524 template<class T>
    525 int_4 SphereHEALPix<T>::PixIndexSphNest(double theta,double  phi) const
    526 
    527 {
    528   return ang2pix_nest(nSide_,theta,phi);
    529 }
    530 */
    531494
    532495//!  \return (theta,phi) coordinates of middle of  pixel with "RING" index k
     
    547510
    548511
    549 
    550 /*! \fn void SOPHYA::SphereHEALPix::PixThetaPhiNest(int_4 k,double& theta,double& phi) const
    551 
    552   \return (theta,phi) coordinates of middle of  pixel with "NESTED" index k
    553 template<class T>
    554 void SphereHEALPix<T>::PixThetaPhiNest(int_4 k,double& theta,double& phi) const
    555 
    556 {   
    557   pix2ang_nest(nSide_,k,theta,phi);
    558 }
    559 */
    560512
    561513//!  Conversion from NESTED index  into RING index
  • trunk/SophyaLib/SkyMap/spherehealpix.h

    r2978 r2985  
    5151  static inline int_4 ResolToNSide(double res)
    5252         { return  HEALPix::ResolToSizeIndex(res); }
     53  //! return the pixel resolution (in radian) for the size index (=nside) m
     54  static inline double  SizeIndexToResol(int_4 m)
     55  { return  HEALPix::SizeIndexToResol(m); }
     56  //! return the pixel resolution (in radian) for the size index (=nside) m
     57  static inline double  NSideToResol(int_4 m)
     58  { return  HEALPix::SizeIndexToResol(m); }
    5359
    5460SphereHEALPix(bool fgring=true);
     
    113119inline bool IfNESTED() const { return ( (fgring_) ? false : true ); }
    114120
    115 /*
    116 virtual T& PixValNest(int_4 k);
    117 virtual T const& PixValNest(int_4 k) const;
    118 virtual int_4 PixIndexSphNest(double theta,double phi) const;
    119 virtual void PixThetaPhiNest(int_4 k,double& theta,double& phi) const;
    120 */
    121121
    122122void Pixelize(int_4);
  • trunk/SophyaLib/SkyMap/spherethetaphi.cc

    r2973 r2985  
    631631
    632632  if(index < 0 || index >= NbThetaSlices())
    633     throw RangeCheckError("SphereThetaPhi::GetThetaSlice() index out of range");
     633    throw RangeCheckError("SphereThetaPhi::GetThetaSlice(idx...) index out of range");
    634634   
    635635
     
    641641  double Te= 0.;
    642642  double Fi= 0.;
    643   for(int kk = 0; kk < lring; kk++)
    644     {
    645       PixThetaPhi(kk+iring,Te,Fi);
    646       phi(kk)= Fi;
    647       value(kk)= PixVal(kk+iring);
    648     }
     643  PixThetaPhi(iring,Te,Fi);
     644  double DFi = DeuxPi/(double)NPhi(index);
     645  for(int kk = 0; kk < lring; kk++)   {
     646    value(kk)= pixels_(kk+iring);
     647    phi(kk)= Fi;
     648    Fi += DFi;
     649  }
    649650  theta= Te;
    650651}
     
    665666
    666667  if(index < 0 || index >= NbThetaSlices())
    667     {
    668        throw RangeCheckError("SphereThetaPhi::PIxVal Pixel index out of range");
    669  
    670     }
     668    throw RangeCheckError("SphereThetaPhi::GetThetaSlice(idx...)  idx out of range");
    671669
    672670  int iring= Index(index,0);
     
    677675  double Te= 0.;
    678676  double Fi= 0.;
    679   for(int kk = 0; kk < lring; kk++)
    680     {
    681       pixelIndices(kk)=kk+iring ;
    682       value(kk)= PixVal(kk+iring);
    683     }
    684       PixThetaPhi(iring,theta,phi0);
     677  for(int kk = 0; kk < lring; kk++)  {
     678    pixelIndices(kk)=kk+iring ;
     679    value(kk)= pixels_(kk+iring);
     680  }
     681  PixThetaPhi(iring,theta,phi0);
    685682}
    686683
     
    692689{
    693690  Show(os);
     691  os << "SphereThetaPhi<T> NTheta_= " << NTheta_ << " NPix_    = " << NPix_
     692     << " Omega_  =  " << Omega_   << endl;
    694693  if(this->mInfo_) os << "  DVList Info= " << *(this->mInfo_) << endl;
    695   //
    696   os << " NTheta_= " << NTheta_ << endl;
    697   os << " NPix_    = " << NPix_   << endl;
    698   os << " Omega_  =  " << Omega_   << endl;
    699 
    700   os << " contenu de NPhi_ : ";
     694
     695  os << "... NPhi_ Values : ";
    701696  int i;
    702697  for(i=0; i < NTheta_; i++)
     
    707702  os << endl;
    708703
    709   os << " contenu de Theta_ : ";
     704  os << "... Theta_ Values : ";
    710705  for(i=0; i < NTheta_+1; i++)
    711706    {
     
    715710  os << endl;
    716711
    717   os << " contenu de TNphi_ : ";
     712  os << "... TNphi_ Values : ";
    718713  for(i=0; i < NTheta_+1; i++)
    719714    {
     
    723718  os << endl;
    724719
    725   os << " contenu de pixels : ";
     720  os << "... Pixel Values : ";
    726721  for(i=0; i < NPix_; i++)
    727722    {
  • trunk/SophyaLib/SkyMap/spherethetaphi.h

    r2978 r2985  
    2727public :
    2828
    29 //! return the size index value corresponding to resolution res (in radian)
     29//! return the size index value corresponding to resolution \b res (in radian)
    3030static inline int_4 ResolToSizeIndex(double res)
    3131  { return (int_4)((M_PI/2./res)+0.5); }
     32//! return the pixel resolution (in radian) for the size index \b m
     33static inline double  SizeIndexToResol(int_4 m)
     34  { return (M_PI/(2.*(double)m)); }
    3235
    3336SphereThetaPhi();
Note: See TracChangeset for help on using the changeset viewer.