Changeset 2960 in Sophya for trunk/SophyaLib


Ignore:
Timestamp:
Jun 1, 2006, 4:35:47 PM (19 years ago)
Author:
ansari
Message:

petites corrections + doc(xygen) / Protection Resize() ds SphereHEALPix et SphereThetaPhi - Reza 1/06/2006

Location:
trunk/SophyaLib/SkyMap
Files:
3 edited

Legend:

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

    r2885 r2960  
    2828
    2929\verbatim
    30 
     30    Adapted from :
    3131    -----------------------------------------------------------------------
    3232     version 0.8.2  Aug97 TAC  Eric Hivon, Kris Gorski
     
    8484
    8585{
    86 
    87   if(m <= 0 || m > 8192)
    88     {
    89       cout << "SphereHEALPix : m hors bornes [0,8192], m= " << m << endl;
    90       throw RangeCheckError("SphereHEALPix<T>::SphereHEALPix() - Out of bound nside (< 8192)!");
    91     }
    92   // verifier que m est une puissance de deux
    93   int x= m;
    94   while(x%2 == 0) x/=2;
    95   if(x != 1)
    96     { 
    97       cout<<"SphereHEALPix: m doit etre une puissance de deux, m= "<<m<<endl;
    98       throw ParmError("SphereHEALPix<T>::SphereHEALPix() - nside != 2^n !");
    99     }
    10086  InitNul();
    10187  Pixelize(m);
    10288  SetThetaSlices();
    10389}
    104 //++
     90//!    Copy constructor
    10591template<class T>
    10692SphereHEALPix<T>::SphereHEALPix(const SphereHEALPix<T>& s, bool share)
    10793  : pixels_(s.pixels_, share), sliceBeginIndex_(s.sliceBeginIndex_, share),
    10894                                sliceLenght_(s.sliceLenght_, share)
    109 //    copy constructor
    11095//--
    11196{
     
    214199
    215200/*!  \fn   void SOPHYA::SphereHEALPix::Resize(int_4 m)
    216   \param <m>   "nside" of the Gorski algorithm
     201  \param <m>   "nside" of the HEALPix algorithm
    217202
    218203  The total number of pixels will be Npix =  12*nside**2
     
    225210
    226211{
     212  if ((m <= 0 && nSide_ > 0))  {
     213    cout << "SphereHEALPix<T>::Resize(m) with m<=0, NOT resized" << endl;
     214    return;
     215  }
     216  InitNul();
     217  Pixelize(m);
     218  SetThetaSlices();
     219}
     220
     221template<class T>
     222void  SphereHEALPix<T>::Pixelize( int_4 m)
     223
     224//    prépare la pixelisation Gorski (m a la même signification
     225//    que pour le constructeur)
     226//
     227//   
     228{
    227229  if (m<=0 || m> 8192) {
    228     cout << "SphereHEALPix : m hors bornes [0,8192], m= " << m << endl;
    229     exit(1);
     230    cout << "SphereHEALPix<T>::Pixelize() m=" << m <<" out of range [0,8192]" << endl;
     231    throw ParmError("SphereHEALPix<T>::Pixelize() m out of range");
    230232  }
    231233  // verifier que m est une puissance de deux
    232234  int x= m;
    233235  while (x%2==0) x/=2;
    234   if(x != 1)
    235     { 
    236       cout<<"SphereHEALPix: m doit etre une puissance de deux, m= "<<m<<endl;
    237       exit(1);
    238     }
    239   InitNul();
    240   Pixelize(m);
    241   SetThetaSlices();
    242 }
    243 
    244 template<class T>
    245 void  SphereHEALPix<T>::Pixelize( int_4 m)
    246 
    247 //    prépare la pixelisation Gorski (m a la même signification
    248 //    que pour le constructeur)
    249 //
    250 //   
    251 {
     236  if(x != 1) { 
     237    cout << "SphereHEALPix<T>::Pixelize() m=" << m << " != 2^n " << endl;
     238    throw ParmError("SphereHEALPix<T>::Pixelize() m!=2^n");
     239  }
     240
    252241  // On memorise les arguments d'appel
    253242  nSide_= m; 
  • trunk/SophyaLib/SkyMap/spherethetaphi.cc

    r2885 r2960  
    6060/* --Methode-- */
    6161
    62 //++
     62/*! 
     63  \brief Constructor with specification of number of slices (in a hemisphere)
     64  \param m is the number of slices in theta on an hemisphere (the polar cap
     65  forms the first slice).
     66*/
    6367template <class T>
    6468SphereThetaPhi<T>::SphereThetaPhi(int_4 m)
    65 
    66 //    m is the number of slices in theta on an hemisphere (the polar cap
    67 //    forms the first slice).
    68 //--
    6969{
    7070  InitNul();
     
    7272}
    7373
     74//! Copy constructor (shares the pixel data if share==true)
    7475template <class T>
    7576SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s, bool share)
     
    8485}
    8586
     87//! Copy constructor (shares the pixel data)
    8688template <class T>
    8789SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s)
     
    105107{}
    106108
    107 //++
    108 // Titre        Public Méthods
    109 //--
    110109template <class T>
    111110void SphereThetaPhi<T>::InitNul()
     
    118117
    119118
    120 //++
     119//!   re-pixelize the sphere if (m > 0)
    121120template <class T>
    122121void SphereThetaPhi<T>::Resize(int_4 m)
    123 //   re-pixelize the sphere
    124 //--
    125 {
     122{
     123  if ((m <= 0) && (NTheta_ > 0) ) {
     124    cout << "SphereThetaPhi<T>::Resize(m) with m<=0 - NOT resized" << endl;
     125    return;
     126  }
    126127  InitNul();
    127128  Pixelize(m);
    128129}
    129130
     131//! Clone or share the SphereThetaPhi object \b a
    130132template<class T>
    131133void  SphereThetaPhi<T>::CloneOrShare(const  SphereThetaPhi<T>& a)
     
    142144  if (a.mInfo_) this->mInfo_ = new DVList(*(a.mInfo_));
    143145}
     146//! Share the pixel data with object \b a
    144147template<class T>
    145148void  SphereThetaPhi<T>::Share(const  SphereThetaPhi<T>& a)
     
    158161
    159162////////////////////////// methodes de copie/share
     163//! Perform data copy or shares the data
    160164template<class T>
    161165SphereThetaPhi<T>& SphereThetaPhi<T>::Set(const SphereThetaPhi<T>& a)
     
    176180}
    177181
     182//! Perform data copy or shares the data
    178183template<class T>
    179184SphereThetaPhi<T>& SphereThetaPhi<T>::CopyElt(const SphereThetaPhi<T>& a)
     
    197202
    198203/* --Methode-- */
    199 //++
     204//!    Return total number of pixels
    200205template <class T>
    201206int_4 SphereThetaPhi<T>::NbPixels() const
    202 
    203 //    Return total number of pixels
    204 //--
    205207{
    206208  return(NPix_);
     
    208210
    209211/* --Methode-- */
    210 //++
     212//!    Return value of pixel with index k
    211213template <class T>
    212214T& SphereThetaPhi<T>::PixVal(int_4 k)
    213 
    214 //    Return value of pixel with index k
    215 //--
    216215{
    217216  if((k < 0) || (k >= NPix_))
     
    222221}
    223222
    224 //++
     223//!    Return value of pixel with index k
    225224template <class T>
    226225T const& SphereThetaPhi<T>::PixVal(int_4 k) const
    227 
    228 //    Return value of pixel with index k
    229 //--
    230226{
    231227  if((k < 0) || (k >= NPix_))
     
    237233
    238234/* --Methode-- */
    239 //++
     235//! Return true if teta,phi in map 
    240236template <class T>
    241237bool SphereThetaPhi<T>::ContainsSph(double /*theta*/, double /*phi*/) const
    242 //--
    243238{
    244239  return(true);
     
    246241
    247242/* --Methode-- */
    248 //++
     243//!    Return index of the pixel corresponding to direction (theta, phi).
    249244template <class T>
    250245int_4 SphereThetaPhi<T>::PixIndexSph(double theta, double phi) const
    251 
    252 //    Return index of the pixel corresponding to
    253 //    direction (theta, phi).
    254 //--
    255246{
    256247  double dphi;
     
    275266
    276267/* --Methode-- */
    277 //++
     268//!   Return (theta,phi) coordinates of middle of  pixel with  index k
    278269template <class T>
    279270void SphereThetaPhi<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const
    280 
    281 //   Return (theta,phi) coordinates of middle of  pixel with  index k
    282 //--
    283271{
    284272  int i;
     
    302290}
    303291
     292//! Setting pixel values to a constant
    304293template <class T>
    305294T SphereThetaPhi<T>::SetPixels(T v)
     
    309298}
    310299
    311 //++
     300/*!
     301  \brief Pixel Solid angle  (steradians)
     302  All the pixels have the same solid angle. The dummy argument is
     303  for compatibility with eventual pixelizations which would not
     304  fulfil this requirement.
     305*/
    312306template <class T>
    313307double SphereThetaPhi<T>::PixSolAngle(int_4 /*dummy*/) const
    314308
    315 //    Pixel Solid angle  (steradians)
    316 //    All the pixels have the same solid angle. The dummy argument is
    317 //    for compatibility with eventual pixelizations which would not
    318 //    fulfil this requirement.
    319 //--
    320309{
    321310  return Omega_;
     
    323312
    324313/* --Methode-- */
    325 //++
     314//!   Return values of theta,phi which limit the pixel with  index k
    326315template <class T>
    327316void SphereThetaPhi<T>::Limits(int_4 k,double& tetMin,double& tetMax,double& phiMin,double& phiMax)
    328 
    329 //   Return values of theta,phi which limit the pixel with  index k
    330 //--
    331317  {
    332318  int j;
     
    376362
    377363/* --Methode-- */
    378 //++
     364//!    Return number of theta-slices on the sphere
    379365template <class T>
    380366uint_4 SphereThetaPhi<T>::NbThetaSlices() const
    381 
    382 //    Return number of theta-slices on the sphere
    383 //--
    384367{
    385368  if (NTheta_<=0)
     
    391374
    392375/* --Methode-- */
    393 //++
     376//!    Return number of pixels along the phi-direction of the kt-th slice
    394377template <class T>
    395378int_4 SphereThetaPhi<T>::NPhi(int_4 kt) const
    396 
    397 //    Return number of pixels in phi-direction of the kt-th slice
    398 //--
    399379{
    400380  int nbpix; 
     
    414394
    415395/* --Methode-- */
    416 //++
     396//!    Return  theta values which limit the slice kt
    417397template <class T>
    418398void SphereThetaPhi<T>::Theta(int_4 kt,double& tetMin,double& tetMax)
    419 
    420 //    Return  theta values which limit the slice kt
    421 //--
    422399{
    423400  bool fgzn= false;
     
    446423
    447424/* --Methode-- */
    448 //++
     425//!   Return values of phi which limit the jp-th pixel of the kt-th slice
    449426template <class T>
    450427void SphereThetaPhi<T>::Phi(int_4 kt,int_4 jp,double& phiMin,double& phiMax)
    451 
    452 //   Return values of phi which limit the jp-th pixel of the kt-th slice
    453 //--
    454428{
    455429  // verification
     
    477451
    478452/* --Methode-- */
    479 //++
     453//!    Return pixel index  with sequence index jp in the slice kt
    480454template <class T>
    481455int_4 SphereThetaPhi<T>::Index(int_4 kt,int_4 jp) const
    482 
    483 //    Return pixel index  with sequence index jp in the slice kt
    484 //--
    485456{
    486457  int k;
     
    510481
    511482/* --Methode-- */
    512 //++
     483//!    Return indices kt (theta) and jp (phi) of  pixel with index k
    513484template <class T>
    514485void SphereThetaPhi<T>::ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp)
    515 
    516 //    Return indices kt (theta) and jp (phi) of  pixel with index k
    517 //--
    518486{
    519487  bool fgzn= false; 
     
    538506  else jp= k-TNphi_(i); 
    539507}
    540 //++
     508/*!
     509  \brief achieve the splitting into pixels
     510  m has the same signification as for the constructor
     511 
     512  Each theta-slice of the north hemisphere will be spitted starting f
     513  from  phi=0 ...
     514 
     515  South hemisphere is scanned in the same direction according to phi
     516  and from equator to the pole (the pixel following the last one of
     517  the slice closest to the equator with z>0, is the pixel with lowest
     518  phi of the slice closest of the equator with z<0).
     519*/
    541520template <class T>
    542521void  SphereThetaPhi<T>::Pixelize(int_4 m)
    543522
    544 //    achieve the splitting into pixels (m has the same signification
    545 //    as for the constructor)
    546 //
    547 //    Each theta-slice of the north hemisphere will be spitted starting f
    548 //    from  phi=0 ...
    549 //
    550 //    South hemisphere is scanned in the same direction according to phi
    551 //    and from equator to the pole (the pixel following the last one of
    552 //    the slice closest to the equator with z>0, is the pixel with lowest
    553 //    phi of the slice closest of the equator with z<0).
    554523//--
    555524{
     
    557526 
    558527  // Decodage et controle des arguments d'appel :
    559   // au moins 2 et au plus 16384 bandes d'un hemisphere en theta
     528  // au moins 2 et au plus 524288 bandes d'un hemisphere en theta
    560529  if (m < 2) m = 2;
    561   if (m > 16384) m = 16384;
     530  if (m > 524288) m = 524288;
    562531 
    563532  // On memorise les arguments d'appel
     
    623592}
    624593
    625 //++
     594
     595/*!   
     596  \brief return a Theta slice information
     597  For a theta-slice with index 'index', return :
     598  the corresponding "theta"
     599  a vector containing the phi's of the pixels of the slice
     600  a vector containing the corresponding values of pixels
     601*/
    626602template <class T>
    627603void SphereThetaPhi<T>::GetThetaSlice(int_4 index,r_8& theta, TVector<r_8>& phi, TVector<T>& value) const
    628 
    629 //    For a theta-slice with index 'index', return :
    630 //    the corresponding "theta"
    631 //    a vector containing the phi's of the pixels of the slice
    632 //    a vector containing the corresponding values of pixels
    633 //--
    634604
    635605{
     
    656626}
    657627
    658 //++
     628/*
     629  \brief return information on a theta slice
     630  For a theta-slice with index 'index', return :
     631  the corresponding "theta"
     632  the corresponding "phi" for first pixel of the slice
     633  a vector containing the indices of the pixels of the slice
     634  (equally distributed in phi)
     635  a vector containing the corresponding values of pixels
     636*/
    659637template <class T>
    660638void SphereThetaPhi<T>::GetThetaSlice(int_4 index,r_8& theta, r_8& phi0,TVector<int_4>& pixelIndices, TVector<T>& value) const
    661 
    662 //    For a theta-slice with index 'index', return :
    663 //    the corresponding "theta"
    664 //    the corresponding "phi" for first pixel of the slice
    665 //    a vector containing the indices of the pixels of the slice
    666 //    (equally distributed in phi)
    667 //    a vector containing the corresponding values of pixels
    668 //--
    669639
    670640{
  • trunk/SophyaLib/SkyMap/spherethetaphi.h

    r2433 r2960  
    2121
    2222// ***************** Class SphereThetaPhi *****************************
    23 /*!    sphere splitted with respect to theta, phi : each hemisphere is
    24     splitted into (m-1) parallels (equator does not enter into account).
    25    This operation defines m slices, each of which is splitted into
    26     equidistant meridians. This splitting is realized in such a way that
    27     all pixels have the same area and are as square as possible.
    28 
    29     One begins with the hemisphere with positive z, starting from the pole
    30     toward the equator. The first pixel is the polar cap ; it is circular
    31     and centered on theta=0.
    32 */
    3323template <class T>
    3424class SphereThetaPhi : public SphericalMap<T>
     
    3828
    3929SphereThetaPhi();
    40 /*!    m is the number of slices in theta on an hemisphere (the polar cap
    41    forms the first slice).
    42     pet is a dummy parameter at the moment.
    43 */
    4430SphereThetaPhi(int_4 m);
    4531SphereThetaPhi(const SphereThetaPhi<T>& s, bool share);
     
    6854
    6955/* retourne le nombre de pixels */
    70 /*!    Return total number of pixels  */
    7156virtual int_4 NbPixels() const;
    7257
    7358/* retourne la valeur du pixel d'indice k */
    74 /*!    Return value of pixel with index k */
    7559virtual T&       PixVal(int_4 k);
    7660virtual T const& PixVal(int_4 k) const;
     
    8367
    8468/* retourne les coordonnees Spheriques du centre du pixel d'indice k */
    85 /*!   Return (theta,phi) coordinates of middle of  pixel with  index k */
    8669virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const;
    8770
    88 /*! Setting pixel values to a constant */
     71/* Setting pixel values to a constant */
    8972virtual T SetPixels(T v);
    9073
    9174/* retourne/fixe l'angle Solide de Pixel   (steradians) */
    92 /*!   Pixel Solid angle  (steradians)
    93 
    94     All the pixels have the same solid angle. The dummy argument is
    95    for compatibility with eventual pixelizations which would not
    96     fulfil this requirement.
    97 */
    9875virtual double PixSolAngle(int_4 dummy=0) const;
    9976 
    10077/* retourne/fixe la valeur du parametre de decoupage m */
     78//! Return the pixelisation parameter (number of slices in a hemisphere)
    10179inline virtual int_4 SizeIndex() const { return( NTheta_); }
    10280
    10381/*  Acces to the DataBlock  */
     82//! Acces to the pixel data NDataBlock<T> object
    10483inline       NDataBlock<T>& DataBlock()       {return pixels_;}
     84//! Acces to the pixel data NDataBlock<T> object (const version)
    10585inline const NDataBlock<T>& DataBlock() const {return pixels_;}
    10686
    10787// ------------- Specific methods  ----------------------
    10888
    109 /*!   re-pixelize the sphere */
    11089virtual void Resize(int_4 m);
    11190
     
    11796
    11897/* Nombre de tranches en theta */
    119 /*!    Return number of theta-slices on the sphere */
     98/*    Return number of theta-slices on the sphere */
    12099uint_4 NbThetaSlices() const;
    121100
     
    125104/* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max  */
    126105/* de la tranche d'indice kt  */
    127 /*!    Return  theta values which limit the slice kt */
    128106void Theta(int_4 kt, double& t1, double& t2);
    129107
    130108/* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp  */
    131109/* dans la tranche d'indice kt  */
    132 /*!   Return values of phi which limit the jp-th pixel of the kt-th slice */
    133110void Phi(int_4 kt, int_4 jp, double& p1, double& p2);
    134111
     
    138115
    139116/* Indice kt de la tranche et indice jp du pixel d'indice k  */
    140 /*!    Return indices kt (theta) and jp (phi) of  pixel with index k */
    141117void ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp);
    142118
    143 /*!    achieve the splitting into pixels (m has the same signification
    144     as for the constructor)
    145 
    146     Each theta-slice of the north hemisphere will be spitted starting f
    147     from  phi=0 ...
    148 
    149     South hemisphere is scanned in the same direction according to phi
    150     and from equator to the pole (the pixel following the last one of
    151     the slice closest to the equator with z>0, is the pixel with lowest
    152     phi of the slice closest of the equator with z<0).
    153 */
    154119void Pixelize(int_4);
    155120
    156 /*!   For a theta-slice with index 'index', return :
    157 
    158    the corresponding "theta"
    159 
    160     a vector containing the phi's of the pixels of the slice
    161 
    162     a vector containing the corresponding values of pixels
    163 */
    164121virtual void GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const;
    165 
    166 /*!   For a theta-slice with index 'index', return :
    167 
    168    the corresponding "theta"
    169 
    170    the corresponding "phi" for first pixel of the slice
    171 
    172     a vector containing indices of the pixels of the slice
    173 
    174    (equally distributed in phi)
    175 
    176     a vector containing the corresponding values of pixels
    177 */
    178122virtual void GetThetaSlice(int_4 index, r_8& theta, r_8& phi0,TVector<int_4>& pixelIndices, TVector<T>& value) const ;
    179123
    180124
    181 /* impression */
     125//! ASCII dump (print) of the pixel map
    182126void print(ostream& os) const;
    183127
     
    331275inline SphereThetaPhi<T> operator - (const SphereThetaPhi<T>& a,const SphereThetaPhi<T>& b)
    332276    { SphereThetaPhi<T> result; result.SetTemp(true);
    333     if (b.IsTemp())  { result.Share(b); result.SubElt(a, true); }
    334     else { result.CloneOrShare(a); result.SubElt(b); }
     277    result.CloneOrShare(a); result.SubElt(b);
    335278    return result; }
    336279
Note: See TracChangeset for help on using the changeset viewer.