Changeset 390 in Sophya for trunk/SophyaPI
- Timestamp:
- Aug 13, 1999, 4:01:37 PM (26 years ago)
- Location:
- trunk/SophyaPI/PIext
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/piafitting.cc
r386 r390 118 118 //| F : initialisation a partir des resultats et de l'etat du fit precedent 119 119 //| (option non prioritaire sur les definitions p:,s:,m:,M:,f:o:) 120 //| a : initialisation automatique des parametres du fit (si disponible) 121 //| (option non prioritaire sur les definitions p:,s:,m:,M:,f:o: 122 //| et sur l'initialisation pa l'option "F") 120 123 //| f : generation d'un Objet identique contenant la fonction fittee 121 124 //| r : generation d'un Objet identique contenant les residus … … 176 179 , mFit(NULL) 177 180 , mV(NULL), mH(NULL), mM(NULL), mH2(NULL), mIm(NULL), mG(NULL) 178 , mFunction(NULL), mFName(""), mFunc(NULL) 181 , mFunction(NULL), mFName(""), mFunc(NULL), mFitUserFunc(false) 179 182 , mDlUFunc(NULL), mNameFitFunc(""), mFitFunc(NULL), mFitFuncDer(NULL) 180 183 , mUFNVar(0), mUFNPar(0) … … 249 252 mOpt.i1 = mOpt.j1 = mOpt.i2 = mOpt.j2 = -1; 250 253 mOpt.fromlastfit = false; 254 mOpt.autoinifit = false; 251 255 } 252 256 … … 263 267 if(strstr(opt.c_str(),",F,")) // init options/param a partir du fit precedent 264 268 {mOpt = mOptSave; mOpt.fromlastfit = true;} 269 if(strstr(opt.c_str(),",a,")) mOpt.autoinifit = true; // init auto par fit 265 270 if(strstr(opt.c_str(),",r,")) mOpt.okres = true; // residus 266 271 if(strstr(opt.c_str(),",f,")) mOpt.okfun = true; // fonction fittee … … 436 441 <<" TypE="<<mOpt.err_e<<","<<mOpt.err_E 437 442 <<" StpX2="<<mOpt.stc2<<" Nstep="<<mOpt.nstep<<endl 438 <<" Init.LFit="<<mOpt.fromlastfit 443 <<" Init.LFit="<<mOpt.fromlastfit<<" AutoIni.Fit="<<mOpt.autoinifit 439 444 <<" lp,lpg="<<mOpt.lp<<","<<mOpt.lpg<<endl; 440 445 return; … … 504 509 if(mFunc!=NULL) {delete mFunc; mFunc=NULL;} 505 510 mNPar=0; 511 mFitUserFunc = false; 506 512 507 513 if(func == mNameFitFunc) { // Fonction utilisateur 508 514 mFunc = new GeneralFunc(mUFNVar,mUFNPar,mFitFunc,mFitFuncDer); 509 515 mNPar = mUFNPar; 516 mFitUserFunc = true; 510 517 cout<<"Fonction utilisateur nvar="<<mUFNVar<<", npar="<<mNPar<<endl; 511 518 } else if(func[0]=='p' && mNVar==1) { //polynome … … 596 603 597 604 /* --Methode-- */ 605 void PIAFitter::AutoIniFit(void) 606 // Initialisation automatique des parametres du fit 607 { 608 cout<<"CMV: to be done : PIAFitter::AutoIniFit"<<endl; 609 if(mFitUserFunc) { // Fonction utilisateur 610 cout<<"PIAFitter::AutoIniFit : Fonction utilisateur, pas d'init auto"<<endl; 611 612 } else if(mFName[0]=='p' && mNVar==1) { //poly 1D 613 cout<<"PIAFitter::AutoIniFit : Auto Init type polynome 1D"<<endl; 614 615 } else if(mFName[0]=='e' && mNVar==1) { //expo+pol 1D 616 cout<<"PIAFitter::AutoIniFit : Auto Init type expo+pol 1D"<<endl; 617 618 } else if(mFName[0]=='g' && mNVar==1) { //gauss en haut 1D 619 cout<<"PIAFitter::AutoIniFit : Auto Init type gauss_haut+pol 1D"<<endl; 620 621 } else if(mFName[0]=='G' && mNVar==1) { //gauss en vol 1D 622 cout<<"PIAFitter::AutoIniFit : Auto Init type gauss_vol+pol 1D"<<endl; 623 624 } else if(mFName[0]=='p' && mNVar==2) { //poly 2D 625 cout<<"PIAFitter::AutoIniFit : Auto Init type polynome 2D"<<endl; 626 627 } else if((mFName[0]=='G'||mFName[0]=='d') && mNVar==2) { //gauss+fond en vol 628 cout<<"PIAFitter::AutoIniFit : Auto Init type gauss_vol+fond 2D"<<endl; 629 630 } else if(mFName[0]=='D' && mNVar==2) { //DLgauss+fond en vol 2D 631 cout<<"PIAFitter::AutoIniFit : Auto Init type DLgauss_vol+fond 2D"<<endl; 632 Vector dum(mNPar); 633 dum = mPar; mPar(6)=0.5; mPar(7)=dum(6); 634 dum = mStep; mStep(6)=0.05; mStep(7)=dum(6); 635 dum = mMin; mMin(6)=0.; mMin(7)=dum(6); 636 dum = mMax; mMax(6)=10.; mMax(7)=dum(6); 637 dum = mFix; mFix(6)=1.1; mFix(7)=dum(6); 638 639 } else if(mFName[0]=='M' && mNVar==2) { //Moffat+fond en vol 2D 640 cout<<"PIAFitter::AutoIniFit : Auto Init type moffat_vol+fond 2D"<<endl; 641 Vector dum(mNPar); 642 dum = mPar; mPar(6)=2.5; mPar(7)=dum(6); 643 dum = mStep; mStep(6)=0.05; mStep(7)=dum(6); 644 dum = mMin; mMin(6)=1.2; mMin(7)=dum(6); 645 dum = mMax; mMax(6)=10.; mMax(7)=dum(6); 646 dum = mFix; mFix(6)=1.1; mFix(7)=dum(6); 647 648 } else { 649 cout<<"PIAFitter::AutoIniFit : Fonction "<<mFName 650 <<", \n pas d'init auto en dim "<<mNVar<<endl; 651 return; 652 } 653 654 return; 655 } 656 657 /* --Methode-- */ 598 658 void PIAFitter::InitParFromLastFit(void) 599 659 // Initialisation du fit a partir des resultats du fit precedent … … 625 685 if(mNPar==0) return; 626 686 ReSetParam(); 687 if(mOpt.autoinifit) AutoIniFit(); 627 688 if(mOpt.fromlastfit) InitParFromLastFit(); 628 689 Vector* v=NULL; string* s=NULL; … … 913 974 914 975 // Alloc de la taille 915 nlab = 1 4+npar; lab = new PILabel*[nlab]; {for(int i=0;i<nlab;i++) lab[i]=NULL;}976 nlab = 13+npar; lab = new PILabel*[nlab]; {for(int i=0;i<nlab;i++) lab[i]=NULL;} 916 977 ntxt = 10+4*npar; txt = new PIText*[ntxt]; {for(int i=0;i<ntxt;i++) txt[i]=NULL;} 917 nbut = 5; but = new PIButton*[nbut]; {for(int i=0;i<nbut;i++) but[i]=NULL;}978 nbut = 6; but = new PIButton*[nbut]; {for(int i=0;i<nbut;i++) but[i]=NULL;} 918 979 nckb = 2+npar; ckb = new PICheckBox*[nckb]; {for(int i=0;i<nckb;i++) ckb[i]=NULL;} 919 980 npom = 3; pom = new PIOptMenu*[npom]; {for(int i=0;i<npom;i++) pom[i]=NULL;} … … 933 994 // new ligne 934 995 cpx = spx; cpy = spy; 935 string dum = "Object: "+mFitter->mNObj+" , Fun: "+mFitter->mFName; 996 string dum = "Object: "+mFitter->mNObj+" , Fun: "; 997 if(mFitter->mFitUserFunc) dum+=mFitter->mNameFitFunc; else dum+=mFitter->mFName; 936 998 lab[0] = new PILabel(this,dum.c_str(),4*bsx,bsy,cpx,cpy); 937 999 lab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); … … 1039 1101 but[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1040 1102 cpx += bsx+spx; 1041 lab[7] = new PILabel(this,mFitter->mFName.c_str(),2*bsx,bsy,cpx,cpy);1042 lab[7]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1103 but[5] = new PIButton(this, "Ini Auto",444,bsx,bsy,cpx,cpy); 1104 but[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1043 1105 1044 1106 // new ligne 1045 1107 cpx = spx; cpy += bsy+spy; 1046 lab[8] = new PILabel(this,"Par",bsx/2,bsy,cpx,cpy); 1108 lab[7] = new PILabel(this,"Par",bsx/2,bsy,cpx,cpy); 1109 lab[7]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1110 cpx += int(bsx/2.+spx); 1111 lab[8] = new PILabel(this,"Fx",bsx/3,bsy,cpx,cpy); 1047 1112 lab[8]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1048 cpx += int(bsx/ 2.+spx);1049 lab[9] = new PILabel(this," Fx",bsx/3,bsy,cpx,cpy);1113 cpx += int(bsx/3.+spx); 1114 lab[9] = new PILabel(this,"Init",bsx,bsy,cpx,cpy); 1050 1115 lab[9]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1051 cpx += int(bsx/3.+spx);1052 lab[10] = new PILabel(this," Init",bsx,bsy,cpx,cpy);1116 cpx += bsx+spx; 1117 lab[10] = new PILabel(this,"Step",bsx,bsy,cpx,cpy); 1053 1118 lab[10]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1054 1119 cpx += bsx+spx; 1055 lab[11] = new PILabel(this," Step",bsx,bsy,cpx,cpy);1120 lab[11] = new PILabel(this,"Min",bsx,bsy,cpx,cpy); 1056 1121 lab[11]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1057 1122 cpx += bsx+spx; 1058 lab[12] = new PILabel(this,"M in",bsx,bsy,cpx,cpy);1123 lab[12] = new PILabel(this,"Max",bsx,bsy,cpx,cpy); 1059 1124 lab[12]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1060 cpx += bsx+spx;1061 lab[13] = new PILabel(this,"Max",bsx,bsy,cpx,cpy);1062 lab[13]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1063 1125 1064 1126 // new lines: Parametres (npar lignes) … … 1067 1129 cpx = spx; cpy += bsy+spy; 1068 1130 char str[8]; sprintf(str,"P%d",i); 1069 lab[1 4+i] = new PILabel(this,str,bsx/2,bsy,cpx,cpy);1070 lab[1 4+i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);1131 lab[13+i] = new PILabel(this,str,bsx/2,bsy,cpx,cpy); 1132 lab[13+i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1071 1133 cpx += int(bsx/2.+spx); 1072 1134 // Attention pas de message entre 1500 et 2000 (permet 500 parametres!) 1073 ckb[2+i] = new PICheckBox(this,"",1500+i,bsx/3,bsy,cpx,cpy+ bsy/2);1135 ckb[2+i] = new PICheckBox(this,"",1500+i,bsx/3,bsy,cpx,cpy+spy); 1074 1136 ckb[2+i]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); 1075 1137 cpx+=int(bsx/3.+spx); … … 1251 1313 if(rc>=0) mFitter->FitFunRes(); 1252 1314 } 1315 else if(msg ==444) { 1316 if(lp) cout<<"Automatic initialisation"<<endl; 1317 mFitter->AutoIniFit(); 1318 } 1253 1319 else if(msg==1001) { 1254 1320 if(ckb[0]->GetState()) { -
trunk/SophyaPI/PIext/piafitting.h
r385 r390 50 50 int lp,lpg; 51 51 int i1,i2,j1,j2; 52 bool fromlastfit ;52 bool fromlastfit,autoinifit; 53 53 } DFOPTIONS ; 54 54 … … 62 62 void DecodeFunction(string func); 63 63 void ReSetParam(void); 64 void AutoIniFit(void); 64 65 void InitParFromLastFit(void); 65 66 void DecodeParam(string par,string step,string min,string max,string fix); … … 88 89 GeneralFunction* mFunction; string mFName; 89 90 // Gestion de fonction de fit definie par l'utilisateur 91 bool mFitUserFunc; 90 92 GeneralFunc* mFunc; 91 93 PDynLinkMgr* mDlUFunc;
Note:
See TracChangeset
for help on using the changeset viewer.