Changeset 3149 in Sophya for trunk/SophyaPI
- Timestamp:
- Jan 18, 2007, 7:21:49 PM (19 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/nomherradapter.cc
r3145 r3149 16 16 17 17 #include "objfitter.h" 18 #include "strutilxx.h" 18 19 19 20 //----------------------------------------------------------------------------- … … 243 244 PIDrawer* NOMAdapter_Histo2DErr::GetDrawer(string & dopt) 244 245 { 245 dopt = "thinline " + dopt; // $CHECK$ CMV : faut-il ajouter thinline246 dopt = "thinline " + dopt; 246 247 return( new PIHisto2D(new Histo2DErrWrapper(mHerr, false), true) ); 247 248 } … … 250 251 P2DArrayAdapter* NOMAdapter_Histo2DErr::Get2DArray(string & dopt) 251 252 { 252 // DEL return ( new POHe2DAdapter(mHerr, false) ); -- A SUPPRIMER253 253 Histo2DErrWrapper* hwp = new Histo2DErrWrapper(mHerr, false); 254 // $CHECK$ CMV : pour les options hbincont hbinerr ... 255 // voir NOMAdapter_Histo2D::Get2DArray(string & dopt) ds nomhistadapter.cc 256 return hwp; 254 vector<string> vopts; 255 FillVStringFrString(dopt,vopts,' '); 256 hwp->DecodeOptionString(vopts,false); 257 return hwp; 257 258 } 258 259 -
trunk/SophyaPI/PIext/nomhistadapter.cc
r3145 r3149 14 14 15 15 #include "servnobjm.h" 16 #include "strutilxx.h" 16 17 17 18 #ifndef SANS_EVOLPLANCK … … 331 332 PIDrawer* NOMAdapter_Histo2D::GetDrawer(string & dopt) 332 333 { 333 dopt = "thinline " + dopt; // $CHECK$ CMV : faut-il ajouter thinline334 dopt = "thinline " + dopt; 334 335 return( new PIHisto2D(new Histo2DWrapper(mHis, false), true) ); 335 336 } … … 338 339 P2DArrayAdapter* NOMAdapter_Histo2D::Get2DArray(string & dopt) 339 340 { 340 // DEL return (new POH2DAdapter(mHis, false) ); -- A SUPPRIMER341 341 Histo2DWrapper* hwp = new Histo2DWrapper(mHis, false); 342 // $CHECK$ CMV : pour les options hbincont hbinerr ... 343 // On peut decoder les options si on veut, par exemple avec : 344 // vector<string> vopts; 345 // FillVStringFrString(string const & dopt, vector<string>& vopts,char sep = ' ') 346 // hwp->DecodeOptionString(vopts, false); 342 vector<string> vopts; 343 FillVStringFrString(dopt,vopts,' '); 344 hwp->DecodeOptionString(vopts,false); 347 345 return hwp; 348 346 } -
trunk/SophyaPI/PIext/pawexecut.cc
r3135 r3149 311 311 piac->RegisterCommand(kw,usage,this,hgrp); 312 312 313 kw = "herr/ correl";313 kw = "herr/mean"; 314 314 usage = "Perform bin mean computation for HistoErr and Histo2DErr"; 315 usage += "\n herr/ correlnameherr todo";315 usage += "\n herr/mean nameherr todo"; 316 316 usage += "\n todo = +1 : compute mean"; 317 usage += "\n = -1 : cancel computation"; 318 piac->RegisterCommand(kw,usage,this,hgrp); 319 320 kw = "herr/variance"; 321 usage = "Perform bin mean and variance computation for HistoErr and Histo2DErr"; 322 usage += "\n herr/variance nameherr todo"; 323 usage += "\n todo = +1 : compute mean and variance"; 317 324 usage += "\n = -1 : cancel computation"; 318 325 piac->RegisterCommand(kw,usage,this,hgrp); … … 382 389 } else if(kw == "h/err") { 383 390 h_err(tokens); return(0); 384 } else if(kw == "herr/correl") { 385 herr_correl(tokens); return(0); 391 } else if(kw == "herr/mean") { 392 herr_mean_variance(tokens,0); return(0); 393 } else if(kw == "herr/variance") { 394 herr_mean_variance(tokens,1); return(0); 386 395 } else return(1); 387 396 } 397 388 398 389 399 /* methode */ … … 2425 2435 2426 2436 /* methode */ 2427 void PAWExecutor::herr_correl(vector<string>& tokens) 2428 // Pour appliquer ToCorrel ou FromCorrel a un HistoErr ou Histo2DErr 2437 void PAWExecutor::herr_mean_variance(vector<string>& tokens,int var) 2438 // Pour appliquer ToMean ou FromMean a un HistoErr ou Histo2DErr 2439 // Pour appliquer ToVariance ou FromVariance a un HistoErr ou Histo2DErr 2429 2440 { 2430 2441 int_4 tks = tokens.size(); 2431 if(tks<1) 2432 {cout<<"Usage: herr_correl namehisterr [+1,-1]"<<endl; 2433 return;} 2442 if(tks<1) { 2443 cout<<"Usage: herr_mean_variance namehisterr [+1,-1]"<<endl; 2444 return; 2445 } 2434 2446 2435 2447 NamedObjMgr omg; … … 2446 2458 2447 2459 if(sens>=0) { 2448 if(herr) herr->ToCorrel();2449 else if(herr2) herr2->ToCorrel();2460 if(herr) {if(var==1) herr->ToVariance(); else herr->ToMean();} 2461 else if(herr2) {if(var==1) herr2->ToVariance(); else herr2->ToMean();} 2450 2462 } else { 2451 if(herr) herr->FromCorrel();2452 else if(herr2) herr2->FromCorrel();2463 if(herr) {if(var==1) herr->FromVariance(); else herr->FromMean();} 2464 else if(herr2) {if(var==1) herr2->FromVariance(); else herr2->FromMean();} 2453 2465 } 2454 2466 2455 int n correl= 0;2456 if(herr) n correl = herr->NCorrel();2457 else if(herr2) n correl = herr2->NCorrel();2458 cout<<tokens[0]<<" : n correl = "<<ncorrel<<endl;2459 2460 } 2467 int nmean = 0; 2468 if(herr) nmean = herr->NMean(); 2469 else if(herr2) nmean = herr2->NMean(); 2470 cout<<tokens[0]<<" : nmean = "<<nmean<<endl; 2471 2472 } -
trunk/SophyaPI/PIext/pawexecut.h
r3135 r3149 47 47 void h_set(string dum,vector<string>& tokens); 48 48 void h_err(vector<string>& tokens); 49 void herr_ correl(vector<string>& tokens);49 void herr_mean_variance(vector<string>& tokens,int var=0); 50 50 int_4 decodepawstring(string tokens,string& nameobj 51 51 ,string& xexp,string& yexp,string& zexp); -
trunk/SophyaPI/PIext/pihisto.cc
r3145 r3149 48 48 mRetFg = 0; 49 49 } 50 else if(opts.substr(0, 8) == "hbinerr") {50 else if(opts.substr(0,7) == "hbinerr") { 51 51 mRetFg = 1; 52 52 } 53 else if(opts.substr(0, 8) == "hbinent") {53 else if(opts.substr(0,7) == "hbinent") { 54 54 mRetFg = 2; 55 55 } … … 269 269 else if(opts=="err") error=true; 270 270 else if(opts=="noerr" || opts=="nerr") error=false; 271 // $CHECK$CMV : on desactive pline si fill ?272 271 else if(opts=="fill") { filled=true; pline=false; } 273 272 else if(opts=="nofill" || opts=="nfill") filled=false; 274 // $CHECK$CMV : on desactive fill si pline ?275 273 else if(opts=="pline") { pline=true; filled=false; } 276 274 else if(opts=="nopline") pline=false; 277 275 else if(opts.substr(0,11) == "statposoff=") { 278 floatxo=0., yo=0.;279 sscanf(opts.substr(11).c_str(),"% g,%g",&xo, &yo);276 double xo=0., yo=0.; 277 sscanf(opts.substr(11).c_str(),"%lf,%lf",&xo, &yo); 280 278 spoX=xo; spoY=yo; 281 279 } -
trunk/SophyaPI/PIext/pihisto.h
r3145 r3149 36 36 bool pline; // if true: draw histogram as polyline 37 37 bool error; // if true: draw error bars 38 floatspoX, spoY; // Stat pos offset par rapport a position defaut38 double spoX, spoY; // Stat pos offset par rapport a position defaut 39 39 }; 40 40 -
trunk/SophyaPI/PIext/pihisto2d.cc
r3145 r3149 51 51 mRetFg = 0; 52 52 } 53 else if(opts.substr(0, 8) == "hbinerr") {53 else if(opts.substr(0,7) == "hbinerr") { 54 54 mRetFg = 1; 55 55 } 56 else if(opts.substr(0, 8) == "hbinent") {56 else if(opts.substr(0,7) == "hbinent") { 57 57 mRetFg = 2; 58 58 } … … 157 157 158 158 //++ 159 void PIHisto2D::UseScale(unsigned short type, floatlogscale)159 void PIHisto2D::UseScale(unsigned short type,double logscale) 160 160 // 161 161 // Pour changer les echelles (lineaire ou logarithmique) … … 184 184 185 185 //++ 186 void PIHisto2D::UseDisplay(unsigned short type, floatfnpt)186 void PIHisto2D::UseDisplay(unsigned short type,double fnpt) 187 187 // 188 188 // Type de Display … … 212 212 213 213 //++ 214 void PIHisto2D::UseDyn( float fmin,floatfmax)214 void PIHisto2D::UseDyn(double fmin,double fmax) 215 215 // 216 216 // Gestion de la dynamique a representer: … … 224 224 //-- 225 225 { 226 if( (mHistoWp) && (mHistoWp->NBinX()>0) && (mHistoWp->NBinY()>0) && (fmin>=fmax) ) { 227 double v,hmin,hmax; 228 hmin = hmax = (*mHistoWp)(0,0); 229 for (int_4 i=0; i<mHistoWp->NBinX(); i++) 230 for (int_4 j=0; j<mHistoWp->NBinY(); j++) { 231 v = (*mHistoWp)(i, j); 232 if(v<hmin) hmin = v; 233 if(v>hmax) hmax = v; 234 } 235 fmin = hmin; fmax = hmax; // $CHECK$ CMV : attention, double vers float !! 236 } 237 238 // $CHECK$ CMV : Ne faut-il pas passer les attributs de la classe en double ?? 226 if( (mHistoWp) && (mHistoWp->NBinX()>0) && (mHistoWp->NBinY()>0) && (fmin>=fmax) ) { 227 double v,hmin,hmax; 228 hmin = hmax = (*mHistoWp)(0,0); 229 for (int_4 i=0; i<mHistoWp->NBinX(); i++) 230 for (int_4 j=0; j<mHistoWp->NBinY(); j++) { 231 v = (*mHistoWp)(i, j); 232 if(v<hmin) hmin = v; 233 if(v>hmax) hmax = v; 234 } 235 fmin = hmin; fmax = hmax; 236 } 237 239 238 if(fmin>=fmax) fmax = fmin+1.; 240 239 mHMin = fmin; mHMax = fmax; … … 242 241 243 242 //++ 244 void PIHisto2D::UseFrac( float frmin,floatfrmax)243 void PIHisto2D::UseFrac(double frmin,double frmax) 245 244 // 246 245 // Pour definir la fraction de la dynamique a dessiner: … … 274 273 printf(" Dyn=%g,%g Frac=%g,%g LogSc=%g H=%p\n" 275 274 ,mHMin,mHMax,mFracMin,mFracMax,mLogScale,mHistoWp); 276 // if(lp>=1) mHistoWp->PrintStatus(); $CHECK$ CMV : que faut-il faire ?277 275 fflush(stdout); 278 276 } … … 352 350 353 351 // Gamme a representer entre [0,1] mais >=fracmin et scale fracmax 354 floatfracmin=FMin(), fracmax=FMax();355 float llscale = (float) log10((double)LogScale());352 double fracmin=FMin(), fracmax=FMax(); 353 double llscale = log10(LogScale()); 356 354 357 355 // gestion Couleurs. … … 377 375 if(mTypDisp==1) { 378 376 g->SelMarker(1,PI_DotMarker); 379 npt = (int) ((float)NPixBin(g)*FPoints()); if(npt<=0) npt = 2;377 npt = (int)(NPixBin(g)*FPoints()); if(npt<=0) npt = 2; 380 378 } 381 379 … … 400 398 401 399 // Gestion de la dynamique a dessiner 402 floatfrac = ((*mHistoWp)(i,j)-HMin())/(HMax()-HMin());400 double frac = ((*mHistoWp)(i,j)-HMin())/(HMax()-HMin()); 403 401 if(frac<0.) continue; 404 402 if(mTypScal==1) { // echelle log10 … … 408 406 if(frac<=fracmin) continue; 409 407 if(frac>1.) frac = 1.; 410 floatfracred = frac * fracmax;408 double fracred = frac * fracmax; 411 409 412 410 // Gestion de la couleur 413 411 int icol = 0; 414 412 if (cmap) { 415 icol = int( (float) ncol*frac);413 icol = int(ncol*frac); 416 414 if(icol>=ncol) icol = ncol-1; else if(icol<0) icol=0; 417 415 g->SelForeground(*cmap,icol); … … 431 429 } else if(mTypDisp==1) { 432 430 //..... nuage de points ..... 433 int ipt = int( (float) npt *frac);431 int ipt = int(npt *frac); 434 432 for(int k=0;k<ipt;k++) { 435 433 double x = left0 + frand01()*dx; … … 559 557 560 558 //++ 561 char PIHisto2D::HPrint2( floatf)559 char PIHisto2D::HPrint2(double f) 562 560 // 563 561 // Codage des valeurs en caracteres (fct privee). … … 638 636 SetStats(false); 639 637 } else if(opts.substr(0,11) == "statposoff=") { 640 floatxo=0., yo=0.;641 sscanf(opts.substr(11).c_str(),"% g,%g",&xo, &yo);638 double xo=0., yo=0.; 639 sscanf(opts.substr(11).c_str(),"%lf,%lf",&xo, &yo); 642 640 SetStatPosOffset(xo, yo); 643 641 } else if(opts.substr(0,8)=="h2scale=") { 644 unsigned short t=TypScale(); floatls=LogScale();642 unsigned short t=TypScale(); double ls=LogScale(); 645 643 if(opts.substr(8,3)=="lin") t=0; 646 644 else if(opts.substr(8,3)=="log") 647 {t=1; sscanf(opts.c_str(),"h2scale=log,% g",&ls);}645 {t=1; sscanf(opts.c_str(),"h2scale=log,%lf",&ls);} 648 646 UseScale(t,ls); 649 647 } else if(opts.substr(0,7)=="h2disp=") { 650 unsigned short t=TypDisplay(); floatfpts=FPoints();648 unsigned short t=TypDisplay(); double fpts=FPoints(); 651 649 if(opts.substr(7,3)=="var") t=0; 652 650 else if(opts.substr(7,3)=="hbk") t=2; 653 651 else if(opts.substr(7,3)=="img") t=3; 654 652 else if(opts.substr(7,3)=="pts") 655 {t=1; sscanf(opts.c_str(),"h2disp=pts,% g",&fpts);}653 {t=1; sscanf(opts.c_str(),"h2disp=pts,%lf",&fpts);} 656 654 UseDisplay(t,fpts); 657 655 } else if(opts.substr(0,6)=="h2dyn=") { 658 floathmin=HMin(),hmax=HMax(); size_t q = opts.find(',');659 sscanf(opts.c_str(),"h2dyn=% g",&hmin);660 if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"% g",&hmax);656 double hmin=HMin(),hmax=HMax(); size_t q = opts.find(','); 657 sscanf(opts.c_str(),"h2dyn=%lf",&hmin); 658 if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"%lf",&hmax); 661 659 UseDyn(hmin,hmax); 662 660 } else if(opts.substr(0,7)=="h2frac=") { 663 floatfmin=FMin(),fmax=FMax(); size_t q = opts.find(',');664 sscanf(opts.c_str(),"h2frac=% g",&fmin);665 if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"% g",&fmax);661 double fmin=FMin(),fmax=FMax(); size_t q = opts.find(','); 662 sscanf(opts.c_str(),"h2frac=%lf",&fmin); 663 if(q<opts.length()-1) sscanf(opts.substr(q+1).c_str(),"%lf",&fmax); 666 664 UseFrac(fmin,fmax); 667 665 } else { … … 1077 1075 1078 1076 else if(opt==6001) { 1079 sscanf(mText[0]->GetText().c_str(),"% g %g",&mHMin,&mHMax);1080 sscanf(mText[1]->GetText().c_str(),"% g %g",&mFracMin,&mFracMax);1081 sscanf(mText[2]->GetText().c_str(),"% g",&mLogScale);1077 sscanf(mText[0]->GetText().c_str(),"%lf %lf",&mHMin,&mHMax); 1078 sscanf(mText[1]->GetText().c_str(),"%lf %lf",&mFracMin,&mFracMax); 1079 sscanf(mText[2]->GetText().c_str(),"%lf",&mLogScale); 1082 1080 mpih->UseColors(mFgCol,mCmap,mRevCmap); 1083 1081 mpih->UseScale(mTypScal,mLogScale); -
trunk/SophyaPI/PIext/pihisto2d.h
r3145 r3149 24 24 25 25 void UseColors(bool fg=false,CMapId cmap=CMAP_GREYINV32,bool revcmap=false); 26 void UseScale(unsigned short type=0, floatlogscale=10.);27 void UseDisplay(unsigned short type=0, floatfnpt=0.5);28 void UseDyn( float hmin=1.,floathmax=-1.);29 void UseFrac( float frmin=0.1,floatfrmax=0.9);26 void UseScale(unsigned short type=0,double logscale=10.); 27 void UseDisplay(unsigned short type=0,double fnpt=0.5); 28 void UseDyn(double hmin=1.,double hmax=-1.); 29 void UseFrac(double frmin=0.1,double frmax=0.9); 30 30 void Print(int lp=0); 31 31 … … 43 43 virtual void DrawStats(PIGraphicUC* g); 44 44 inline void SetStats(bool fg=true) {stats=fg;} 45 inline void SetStatPosOffset( float ofx=-0.01, floatofy=-0.01)45 inline void SetStatPosOffset(double ofx=-0.01, double ofy=-0.01) 46 46 {spoX=ofx; spoY=ofy; } 47 47 … … 63 63 inline unsigned short TypScale() {return(mTypScal);} 64 64 inline unsigned short TypDisplay() {return(mTypDisp);} 65 inline floatFPoints() {return(mFPoints);}66 inline floatHMax() {return(mHMax);}67 inline floatHMin() {return(mHMin);}68 inline floatFMax() {return(mFracMax);}69 inline floatFMin() {return(mFracMin);}70 inline floatLogScale() {return(mLogScale);}65 inline double FPoints() {return(mFPoints);} 66 inline double HMax() {return(mHMax);} 67 inline double HMin() {return(mHMin);} 68 inline double FMax() {return(mFracMax);} 69 inline double FMin() {return(mFracMin);} 70 inline double LogScale() {return(mLogScale);} 71 71 72 72 protected: 73 73 int NPixBin(PIGraphicUC* g); 74 char HPrint2( floatf);74 char HPrint2(double f); 75 75 76 76 P2DHistoWrapper* mHistoWp; 77 77 bool mAdDO; bool stats; 78 78 bool mFgCol; CMapId mCmap; bool mRevCmap; 79 unsigned short mTypScal; floatmLogScale;80 unsigned short mTypDisp; floatmFPoints;81 floatmHMin,mHMax;82 floatmFracMin,mFracMax;83 floatspoX, spoY; // Stat pos offset par rapport a position defaut79 unsigned short mTypScal; double mLogScale; 80 unsigned short mTypDisp; double mFPoints; 81 double mHMin,mHMax; 82 double mFracMin,mFracMax; 83 double spoX, spoY; // Stat pos offset par rapport a position defaut 84 84 }; 85 85 … … 117 117 118 118 bool mFgCol; CMapId mCmap; bool mRevCmap; 119 unsigned short mTypScal; floatmLogScale;120 unsigned short mTypDisp; floatmFPoints;121 floatmHMin,mHMax;122 floatmFracMin,mFracMax;119 unsigned short mTypScal; double mLogScale; 120 unsigned short mTypDisp; double mFPoints; 121 double mHMin,mHMax; 122 double mFracMin,mFracMax; 123 123 }; 124 124 -
trunk/SophyaPI/PIext/pintuple.cc
r2755 r3149 364 364 || opts=="nostat" || opts=="nostats") SetStats(false); 365 365 else if(opts.substr(0,11) == "statposoff=") { 366 floatxo=0., yo=0.;367 sscanf(opts.substr(11).c_str(),"% g,%g",&xo, &yo);366 double xo=0., yo=0.; 367 sscanf(opts.substr(11).c_str(),"%lf,%lf",&xo, &yo); 368 368 SetStatPosOffset(xo, yo); 369 369 } … … 400 400 if(stats) opt.push_back("stat"); else opt.push_back("nstat"); 401 401 402 sprintf(str,"statposoff=% g,%g",spoX,spoY); opt.push_back(str);402 sprintf(str,"statposoff=%lf,%lf",spoX,spoY); opt.push_back(str); 403 403 404 404 if(connectPts) opt.push_back("connectpoints"); -
trunk/SophyaPI/PIext/pintuple.h
r2524 r3149 35 35 36 36 inline void SetStats(bool fg=true) { stats = fg; } 37 inline void SetStatPosOffset( float ofx=-0.01, floatofy=-0.01)37 inline void SetStatPosOffset(double ofx=-0.01, double ofy=-0.01) 38 38 {spoX=ofx; spoY=ofy; } 39 39 … … 62 62 bool stats; // true -> indication du nb de points 63 63 bool connectPts; // true -> les points sont relies par une ligne 64 floatspoX, spoY; // Stat pos offset par rapport a position defaut64 double spoX, spoY; // Stat pos offset par rapport a position defaut 65 65 long NptDraw; // nombre de points effectivement dessines dans la fenetre 66 66 }; -
trunk/SophyaPI/PIext/sohiswrap.h
r3145 r3149 106 106 char label[64]; string s; 107 107 108 sprintf(label, "N Cor= %d",mHis->NCorrel());108 sprintf(label, "NMean= %d",mHis->NMean()); 109 109 s = label; text.push_back(s); 110 110 … … 154 154 virtual r_8 Content(int_4 i, int_4 j) { return (*mHis)(i,j) ; } 155 155 virtual r_8 Error(int_4 i, int_4 j) { return mHis->Error(i,j) ; } 156 virtual r_8 NbEntries(int_4 i, int_4 j) { return 0.; } // $CHECK$ CMV 0 ?? 157 158 // Methode de mise a jour du contenu 159 // virtual void Update() $CHECK$ CMV a supprimer ? 156 virtual r_8 NbEntries(int_4 i, int_4 j) { return 0.; } 160 157 161 158 // ajoute des lignes de texte avec les infos statistiques (dans text) … … 163 160 virtual int GetStatInfoAsText(vector<string> & text ) 164 161 { 165 // $CHECK$ CMV , faut-il completer ?166 162 char label[64]; 167 163 string s; … … 213 209 virtual r_8 Content(int_4 i, int_4 j) { return (*mHis)(i,j) ; } 214 210 virtual r_8 Error(int_4 i, int_4 j) { return mHis->Error(i,j) ; } 215 virtual r_8 NbEntries(int_4 i, int_4 j) { return mHis->NEntBin(i,j) ; } // $CHECK$ CMV OK ? 216 217 // Methode de mise a jour du contenu 218 // virtual void Update() $CHECK$ CMV a supprimer ? 211 virtual r_8 NbEntries(int_4 i, int_4 j) { return mHis->NEntBin(i,j) ; } 219 212 220 213 // ajoute des lignes de texte avec les infos statistiques (dans text) … … 222 215 virtual int GetStatInfoAsText(vector<string> & text ) 223 216 { 224 // $CHECK$ CMV , faut-il completer ?225 217 char label[64]; 226 218 string s; 227 sprintf(label,"N Correl= %d", mHis->NCorrel());219 sprintf(label,"NMean= %d", mHis->NMean()); 228 220 text.push_back(label); 229 221 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.