T O P I C R E V I E W |
Lindax |
Posted - 01/22/2003 : 04:51:43 AM Hi,
I want to fit 6 graphs with the same fitting function (pseudovoigt1). I wrote a script to do the fitting and it actually works pretty well if I just fit one graph. But as soon as I try to integrate the fitting routine in a loop it does not work anymore. I suppose the problem is due to the "getpts" command I use to go the starting values of the peaks. This command is interrupted so that the quittoolbox macro is executed when I try to do the loop. My question is: Is there any command that says that first I have to get the points from the graph, then the endtoolbox macro has to be executed and then I want to repeat it for the next graph window.
Here I send you the script I basically used (I left out some details about the fitting routine which should not be of interest for this specific problem)
loop (j,1,6) { window -a graph$(j); nlsf.func$=psdvoigt1; /*left out something*/
GetNumber -s $Fit.FitNPeaksnumpeaks NumPeaks; nlsf.numReplica=NumPeaks-1;
/*left out some initialisation*/
def EndToolbox { doTool 0; loop(i,1,NumPeaks) { if (NumPeaks==1) XC=_Peak_A[i]; else XC$(i)=_Peak_A[i]; } nlsf.fitdata$=%C; noFitCurve=-1; nlsf -v 0 1 3; nlsf.datastep*=2; if(nlsf.iterate(2)==-1) return 1; nlsf.datastep/=2; nlsf.iterate(1000000); nlsf.datastep/=20000; nlsf.iterate(1000000); nlsf -v 1 1 3; nlsf.datastep*=2; nlsf.iterate(100000); nlsf.datastep/=5000; nlsf.fit(1000000); nlsf.end(100000); };
GetPts -n _Peak_Y NumPeaks [Double-click (or strike Enter) to set Peak$(1+GetPts.count)]; }; /*end of loop*/
I would appreciate any suggestions how to solve that problem.
Linda
|
1 L A T E S T R E P L I E S (Newest First) |
CStorey |
Posted - 01/22/2003 : 2:23:04 PM Hi Linda,
I think your problem is going to be with the doTool command not causing the loop to pause and wait for your input.
The doTool Macro is a wierd beast. I've tried to do something similar before and run into problems. I suggest that you modify the pointProc Macro to do the work for you once you make a selection with the doTool data selector.
Here's an example of multiple Linear Regressions using the data selector and a redifinied PointProc Macro. In the end it worked pretty well. I think the secret was breaking the code up into sections...but I didn't write myself enough documentation after the fact to be able to remember all the details.
Hope this helps!
[main] type.redirection=1; // All "type" statements are printed to the 'Script Window' system.debug=1; // Debugging is turned ON! echo=1;
////// Ask User to pick a graph ////// ijk=1; %Z=""; doc -e P { %Z=%Z %H;}; getn (Graph List:) ijk:Z (Select the Graph to find Ft/Fmax...); // end of getnumber %V=%[%Z, #ijk];
////// Create a Worksheet for the Output ////// win -t wks Origin %Vftfmx; // Create a new worksheet %N=%H; // Remember worksheet name wks.col1.format=2; // Set Colum A as Text wks.col1.name$="Curve"; // Rename A to Dataset wks.col2.name$="FtFmax"; wks.col1.width=20; // Widen Column #1 to 20 chars wks.col2.width=12; // Widen Column #2 to 12 chars wks.addcol(B); wks.col3.name$="Ib"; wks.addcol(C); wks.col4.name$="Ic";
win -a %V; // Make selected the selected Graph the Active Graph win -z; // Makes Active graph Maximized!
type -b "Sect the Data Range for LR using the mouse then press 'Enter'";
// Layer -c command: // Count how many datasets are plotted in the active layer. // Put the result into the count variable, and concatenate // the names of all datasets into %Z. type "***** Ft/Fmax Analysis for Graph %V ******"; type "===================================================="; layer -c; loop(ii,1,3) { %C=%[%Z,#ii]; run.section(,LRAnalysis); }
[LRAnalysis] dotool -dh 4; def pointproc{ type " $(ii)) %C curve"; %U=xof(%C); lr -x %U %C -b mks1 -e mks2; xintercept=-1*(lr.a)/(lr.b); type " --> Range = ($(ptbx), $(ptby)) to ($(ptex), $(ptey))"; /// LR Range in XY for each curve type " --> Slope = $(lr.b,%9.4g) +- $(lr.sdB,%9.4g)"; type " --> Y-intercept = $(lr.a,%9.4g) +- $(lr.sda,%9.4g)"; type " --> Correlation R = $(lr.r,%9.4g)"; type " --> X-intercept = $(xintercept,%9.4g)"; type "===================================================="; done=1; dotool 0; };
for(done=0;done==0; ) { sec -p .05; }; ///// Wait until Done=1!
Return
Craig Storey Origin WebRing Member - http://g.webring.com/hub?ring=originwebring |
|
|