Changeset 3506 in Sophya for trunk/SophyaLib/SkyMap/sphereecp.cc


Ignore:
Timestamp:
Aug 8, 2008, 12:52:17 PM (17 years ago)
Author:
ansari
Message:

Ajout SphereECP::ExtractPartial() et correction ds SphereECP::PixThetaPhi() - Reza 08/08/2008

File:
1 edited

Legend:

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

    r2995 r3506  
    99
    1010  Class implementing spherical maps, with a pixelisation
    11   corresponding to the an Equatorial Cylindrical Projection.
     11  corresponding to the an Equatorial Cylindrical Projection (ECP).
    1212  Pixel size varie from equator to poles. The sphere is divided
    1313  into a number of slices along the parallels. Each slice is subdivided
     
    164164}
    165165
     166/*!
     167  \brief Extract a partial map from a full ECP skymap
     168  Theta and Phi limits are adjusted automatically to be correspond to the source map pixel boundaries
     169*/
     170template <class T>
     171SphereECP<T> SphereECP<T>::ExtractPartial(r_8 tet1, r_8 tet2, r_8 phi1, r_8 phi2)
     172{
     173  if (IsPartial())     
     174    throw  ParmError("SphereECP::ExtractPartial() source map NOT a full sky map");
     175  if( (tet1 > M_PI) || (tet1 < 0.) || (tet2 > M_PI) || (tet2 < 0.) ||
     176      (phi1 < 0.) || (phi1 > 2*M_PI) || (phi1 < 0.) || (phi1 > 2*M_PI) ||
     177      (tet2 <= tet1) || (phi2 <= phi1) )
     178    throw  ParmError("SphereECP::ExtractPartial() Bad range for theta/phi limits");
     179
     180// correction/calcul des limites en theta et nombre de rangees en theta 
     181  sa_size_t ntet = (sa_size_t)((tet2-tet1)/_dtheta + 0.5);
     182  sa_size_t offt = (sa_size_t)(tet1/_dtheta + 1e-3);
     183  tet1 = _dtheta*offt;
     184  tet2 = tet1+ntet*_dtheta;
     185// correction/calcul des limites en phi et nombre de colonnes en phi
     186  sa_size_t nphi = (sa_size_t)((phi2-phi1)/_dphi + 0.5);
     187  sa_size_t offp = (sa_size_t)(phi1/_dphi + 1e-3);
     188  phi1 = _dphi*offp;
     189  phi2 = phi1+nphi*_dphi;
     190
     191// On cree une carte partielle avec les bons parametres
     192  SphereECP<T> pmap(tet1, tet2, ntet, phi1, phi2, nphi);
     193// On recopie les valeurs de pixels de la zone correspondante
     194  pmap.GetPixelArray() = _pixels.SubArray(Range(offp, 0, nphi, 0), Range(offt, 0, ntet, 0),
     195                                          Range::first(), Range::first(), Range::first());
     196  return pmap;
     197}
     198
    166199template <class T>
    167200string SphereECP<T>::TypeOfMap() const
     
    242275  int_4 jp = k % _pixels.SizeX();
    243276  theta = _theta1+(it+0.5)*_dtheta;
    244   phi = _phi1*(jp+0.5)*_dphi;
     277  phi = _phi1+(jp+0.5)*_dphi;
    245278  return;
    246279}
Note: See TracChangeset for help on using the changeset viewer.