Changeset 908 in Sophya for trunk/SophyaLib/SkyMap


Ignore:
Timestamp:
Apr 13, 2000, 3:31:18 PM (25 years ago)
Author:
ansari
Message:

divers nettoyages : const. de copie, surcharge = etc.

Location:
trunk/SophyaLib/SkyMap
Files:
8 edited

Legend:

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

    r841 r908  
    9696//--
    9797{
    98   cout<<" LocalMap:: Appel du constructeur de recopie " << endl;
    9998
    10099  if(lm.mInfo_) mInfo_= new DVList(*lm.mInfo_);
     100  recopierVariablesSimples(lm);
     101}
     102
     103//++
     104template<class T>
     105LocalMap<T>::LocalMap(const LocalMap<T>& lm)
     106  : pixels_(lm.pixels_)
     107
     108//
     109//    copy constructor
     110//--
     111{
     112
     113  if(lm.mInfo_) mInfo_= new DVList(*lm.mInfo_);
     114  recopierVariablesSimples(lm);
     115}
     116
     117//++
     118// Titre        Destructor
     119//--
     120//++
     121template<class T>
     122LocalMap<T>::~LocalMap()
     123//
     124//--
     125{
     126  InitNul();
     127}
     128
     129
     130
     131//++
     132// Titre        Public Methods
     133//--
     134
     135//++
     136template<class T>
     137void LocalMap<T>::ReSize(int_4 nx, int_4 ny)
     138//
     139//    Resize storage area for pixels
     140//--
     141{
     142  InitNul();
     143  nSzX_ = nx;
     144  nSzY_ = ny;
     145  nPix_= nx*ny;
     146  pixels_.ReSize(nPix_);
     147  pixels_.Reset();
     148}
     149
     150template<class T>
     151LocalMap<T>& LocalMap<T>::Set(const LocalMap<T>& a)
     152   {
     153  if (this != &a)
     154    {
     155      recopierVariablesSimples(a);     
     156      pixels_.CloneOrShare(a.pixels_);
     157      if (mInfo_) delete mInfo_;
     158      mInfo_ = NULL;
     159      if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
     160    }
     161  return(*this);
     162   }
     163
     164
     165//++
     166template<class T>
     167int_4 LocalMap<T>::NbPixels() const
     168//
     169//    Return number of pixels
     170//--
     171{
     172  return(nPix_);
     173}
     174
     175//++
     176template<class T>
     177T& LocalMap<T>::PixVal(int_4 k)
     178//
     179//    Return value of pixel with index k
     180//--
     181{
     182  if((k < 0) || (k >= nPix_))
     183    {
     184      cout << " LocalMap::PIxVal : exceptions  a mettre en place" <<endl;
     185      //  THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
     186      THROW(rangeCheckErr);
     187      //throw "LocalMap::PIxVal Pixel index out of range";
     188    }
     189  return(pixels_(k));
     190}
     191
     192//++
     193
     194template<class T>
     195T const& LocalMap<T>::PixVal(int_4 k) const
     196//
     197//   const version of previous method
     198//--
     199{
     200  if((k < 0) || (k >= nPix_))
     201    {
     202      cout << " LocalMap::PIxVal : exceptions  a mettre en place" <<endl;
     203      //    THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
     204     
     205      throw "LocalMap::PIxVal Pixel index out of range";
     206    }
     207  return *(pixels_.Data()+k);
     208}
     209
     210template<class T>
     211bool LocalMap<T>::ContainsSph(double theta, double phi) const
     212{
     213// $CHECK$  Reza 11/11/99 - A modifier
     214return(true);
     215}
     216
     217//++
     218template<class T>
     219int_4 LocalMap<T>::PixIndexSph(double theta,double phi) const
     220//
     221//    Return index of the pixel with spherical coordinates (theta,phi)
     222//--
     223{
     224  int_4 i,j;
     225  if(!(originFlag_) || !(extensFlag_))
     226    {
     227      cout << " LocalMap: correspondance carte-sphere non etablie" << endl;
     228      exit(0);
     229    }
     230
     231  // theta et phi en coordonnees relatives (on se ramene a une situation par rapport au plan de reference)
     232  double theta_aux= theta;
     233  double phi_aux  = phi;
     234  UserToReference(theta_aux, phi_aux);
     235
     236  // coordonnees dans le plan local en unites de pixels
     237  double x,y;
     238  AngleProjToPix(theta_aux,phi_aux, x, y);
     239
     240  double xmin= -x0_-0.5;
     241  double xmax= xmin+nSzX_;
     242  if((x > xmax) || (x < xmin)) return(-1);
     243  double xcurrent= xmin;
     244  for(i = 0; i < nSzX_; i++ )
     245    {
     246      xcurrent += 1.;
     247      if( x < xcurrent ) break;
     248    }
     249  double ymin= -y0_-0.5;
     250  double ymax= ymin+nSzY_;
     251  if((y >  ymax) || (y < ymin)) return(-1);
     252  double ycurrent= ymin;
     253  for(j = 0; j < nSzY_; j++ )
     254    {
     255      ycurrent += 1.;
     256      if( y < ycurrent ) break;
     257    }
     258  return (j*nSzX_+i);
     259}
     260
     261//++
     262template<class T>
     263void LocalMap<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const
     264//
     265//    Return (theta, phi) coordinates of pixel with index k
     266//--
     267{
     268  if(!(originFlag_) || !(extensFlag_))
     269    {
     270      cout << " LocalMap: correspondance carte-sphere non etablie" << endl;
     271      exit(0);
     272    }
     273
     274  int_4 i,j;
     275  Getij(k,i,j);
     276
     277  double X= double(i-x0_);
     278  double Y= double(j-y0_);
     279  // situation de ce pixel dans le plan de reference
     280  double x= X*cos_angle_-Y*sin_angle_;
     281  double y= X*sin_angle_+Y* cos_angle_;
     282  // projection sur la sphere
     283  PixProjToAngle(x, y, theta, phi);
     284  // retour au plan utilisateur
     285  ReferenceToUser(theta, phi);
     286}
     287
     288template <class T>
     289T LocalMap<T>::SetPixels(T v)
     290{
     291pixels_.Reset(v);
     292return(v);
     293}
     294 
     295//++
     296template<class T>
     297double LocalMap<T>::PixSolAngle(int_4 k) const
     298//
     299//    Pixel Solid angle  (steradians)
     300//    All the pixels have not necessarly the same size in (theta, phi)
     301//    because of the projection scheme which is not yet fixed.   
     302//--
     303{
     304  int_4 i,j;
     305  Getij(k,i,j);
     306  double X= double(i-x0_);
     307  double Y= double(j-y0_);
     308  double XR= X+double(i)*0.5;
     309  double XL= X-double(i)*0.5;
     310  double YU= Y+double(j)*0.5;
     311  double YL= Y-double(j)*0.5;
     312
     313  // situation  dans le plan de reference
     314  double x0= XL*cos_angle_-YL*sin_angle_;
     315  double y0= XL*sin_angle_+YL*cos_angle_;
     316  double xa= XR*cos_angle_-YL*sin_angle_;
     317  double ya= XR*sin_angle_+YL*cos_angle_;
     318  double xb= XL*cos_angle_-YU*sin_angle_;
     319  double yb= XL*sin_angle_+YU*cos_angle_;
     320
     321  // projection sur la sphere
     322  double thet0,phi0,theta,phia,thetb,phib;
     323  PixProjToAngle(x0, y0, thet0, phi0);
     324  PixProjToAngle(xa, ya, theta, phia);
     325  PixProjToAngle(xb, yb, thetb, phib);
     326
     327  // angle solide
     328  double sol= fabs((xa-x0)*(yb-y0)-(xb-x0)*(ya-y0));
     329  return sol;
     330}
     331
     332//++
     333template<class T>
     334void LocalMap<T>::SetOrigin(double theta0,double phi0,double angle)
     335//
     336//    set the referential of the map (angles in degrees)
     337//    (default x0=siz_x/2,  y0=siz_y/2)
     338//--
     339{
     340  theta0_= theta0;
     341  phi0_  = phi0;
     342  angle_ = angle;
     343  x0_= nSzX_/2;
     344  y0_= nSzY_/2;
     345  cos_angle_= cos(angle*Pi/180.);
     346  sin_angle_= sin(angle*Pi/180.);
     347  originFlag_= true;
     348  cout << " LocalMap:: set origin 1 done" << endl;
     349}
     350 
     351//++
     352template<class T>
     353void LocalMap<T>::SetOrigin(double theta0,double phi0,int_4 x0,int_4 y0,double angle)
     354//
     355//    set the referential of the map (angles in degrees)
     356//--
     357{
     358  theta0_= theta0;
     359  phi0_  = phi0;
     360  angle_ = angle;
     361  x0_= x0;
     362  y0_= y0;
     363  cos_angle_= cos(angle*Pi/180.);
     364  sin_angle_= sin(angle*Pi/180.);
     365  originFlag_= true;
     366  cout << " LocalMap:: set origin 2 done" << endl;
     367}
     368
     369//++
     370template<class T>
     371void LocalMap<T>::SetSize(double angleX,double angleY)
     372//
     373//    angle range of tthe map (angles in degrees)
     374//--
     375{
     376  angleX_= angleX;
     377  angleY_= angleY;
     378
     379  // tangente de la moitie de l'ouverture angulaire totale
     380  tgAngleX_= tan(0.5*angleX_*Pi/180.);
     381  tgAngleY_= tan(0.5*angleY_*Pi/180.);
     382
     383  extensFlag_= true;
     384  cout << " LocalMap:: set extension done" << endl;
     385}
     386
     387//++
     388template<class T>
     389void LocalMap<T>::Project(SphericalMap<T>& sphere) const
     390//
     391//    Projection to a spherical map   
     392//--
     393{
     394  for(int m = 0; m < nPix_; m++)
     395    {
     396      double theta,phi;
     397      PixThetaPhi(m,theta,phi);
     398      sphere(theta,phi)= pixels_(m);
     399      // cout << "theta " << theta << " phi " << phi << " valeur " << sphere(theta,phi)<< endl;
     400    }
     401}
     402// Titre        Private Methods
     403//++
     404template<class T>
     405void LocalMap<T>::InitNul()
     406//
     407//    set some attributes to zero
     408//--
     409{
     410  originFlag_= false;
     411  extensFlag_= false;
     412  cos_angle_= 1.0;
     413  sin_angle_= 0.0;
     414//  pixels_.Reset(); Pas de reset par InitNul (en cas de share) - Reza 20/11/99 $CHECK$
     415}
     416
     417//++
     418template<class T>
     419void LocalMap<T>::Getij(int_4 k,int_4& i,int_4& j) const
     420//
     421//    Return 2 indices corresponding to the pixel number k
     422//--
     423{
     424  i= (k+1)%nSzX_-1;
     425  if(i == -1) i= nSzX_-1;
     426  j= (k-i+2)/nSzX_;
     427}
     428
     429//++
     430template<class T>
     431void  LocalMap<T>::ReferenceToUser(double& theta,double& phi) const
     432//
     433//    Transform a pair of coordinates (theta, phi) given in
     434//    reference coordinates into map coordinates
     435//--     
     436{
     437  if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi)
     438    {
     439      throw "LocalMap::ReferenceToUser (theta,phi) out of range";
     440    }
     441
     442  theta= theta0_*Pi/180.+theta-Pi*0.5;
     443  if(theta < 0.)
     444    {
     445      theta= -theta;
     446      phi += Pi;
     447    }
     448  else
     449    {
     450      if(theta > Pi)
     451        {
     452          theta= 2.*Pi-theta;
     453          phi += Pi;
     454        }
     455    }
     456
     457  phi= phi0_*Pi/180.+phi;
     458  while(phi >= 2.*Pi) phi-= 2.*Pi;
     459
     460  if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi)
     461    {
     462      cout <<  " LocalMap::ReferenceToUser : erreur bizarre dans le transfert a la carte utilisateur " << endl;
     463      cout << " theta= " << theta << " phi= " << phi << endl;
     464      exit(0);
     465    }
     466}
     467
     468//++
     469template<class T>
     470void  LocalMap<T>::UserToReference(double& theta,double& phi) const
     471//
     472//    Transform a pair of coordinates (theta, phi) given in
     473//    map coordinates into reference coordinates
     474//--     
     475{
     476  if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi)
     477    {
     478      cout<<" LocalMap::UserToReference: exceptions a mettre en place" <<endl;
     479      // THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
     480      throw "LocalMap::UserToReference (theta,phi) out of range";
     481    }
     482
     483  double phi1= phi-phi0_*Pi/180.;
     484  if(phi1 < 0.) phi1+= 2.*Pi;
     485
     486  double theta1= theta-theta0_*Pi/180.+Pi*0.5;
     487  if(theta1 < 0.)
     488    {
     489      theta= -theta1;
     490      phi1+= Pi;
     491    }
     492  else
     493    {
     494      if(theta1 > Pi)
     495        {
     496          theta= 2.*Pi-theta1;
     497          phi1+= Pi;
     498        }
     499    }
     500
     501  while(phi1 >= 2.*Pi) phi1-= 2.*Pi;
     502  phi= phi1;
     503  if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi)
     504    {
     505      cout <<  " LocalMap::UserToReference : erreur bizarre dans le transfert a la carte de reference " << endl;
     506      cout << " theta= " << theta << " phi= " << phi << endl;
     507      exit(0);
     508    }
     509}
     510
     511//++
     512template<class T>
     513void LocalMap<T>::PixProjToAngle(double x,double y,double& theta,double& phi) const
     514//
     515// 
     516//    Given coordinates in pixel units in the REFERENCE PLANE, return
     517//    (theta, phi) in "absolute" referential theta=pi/2 ,phi=0.   
     518//--
     519{
     520  theta= Pi*0.5-atan(2.*y*tgAngleY_/(double)nSzY_);
     521  phi= atan2(2.*x*tgAngleX_,(double)nSzX_);
     522  if(phi < 0.) phi += DeuxPi;
     523}
     524
     525//++
     526template<class T>
     527void LocalMap<T>::AngleProjToPix(double theta,double phi,double& x,double& y) const
     528//
     529//    Given coordinates  (theta, phi) in "absolute" referential
     530//    theta=pi/2 ,phi=0  return pixel indices  (i,j) in the REFERENCE PLANE.
     531//--
     532{
     533  if(phi >= Pi) phi-= DeuxPi;
     534  //  y=0.5*mSzY_*cot(theta)/tgAngleY_;  $CHECK-REZA-04/99$
     535  y= 0.5*nSzY_/tan(theta)/tgAngleY_;  // ? cot = 1/tan ? 
     536  x= 0.5*nSzX_*tan(phi)/tgAngleX_;
     537}
     538
     539template<class T>
     540void LocalMap<T>::print(ostream& os) const
     541{
     542  os<<" SzX= "<<nSzX_<<", SzY= "<<nSzY_<<", NPix= "<<nPix_<<endl;
     543  if(LocalMap_isDone())
     544    {
     545      os<<" theta0= "<<theta0_<<", phi0= "<<phi0_<<", angle= "<<angle_<<endl;
     546      os<<" x0= "<<x0_<<", y0= "<<y0_<<endl;
     547      os<<" cos= "<<cos_angle_<<", & sin= "<<sin_angle_<<endl;
     548      os<<" angleX= "<<angleX_<<", angleY= "<<angleY_<<endl;
     549      os<<" tg(angleX)= "<<tgAngleX_<<", tg(angleY)= "<<tgAngleY_<<endl;
     550    }
     551
     552  os << " contenu de pixels : ";
     553  for(int i=0; i < nPix_; i++)
     554    {
     555      if(i%5 == 0) os << endl;
     556      os <<  pixels_(i) <<", ";
     557    }
     558  os << endl;
     559}
     560
     561
     562template<class T>
     563void LocalMap<T>::recopierVariablesSimples(const LocalMap<T>& lm)
     564{
    101565  nSzX_= lm.nSzX_;
    102566  nSzY_= lm.nSzY_;
     
    117581}
    118582
    119 //++
    120 // Titre        Destructor
    121 //--
    122 //++
    123 template<class T>
    124 LocalMap<T>::~LocalMap()
    125 //
    126 //--
    127 {
    128   InitNul();
    129 }
    130 
    131 
    132 
    133 //++
    134 // Titre        Public Methods
    135 //--
    136 
    137 //++
    138 template<class T>
    139 void LocalMap<T>::ReSize(int_4 nx, int_4 ny)
    140 //
    141 //    Resize storage area for pixels
    142 //--
    143 {
    144   InitNul();
    145   nSzX_ = nx;
    146   nSzY_ = ny;
    147   nPix_= nx*ny;
    148   pixels_.ReSize(nPix_);
    149   pixels_.Reset();
    150 }
    151 
    152 //++
    153 template<class T>
    154 int_4 LocalMap<T>::NbPixels() const
    155 //
    156 //    Return number of pixels
    157 //--
    158 {
    159   return(nPix_);
    160 }
    161 
    162 //++
    163 template<class T>
    164 T& LocalMap<T>::PixVal(int_4 k)
    165 //
    166 //    Return value of pixel with index k
    167 //--
    168 {
    169   if((k < 0) || (k >= nPix_))
    170     {
    171       cout << " LocalMap::PIxVal : exceptions  a mettre en place" <<endl;
    172       //  THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
    173       THROW(rangeCheckErr);
    174       //throw "LocalMap::PIxVal Pixel index out of range";
    175     }
    176   return(pixels_(k));
    177 }
    178 
    179 //++
    180 
    181 template<class T>
    182 T const& LocalMap<T>::PixVal(int_4 k) const
    183 //
    184 //   const version of previous method
    185 //--
    186 {
    187   if((k < 0) || (k >= nPix_))
    188     {
    189       cout << " LocalMap::PIxVal : exceptions  a mettre en place" <<endl;
    190       //    THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
    191      
    192       throw "LocalMap::PIxVal Pixel index out of range";
    193     }
    194   return *(pixels_.Data()+k);
    195 }
    196 
    197 template<class T>
    198 bool LocalMap<T>::ContainsSph(double theta, double phi) const
    199 {
    200 // $CHECK$  Reza 11/11/99 - A modifier
    201 return(true);
    202 }
    203 
    204 //++
    205 template<class T>
    206 int_4 LocalMap<T>::PixIndexSph(double theta,double phi) const
    207 //
    208 //    Return index of the pixel with spherical coordinates (theta,phi)
    209 //--
    210 {
    211   int_4 i,j;
    212   if(!(originFlag_) || !(extensFlag_))
    213     {
    214       cout << " LocalMap: correspondance carte-sphere non etablie" << endl;
    215       exit(0);
    216     }
    217 
    218   // theta et phi en coordonnees relatives (on se ramene a une situation par rapport au plan de reference)
    219   double theta_aux= theta;
    220   double phi_aux  = phi;
    221   UserToReference(theta_aux, phi_aux);
    222 
    223   // coordonnees dans le plan local en unites de pixels
    224   double x,y;
    225   AngleProjToPix(theta_aux,phi_aux, x, y);
    226 
    227   double xmin= -x0_-0.5;
    228   double xmax= xmin+nSzX_;
    229   if((x > xmax) || (x < xmin)) return(-1);
    230   double xcurrent= xmin;
    231   for(i = 0; i < nSzX_; i++ )
    232     {
    233       xcurrent += 1.;
    234       if( x < xcurrent ) break;
    235     }
    236   double ymin= -y0_-0.5;
    237   double ymax= ymin+nSzY_;
    238   if((y >  ymax) || (y < ymin)) return(-1);
    239   double ycurrent= ymin;
    240   for(j = 0; j < nSzY_; j++ )
    241     {
    242       ycurrent += 1.;
    243       if( y < ycurrent ) break;
    244     }
    245   return (j*nSzX_+i);
    246 }
    247 
    248 //++
    249 template<class T>
    250 void LocalMap<T>::PixThetaPhi(int_4 k,double& theta,double& phi) const
    251 //
    252 //    Return (theta, phi) coordinates of pixel with index k
    253 //--
    254 {
    255   if(!(originFlag_) || !(extensFlag_))
    256     {
    257       cout << " LocalMap: correspondance carte-sphere non etablie" << endl;
    258       exit(0);
    259     }
    260 
    261   int_4 i,j;
    262   Getij(k,i,j);
    263 
    264   double X= double(i-x0_);
    265   double Y= double(j-y0_);
    266   // situation de ce pixel dans le plan de reference
    267   double x= X*cos_angle_-Y*sin_angle_;
    268   double y= X*sin_angle_+Y* cos_angle_;
    269   // projection sur la sphere
    270   PixProjToAngle(x, y, theta, phi);
    271   // retour au plan utilisateur
    272   ReferenceToUser(theta, phi);
    273 }
    274 
    275 template <class T>
    276 T LocalMap<T>::SetPixels(T v)
    277 {
    278 pixels_.Reset(v);
    279 return(v);
    280 }
    281  
    282 //++
    283 template<class T>
    284 double LocalMap<T>::PixSolAngle(int_4 k) const
    285 //
    286 //    Pixel Solid angle  (steradians)
    287 //    All the pixels have not necessarly the same size in (theta, phi)
    288 //    because of the projection scheme which is not yet fixed.   
    289 //--
    290 {
    291   int_4 i,j;
    292   Getij(k,i,j);
    293   double X= double(i-x0_);
    294   double Y= double(j-y0_);
    295   double XR= X+double(i)*0.5;
    296   double XL= X-double(i)*0.5;
    297   double YU= Y+double(j)*0.5;
    298   double YL= Y-double(j)*0.5;
    299 
    300   // situation  dans le plan de reference
    301   double x0= XL*cos_angle_-YL*sin_angle_;
    302   double y0= XL*sin_angle_+YL*cos_angle_;
    303   double xa= XR*cos_angle_-YL*sin_angle_;
    304   double ya= XR*sin_angle_+YL*cos_angle_;
    305   double xb= XL*cos_angle_-YU*sin_angle_;
    306   double yb= XL*sin_angle_+YU*cos_angle_;
    307 
    308   // projection sur la sphere
    309   double thet0,phi0,theta,phia,thetb,phib;
    310   PixProjToAngle(x0, y0, thet0, phi0);
    311   PixProjToAngle(xa, ya, theta, phia);
    312   PixProjToAngle(xb, yb, thetb, phib);
    313 
    314   // angle solide
    315   double sol= fabs((xa-x0)*(yb-y0)-(xb-x0)*(ya-y0));
    316   return sol;
    317 }
    318 
    319 //++
    320 template<class T>
    321 void LocalMap<T>::SetOrigin(double theta0,double phi0,double angle)
    322 //
    323 //    set the referential of the map (angles in degrees)
    324 //    (default x0=siz_x/2,  y0=siz_y/2)
    325 //--
    326 {
    327   theta0_= theta0;
    328   phi0_  = phi0;
    329   angle_ = angle;
    330   x0_= nSzX_/2;
    331   y0_= nSzY_/2;
    332   cos_angle_= cos(angle*Pi/180.);
    333   sin_angle_= sin(angle*Pi/180.);
    334   originFlag_= true;
    335   cout << " LocalMap:: set origin 1 done" << endl;
    336 }
    337  
    338 //++
    339 template<class T>
    340 void LocalMap<T>::SetOrigin(double theta0,double phi0,int_4 x0,int_4 y0,double angle)
    341 //
    342 //    set the referential of the map (angles in degrees)
    343 //--
    344 {
    345   theta0_= theta0;
    346   phi0_  = phi0;
    347   angle_ = angle;
    348   x0_= x0;
    349   y0_= y0;
    350   cos_angle_= cos(angle*Pi/180.);
    351   sin_angle_= sin(angle*Pi/180.);
    352   originFlag_= true;
    353   cout << " LocalMap:: set origin 2 done" << endl;
    354 }
    355 
    356 //++
    357 template<class T>
    358 void LocalMap<T>::SetSize(double angleX,double angleY)
    359 //
    360 //    angle range of tthe map (angles in degrees)
    361 //--
    362 {
    363   angleX_= angleX;
    364   angleY_= angleY;
    365 
    366   // tangente de la moitie de l'ouverture angulaire totale
    367   tgAngleX_= tan(0.5*angleX_*Pi/180.);
    368   tgAngleY_= tan(0.5*angleY_*Pi/180.);
    369 
    370   extensFlag_= true;
    371   cout << " LocalMap:: set extension done" << endl;
    372 }
    373 
    374 //++
    375 template<class T>
    376 void LocalMap<T>::Project(SphericalMap<T>& sphere) const
    377 //
    378 //    Projection to a spherical map   
    379 //--
    380 {
    381   for(int m = 0; m < nPix_; m++)
    382     {
    383       double theta,phi;
    384       PixThetaPhi(m,theta,phi);
    385       sphere(theta,phi)= pixels_(m);
    386       // cout << "theta " << theta << " phi " << phi << " valeur " << sphere(theta,phi)<< endl;
    387     }
    388 }
    389 // Titre        Private Methods
    390 //++
    391 template<class T>
    392 void LocalMap<T>::InitNul()
    393 //
    394 //    set some attributes to zero
    395 //--
    396 {
    397   originFlag_= false;
    398   extensFlag_= false;
    399   cos_angle_= 1.0;
    400   sin_angle_= 0.0;
    401 //  pixels_.Reset(); Pas de reset par InitNul (en cas de share) - Reza 20/11/99 $CHECK$
    402 }
    403 
    404 //++
    405 template<class T>
    406 void LocalMap<T>::Getij(int_4 k,int_4& i,int_4& j) const
    407 //
    408 //    Return 2 indices corresponding to the pixel number k
    409 //--
    410 {
    411   i= (k+1)%nSzX_-1;
    412   if(i == -1) i= nSzX_-1;
    413   j= (k-i+2)/nSzX_;
    414 }
    415 
    416 //++
    417 template<class T>
    418 void  LocalMap<T>::ReferenceToUser(double& theta,double& phi) const
    419 //
    420 //    Transform a pair of coordinates (theta, phi) given in
    421 //    reference coordinates into map coordinates
    422 //--     
    423 {
    424   if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi)
    425     {
    426       throw "LocalMap::ReferenceToUser (theta,phi) out of range";
    427     }
    428 
    429   theta= theta0_*Pi/180.+theta-Pi*0.5;
    430   if(theta < 0.)
    431     {
    432       theta= -theta;
    433       phi += Pi;
    434     }
    435   else
    436     {
    437       if(theta > Pi)
    438         {
    439           theta= 2.*Pi-theta;
    440           phi += Pi;
    441         }
    442     }
    443 
    444   phi= phi0_*Pi/180.+phi;
    445   while(phi >= 2.*Pi) phi-= 2.*Pi;
    446 
    447   if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi)
    448     {
    449       cout <<  " LocalMap::ReferenceToUser : erreur bizarre dans le transfert a la carte utilisateur " << endl;
    450       cout << " theta= " << theta << " phi= " << phi << endl;
    451       exit(0);
    452     }
    453 }
    454 
    455 //++
    456 template<class T>
    457 void  LocalMap<T>::UserToReference(double& theta,double& phi) const
    458 //
    459 //    Transform a pair of coordinates (theta, phi) given in
    460 //    map coordinates into reference coordinates
    461 //--     
    462 {
    463   if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi)
    464     {
    465       cout<<" LocalMap::UserToReference: exceptions a mettre en place" <<endl;
    466       // THROW(out_of_range("LocalMap::PIxVal Pixel index out of range"));
    467       throw "LocalMap::UserToReference (theta,phi) out of range";
    468     }
    469 
    470   double phi1= phi-phi0_*Pi/180.;
    471   if(phi1 < 0.) phi1+= 2.*Pi;
    472 
    473   double theta1= theta-theta0_*Pi/180.+Pi*0.5;
    474   if(theta1 < 0.)
    475     {
    476       theta= -theta1;
    477       phi1+= Pi;
    478     }
    479   else
    480     {
    481       if(theta1 > Pi)
    482         {
    483           theta= 2.*Pi-theta1;
    484           phi1+= Pi;
    485         }
    486     }
    487 
    488   while(phi1 >= 2.*Pi) phi1-= 2.*Pi;
    489   phi= phi1;
    490   if(theta > Pi || theta < 0. || phi < 0. || phi >= 2*Pi)
    491     {
    492       cout <<  " LocalMap::UserToReference : erreur bizarre dans le transfert a la carte de reference " << endl;
    493       cout << " theta= " << theta << " phi= " << phi << endl;
    494       exit(0);
    495     }
    496 }
    497 
    498 //++
    499 template<class T>
    500 void LocalMap<T>::PixProjToAngle(double x,double y,double& theta,double& phi) const
    501 //
    502 // 
    503 //    Given coordinates in pixel units in the REFERENCE PLANE, return
    504 //    (theta, phi) in "absolute" referential theta=pi/2 ,phi=0.   
    505 //--
    506 {
    507   theta= Pi*0.5-atan(2.*y*tgAngleY_/(double)nSzY_);
    508   phi= atan2(2.*x*tgAngleX_,(double)nSzX_);
    509   if(phi < 0.) phi += DeuxPi;
    510 }
    511 
    512 //++
    513 template<class T>
    514 void LocalMap<T>::AngleProjToPix(double theta,double phi,double& x,double& y) const
    515 //
    516 //    Given coordinates  (theta, phi) in "absolute" referential
    517 //    theta=pi/2 ,phi=0  return pixel indices  (i,j) in the REFERENCE PLANE.
    518 //--
    519 {
    520   if(phi >= Pi) phi-= DeuxPi;
    521   //  y=0.5*mSzY_*cot(theta)/tgAngleY_;  $CHECK-REZA-04/99$
    522   y= 0.5*nSzY_/tan(theta)/tgAngleY_;  // ? cot = 1/tan ? 
    523   x= 0.5*nSzX_*tan(phi)/tgAngleX_;
    524 }
    525 
    526 template<class T>
    527 void LocalMap<T>::print(ostream& os) const
    528 {
    529   os<<" SzX= "<<nSzX_<<", SzY= "<<nSzY_<<", NPix= "<<nPix_<<endl;
    530   if(LocalMap_isDone())
    531     {
    532       os<<" theta0= "<<theta0_<<", phi0= "<<phi0_<<", angle= "<<angle_<<endl;
    533       os<<" x0= "<<x0_<<", y0= "<<y0_<<endl;
    534       os<<" cos= "<<cos_angle_<<", & sin= "<<sin_angle_<<endl;
    535       os<<" angleX= "<<angleX_<<", angleY= "<<angleY_<<endl;
    536       os<<" tg(angleX)= "<<tgAngleX_<<", tg(angleY)= "<<tgAngleY_<<endl;
    537     }
    538 
    539   os << " contenu de pixels : ";
    540   for(int i=0; i < nPix_; i++)
    541     {
    542       if(i%5 == 0) os << endl;
    543       os <<  pixels_(i) <<", ";
    544     }
    545   os << endl;
    546 }
     583
    547584//++
    548585// Titre        class FIO_LocalMap
  • trunk/SophyaLib/SkyMap/localmap.h

    r841 r908  
    7272LocalMap(int_4 nx, int_4 ny);
    7373LocalMap(const LocalMap<T>& lm, bool share=false);
     74LocalMap(const LocalMap<T>& lm);
    7475virtual ~LocalMap();
    7576
     77inline virtual bool IsTemp(void) const { return pixels_.IsTemp();}
    7678/*! Setting blockdata to temporary (see ndatablock documentation) */
    7779inline virtual void SetTemp(bool temp=false) const {pixels_.SetTemp(temp);};
     
    166168void print(ostream& os) const;
    167169
     170inline  LocalMap<T>& operator = (const LocalMap<T>& a) {return Set(a);}
     171
     172
     173
    168174// ---------- Méthodes internes -----------------------------
    169175         
     
    189195*/
    190196void AngleProjToPix(double theta,double phi,double& x,double& y) const;
     197
     198void recopierVariablesSimples(const LocalMap<T>& lm);
     199LocalMap<T>& Set(const LocalMap<T>& a);
     200
    191201
    192202// ---------- Variables internes ----------------------------
  • trunk/SophyaLib/SkyMap/pixelmap.h

    r764 r908  
    1919\endverbatim
    2020*/
     21
     22
     23namespace SOPHYA {
     24
     25
     26
     27
    2128template<class T>
    2229class PixelMap  : public AnyDataObj
     
    136143}
    137144
     145
     146} // Fin du namespace
     147
    138148#endif
  • trunk/SophyaLib/SkyMap/spherehealpix.cc

    r906 r908  
    246246void SphereHEALPix<T>::CloneOrShare(const SphereHEALPix<T>& a)
    247247{
    248   string exmsg = "SphereHEALPix<T>::CloneOrShare()";
    249   if (nSide_ != a.nSide_ )
    250     {
    251       cout << " spheres of different sizes " << endl;
    252       string exmsg = "SphereHEALPix<T>::CloneOrShare()";
    253       throw( ParmError(exmsg) );
    254     }
    255248  pixels_.CloneOrShare(a.pixels_);
    256249  sliceBeginIndex_.CloneOrShare(a.sliceBeginIndex_);
     
    263256  if (this != &a)
    264257    {
    265       CloneOrShare(a);
    266258      nSide_= a.nSide_;
    267259     nPix_ = a.nPix_;
    268260     omeg_ = a.omeg_;
     261     CloneOrShare(a);
    269262     if (mInfo_) delete mInfo_;
     263     mInfo_ = NULL;
    270264     if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
    271265    }
  • trunk/SophyaLib/SkyMap/spherehealpix.h

    r906 r908  
    8484virtual ~SphereHEALPix();
    8585
     86  // Temporaire?
     87inline virtual bool   IsTemp(void) const {
     88
     89    if (sliceBeginIndex_.IsTemp() != pixels_.IsTemp() || sliceLenght_.IsTemp() != pixels_.IsTemp() )
     90      throw PException(" l'etat 'temporaire' de la spherehealpix est incoherent");
     91    return pixels_.IsTemp();
     92}
    8693/*! Setting blockdata to temporary (see ndatablock documentation) */
    8794inline virtual void SetTemp(bool temp=false) const
     
    206213
    207214
    208  void CloneOrShare(const SphereHEALPix<T>& a);
    209 
    210  SphereHEALPix<T>& Set(const SphereHEALPix<T>& a);
    211215
    212216inline  SphereHEALPix<T>& operator = (const SphereHEALPix<T>& a)
     
    233237  }
    234238
     239 void CloneOrShare(const SphereHEALPix<T>& a);
     240 SphereHEALPix<T>& Set(const SphereHEALPix<T>& a);
     241
    235242// ------------- variables internes -----------------------
    236243
  • trunk/SophyaLib/SkyMap/spherethetaphi.cc

    r840 r908  
    6464template <class T>
    6565SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s, bool share)
    66   : pixels_(s.pixels_ , share)
     66  : NPhi_(s.NPhi_, share), TNphi_(s.TNphi_, share), Theta_(s.Theta_, share),
     67    pixels_(s.pixels_ , share)
    6768{
    6869  if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
     70
    6971  NTheta_= s.NTheta_;
    7072  NPix_  = s.NPix_;
    71   NPhi_.ReSize(NTheta_);
    72   Theta_.ReSize(NTheta_+1);
    73   TNphi_.ReSize(NTheta_+1);
    74 
    75   NPhi_  = s.NPhi_;
    76   TNphi_ = s.TNphi_;
    77   Theta_ = s.Theta_;
     73  Omega_ = s.Omega_;
     74}
     75
     76template <class T>
     77SphereThetaPhi<T>::SphereThetaPhi(const SphereThetaPhi<T>& s)
     78  : NPhi_(s.NPhi_), TNphi_(s.TNphi_), Theta_(s.Theta_), pixels_(s.pixels_)
     79{
     80  if(s.mInfo_) mInfo_= new DVList(*s.mInfo_);
     81
     82  NTheta_= s.NTheta_;
     83  NPix_  = s.NPix_;
    7884  Omega_ = s.Omega_;
    7985}
     
    111117  Pixelize(m);
    112118}
     119
     120template<class T>
     121void  SphereThetaPhi<T>::CloneOrShare(const  SphereThetaPhi<T>& a)
     122{
     123
     124    NPhi_.CloneOrShare(a.NPhi_);
     125    TNphi_.CloneOrShare(a.TNphi_);
     126    Theta_.CloneOrShare(a.Theta_);
     127    pixels_.CloneOrShare(a.pixels_);
     128}
     129
     130template<class T>
     131SphereThetaPhi<T>& SphereThetaPhi<T>::Set(const SphereThetaPhi<T>& a)
     132   {
     133  if (this != &a)
     134    {
     135
     136
     137      NTheta_= a.NTheta_;
     138      NPix_  = a.NPix_;
     139      Omega_ = a.Omega_;
     140      CloneOrShare(a);
     141      if (mInfo_) delete mInfo_;
     142      mInfo_ = NULL;
     143      if (a.mInfo_) mInfo_ = new DVList(*(a.mInfo_));
     144    }
     145  return(*this);
     146   }
     147
     148
    113149
    114150/* --Methode-- */
  • trunk/SophyaLib/SkyMap/spherethetaphi.h

    r840 r908  
    4242*/
    4343SphereThetaPhi(int_4 m);
    44 SphereThetaPhi(const SphereThetaPhi<T>& s, bool share=false);
     44SphereThetaPhi(const SphereThetaPhi<T>& s, bool share);
     45SphereThetaPhi(const SphereThetaPhi<T>& s);
    4546virtual ~SphereThetaPhi();
    4647
     48  // Temporaire?
     49inline virtual bool IsTemp(void) const {
     50
     51    if (  NPhi_.IsTemp()  != pixels_.IsTemp() ||
     52          TNphi_.IsTemp() != pixels_.IsTemp()||
     53          Theta_.IsTemp() != pixels_.IsTemp()    )
     54      throw PException(" l'etat 'temporaire' de la spherethetaphi est incoherent");
     55    return pixels_.IsTemp();
     56}
    4757/*! Setting blockdata to temporary (see ndatablock documentation) */
    48 inline virtual void SetTemp(bool temp=false) const {pixels_.SetTemp(temp);};
     58inline virtual void SetTemp(bool temp=false) const
     59  {
     60    NPhi_.SetTemp(temp);
     61    TNphi_.SetTemp(temp);
     62    Theta_.SetTemp(temp);
     63    pixels_.SetTemp(temp);
     64  };
    4965
    5066// ------------ Definition of PixelMap abstract methods -
     
    164180/* impression */
    165181void print(ostream& os) const;
     182
     183inline  SphereThetaPhi<T>& operator = (const SphereThetaPhi<T>& a)
     184                                                       {return Set(a);}
     185
    166186
    167187private :
     
    175195    NTheta_= nbThetaIndex;
    176196  }
     197void CloneOrShare(const SphereThetaPhi<T>& a);
     198
     199SphereThetaPhi<T>& Set(const SphereThetaPhi<T>& a);
    177200
    178201// ------------- variables internes ---------------------
  • trunk/SophyaLib/SkyMap/sphericalmap.h

    r783 r908  
    1616//         SphereIco
    1717//      LocalMap
     18
     19
     20
     21
     22namespace SOPHYA {
     23
     24
    1825
    1926template<class T>
     
    3946virtual void GetThetaSlice(int_4 sliceIndex, r_8& theta, r_8& phi0, TVector<int_4>& pixelIndices,TVector<T>& value) const=0 ;
    4047};
     48
     49
     50} // Fin du namespace
     51
     52
     53
     54
    4155#endif
    4256
Note: See TracChangeset for help on using the changeset viewer.