| T O P I C R E V I E W |
| G.Bartsch |
Posted - 09/19/2006 : 10:58:52 AM I have a strange problem I dont understand: I have a script in which there is something like a while loop with which I want to keep an eye on the change of a variable. In the meanwhile I want to use the graph tools (dotool 3, 4). If I type the scripts definition name in the script window everythin works pretty fine. But if I copy the definition and the execution in a txt file and run that by a toolbar button the tools toolbar is not available (in terms of not reacting on the mouse) as long as the while loop is running. In the active Graph itself I can click my user defined buttons all the time. Maybe you know something?
|
| 5 L A T E S T R E P L I E S (Newest First) |
| G.Bartsch |
Posted - 09/20/2006 : 11:47:52 AM i finally found a solution. thank you. |
| G.Bartsch |
Posted - 09/20/2006 : 08:49:12 AM the "while loop" is in handsort |
| G.Bartsch |
Posted - 09/20/2006 : 07:36:58 AM if i run the content of getvarauto by copying to the script window everyting works pretty fine. |
| G.Bartsch |
Posted - 09/20/2006 : 07:33:08 AM this is the complete txt file, hope this helps:
def part1{ width=10; height=10;
getnumber (width) width (height) height (Parameters for origins peaks() function. See Help>Programming for more information.);
win -a %1;
cols=%H!wks.ncols;
if (exist(peaktmp)==2){win -cd peaktmp;}; win -t data "%YLorentzMultiFit\wks_xonly.otw" [peaktmp]; for(i=1;i<=(cols-1);i++) { peaktmp!wks.addcol($(i)); };
delete col(0);
for (i=1;i<=(cols-1);i++) { peaktmp_$(i)=%1!cell(peaks(%1_$(i),width,height),1); };
pntmp=peaktmp!wks.maxrows;
if (exist(difftmp)==2){win -cd difftmp;}; win -t data "%YLorentzMultiFit\wks_difftmp.otw" [difftmp];
for (i=1;i<=1000;i++) { difftmp!cell($(i),1)=$(i); };
//for(j=1;j<=(cols-1);j++) //{ //limit peaktmp_$(j); //for(o=$(limit.size+1);o<=$(pntmp);o++) //{ //peaktmp!cell($(o),$(j))=0; //};
//};
//new copy function limit=15;
if (exist(PDpeakonly)==2){win -cd PDpeakonly;}; win -t data "%YLorentzMultiFit\wks_xonly.otw" [PDpeakonly]; peaks=0; limit peaktmp_1; for(i=1;i<=limit.size;i++) { PDpeakonly!wks.addcol($(i));
peaks++; };
for(i=1;i<=limit.size;i++) { PDpeakonly_$(i)[1]=peaktmp_1[$(i)];
};
cols=%1!wks.ncols; for (ii = 2; ii <= cols; ii += 1) { %u=%1!wks.col$(ii).label$; PDpeakonly!cell($(ii-1),1) = $(%u);
};
};
def part2{ rwbkz=100; getnumber (RWBKZ) rwbkz (Reichweitenbeschraenkungs- kennziffer (a tribut to Mr. Finke): The higher the value the more old peaks will be neglected.); break.open(Sorting...); step=100/(cols-2);
for(j=1;j<=(cols-2);j++) { break.set(step*$(j)); win -a difftmp; for(a=2;a<=4;a++) { wo -s $(a) 1; for(b=1;b<=peaks;b++) { menu -e 36442; }; };
for(i=1;i<=peaks;i++) { limit PDpeakonly_$(i); pend=limit.size;
set PDpeakonly_$(i) -b 1; set PDpeakonly_$(i) -e pend; //type "j=$(j) i=$(i) pend=$(pend)";
if(pend==1)//first step { //type "first step"; ytmp=PDpeakonly_$(i)[1];
}; else {
if(PDpeakonly_$(i)[$(pend-1)]==-)//other special cases { //type "other special cases"; for(b=2;b<=pend;b++) { if(PDpeakonly_$(i)[$(pend-b)]==-){}; else{break;}; if(b==pend){newcol=1;};//run through to the top };
if(newcol==1)//except the last value empty ones { //type "except the last value emty ones"; ytmp=PDpeakonly_$(i)[pend]; newcol=0; }; else //some missin values { //type "some missin values"; stat.data$ = PDpeakonly_$(i); set PDpeakonly_$(i) -b (pend-$(b)); set PDpeakonly_$(i) -e pend; stat.lr(); set PDpeakonly_$(i) -b 1; set PDpeakonly_$(i) -e pend; ytmp=$(stat.lr.a)+(PDpeakonly_0[$(j+1)]*$(stat.lr.b)); }; };
else //regular case {
//type "regular case";
stat.data$ = PDpeakonly_$(i); set PDpeakonly_$(i) -b (pend-4); set PDpeakonly_$(i) -e pend; stat.lr(); set PDpeakonly_$(i) -b 1; set PDpeakonly_$(i) -e pend;
ytmp=$(stat.lr.a)+(PDpeakonly_0[$(j+1)]*$(stat.lr.b));
}; };
limit peaktmp_$(j+1); limitk=limit.size; for(k=1;k<=limitk;k++) { difftmp!cell($(k),2)=abs(ytmp-peaktmp!cell($(k),$(j+1)))*(((j-pend+1)*(j-pend+1)/rwbkz)+1); };
limit difftmp_A;
difftmp!cell($(i),4)=peaktmp!cell(list(limit.ymin, difftmp_a),$(j+1)); difftmp!cell($(i),3)=difftmp!cell(list(limit.ymin, difftmp_a),2);
//type "$(ytmp)"; };
//delete bad assignements
limit difftmp_c; limiti=limit.size; for(i=1;i<=limiti;i++) { if(difftmp_c[$(i)]==0){i++;}; limitu=limit.size; for(u=(i+1);u<=limitu;u++) {
if(difftmp_c[$(i)]==difftmp_c[$(u)]) { if(difftmp_b[$(i)]<difftmp_b[$(u)]) { difftmp_c[$(u)]=0; }; else{difftmp_c[$(i)]=0;}; }; }; };
//copy found peaks limit difftmp_c; limiti=limit.size; for(i=1;i<=limiti;i++) { if(difftmp_c[$(i)]==0){}; else{ PDpeakonly_$(i)[$(j+1)]=difftmp_c[$(i)]; }; };
//copy others limit peaktmp_$(j+1); limiti=limit.size; for(i=1;i<=limiti;i++) { found=0; limit difftmp_c; limitu=limit.size; for(u=1;u<=limitu;u++) { if($(i)==list(difftmp_c[$(u)],peaktmp_$(j+1))){found=1;}; //if(difftmp_c[$(u)]==0){found=1;}; }; if(found==0) { peaks++; PDpeakonly!wks.addcol($(peaks)); PDpeakonly_$(peaks)[$(j+1)]=peaktmp_$(j+1)[$(i)]; }; };
};
break.close(Sorting...);
};
def plotunsort{
//inverting peaktmp and plotting not sorted if (exist(peaktmpx)==2){win -cd peaktmpx;}; win -t data "%YLorentzMultiFit\wks_xonly.otw" [peaktmpx];
maxpeaks=peaktmp!wks.maxRows;
for(i=1;i<=maxpeaks;i++) { peaktmpx!wks.addcol($(i));
};
cols=luminescence!wks.ncols; for(j=1;j<=(cols-1);j++) { for(i=1;i<=pntmp;i++) { peaktmpx_$(i)[$(j)]=peaktmp_$(j)[$(i)]; }; };
for (ii = 2; ii <= cols; ii += 1) { %u=luminescence!wks.col$(ii).label$; peaktmpx!cell($(ii-1),1) = $(%u);
};
//plot data if("%1"=="luminescence") { if (exist(matpl)==5){window -cd matpl;}; }; if("%1"=="luminescencep") { if (exist(matplp)==5){window -cd matplp;}; }; if("%1"=="modulation") { if (exist(matm)==5){window -cd matm;}; }; if (exist(magnet)==2){window -cd magnet;}; if (exist(graph)==3){window -cd graph;};
rows=luminescence!wks.maxrows; win -a %1; win -d %1; doc -e W {%S=%H}; win -a %S;
del %S_0;
run.section(WKS,Wks2Mat);
win -cd %S;
if("%1"=="luminescence") { win -r %H matpl; };
if("%1"=="luminescencep") { win -r %H matplp; };
if("%1"=="modulation") { win -r %H matm; };
matrix -ps X 1 (cols-1); matrix -px Y 1 (rows);
win -t data "%YLorentzMultiFit\wks_xonly" magnet;
for (ii = 2; ii <= cols; ii += 1) { %u=luminescence!wks.col$(ii).label$; magnet!cell($(ii-1),1) = $(%u); };
if("%1"=="luminescence") { win -a matpl; worksheet -p 220 "%YLorentzMultiFit\maplum"; };
if("%1"=="luminescencep") { win -a matplp; worksheet -p 220 "%YLorentzMultiFit\maplum"; };
if("%1"=="modulation") { win -a matm; worksheet -p 220 "%YLorentzMultiFit\mapmod"; };
luminescence!wks.col1.digitMode=1; luminescence!wks.col1.digits=0; magnet!wks.col1.digitMode=1; magnet!wks.col1.digits=0;
layer.y.labelType=2;
layer.y.label.dataset$=luminescence_0;
layer.y.from=1; layer.y.to=rows;
layer.x.labelType=2;
layer.x.label.dataset$=magnet_0;
layer.x.from=1; layer.x.to=(cols-1);
layer.x.inc=5;
win -r %H graph;
//merge prefit
win -a graph;
y1image=y1; y2image=y2; x1image=x1; x2image=x2;
layer -n both;
y1=luminescence!cell($(y1image),1); y2=luminescence!cell($(y2image),1);
x1=magnet!cell($(x1image),1); x2=magnet!cell($(x2image),1);
for (jj=1;jj<=maxpeaks;jj++) { layer -i201 peaktmpx_$(jj); set peaktmpx_$(jj) -c $(jj); };
layer.x.showLabels=0; layer.y.showLabels=0; layer.x.showAxes=0; layer.y.showAxes=0; win -z graph;
};
def plotsort{
//plot data if("%1"=="luminescence") { if (exist(matpl)==5){window -cd matpl;}; }; if("%1"=="luminescencep") { if (exist(matplp)==5){window -cd matplp;}; }; if("%1"=="modulation") { if (exist(matm)==5){window -cd matm;}; }; if (exist(magnet)==2){window -cd magnet;}; if (exist(graph)==3){window -cd graph;};
rows=luminescence!wks.maxrows; win -a %1; win -d %1; doc -e W {%S=%H}; win -a %S;
del %S_0;
run.section(WKS,Wks2Mat);
win -cd %S;
if("%1"=="luminescence") { win -r %H matpl; };
if("%1"=="luminescencep") { win -r %H matplp; };
if("%1"=="modulation") { win -r %H matm; };
matrix -ps X 1 (cols-1); matrix -px Y 1 (rows);
win -t data "%YLorentzMultiFit\wks_xonly" magnet;
for (ii = 2; ii <= cols; ii += 1) { %u=luminescence!wks.col$(ii).label$; magnet!cell($(ii-1),1) = $(%u); };
if("%1"=="luminescence") { win -a matpl; worksheet -p 220 "%YLorentzMultiFit\maplum"; };
if("%1"=="luminescencep") { win -a matplp; worksheet -p 220 "%YLorentzMultiFit\maplum"; };
if("%1"=="modulation") { win -a matm; worksheet -p 220 "%YLorentzMultiFit\mapmod"; };
luminescence!wks.col1.digitMode=1; luminescence!wks.col1.digits=0; magnet!wks.col1.digitMode=1; magnet!wks.col1.digits=0;
layer.y.labelType=2;
layer.y.label.dataset$=luminescence_0;
layer.y.from=1; layer.y.to=rows;
layer.x.labelType=2;
layer.x.label.dataset$=magnet_0;
layer.x.from=1; layer.x.to=(cols-1);
layer.x.inc=5;
win -r %H graph;
//merge prefit
win -a graph;
y1image=y1; y2image=y2; x1image=x1; x2image=x2;
layer -n both;
y1=luminescence!cell($(y1image),1); y2=luminescence!cell($(y2image),1);
x1=magnet!cell($(x1image),1); x2=magnet!cell($(x2image),1);
for (jj=1;jj<=peaks;jj++) { layer -i201 PDpeakonly_$(jj); set PDpeakonly_$(jj) -c $(jj); };
layer.x.showLabels=0; layer.y.showLabels=0; layer.x.showAxes=0; layer.y.showAxes=0; win -z graph;
};
def ini{ //create pdini
if (exist(pdini%1)==2){win -cd pdini%1;}; create.wksName$ = "pdini%1"; create.npts = (cols-1); create.numtypes = 2; create.type1 = 4; create.type2 = 1; create.wks(B);
for (i=1;i<=peaks;i++) { pdini%1!wks.addcol(Pwavel$(i)); pdini%1!wks.addcol(Pampl$(i)); };
pdini%1!wks.addcol(Error); pdini%1!wks.col1.Width=6; pdini%1!wks.col$(2*peaks+2).Width=6;
for(ii=2; ii<=((2*peaks)+1);ii+=1) { pdini%1!wks.col$(ii).Width=11; };
cols=luminescence!wks.ncols; for (ii = 2; ii <= cols; ii += 1) { %u=luminescence!wks.col$(ii).label$; pdini%1!cell($(ii-1),1) = $(%u);
};
if("%1"=="l") { for(j=1;j<=(cols-1);j++) { for(i=1;i<=peaks;i++) { pdini%1_Pwavel$(i)[$(j)]=PDpeakonly_$(i)[$(j)]; pdini%1_Pampl$(i)[$(j)]=luminescence_$(j)[list(pdini%1_Pwavel$(i)[$(j)],luminescence_0)]; }; }; };
if("%1"=="lp") { for(j=1;j<=(cols-1);j++) { for(i=1;i<=peaks;i++) { pdini%1_Pwavel$(i)[$(j)]=PDpeakonly_$(i)[$(j)]; pdini%1_Pampl$(i)[$(j)]=luminescencep_$(j)[list(pdini%1_Pwavel$(i)[$(j)],luminescencep_0)]; }; }; };
if("%1"=="m") { for(j=1;j<=(cols-1);j++) { for(i=1;i<=peaks;i++) { pdini%1_Pwavel$(i)[$(j)]=PDpeakonly_$(i)[$(j)]; pdini%1_Pampl$(i)[$(j)]=modulation_$(j)[list(pdini%1_Pwavel$(i)[$(j)],modulation_0)]; }; }; };
};
def plotfirst{
//plot first
if (exist(Spektra)==3){window -cd Spektra;}; if (exist(PeakData)==2){window -cd PeakData; type -b "Attention! Old PeakData will be overwritten if you continue";};
win -t plot "%YLorentzMultiFit\luminescence.otp" Spektra; layer -i %1_1; layer -a;
//create new worksheet
cols=%1!wks.ncols; create.wksName$ = "PeakData"; create.npts = (cols-1); create.numtypes = 2; create.type1 = 4; create.type2 = 1; create.wks(B);
for (i=1;i<=peaks;i++) { PeakData!wks.addcol(Pwavel$(i)); PeakData!wks.addcol(Pampl$(i)); };
PeakData!wks.addcol(Error); PeakData!wks.col1.Width=6; PeakData!wks.col$(2*peaks+2).Width=6;
for(ii=2; ii<=((2*peaks)+1);ii+=1) { PeakData!wks.col$(ii).Width=11; };
//write Bfield
cols=%1!wks.ncols; for (ii = 2; ii <= cols; ii += 1) { %u=%1!wks.col$(ii).label$; PeakData!cell($(ii-1),1) = $(%u);
};
second -p 0.2; };
def getROIlb{ dotool 2 ();
xold=x; p=1; for (;p>0;) { type -q ""; second -p 0.2; type -q "Please select ROI left bound"; if (x==xold){}; else {draw -c 1 -n ROIlb -l -v x; p=0;}; second -p 0.5; }; dotool 0 (); type -y "Accept X = $(x)?"; ok=t;
if (ok==1) {}; if (ok==0) {getROIlb};
xminb=x;
type -q "";
};
def getROIrb{ dotool 2 ();
xold=x;
p=1; for (;p>0;) { type -q ""; second -p 0.2; type -q "Please select ROI right bound"; if (x==xold){}; else {draw -c 1 -n ROIrb -l -v x; p=0;}; second -p 0.5; }; dotool 0 ();
type -y "Accept X = $(x)?"; ok=t;
if (ok==1) {}; if (ok==0) {getROIrb};
xmaxb=x;
type -q "";
};
def gety0{ dotool 2 ();
yold=y; p=1; for (;p>0;) { type -q ""; second -p 0.2; type -q "Please select zero level by clicking on graph"; if (y==yold){}; else {draw -c 4 -n line -l y; p=0;}; second -p 0.5; };
y0b=y;
type -q "------> Y = $(y)";
type -y "Accept this zeor level?"; ok=t;
if (ok==1) {}; if (ok==0) {gety0};
};
def handsort{
win -a graph; layer -s 2;
ydist=(y2-y1)/11; width=(x2-x1)/30; for(i=1;i<=peaks;i++) { draw -n $(i) -f read %YLorentzMultiFit\rect.ogo; $(i).width=150; $(i).height=150; $(i).x=x1+$(i*width); $(i).y=y2+ydist; $(i).fillcolor=$(i); }; draw -n delete -f read %YLorentzMultiFit\delete.ogo; delete.x=x1-(3*$(width)); delete.y=y2+ydist; draw -n continue -f read %YLorentzMultiFit\continue.ogo; continue.x=x1-(3*$(width)); continue.y=y2; go=0; for(wait=1;wait>0;) { if(go==1){wait=0;}; second -p 0.5; }; };
def main{ type.showscript(0); part1 %1; plotunsort %1;
type -y "Are all peaks found you want to fit?"; ok=t;
if (ok==1) { if(maxpeaks>10){type "You are going to sort and fit with a huge number of peaks. This might lead to a very long time of computation. Press 'cancel' to stop and try to reduce peak number. Press 'ok' to continue.";}; part2; plotsort %1; }; if (ok==0) {main %1;};
};
def prelex{ main luminescence; handsort; ini l; type -c "Peaks sorted. Now you have to enter ROI and zero level by hand."; plotfirst luminescence; getROIlb; getROIrb; getY0; fittype=1; };
def prelpex{ main luminescencep; handsort; ini lp; type -c "Peaks sorted. Now you have to enter ROI and zero level by hand."; plotfirst luminescencep; getROIlb; getROIrb; getY0; fittype=1; };
def premex{ main modulation; handsort; ini m; type -c "Peaks sorted. Now you have to enter ROI and zero level by hand."; plotfirst modulation; getROIlb; getROIrb; getY0; fittype=2; };
def getvarauto{ prel=1; prelp=0; prem=0; getnumber (luminescence) prel:2 (luminescencep - not available) prelp:2 (modulation) prem:2 (Choose the data you want to be fitted approximative. Availability of A, B and C will depend on it later.);
if(prel==1){prelex;}; //if(prelp==1){prelpex;}; if(prem==1){premex;}; type -b "Now you may start main fitting procedure"; };
getvarauto; |
| zachary_origin |
Posted - 09/20/2006 : 06:34:21 AM Hi G.Bartsch,
Could you paste the scripts here?
Zachary OriginLab GZ Office |
|
|