#include "machdefs.h" #include #include #include #include #include #include #include #include "piacmd.h" #include "nobjmgr.h" #include "pistdimgapp.h" #include "servnobjm.h" #include "pidrawer.h" #include "nomgadapter.h" #include "tvector.h" #include "ntuple.h" #include "slinparbuff.h" #include "localmap.h" #include "spherehealpix.h" #include "spherethetaphi.h" #include "sphericaltransformserver.h" extern "C" { void skymapmodule_init(); void skymapmodule_end(); } class skymapmoduleExecutor : public CmdExecutor { public: enum {UnKnown=(uint_2) 0, TypeR8=(uint_2) 16, TypeR4=(uint_2) 32, Spherical=(uint_2) 1, HealPix=(uint_2) 2, ThetaPhi=(uint_2) 4, Spherical8=(uint_2) Spherical|TypeR8, Spherical4=(uint_2) Spherical|TypeR4, HealPix8 =(uint_2) Spherical|HealPix|TypeR8, HealPix4 =(uint_2) Spherical|HealPix|TypeR4, ThetaPhi8 =(uint_2) Spherical|ThetaPhi|TypeR8, ThetaPhi4 =(uint_2) Spherical|ThetaPhi|TypeR4}; skymapmoduleExecutor(); virtual ~skymapmoduleExecutor(); virtual int Execute(string& keyw, vector& args, string& toks); void TypeMap(vector& tokens); void Map2Double(vector& tokens); void Map2Float(vector& tokens); void Map2Map(vector& tokens); void MapMult(vector& tokens); void MapCover(vector& tokens); void Map2Cl(vector& tokens); void Cl2Map(vector& tokens); void Map2Alm(vector& tokens); void Alm2Map(vector& tokens); void CrMapMask(vector& tokens); void CrMaskFrMap(vector& tokens); void MaskMap(vector& tokens); void MapProj(vector& tokens); void Map2Local(vector& tokens); void MapOper(vector& tokens); void MapStat(vector& tokens); void Alm2Cl(vector& tokens); void Cl2llCl(vector& tokens); void ClMean(vector& tokens); void ClMult(vector& tokens); void ClOper(vector& tokens); void ClRebin(vector& tokens); void VarOper(vector& tokens); protected: void SetTypeMap(vector& tokens); bool IsNSideGood(int_4 nside); void GetNSideGood(int_4 &nside); uint_2 typemap(AnyDataObj* obj); uint_2 DefTypMap; }; /* --Methode-- */ skymapmoduleExecutor::skymapmoduleExecutor() { PIACmd * mpiac; NamedObjMgr omg; mpiac = omg.GetImgApp()->CmdInterpreter(); string hgrp = "SkyMapCmd"; string kw,usage; kw = "settypemap"; usage = "Set le type de map(double) par default"; usage += "\n Usage: settypemap type"; usage += "\n type= H for Healpix (default)"; usage += "\n T for ThetaPhi"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "typemap"; usage = "Imprime le type de map"; usage += "\n Usage: typemap map"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "map2double"; usage = "Convert a float map to a double map"; usage += "\n Usage: map2double map(float)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "map2float"; usage = "Convert a double map to a float map"; usage += "\n Usage: map2float map(double)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "map2map"; usage = "Convert a map(double) into an other map type"; usage += "\n Usage: map2map map(double) type [nside]"; usage += "\n type= H for Healpix"; usage += "\n T for ThetaPhi"; usage += "\n if nside <=1 use nside from map"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "mapmult"; usage = "Multiply a map(double) by a constant"; usage += "\n Usage: mapmult map(double) cste"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "mapcover"; usage = "Print the covering of a map(double)"; usage += "\n Usage: mapcover map(double) v1,v2 [varname]"; usage += "\n v1,v2: good pixels have v1<=val<=v2 (def=0.99,1.01)"; usage += "\n (use default (0.99,1.01): \"!\")"; usage += "\n $varname: percent of sky covering"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "map2cl"; usage = "SkyMap map(double) to Cl"; usage += "\n Usage: map2cl map(double) clvec [lmax] [niter]"; usage += "\n lmax: if <=0 or \"!\" use default (3*nside-1)"; usage += "\n niter: number of iterations (<=0 or def=3)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "cl2map"; usage = "Generate SkyMap map(double) from Cl"; usage += "\n Usage: cl2map clvec map(double) nside [fwhm]"; usage += "\n (see command settypemap)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "map2alm"; usage = "SkyMap map(double) to Alm"; usage += "\n Usage: map2alm map(double) almmat [lmax] [niter]"; usage += "\n lmax: if <=0 or \"!\" use default (3*nside-1)"; usage += "\n niter: number of iterations (<=0 or def=3)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "alm2map"; usage = "Generate SkyMap map(double) from Alm"; usage += "\n Usage: alm2map almmat map(double) nside"; usage += "\n (see command settypemap)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "crmapmask"; usage = "Create a map mask(double) (nside) between latitudes lat1,lat2 longitudes lon1,lon2"; usage += "\n Usage: crmapmask mapmsk(double) nside lat1,lat2 lon1,lon2 [valmsk,valnomsk]"; usage += "\n mask pixels between [lat1,lat2] ([-90,90] in degrees)"; usage += "\n and [lon1,lon2] ([0,360[ in degrees)"; usage += "\n (for no mask \"!\")"; usage += "\n valmsk=value to be written into masked pixels (def=0)"; usage += "\n valnomsk=value to be written into unmasked pixels (def=1)"; usage += "\n (see command settypemap)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "crmaskfrmap"; usage = "Create a map mask(double) (nside) relative to an other map(double) pixels values"; usage += "\n Usage: crmaskfrmap mapmsk(double) nside map(double) v1,v2 [valmsk,valnomsk]"; usage += "\n mask if v1RegisterCommand(kw, usage, this, hgrp); kw = "maskmap"; usage = "Mask a map(double) with a mask map(double)"; usage += "\n Usage: maskmap map msk"; usage += "\n operation is map(i) *= msk(theta,phi)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "maproj"; usage = "Project a map(double) into an other one"; usage += "\n Usage: maproj map(double) mapproj(double) [nside]"; usage += "\n Create mapproj(nside) and project map into mapproj"; usage += "\n (use \"maproj map mapproj\" to make a copy)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "map2local"; usage = "Project a map(double) into a local map(double)"; usage += "\n Usage: map2local map(double) localmap(double) nx,ny angleX,angleY phi0,theta0 [x0,y0] [angle]"; usage += "\n nx,ny: number of pixels in x(col),y(row) direction"; usage += "\n X-axis==phi, Y-axis==theta"; usage += "\n angleX,angleY: total angle aperture in x,y direction (degrees)"; usage += "\n phi0,theta0: define origin in phi,theta (degrees)"; usage += "\n x0,y0: map phi0,theta0 to pixel x0,y0 (\"!\" or def=middle of the localmap)"; usage += "\n angle: angle (degrees) of rotation between x-axis of map-coordinate system"; usage += "\n and the tangent to parallel on the sphere (def: 0.)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "mapop"; usage = "operation on a map(double)"; usage += "\n Usage: mapop map(double) op1 map1(double) [op2 map2(double)] [op2 map3(double)] [...]"; usage += "\n Do \"map op1= map1\", \"map op2=map2\", ..."; usage += "\n where op = +,-,*,/"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "mapstat"; usage = "Statistics from a map(double)"; usage += "\n Usage: mapstat map(double) [msk(double)] [meanvarname] [sigmavarname]"; usage += "\n msk = mask sphere used as weight"; usage += "\n if msk(i)<=0 do not use that pixel"; usage += "\n if msk(i)>0 use that pixel with weight msk(i)"; usage += "\n msk = \"!\" means no mask sphere"; usage += "\n meanvarname = variable name to store mean"; usage += "\n sigmavarname = variable name to store sigma"; usage += "\n (\"!\" means do not store)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "alm2cl"; usage = "Project alm to cl"; usage += "\n Usage: alm2cl alm cl"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "cl2llcl"; usage = "Project cl to l*(l+1)*cl"; usage += "\n Usage: cl2llcl cl llcl"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "clmean"; usage = "Compute mean for a cl vector"; usage += "\n Usage: clmean cl imin,imax [meanvarname]"; usage += "\n imin,imax = compute between these indices"; usage += "\n meanvarname = variable name to store mean"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "clmult"; usage = "Multiply a cl by a constant"; usage += "\n Usage: clmult cl val"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "clop"; usage = "operation on a cl"; usage += "\n Usage: clop cl(double) op1 cl1(double) [op2 cl2(double)] [op2 cl3(double)] [...]"; usage += "\n Do \"cl op1= cl1\", \"cl op2=cl2\", ..."; usage += "\n where op = +,-,*,/"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "clrebin"; usage = "rebin a cl into an ntuple"; usage += "\n Usage: clrebin cl ntuple nbin,bin0"; usage += "\n nbin: rebin by nbin"; usage += "\n bin0: begin rebinning at bin bin0 (def=0)"; mpiac->RegisterCommand(kw, usage, this, hgrp); kw = "varop"; usage = "operation on variables"; usage += "\n Usage: varop var1 op var2 [resultvarname]"; usage += "\n Do result = var1 op var2"; usage += "\n where op = +,-,*,/,^(pow),exp,sqrt,log,log10"; usage += "\n resultvarname = variable name to store the result"; mpiac->RegisterCommand(kw, usage, this, hgrp); DefTypMap = HealPix; } /* --Methode-- */ skymapmoduleExecutor::~skymapmoduleExecutor() { } /* --Methode-- */ int skymapmoduleExecutor::Execute(string& kw, vector& tokens, string& toks) { if(kw == "settypemap") { SetTypeMap(tokens); } else if(kw == "typemap") { if(tokens.size()<1) { cout<<"Usage: typemap map"<& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); uint_2 t = typemap(obj); if(t==UnKnown) {cout<<"TypeMap: UnKnown"<* map = dynamic_cast*>(obj); nside = map->SizeIndex(); } else if(t&TypeR4) { SphericalMap* map = dynamic_cast*>(obj); nside = map->SizeIndex(); } string dum = ""; if(t==HealPix8) dum = "SphereHEALPix"; else if(t==HealPix4) dum = "SphereHEALPix"; else if(t==ThetaPhi8) dum = "SphereThetaPhi"; else if(t==ThetaPhi4) dum = "SphereThetaPhi"; else if(t==Spherical8) dum = "SphericalMap"; else if(t==Spherical4) dum = "SphericalMap"; cout<<"TypeMap: "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<SizeIndex(); SphericalMap* map8 = NULL; if(t&HealPix) map8 = new SphereHEALPix(nside); else if(t&ThetaPhi) map8 = new SphereThetaPhi(nside); else return; cout<<"Map2Double: converting to double "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<SizeIndex(); SphericalMap* map4 = NULL; if(t&HealPix) map4 = new SphereHEALPix(nside); else if(t&ThetaPhi) map4 = new SphereThetaPhi(nside); else return; cout<<"Map2Float: converting to float "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<SizeIndex(); uint_2 tomap = UnKnown; if(toupper(tokens[1][0])=='H') tomap = HealPix; else if(toupper(tokens[1][0])=='T') tomap = ThetaPhi; else {cout<<"unkown map type "<<(char)toupper(tokens[1][0])<<" (H or T)!"<2) tonside = atoi(tokens[2].c_str()); else { if(tomap&HealPix) {tonside=int(nside/1.5); GetNSideGood(tonside);} else tonside=int(map->NbThetaSlices()/2.5); } if(tomap&HealPix && !IsNSideGood(tonside)) {cout<<"Bad nside for Healpix "<* map8 = NULL; if(tomap&HealPix) map8 = new SphereHEALPix(tonside); else if(tomap&ThetaPhi) map8 = new SphereThetaPhi(tonside); else return; cout<<"Map2Map: convert "< "<NbThetaSlices()<NbPixels();i++) { double theta,phi; map8->PixThetaPhi(i,theta,phi); int_4 ip = map->PixIndexSph(theta,phi); if(ip<0 || ip>=map->NbPixels()) continue; (*map8)(i)=(*map)(ip); } omg.AddObj(map8,tokens[0]); } /* --Methode-- */ void skymapmoduleExecutor::MapMult(vector& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<NbPixels();i++) (*map)(i) *= v; } /* --Methode-- */ void skymapmoduleExecutor::MapCover(vector& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<1) if(tokens[1][0]!='!') sscanf(tokens[1].c_str(),"%lf,%lf",&v1,&v2); cout<<"MapCover: "<NbPixels();i++) if(v1<=(*map)(i) && (*map)(i)<=v2) ngood++; double per = (double)ngood/(double)map->NbPixels(); cout<<"NGood="< "<<100.*per<<" %"; if(tokens.size()>2) { if(omg.HasVar(tokens[2])) omg.DeleteVar(tokens[2]); char str[128]; sprintf(str,"%g",per); omg.SetVar(tokens[2],(string)str); cout<<" stored into $"<& tokens) { NamedObjMgr omg; int_4 lmax=0, niter=3; if(tokens.size()>2) if(tokens[2][0]!='!') lmax = atoi(tokens[2].c_str()); if(tokens.size()>3) niter = atoi(tokens[3].c_str()); if(niter<=0) niter = 3; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"< ylmserver; int_4 nside = map->SizeIndex(); if(lmax<=0) lmax = 3*nside-1; SphericalMap* tmpmap = NULL; if(t&HealPix) tmpmap = new SphereHEALPix(*((SphereHEALPix*)map),false); else if(t&ThetaPhi) tmpmap = new SphereThetaPhi(*((SphereThetaPhi*)map),false); else return; cout<<"Map2Cl: "< "< cltmp = ylmserver.DecomposeToCl(*tmpmap,lmax,0.,niter); cout<<"("<& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* cl = dynamic_cast*>(obj); if(cl==NULL) { cout<<"Error: "<"<2) nside = atoi(tokens[2].c_str()); if(DefTypMap&HealPix && !IsNSideGood(nside)) {cout<<"Cl2Map: Bad nside for HealPix "<3) fwhm = atof(tokens[3].c_str()); SphericalMap* map = NULL; if(DefTypMap&HealPix) map = new SphereHEALPix; else if(DefTypMap&ThetaPhi) map = new SphereThetaPhi; else return; SphericalTransformServer ylmserver; cout<<"Cl2Map: Generate map "<Size()<<")" <<" with fwhm="<& tokens) { NamedObjMgr omg; int_4 lmax=0, niter=3; if(tokens.size()>2) if(tokens[2][0]!='!') lmax = atoi(tokens[2].c_str()); if(tokens.size()>3) niter = atoi(tokens[3].c_str()); if(niter<=0) niter = 3; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"< ylmserver; int_4 nside = map->SizeIndex(); if(lmax<=0) lmax = 3*nside-1; SphericalMap* tmpmap = NULL; if(t&HealPix) tmpmap = new SphereHEALPix(*((SphereHEALPix*)map),false); else if(t&ThetaPhi) tmpmap = new SphereThetaPhi(*((SphereThetaPhi*)map),false); else return; cout<<"Map2Alm: "< "< almtmp; ylmserver.DecomposeToAlm(*tmpmap,almtmp,lmax,0.,niter); cout<<"("< >* alm = new TMatrix< complex >(n,n); *alm = (complex)0.; for(int i=0;i& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "< >* almmat = dynamic_cast >*>(obj); if(almmat==NULL) { cout<<"Error: "< >"<NRows()-1; Alm alm(lmax); alm = (complex)0.; for(int i=0;i2) nside = atoi(tokens[2].c_str()); if(DefTypMap&HealPix && !IsNSideGood(nside)) {cout<<"Alm2Map: Bad nside for HealPix "<* map = NULL; if(DefTypMap&HealPix) map = new SphereHEALPix; else if(DefTypMap&ThetaPhi) map = new SphereThetaPhi; else return; SphericalTransformServer ylmserver; cout<<"Alm2Map: Generate map "<& tokens) { NamedObjMgr omg; int_4 nside = atoi(tokens[1].c_str()); if(DefTypMap&HealPix && !IsNSideGood(nside)) {cout<<"CrMapMask: Bad nside "<* map = NULL; if(DefTypMap&HealPix) map = new SphereHEALPix(nside); else if(DefTypMap&ThetaPhi) map = new SphereThetaPhi(nside); else return; bool lat=false, lon=false; double lat1=-99., lat2=99., lon1=-999., lon2=999.; if(tokens.size()>2) if(tokens[2][0]!='!') {lat=true; sscanf(tokens[2].c_str(),"%lf,%lf",&lat1,&lat2);} if(tokens.size()>3) if(tokens[3][0]!='!') {lon=true; sscanf(tokens[3].c_str(),"%lf,%lf",&lon1,&lon2);} double valmsk=0., unvalmsk=1.; if(tokens.size()>4) sscanf(tokens[4].c_str(),"%lf,%lf",&valmsk,&unvalmsk); cout<<"CrMapMask "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<* msk = NULL; if(t&HealPix) msk = new SphereHEALPix(nside); else if(t&ThetaPhi) msk = new SphereThetaPhi(nside); else return; double v1=-1.e100, v2=1.e100; if(tokens.size()>3) if(tokens[3][0]!='!') sscanf(tokens[3].c_str(),"%lf,%lf",&v1,&v2); double valmsk=0., unvalmsk=1.; if(tokens.size()>4) sscanf(tokens[4].c_str(),"%lf,%lf",&valmsk,&unvalmsk); cout<<"CrMaskFrMap "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<* msk = dynamic_cast*>(objm); if(msk==NULL) { cout<<"Error: "<"<NbPixels();i++) { double theta,phi; map->PixThetaPhi(i,theta,phi); int_4 ip = msk->PixIndexSph(theta,phi); if(ip<0 || ip>=msk->NbPixels()) continue; (*map)(i) *= (*msk)(ip); } } /* --Methode-- */ void skymapmoduleExecutor::MapProj(vector& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<SizeIndex(); uint_2 t = typemap(obj); int_4 nside = nsidemap; if(tokens.size()>2) nside = atoi(tokens[2].c_str()); if(t&HealPix && !IsNSideGood(nside)) {cout<<"MapProj: Bad nside for Healpix "<* mapproj = NULL; if(t&HealPix) mapproj = new SphereHEALPix(nside); else if(t&ThetaPhi) mapproj = new SphereThetaPhi(nside); else return; cout<<"MapProj: project "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<2) sscanf(tokens[2].c_str(),"%d,%d",&nx,&ny); if(nx<=0) {cout<<"Error: nx="<0"<0"<3) sscanf(tokens[3].c_str(),"%lf,%lf",&angleX,&angleY); if(angleX<=0. || angleX>180.) {cout<<"Error: bad angleX="<180.) {cout<<"Error: bad angleY="<4) sscanf(tokens[4].c_str(),"%lf,%lf",&phi0,&theta0); if(phi0<0. || phi0>=360.) {cout<<"Error: bad phi0="<90.) {cout<<"Error: bad theta0="<5) if(tokens[5][0]!='!') sscanf(tokens[5].c_str(),"%d,%d",&x0,&y0); double angle=0.; if(tokens.size()>6) sscanf(tokens[6].c_str(),"%lf",&angle); cout<<"Map2Local: proj "<* lmap = new LocalMap(nx,ny,angleX,angleY,theta0,phi0,x0,y0,angle); *lmap = 0.; //lmap->print(cout); int_4 nbad=0; double tmax=-9999., pmax=-9999., tmin=9999., pmin=9999.; for(int_4 i=0;iNbPixels();i++) { double theta,phi; lmap->PixThetaPhi(i,theta,phi); int_4 ip = map->PixIndexSph(theta,phi); if(ip<0 || ip>=map->NbPixels()) {nbad++; continue;} if(thetatmax) tmax=theta; if(phipmax) pmax=phi; (*lmap)(i) = (*map)(ip); } if(nbad) cout<<"Warning: "<& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<* map1 = dynamic_cast*>(obj1); if(map1==NULL) {cout<<"Error: "<"<& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* map = dynamic_cast*>(obj); if(map==NULL) { cout<<"Error: "<"<* msk = NULL; if(tokens.size()>1) { if(tokens[1][0]!='!') { AnyDataObj* objm=omg.GetObj(tokens[1]); if(objm==NULL) { cout<<"Error: Pas d'objet de nom "<*>(objm); if(msk==NULL) { cout<<"Error: "<"<NbPixels(), npixgood=0; for(int_4 i=0;iPixThetaPhi(i,theta,phi); int_4 ip = msk->PixIndexSph(theta,phi); if(ip<0 || ip>=msk->NbPixels()) w=0.; else w=(*msk)(ip); } if(w<=0.) continue; npixgood++; sumw += w; sum += (*map)(i)*w; sum2 += (*map)(i)*(*map)(i)*w*w; } if(sumw<=0. || npixgood==0) { sum = sum2 = sumw=0.; } else { sum /= sumw; sum2 = sum2/sumw - sum*sum; if(sum2<=0.) sum2=0.; else sum2=sqrt(sum2); } cout<<"Number of good px="<3) if(tokens[3][0]!='!') { if(omg.HasVar(tokens[3])) omg.DeleteVar(tokens[3]); char str[128]; sprintf(str,"%.8f",sum2); omg.SetVar(tokens[3],(string)str); cout<<" sigma stored into $"<2) cout<& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "< >* almmat = dynamic_cast >*>(obj); if(almmat==NULL) { cout<<"Error: "< >"<NRows()-1; Alm alm(lmax); alm = (complex)0.; for(int i=0;i cl(almmat->NRows()); cl = 0.; cout<<"Alm2Cl: project alm "<0) for(int_4 m=1;m<=l;m++) cl(l) += 2.*(alm(l,m).real()*alm(l,m).real()+alm(l,m).imag()*alm(l,m).imag()); cl(l) /= 2.*l+1; } omg.AddObj(cl,tokens[1]); } /* --Methode-- */ void skymapmoduleExecutor::Cl2llCl(vector& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* cl = dynamic_cast*>(obj); if(cl==NULL) { cout<<"Error: "<"< llcl(*cl,false); cout<<"Cl2llCl: project "<Size() <<") to l*(l+1)*cl "<& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* cl = dynamic_cast*>(obj); if(cl==NULL) { cout<<"Error: "<"<1) if(tokens[1][0]!='!') sscanf(tokens[1].c_str(),"%d,%d",&lmin,&lmax); if(lmin<0) lmin=0; if(lmax>=cl->Size()) lmax=cl->Size()-1; if(lmin>lmax) {lmin=0; lmax=cl->Size()-1;} cout<<"ClMean: compute mean "<Size() <<") between ["<& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* cl = dynamic_cast*>(obj); if(cl==NULL) { cout<<"Error: "<"<1) val=atof(tokens[1].c_str()); cout<<"ClMult: multiply "<Size()<<") by "<& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* cl = dynamic_cast*>(obj); if(cl==NULL) { cout<<"Error: "<"<Size()<<")"; for(unsigned short iop=1;iop* cl1 = dynamic_cast*>(obj1); if(cl1==NULL) {cout<<"Error: "<"<Size()<<")"; int_4 n=cl->Size(); if(n>cl1->Size()) n=cl1->Size(); for(int_4 i=0;i& tokens) { NamedObjMgr omg; AnyDataObj* obj=omg.GetObj(tokens[0]); if(obj==NULL) { cout<<"Error: Pas d'objet de nom "<* cl = dynamic_cast*>(obj); if(cl==NULL) { cout<<"Error: "<"<Size(); if(nn<=0) return; int_4 nrebin=1, ibin0=0; if(tokens.size()>2) sscanf(tokens[2].c_str(),"%d,%d",&nrebin,&ibin0); if(ibin0<0 || ibin0>=nn) ibin0=0; cout<<"ClRebin: rebin "< "<=nrebin) break; } if(slp.NPoints()<=0) continue; ll /= (r_8) slp.NPoints(); xnt[0] = ll; xnt[1] = slp.NPoints(); r_8 s,a0,a1,a2; s = slp.Compute(a0); if(s>0.) {xnt[2]=a0; xnt[5]=s;} s = slp.Compute(a0,a1); if(s>0.) {xnt[3]=a0+a1*ll; xnt[6]=s;} s = slp.Compute(a0,a1,a2); if(s>0.) {xnt[4]=a0+a1*ll+a2*ll*ll; xnt[7]=s;} clbin.Fill(xnt); } omg.AddObj(clbin,tokens[1]); } /* --Methode-- */ void skymapmoduleExecutor::VarOper(vector& tokens) { NamedObjMgr omg; double var1=0., var2=0.; string op = "?"; if(tokens.size()>0) var1 = atof(tokens[0].c_str()); if(tokens.size()>1) op = tokens[1]; if(tokens.size()>2) if(tokens[2][0]!='!') var2 = atof(tokens[2].c_str()); double result = 0.; try { if(op=="+") result = var1 + var2; else if(op=="-") result = var1 - var2; else if(op=="*") result = var1 * var2; else if(op=="/" && var2!=0.) result = var1 / var2; else if(op=="^" && var2>0.) result = pow(var1,var2); else if(op=="pow" && var2>0.) result = pow(var1,var2); else if(op=="exp") result = exp(var1); else if(op=="sqrt" && var1>0.) result = sqrt(var1); else if(op=="log" && var1>0.) result = log(var1); else if(op=="log10" && var1>0.) result = log10(var1); } catch ( ... ) { cout<<"An operation exception occurs"<& tokens) { if(tokens.size()<1) { cout<<"SetTypeMap: Usage: settypemap type"<1) {if(nside%2!=0) return false; else nside/=2;} return true; } /* --Methode-- */ void skymapmoduleExecutor::GetNSideGood(int_4 &nside) // get the nearest good nside for HealPix { double n=1.e50; int_4 ns=nside; for(int_4 i=1;i<66000;i*=2) { double v = fabs((double)(nside-i)); if(v>n) continue; n=v; ns=i; } nside = ns; } /* --Methode-- */ uint_2 skymapmoduleExecutor::typemap(AnyDataObj* obj) { if(obj==NULL) return UnKnown; if(dynamic_cast *>(obj)) return HealPix4; if(dynamic_cast *>(obj)) return HealPix8; if(dynamic_cast*>(obj)) return ThetaPhi4; if(dynamic_cast*>(obj)) return ThetaPhi8; if(dynamic_cast *>(obj)) return Spherical4; if(dynamic_cast *>(obj)) return Spherical8; return UnKnown; } //////////////////////////////////////////////////////////// static skymapmoduleExecutor * piaskmex = NULL; void skymapmodule_init() { if (piaskmex) delete piaskmex; piaskmex = new skymapmoduleExecutor; } void skymapmodule_end() { // Desactivation du module if (piaskmex) delete piaskmex; piaskmex = NULL; }