Changeset 2175 in Sophya for trunk/SophyaPI/ProgPI


Ignore:
Timestamp:
Aug 10, 2002, 9:04:07 PM (23 years ago)
Author:
cmv
Message:

tous types de MAP dans skymapmodule
fichier d'exemple skymapmodule.pic cmv 10/8/2002

Location:
trunk/SophyaPI/ProgPI
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/ProgPI/skymapmodule.cc

    r2162 r2175  
    2020#include "sphericaltransformserver.h"
    2121
    22 static bool IsNSideGood(int_4 nside) {
    23  if(nside<=1) return false;
    24  while(nside>1) {if(nside%2!=0) return false; else nside/=2;}
    25  return true;
    26 }
    27 
    2822extern "C" {
    2923  void skymapmodule_init();
     
    3327class skymapmoduleExecutor : public CmdExecutor {
    3428public:
     29  enum {UnKnown=(uint_2) 0,
     30        TypeR8=(uint_2) 16, TypeR4=(uint_2) 32,
     31        Spherical=(uint_2) 1, HealPix=(uint_2) 2, ThetaPhi=(uint_2) 4,
     32        Spherical8=(uint_2) Spherical|TypeR8,
     33        Spherical4=(uint_2) Spherical|TypeR4,
     34        HealPix8  =(uint_2) Spherical|HealPix|TypeR8,
     35        HealPix4  =(uint_2) Spherical|HealPix|TypeR4,
     36        ThetaPhi8 =(uint_2) Spherical|ThetaPhi|TypeR8,
     37        ThetaPhi4 =(uint_2) Spherical|ThetaPhi|TypeR4};
     38
    3539                skymapmoduleExecutor();
    3640  virtual       ~skymapmoduleExecutor();
    3741  virtual int   Execute(string& keyw, vector<string>& args, string& toks);
     42
     43  void TypeMap(vector<string>& tokens);
    3844  void Map2Double(vector<string>& tokens);
     45  void Map2Map(vector<string>& tokens);
    3946  void MapMult(vector<string>& tokens);
    4047  void MapCover(vector<string>& tokens);
     
    5057  void MapOper(vector<string>& tokens);
    5158  void MapStat(vector<string>& tokens);
     59protected:
     60  void SetTypeMap(vector<string>& tokens);
     61  bool IsNSideGood(int_4 nside);
     62  void GetNSideGood(int_4 &nside);
     63  uint_2 typemap(AnyDataObj* obj);
     64
     65  uint_2 DefTypMap;
    5266};
    5367
     
    6074
    6175string hgrp = "SkyMapCmd";
    62 
    63 string kw = "map2double";
    64 string usage = "Convert a float map to a double map";
     76string kw,usage;
     77
     78kw = "settypemap";
     79usage = "Set le type de map par default";
     80usage += "\n   type= H for Healpix (default)";
     81usage += "\n         T for ThetaPhi";
     82usage += "\n Usage: settypemap type";
     83mpiac->RegisterCommand(kw, usage, this, hgrp);
     84
     85kw = "typemap";
     86usage = "Imprime le type de map";
     87usage += "\n Usage: typemap map";
     88mpiac->RegisterCommand(kw, usage, this, hgrp);
     89
     90kw = "map2double";
     91usage = "Convert a float map to a double map";
    6592usage += "\n Usage: map2double map";
     93mpiac->RegisterCommand(kw, usage, this, hgrp);
     94
     95kw = "map2map";
     96usage = "Convert a map into an other map type";
     97usage += "\n   type= H for Healpix";
     98usage += "\n         T for ThetaPhi";
     99usage += "\n   if nside <=1 use nside from map";
     100usage += "\n Usage: map2map map type [nside]";
    66101mpiac->RegisterCommand(kw, usage, this, hgrp);
    67102
     
    89124usage = "Generate SkyMap from Cl";
    90125usage += "\n Usage: cl2map clvec map nside [fwhm]";
     126usage += "\n    (see command settypemap)";
    91127mpiac->RegisterCommand(kw, usage, this, hgrp);
    92128
     
    101137usage = "Generate SkyMap from Alm";
    102138usage += "\n Usage: alm2map almmat map nside";
     139usage += "\n    (see command settypemap)";
    103140mpiac->RegisterCommand(kw, usage, this, hgrp);
    104141
     
    111148usage += "\n    valmsk=value to be written into masked pixels (def=0)";
    112149usage += "\n    valnomsk=value to be written into unmasked pixels (def=1)";
     150usage += "\n          (see command settypemap)";
    113151mpiac->RegisterCommand(kw, usage, this, hgrp);
    114152
     
    165203mpiac->RegisterCommand(kw, usage, this, hgrp);
    166204
     205DefTypMap = HealPix;
    167206}
    168207
     
    176215{
    177216
    178 if(kw == "map2double") {
     217if(kw == "settypemap") {
     218  SetTypeMap(tokens);
     219} else if(kw == "typemap") {
     220  if(tokens.size()<1) {
     221    cout<<"Usage: typemap map"<<endl;
     222    return(0);
     223  }
     224  TypeMap(tokens);
     225} else if(kw == "map2double") {
    179226  if(tokens.size()<1) {
    180227    cout<<"Usage: map2double map"<<endl;
     
    182229  }
    183230  Map2Double(tokens);
     231} else if(kw == "map2map") {
     232  if(tokens.size()<2) {
     233    cout<<"Usage: map2map map type [nside]"<<endl;
     234    return(0);
     235  }
     236  Map2Map(tokens);
    184237} else if(kw == "mapmult") {
    185238  if(tokens.size()<2) {
     
    266319
    267320/* --Methode-- */
     321void skymapmoduleExecutor::TypeMap(vector<string>& tokens)
     322{
     323 NamedObjMgr omg;
     324 AnyDataObj* obj=omg.GetObj(tokens[0]);
     325 uint_2 t = typemap(obj);
     326 if(t==UnKnown)  {cout<<"TypeMap: UnKnown"<<endl; return;}
     327
     328 int nside = 0;
     329 if(t&TypeR8) {
     330   SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
     331   nside = map->SizeIndex();
     332 } else if(t&TypeR4) {
     333   SphericalMap<r_4>* map = dynamic_cast<SphericalMap<r_4>*>(obj);
     334   nside = map->SizeIndex();
     335 }
     336
     337 string dum = "";
     338 if(t==HealPix8)        dum = "SphereHEALPix<r_8>";
     339 else if(t==HealPix4)   dum = "SphereHEALPix<r_4>";
     340 else if(t==ThetaPhi8)  dum = "SphereThetaPhi<r_8>";
     341 else if(t==ThetaPhi4)  dum = "SphereThetaPhi<r_4>";
     342 else if(t==Spherical8) dum = "SphericalMap<r_8>";
     343 else if(t==Spherical4) dum = "SphericalMap<r_4>";
     344
     345 cout<<"TypeMap: "<<dum<<" nside="<<nside<<endl;
     346}
     347
     348/* --Methode-- */
    268349void skymapmoduleExecutor::Map2Double(vector<string>& tokens)
    269350{
     
    274355   return;
    275356 }
    276  SphereHEALPix<r_4>* map = dynamic_cast<SphereHEALPix<r_4>*>(obj);
     357 SphericalMap<r_4>* map = dynamic_cast<SphericalMap<r_4>*>(obj);
    277358 if(map==NULL) {
    278    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_4>"<<endl;
    279    return;
    280  }
     359   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_4>"<<endl;
     360   return;
     361 }
     362 uint_2 t = typemap(obj);
    281363 int_4 nside = map->SizeIndex();
    282  SphereHEALPix<r_8>* map8 = new SphereHEALPix<r_8>(nside);
    283  cout<<"Map2Double: converting to double "<<tokens[0]<<endl;
     364
     365 SphericalMap<r_8>* map8 = NULL;
     366 if(t&HealPix)       map8 = new SphereHEALPix<r_8>(nside);
     367 else if(t&ThetaPhi) map8 = new SphereThetaPhi<r_8>(nside);
     368 else return;
     369
     370 cout<<"Map2Double: converting to double "<<tokens[0]<<" nside="<<nside<<endl;
    284371 for(int_4 i=0;i<map8->NbPixels();i++) (*map8)(i) = (r_8) (*map)(i);
     372
    285373 omg.AddObj(map8,tokens[0]);
    286374}
    287375
    288376/* --Methode-- */
     377void skymapmoduleExecutor::Map2Map(vector<string>& tokens)
     378{
     379 NamedObjMgr omg;
     380 AnyDataObj* obj=omg.GetObj(tokens[0]);
     381 if(obj==NULL) {
     382   cout<<"Error: Pas d'objet de nom "<<tokens[0]<<endl;
     383   return;
     384 }
     385 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
     386 if(map==NULL) {
     387   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
     388   return;
     389 }
     390 uint_2 t = typemap(obj);
     391 int_4 nside = map->SizeIndex();
     392
     393 uint_2 tomap = UnKnown;
     394 if(toupper(tokens[1][0])=='H')      tomap = HealPix;
     395 else if(toupper(tokens[1][0])=='T') tomap = ThetaPhi;
     396 else {cout<<"unkown map type "<<(char)toupper(tokens[1][0])<<" (H or T)!"<<endl; return;}
     397 if(t&tomap) {cout<<"map of same type, no conversion done"<<endl; return;}
     398
     399 int_4 tonside = nside;
     400 if(tokens.size()>2) tonside = atoi(tokens[2].c_str());
     401 else {
     402   if(tomap&HealPix) {tonside=int(nside/1.5); GetNSideGood(tonside);}
     403   else tonside=int(map->NbThetaSlices()/2.5);
     404 }
     405 if(tomap&HealPix && !IsNSideGood(tonside))
     406   {cout<<"Bad nside for Healpix "<<tonside<<endl; return;}
     407
     408 SphericalMap<r_8>* map8 = NULL;
     409 if(tomap&HealPix)       map8 = new SphereHEALPix<r_8>(tonside);
     410 else if(tomap&ThetaPhi) map8 = new SphereThetaPhi<r_8>(tonside);
     411 else return;
     412
     413 cout<<"Map2Map: convert "<<tokens[0]<<" nside="<<nside
     414     <<" to type "<<tokens[1]<<" tonside="<<tonside
     415     <<"   ntheta="<<map->NbThetaSlices()<<" -> "<<map8->NbThetaSlices()<<endl;
     416
     417 for(int_4 i=0;i<map8->NbPixels();i++) {
     418   double theta,phi; map8->PixThetaPhi(i,theta,phi);
     419   int_4 ip = map->PixIndexSph(theta,phi);
     420   if(ip<0 || ip>=map->NbPixels()) continue;
     421   (*map8)(i)=(*map)(ip);
     422 }
     423
     424 omg.AddObj(map8,tokens[0]);
     425}
     426
     427/* --Methode-- */
    289428void skymapmoduleExecutor::MapMult(vector<string>& tokens)
    290429{
     
    295434   return;
    296435 }
    297  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
     436 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
    298437 if(map==NULL) {
    299    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_8>"<<endl;
     438   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
    300439   return;
    301440 }
     
    314453   return;
    315454 }
    316  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
     455 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
    317456 if(map==NULL) {
    318    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_8>"<<endl;
     457   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
    319458   return;
    320459 }
     
    323462 if(tokens.size()>1) if(tokens[1][0]!='!')
    324463   sscanf(tokens[1].c_str(),"%lf,%lf",&v1,&v2);
     464
    325465 cout<<"MapCover: "<<tokens[0]<<" good px=["<<v1<<","<<v2<<"]"<<endl;
     466
    326467 int_4 ngood=0;
    327468 for(int_4 i=0;i<map->NbPixels();i++)
     
    355496   return;
    356497 }
    357  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
     498 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
    358499 if(map==NULL) {
    359    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_8>"<<endl;
    360    return;
    361  }
     500   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
     501   return;
     502 }
     503 uint_2 t = typemap(obj);
    362504
    363505 SphericalTransformServer<r_8> ylmserver;
     
    369511     <<" lmax="<<lmax<<" niter="<<niter<<endl;
    370512
    371  SphereHEALPix<r_8> tmpmap(*map,false);
    372  TVector<r_8> cltmp = ylmserver.DecomposeToCl(tmpmap,lmax,0.,niter);
    373 
    374  TVector<r_8>* cl = new TVector<r_8>(cltmp,false);
    375  omg.AddObj(cl,tokens[1]);
     513 SphericalMap<r_8>* tmpmap = NULL;
     514 if(t&HealPix)       tmpmap = new SphereHEALPix<r_8>(*((SphereHEALPix<r_8>*)map),false);
     515 else if(t&ThetaPhi) tmpmap = new SphereThetaPhi<r_8>(*((SphereThetaPhi<r_8>*)map),false);
     516 else return;
     517
     518 TVector<r_8> cltmp = ylmserver.DecomposeToCl(*tmpmap,lmax,0.,niter);
     519 delete tmpmap;
     520
     521 omg.AddObj(cltmp,tokens[1]);
    376522}
    377523
     
    394540 int nside = 128;
    395541 if(tokens.size()>2) nside = atoi(tokens[2].c_str());
     542 if(DefTypMap&HealPix && !IsNSideGood(nside))
     543   {cout<<"Cl2Map: Bad nside for HealPix "<<nside<<endl; return;}
     544
    396545 double fwhm = 0.;
    397546 if(tokens.size()>3) fwhm = atof(tokens[3].c_str());
    398547
    399  SphereHEALPix<r_8>* map = new SphereHEALPix<r_8>;
     548 SphericalMap<r_8>* map = NULL;
     549 if(DefTypMap&HealPix)       map = new SphereHEALPix<r_8>;
     550 else if(DefTypMap&ThetaPhi) map = new SphereThetaPhi<r_8>;
     551 else return;
    400552
    401553 SphericalTransformServer<r_8> ylmserver;
     
    423575   return;
    424576 }
    425  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
     577 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
    426578 if(map==NULL) {
    427    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_8>"<<endl;
    428    return;
    429  }
     579   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
     580   return;
     581 }
     582 uint_2 t = typemap(obj);
    430583
    431584 SphericalTransformServer<r_8> ylmserver;
     
    437590     <<" lmax="<<lmax<<" niter="<<niter<<endl;
    438591
    439  SphereHEALPix<r_8> tmpmap(*map,false);
     592 SphericalMap<r_8>* tmpmap = NULL;
     593 if(t&HealPix)       tmpmap = new SphereHEALPix<r_8>(*((SphereHEALPix<r_8>*)map),false);
     594 else if(t&ThetaPhi) tmpmap = new SphereThetaPhi<r_8>(*((SphereThetaPhi<r_8>*)map),false);
     595 else return;
     596
    440597 Alm<r_8> almtmp;
    441  ylmserver.DecomposeToAlm(tmpmap,almtmp,lmax,0.,niter);
     598 ylmserver.DecomposeToAlm(*tmpmap,almtmp,lmax,0.,niter);
     599 delete tmpmap;
    442600
    443601 int n = almtmp.rowNumber();
     
    471629 int nside = 128;
    472630 if(tokens.size()>2) nside = atoi(tokens[2].c_str());
    473  SphereHEALPix<r_8>* map = new SphereHEALPix<r_8>;
     631 if(DefTypMap&HealPix && !IsNSideGood(nside))
     632   {cout<<"Alm2Map: Bad nside for HealPix "<<nside<<endl; return;}
     633
     634 SphericalMap<r_8>* map = NULL;
     635 if(DefTypMap&HealPix)       map = new SphereHEALPix<r_8>;
     636 else if(DefTypMap&ThetaPhi) map = new SphereThetaPhi<r_8>;
     637 else return;
    474638
    475639 SphericalTransformServer<r_8> ylmserver;
     
    487651
    488652 int_4 nside = atoi(tokens[1].c_str());
    489  if(!IsNSideGood(nside)) {cout<<"CrMapMask: Bad nside "<<nside<<endl; return;}
    490 
    491  SphereHEALPix<r_8>* map = new SphereHEALPix<r_8>(nside);
     653 if(DefTypMap&HealPix && !IsNSideGood(nside))
     654   {cout<<"CrMapMask: Bad nside "<<nside<<endl; return;}
     655
     656 SphericalMap<r_8>* map = NULL;
     657 if(DefTypMap&HealPix)       map = new SphereHEALPix<r_8>(nside);
     658 else if(DefTypMap&ThetaPhi) map = new SphereThetaPhi<r_8>(nside);
     659 else return;
    492660
    493661 bool lat=false, lon=false;
     
    526694 NamedObjMgr omg;
    527695
     696 AnyDataObj* obj=omg.GetObj(tokens[2]);
     697 if(obj==NULL) {
     698   cout<<"Error: Pas d'objet de nom "<<tokens[2]<<endl;
     699   return;
     700 }
     701 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
     702 if(map==NULL) {
     703   cout<<"Error: "<<tokens[2]<<" is not a SphericalMap<r_8>"<<endl;
     704   return;
     705 }
     706 uint_2 t = typemap(obj);
     707
    528708 int_4 nside = atoi(tokens[1].c_str());
    529709 if(nside<=1) return;
    530  if(!IsNSideGood(nside)) {cout<<"CrMapMask: Bad nside "<<nside<<endl; return;}
    531 
    532  AnyDataObj* obj=omg.GetObj(tokens[2]);
    533  if(obj==NULL) {
    534    cout<<"Error: Pas d'objet de nom "<<tokens[2]<<endl;
    535    return;
    536  }
    537  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
    538  if(map==NULL) {
    539    cout<<"Error: "<<tokens[2]<<" is not a SphereHEALPix<r_8>"<<endl;
    540    return;
    541  }
    542 
    543  SphereHEALPix<r_8>* msk = new SphereHEALPix<r_8>(nside);
     710 if(t&HealPix && !IsNSideGood(nside))
     711   {cout<<"CrMapMask: Bad nside for HealPix "<<nside<<endl; return;}
     712
     713 SphericalMap<r_8>* msk = NULL;
     714 if(t&HealPix)       msk = new SphereHEALPix<r_8>(nside);
     715 else if(t&ThetaPhi) msk = new SphereThetaPhi<r_8>(nside);
     716 else return;
    544717
    545718 double v1=-1.e100, v2=1.e100;
     
    550723 if(tokens.size()>4) sscanf(tokens[4].c_str(),"%lf,%lf",&valmsk,&unvalmsk);
    551724
    552  cout<<"CrMaskFrMap "<<tokens[0]<<" nside"<<nside<<" with "<<tokens[2]<<endl
     725 cout<<"CrMaskFrMap "<<tokens[0]<<" nside="<<nside<<" with "<<tokens[2]<<endl
    553726     <<"   for value in ["<<v1<<","<<v2<<"]"
    554727     <<" valmsk="<<valmsk<<" unvalmsk="<<unvalmsk<<endl;
     
    576749   return;
    577750 }
    578  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
     751 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
    579752 if(map==NULL) {
    580    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_8>"<<endl;
     753   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
    581754   return;
    582755 }
     
    587760   return;
    588761 }
    589  SphereHEALPix<r_8>* msk = dynamic_cast<SphereHEALPix<r_8>*>(objm);
     762 SphericalMap<r_8>* msk = dynamic_cast<SphericalMap<r_8>*>(objm);
    590763 if(msk==NULL) {
    591    cout<<"Error: "<<tokens[1]<<" is not a SphereHEALPix<r_8>"<<endl;
     764   cout<<"Error: "<<tokens[1]<<" is not a SphericalMap<r_8>"<<endl;
    592765   return;
    593766 }
     
    614787   return;
    615788 }
    616  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
     789 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
    617790 if(map==NULL) {
    618    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_8>"<<endl;
     791   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
    619792   return;
    620793 }
    621794 int_4 nsidemap = map->SizeIndex();
     795 uint_2 t = typemap(obj);
    622796
    623797 int_4 nside = nsidemap;
    624798 if(tokens.size()>2) nside = atoi(tokens[2].c_str());
    625  if(!IsNSideGood(nside)) {cout<<"MapProj: Bad nside "<<nside<<endl; return;}
    626 
    627  SphereHEALPix<r_8>* mapproj = new SphereHEALPix<r_8>(nside);
     799 if(t&HealPix && !IsNSideGood(nside))
     800   {cout<<"MapProj: Bad nside for Healpix "<<nside<<endl; return;}
     801
     802 SphericalMap<r_8>* mapproj = NULL;
     803 if(t&HealPix)       mapproj = new SphereHEALPix<r_8>(nside);
     804 else if(t&ThetaPhi) mapproj = new SphereThetaPhi<r_8>(nside);
     805 else return;
     806
     807 cout<<"MapProj: project "<<tokens[0]<<" n="<<nsidemap
     808     <<" to "<<tokens[1]<<" n="<<nside<<endl;
    628809
    629810 if(nsidemap==nside) {  // tailles egales
     
    638819   }
    639820 } else {  // mapproj<map
    640    SphereHEALPix<int_4> nproj(nside);
    641    nproj = 0; *mapproj = 0.;
     821   SphericalMap<int_4>*  nproj= NULL;
     822   if(t&HealPix)       nproj= new SphereHEALPix<int_4>(nside);
     823   else if(t&ThetaPhi) nproj= new SphereThetaPhi<int_4>(nside);
     824   for(int_4 i=0;i<nproj->NbPixels();i++) {(*nproj)(i)=0;(*mapproj)(i)=0.;}
    642825   for(int_4 i=0;i<map->NbPixels();i++) {
    643826     double theta,phi; map->PixThetaPhi(i,theta,phi);
     
    645828     if(ip<0 || ip>=mapproj->NbPixels()) continue;
    646829     (*mapproj)(ip) += (*map)(i);
    647      nproj(ip)++;
     830     (*nproj)(ip)++;
    648831   }
    649832   for(int_4 i=0;i<mapproj->NbPixels();i++)
    650       (*mapproj)(i) /= (r_8) nproj(i);
     833      (*mapproj)(i) /= (r_8) (*nproj)(i);
     834   delete nproj;
    651835 }
    652836 
     
    664848   return;
    665849 }
    666  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
     850 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
    667851 if(map==NULL) {
    668    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_8>"<<endl;
     852   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
    669853   return;
    670854 }
     
    739923   return;
    740924 }
    741  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
     925 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
    742926 if(map==NULL) {
    743    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_8>"<<endl;
     927   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
    744928   return;
    745929 }
     
    753937     {cout<<"Error: Pas d'objet de nom "<<tokens[iop+1]<<endl;
    754938      continue;}
    755    SphereHEALPix<r_8>* map1 = dynamic_cast<SphereHEALPix<r_8>*>(obj1);
     939   SphericalMap<r_8>* map1 = dynamic_cast<SphericalMap<r_8>*>(obj1);
    756940   if(map1==NULL)
    757      {cout<<"Error: "<<tokens[iop+1]<<" is not a SphereHEALPix<r_8>"<<endl;
     941     {cout<<"Error: "<<tokens[iop+1]<<" is not a SphericalMap<r_8>"<<endl;
    758942      continue;}
    759943   cout<<" "<<op<<"= "<<tokens[iop+1];
     
    783967   return;
    784968 }
    785  SphereHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);
     969 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj);
    786970 if(map==NULL) {
    787    cout<<"Error: "<<tokens[0]<<" is not a SphereHEALPix<r_8>"<<endl;
    788    return;
    789  }
    790 
    791  SphereHEALPix<r_8>* msk = NULL;
     971   cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl;
     972   return;
     973 }
     974
     975 SphericalMap<r_8>* msk = NULL;
    792976 if(tokens.size()>1) {
    793977   if(tokens[1][0]!='!') {
     
    797981       return;
    798982     }
    799      msk = dynamic_cast<SphereHEALPix<r_8>*>(objm);
     983     msk = dynamic_cast<SphericalMap<r_8>*>(objm);
    800984     if(msk==NULL) {
    801        cout<<"Error: "<<tokens[1]<<" is not a SphereHEALPix<r_8>"<<endl;
     985       cout<<"Error: "<<tokens[1]<<" is not a SphericalMap<r_8>"<<endl;
    802986       return;
    803987     }
     
    8521036
    8531037////////////////////////////////////////////////////////////
     1038
     1039/* --Methode-- */
     1040void skymapmoduleExecutor::SetTypeMap(vector<string>& tokens)
     1041{
     1042 if(tokens.size()<1) {
     1043   cout<<"SetTypeMap: Usage: settypemap type"<<endl;
     1044 } else {
     1045   if(toupper(tokens[0][0])=='H')      DefTypMap = HealPix;
     1046   else if(toupper(tokens[0][0])=='T') DefTypMap = ThetaPhi;
     1047   else cout<<"unkown map type, should be (H or T)!"<<endl;
     1048 }
     1049 string dum;
     1050 if(DefTypMap&HealPix)       dum="HealPix";
     1051 else if(DefTypMap&ThetaPhi) dum="ThetaPhi";
     1052 cout<<"SetTypeMap: type map is "<<dum<<" ("<<DefTypMap<<")"<<endl;
     1053}
     1054
     1055/* --Methode-- */
     1056bool skymapmoduleExecutor::IsNSideGood(int_4 nside)
     1057{
     1058 if(nside<=1) return false;
     1059 while(nside>1) {if(nside%2!=0) return false; else nside/=2;}
     1060 return true;
     1061}
     1062
     1063/* --Methode-- */
     1064void skymapmoduleExecutor::GetNSideGood(int_4 &nside)
     1065// get the nearest good nside for HealPix
     1066{
     1067 double n=1.e50; int_4 ns=nside;
     1068 for(int_4 i=1;i<66000;i*=2) {
     1069   double v = fabs((double)(nside-i));
     1070   if(v>n) continue;
     1071   n=v; ns=i;
     1072 }
     1073 nside = ns;
     1074}
     1075
     1076/* --Methode-- */
     1077uint_2 skymapmoduleExecutor::typemap(AnyDataObj* obj)
     1078{
     1079  if(obj==NULL) return UnKnown;
     1080  if(dynamic_cast<SphereHEALPix<r_4> *>(obj)) return HealPix4;
     1081  if(dynamic_cast<SphereHEALPix<r_8> *>(obj)) return HealPix8;
     1082  if(dynamic_cast<SphereThetaPhi<r_4>*>(obj)) return ThetaPhi4;
     1083  if(dynamic_cast<SphereThetaPhi<r_8>*>(obj)) return ThetaPhi8;
     1084  if(dynamic_cast<SphericalMap<r_4>  *>(obj)) return Spherical4;
     1085  if(dynamic_cast<SphericalMap<r_8>  *>(obj)) return Spherical8;
     1086  return UnKnown;
     1087}
     1088
     1089////////////////////////////////////////////////////////////
    8541090static skymapmoduleExecutor * piaskmex = NULL;
    8551091
     
    8661102piaskmex = NULL;
    8671103}
    868 
    869 ////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.