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


Ignore:
Timestamp:
Sep 23, 2004, 10:38:41 AM (21 years ago)
Author:
ansari
Message:

Correction pour codage pos theta,phi ds index pour pixels hors couverture de la carte SphereECP - Reza 23/09/2004

File:
1 edited

Legend:

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

    r2620 r2621  
    1515  _phi2 = 2*M_PI;
    1616  _outofmapidx = -99;
     17  _outofmapnphi = 0;
     18  _outofmapntet = 0;
    1719  _outofmappix = 0;
    1820  _outofmapval = 0;
     
    3133  _phi2 = 2*M_PI;
    3234  _outofmapidx = -99;
     35  _outofmapnphi = 0;
     36  _outofmapntet = 0;
    3337  _outofmappix = 0;
    3438  _outofmapval = 0;
     
    4650  _phi2 = 2*M_PI;
    4751  _outofmapidx = -99;
     52  _outofmapnphi = 0;
     53  _outofmapntet = 0;
    4854  _outofmappix = 0;
    4955  _outofmapval = 0;
     
    6773  _phi2 = phi2;
    6874  _outofmapidx = _pixels.Size()+659;
     75  // Reza, 23 sep 2004
     76  // pour des cartes partielles, et des pixels sur la sphere, mais
     77  // en dehors de la couverture, on code le numero de tranche en theta,
     78  // compte a partir de theta=0,phi=0 +  _outofmapidx
     79  // theta -> idx =  _outofmapidx + theta/_dtheta*_outofmapnphi +  _outofmapntet
     80  _outofmapntet = 0;
    6981  _outofmappix = 0;
    7082  _outofmapval = 0;
    7183  _dtheta = (_theta2-_theta1)/ntet;
    7284  _dphi = (_phi2-_phi1)/nphi;
     85
     86  _outofmapntet = M_PI/_dtheta;
     87  _outofmapnphi = 2*M_PI/_dphi;
    7388}
    7489
     
    8398  _phi2 = a._phi2;   
    8499  _outofmapidx = a._outofmapidx;
     100  _outofmapnphi = a._outofmapnphi;
     101  _outofmapntet = a._outofmapntet;
    85102  _outofmappix = a._outofmappix;
    86103  _outofmapval = a._outofmapval;
     
    99116  _phi2 = a._phi2;   
    100117  _outofmapidx = a._outofmapidx;
     118  _outofmapnphi = a._outofmapnphi;
     119  _outofmapntet = a._outofmapntet;
    101120  _outofmappix = a._outofmappix;
    102121  _outofmapval = a._outofmapval;
     
    131150T& SphereECP<T>::PixVal(int_4 k)
    132151{
    133   if ((_partial) && (k==_outofmapidx))   return _outofmappix;
     152  // On pourrait etre plus strict en demandant aussi k<_outofmapidx+_outofmapnphi*_outofmapntet (Reza 23/09/04)
     153  if ((_partial) && (k>=_outofmapidx))   return _outofmappix;
    134154  if((k < 0) || (k >= _pixels.Size()) ) 
    135155     throw RangeCheckError("SphereECP::PIxVal() Pixel index out of range");
     
    140160T const& SphereECP<T>::PixVal(int_4 k)  const
    141161{
    142   if ((_partial) && (k==_outofmapidx))   return _outofmapval;
     162  // On pourrait etre plus strict en demandant aussi k<_outofmapidx+_outofmapnphi*_outofmapntet (Reza 23/09/04)
     163  if ((_partial) && (k>=_outofmapidx))   return _outofmapval;
    143164  if((k < 0) || (k >= _pixels.Size()) ) 
    144165     throw RangeCheckError("SphereECP::PIxVal() Pixel index out of range");
     
    165186  if (_partial) {
    166187    if ( (theta < _theta1) || (theta > _theta2) ||
    167          (phi < _phi1) || (phi > _phi2) )  return _outofmapidx;
     188         (phi < _phi1) || (phi > _phi2) )  return _outofmapidx+theta/_dtheta*_outofmapnphi+phi/_dphi;
    168189  }
    169190  int_4 it = (theta-_theta1)/_dtheta;
     
    175196void  SphereECP<T>::PixThetaPhi(int_4 k, double& theta, double& phi) const
    176197{
    177   if ((_partial) && (k==_outofmapidx)) {
    178     theta = M_PI;
    179     phi = 2*M_PI;
     198  if ((_partial) && (k>=_outofmapidx)) {
     199    theta = (((k-_outofmapidx) / _outofmapnphi)+0.5)*_dtheta;
     200    phi = (((k-_outofmapidx) % _outofmapnphi)+0.5)*_dphi;;
    180201    return;
    181202  }
     
    185206  int_4 it = k / _pixels.SizeX();
    186207  int_4 jp = k % _pixels.SizeX();
    187   theta = _theta1+it*_dtheta;
    188   phi = _phi1*jp*_dphi;
     208  theta = _theta1+(it+0.5)*_dtheta;
     209  phi = _phi1*(jp+0.5)*_dphi;
    189210  return;
    190211}
     
    200221double  SphereECP<T>::PixSolAngle(int_4 k) const
    201222{
    202   if ((k < 0) || (k >= _pixels.Size()))  return (_dtheta*_dphi);
     223  if ((_partial) && (k>=_outofmapidx)) {
     224    double theta = (((k-_outofmapidx) / _outofmapnphi)+0.5)*_dtheta;
     225    return (_dtheta*_dphi*sin(theta));
     226  }
     227  if((k < 0) || (k >= _pixels.Size()) ) 
     228     throw RangeCheckError("SphereECP::PixSolAngle(int_4 k) Pixel index out of range");
     229
    203230  int_4 it = k / _pixels.SizeX();
    204231  double theta = _theta1+it*_dtheta;
     
    229256  _dtheta = (_theta2-_theta1)/m;
    230257  _dphi = (_phi2-_phi1)/mphi;
     258
     259  _outofmapntet = M_PI/_dtheta;
     260  _outofmapnphi = 2*M_PI/_dphi;
    231261  return;
    232262}
     
    245275     throw RangeCheckError("SphereECP::GetThetaSlice() theta index out of range");
    246276
    247   theta = _theta1 + index*_dtheta;
     277  theta = _theta1 + (index+0.5)*_dtheta;
    248278  int_4 nphit = 2.*M_PI/_dphi;
    249279  phi.ReSize(nphit);
     
    252282  int_4 i;
    253283  for(i=0; i<ioff; i++) {
    254     phi(i) = _phi1 + (i-ioff)*_dphi;
     284    phi(i) = _phi1 + (i-ioff+0.5)*_dphi;
    255285    value(i) = _outofmapval;
    256286  }
    257287  for(i=ioff; i<ioff+_pixels.SizeX(); i++) {
    258     phi(i) = _phi1 + (i-ioff)*_dphi;
     288    phi(i) = _phi1 + (i-ioff+0.5)*_dphi;
    259289    value(i) = _pixels(i-ioff,index,0);
    260290  }
    261291  for(i=ioff+_pixels.SizeX(); i<nphit; i++) {
    262     phi(i) = _phi1 + (i-ioff)*_dphi;
     292    phi(i) = _phi1 + (i-ioff+0.5)*_dphi;
    263293    value(i) = _outofmapval;
    264294  }
     
    273303    throw RangeCheckError("SphereECP::GetThetaSlice() theta index out of range");
    274304 
    275   theta = _theta1 + index*_dtheta;
     305  theta = _theta1 + (index+0.5)*_dtheta;
    276306  int_4 ioff = _phi1/_dphi;
    277   phi0 = _phi1 - ioff*_dphi;
     307  phi0 = _phi1 - (ioff-0.5)*_dphi;
    278308
    279309  int_4 nphit = 2.*M_PI/_dphi;
     
    283313  int_4 i;
    284314  for(i=0; i<ioff; i++) {
    285     pixidx(i) =  _outofmapidx;
     315    pixidx(i) = _outofmapidx+theta/_dtheta*_outofmapnphi+phi0/_dphi+i;
    286316    value(i) = _outofmapval;
    287317  }
     
    291321  }
    292322  for(i=ioff+_pixels.SizeX(); i<nphit; i++) {
    293     pixidx(i) =  _outofmapidx;
     323    pixidx(i) = _outofmapidx+theta/_dtheta*_outofmapnphi+phi0/_dphi+i;
    294324    value(i) = _outofmapval;
    295325  }
     
    322352  _phi2 = a._phi2;   
    323353  _outofmapidx = a._outofmapidx;
     354  _outofmapnphi = a._outofmapnphi;
     355  _outofmapntet = a._outofmapntet;
    324356  _outofmappix = a._outofmappix;
    325357  _outofmapval = a._outofmapval;
Note: See TracChangeset for help on using the changeset viewer.