Changeset 2175 in Sophya for trunk/SophyaPI
- Timestamp:
- Aug 10, 2002, 9:04:07 PM (23 years ago)
- Location:
- trunk/SophyaPI/ProgPI
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/ProgPI/skymapmodule.cc
r2162 r2175 20 20 #include "sphericaltransformserver.h" 21 21 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 28 22 extern "C" { 29 23 void skymapmodule_init(); … … 33 27 class skymapmoduleExecutor : public CmdExecutor { 34 28 public: 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 35 39 skymapmoduleExecutor(); 36 40 virtual ~skymapmoduleExecutor(); 37 41 virtual int Execute(string& keyw, vector<string>& args, string& toks); 42 43 void TypeMap(vector<string>& tokens); 38 44 void Map2Double(vector<string>& tokens); 45 void Map2Map(vector<string>& tokens); 39 46 void MapMult(vector<string>& tokens); 40 47 void MapCover(vector<string>& tokens); … … 50 57 void MapOper(vector<string>& tokens); 51 58 void MapStat(vector<string>& tokens); 59 protected: 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; 52 66 }; 53 67 … … 60 74 61 75 string hgrp = "SkyMapCmd"; 62 63 string kw = "map2double"; 64 string usage = "Convert a float map to a double map"; 76 string kw,usage; 77 78 kw = "settypemap"; 79 usage = "Set le type de map par default"; 80 usage += "\n type= H for Healpix (default)"; 81 usage += "\n T for ThetaPhi"; 82 usage += "\n Usage: settypemap type"; 83 mpiac->RegisterCommand(kw, usage, this, hgrp); 84 85 kw = "typemap"; 86 usage = "Imprime le type de map"; 87 usage += "\n Usage: typemap map"; 88 mpiac->RegisterCommand(kw, usage, this, hgrp); 89 90 kw = "map2double"; 91 usage = "Convert a float map to a double map"; 65 92 usage += "\n Usage: map2double map"; 93 mpiac->RegisterCommand(kw, usage, this, hgrp); 94 95 kw = "map2map"; 96 usage = "Convert a map into an other map type"; 97 usage += "\n type= H for Healpix"; 98 usage += "\n T for ThetaPhi"; 99 usage += "\n if nside <=1 use nside from map"; 100 usage += "\n Usage: map2map map type [nside]"; 66 101 mpiac->RegisterCommand(kw, usage, this, hgrp); 67 102 … … 89 124 usage = "Generate SkyMap from Cl"; 90 125 usage += "\n Usage: cl2map clvec map nside [fwhm]"; 126 usage += "\n (see command settypemap)"; 91 127 mpiac->RegisterCommand(kw, usage, this, hgrp); 92 128 … … 101 137 usage = "Generate SkyMap from Alm"; 102 138 usage += "\n Usage: alm2map almmat map nside"; 139 usage += "\n (see command settypemap)"; 103 140 mpiac->RegisterCommand(kw, usage, this, hgrp); 104 141 … … 111 148 usage += "\n valmsk=value to be written into masked pixels (def=0)"; 112 149 usage += "\n valnomsk=value to be written into unmasked pixels (def=1)"; 150 usage += "\n (see command settypemap)"; 113 151 mpiac->RegisterCommand(kw, usage, this, hgrp); 114 152 … … 165 203 mpiac->RegisterCommand(kw, usage, this, hgrp); 166 204 205 DefTypMap = HealPix; 167 206 } 168 207 … … 176 215 { 177 216 178 if(kw == "map2double") { 217 if(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") { 179 226 if(tokens.size()<1) { 180 227 cout<<"Usage: map2double map"<<endl; … … 182 229 } 183 230 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); 184 237 } else if(kw == "mapmult") { 185 238 if(tokens.size()<2) { … … 266 319 267 320 /* --Methode-- */ 321 void 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-- */ 268 349 void skymapmoduleExecutor::Map2Double(vector<string>& tokens) 269 350 { … … 274 355 return; 275 356 } 276 Spher eHEALPix<r_4>* map = dynamic_cast<SphereHEALPix<r_4>*>(obj);357 SphericalMap<r_4>* map = dynamic_cast<SphericalMap<r_4>*>(obj); 277 358 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); 281 363 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; 284 371 for(int_4 i=0;i<map8->NbPixels();i++) (*map8)(i) = (r_8) (*map)(i); 372 285 373 omg.AddObj(map8,tokens[0]); 286 374 } 287 375 288 376 /* --Methode-- */ 377 void 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-- */ 289 428 void skymapmoduleExecutor::MapMult(vector<string>& tokens) 290 429 { … … 295 434 return; 296 435 } 297 Spher eHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);436 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj); 298 437 if(map==NULL) { 299 cout<<"Error: "<<tokens[0]<<" is not a Spher eHEALPix<r_8>"<<endl;438 cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl; 300 439 return; 301 440 } … … 314 453 return; 315 454 } 316 Spher eHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);455 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj); 317 456 if(map==NULL) { 318 cout<<"Error: "<<tokens[0]<<" is not a Spher eHEALPix<r_8>"<<endl;457 cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl; 319 458 return; 320 459 } … … 323 462 if(tokens.size()>1) if(tokens[1][0]!='!') 324 463 sscanf(tokens[1].c_str(),"%lf,%lf",&v1,&v2); 464 325 465 cout<<"MapCover: "<<tokens[0]<<" good px=["<<v1<<","<<v2<<"]"<<endl; 466 326 467 int_4 ngood=0; 327 468 for(int_4 i=0;i<map->NbPixels();i++) … … 355 496 return; 356 497 } 357 Spher eHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);498 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj); 358 499 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); 362 504 363 505 SphericalTransformServer<r_8> ylmserver; … … 369 511 <<" lmax="<<lmax<<" niter="<<niter<<endl; 370 512 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]); 376 522 } 377 523 … … 394 540 int nside = 128; 395 541 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 396 545 double fwhm = 0.; 397 546 if(tokens.size()>3) fwhm = atof(tokens[3].c_str()); 398 547 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; 400 552 401 553 SphericalTransformServer<r_8> ylmserver; … … 423 575 return; 424 576 } 425 Spher eHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);577 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj); 426 578 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); 430 583 431 584 SphericalTransformServer<r_8> ylmserver; … … 437 590 <<" lmax="<<lmax<<" niter="<<niter<<endl; 438 591 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 440 597 Alm<r_8> almtmp; 441 ylmserver.DecomposeToAlm(tmpmap,almtmp,lmax,0.,niter); 598 ylmserver.DecomposeToAlm(*tmpmap,almtmp,lmax,0.,niter); 599 delete tmpmap; 442 600 443 601 int n = almtmp.rowNumber(); … … 471 629 int nside = 128; 472 630 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; 474 638 475 639 SphericalTransformServer<r_8> ylmserver; … … 487 651 488 652 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; 492 660 493 661 bool lat=false, lon=false; … … 526 694 NamedObjMgr omg; 527 695 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 528 708 int_4 nside = atoi(tokens[1].c_str()); 529 709 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; 544 717 545 718 double v1=-1.e100, v2=1.e100; … … 550 723 if(tokens.size()>4) sscanf(tokens[4].c_str(),"%lf,%lf",&valmsk,&unvalmsk); 551 724 552 cout<<"CrMaskFrMap "<<tokens[0]<<" nside "<<nside<<" with "<<tokens[2]<<endl725 cout<<"CrMaskFrMap "<<tokens[0]<<" nside="<<nside<<" with "<<tokens[2]<<endl 553 726 <<" for value in ["<<v1<<","<<v2<<"]" 554 727 <<" valmsk="<<valmsk<<" unvalmsk="<<unvalmsk<<endl; … … 576 749 return; 577 750 } 578 Spher eHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);751 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj); 579 752 if(map==NULL) { 580 cout<<"Error: "<<tokens[0]<<" is not a Spher eHEALPix<r_8>"<<endl;753 cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl; 581 754 return; 582 755 } … … 587 760 return; 588 761 } 589 Spher eHEALPix<r_8>* msk = dynamic_cast<SphereHEALPix<r_8>*>(objm);762 SphericalMap<r_8>* msk = dynamic_cast<SphericalMap<r_8>*>(objm); 590 763 if(msk==NULL) { 591 cout<<"Error: "<<tokens[1]<<" is not a Spher eHEALPix<r_8>"<<endl;764 cout<<"Error: "<<tokens[1]<<" is not a SphericalMap<r_8>"<<endl; 592 765 return; 593 766 } … … 614 787 return; 615 788 } 616 Spher eHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);789 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj); 617 790 if(map==NULL) { 618 cout<<"Error: "<<tokens[0]<<" is not a Spher eHEALPix<r_8>"<<endl;791 cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl; 619 792 return; 620 793 } 621 794 int_4 nsidemap = map->SizeIndex(); 795 uint_2 t = typemap(obj); 622 796 623 797 int_4 nside = nsidemap; 624 798 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; 628 809 629 810 if(nsidemap==nside) { // tailles egales … … 638 819 } 639 820 } 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.;} 642 825 for(int_4 i=0;i<map->NbPixels();i++) { 643 826 double theta,phi; map->PixThetaPhi(i,theta,phi); … … 645 828 if(ip<0 || ip>=mapproj->NbPixels()) continue; 646 829 (*mapproj)(ip) += (*map)(i); 647 nproj(ip)++;830 (*nproj)(ip)++; 648 831 } 649 832 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; 651 835 } 652 836 … … 664 848 return; 665 849 } 666 Spher eHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);850 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj); 667 851 if(map==NULL) { 668 cout<<"Error: "<<tokens[0]<<" is not a Spher eHEALPix<r_8>"<<endl;852 cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl; 669 853 return; 670 854 } … … 739 923 return; 740 924 } 741 Spher eHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);925 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj); 742 926 if(map==NULL) { 743 cout<<"Error: "<<tokens[0]<<" is not a Spher eHEALPix<r_8>"<<endl;927 cout<<"Error: "<<tokens[0]<<" is not a SphericalMap<r_8>"<<endl; 744 928 return; 745 929 } … … 753 937 {cout<<"Error: Pas d'objet de nom "<<tokens[iop+1]<<endl; 754 938 continue;} 755 Spher eHEALPix<r_8>* map1 = dynamic_cast<SphereHEALPix<r_8>*>(obj1);939 SphericalMap<r_8>* map1 = dynamic_cast<SphericalMap<r_8>*>(obj1); 756 940 if(map1==NULL) 757 {cout<<"Error: "<<tokens[iop+1]<<" is not a Spher eHEALPix<r_8>"<<endl;941 {cout<<"Error: "<<tokens[iop+1]<<" is not a SphericalMap<r_8>"<<endl; 758 942 continue;} 759 943 cout<<" "<<op<<"= "<<tokens[iop+1]; … … 783 967 return; 784 968 } 785 Spher eHEALPix<r_8>* map = dynamic_cast<SphereHEALPix<r_8>*>(obj);969 SphericalMap<r_8>* map = dynamic_cast<SphericalMap<r_8>*>(obj); 786 970 if(map==NULL) { 787 cout<<"Error: "<<tokens[0]<<" is not a Spher eHEALPix<r_8>"<<endl;788 return; 789 } 790 791 Spher eHEALPix<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; 792 976 if(tokens.size()>1) { 793 977 if(tokens[1][0]!='!') { … … 797 981 return; 798 982 } 799 msk = dynamic_cast<Spher eHEALPix<r_8>*>(objm);983 msk = dynamic_cast<SphericalMap<r_8>*>(objm); 800 984 if(msk==NULL) { 801 cout<<"Error: "<<tokens[1]<<" is not a Spher eHEALPix<r_8>"<<endl;985 cout<<"Error: "<<tokens[1]<<" is not a SphericalMap<r_8>"<<endl; 802 986 return; 803 987 } … … 852 1036 853 1037 //////////////////////////////////////////////////////////// 1038 1039 /* --Methode-- */ 1040 void 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-- */ 1056 bool 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-- */ 1064 void 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-- */ 1077 uint_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 //////////////////////////////////////////////////////////// 854 1090 static skymapmoduleExecutor * piaskmex = NULL; 855 1091 … … 866 1102 piaskmex = NULL; 867 1103 } 868 869 ////////////////////////////////////////////////////////////
Note:
See TracChangeset
for help on using the changeset viewer.