Help with Displaying Results of Curvefit during a loop
reepingk
I feel dumb. I wrote this program a few years ago at this point, but have been away from igor programming for a good while.
Anyway, I have the following loop in my program.
<br />
do<br />
FindValue /V=(w_wnNm[falsePeakPt]-winDiam/wMod) /T=3 w_wnNm<br />
leftLocPt2 = V_value //Curvefit window variables<br />
FindValue /V=(w_wnNm[falsePeakPt]+winDiam/wMod) /T=3 w_wnNm<br />
rightLocPt2 = V_value<br />
<br />
CurveFit/Q/N/W=2/NTHR=0 gauss kwCWave=coeffWave 'w_wiNm'[rightLocPt2,leftLocPt2] /X='w_wnNm' /D/C=T_Constraints<br />
<br />
Wave W_sigma //Curvefit with constraints, w_sigma used for error checking<br />
if (((coeffWave[1] < 0) || (W_sigma[0] > 9999)|| (W_sigma[1] > 9999)|| (W_sigma[2] > 9999)) && (wMod < 15))<br />
wMod += 0.5 //If height < 0 or any standard deviation parameter are REALLY high, redo fit making the window smaller<br />
elseif (wMod > 15)<br />
wMod = 1.5 //If the window gets too small, expand window to widest and try again.<br />
else<br />
fitDone = 1 //If nothing is wrong, set variable to break loop.<br />
endif<br />
//Print "THINKING",wMod<br />
while (fitDone == 0)<br />
do<br />
FindValue /V=(w_wnNm[falsePeakPt]-winDiam/wMod) /T=3 w_wnNm<br />
leftLocPt2 = V_value //Curvefit window variables<br />
FindValue /V=(w_wnNm[falsePeakPt]+winDiam/wMod) /T=3 w_wnNm<br />
rightLocPt2 = V_value<br />
<br />
CurveFit/Q/N/W=2/NTHR=0 gauss kwCWave=coeffWave 'w_wiNm'[rightLocPt2,leftLocPt2] /X='w_wnNm' /D/C=T_Constraints<br />
<br />
Wave W_sigma //Curvefit with constraints, w_sigma used for error checking<br />
if (((coeffWave[1] < 0) || (W_sigma[0] > 9999)|| (W_sigma[1] > 9999)|| (W_sigma[2] > 9999)) && (wMod < 15))<br />
wMod += 0.5 //If height < 0 or any standard deviation parameter are REALLY high, redo fit making the window smaller<br />
elseif (wMod > 15)<br />
wMod = 1.5 //If the window gets too small, expand window to widest and try again.<br />
else<br />
fitDone = 1 //If nothing is wrong, set variable to break loop.<br />
endif<br />
//Print "THINKING",wMod<br />
while (fitDone == 0)<br />
Apologies for the lack of indentation, the copy and pasting seemed to ruin it. Here's what this loop does in words.
1. Find left and right point for the "bounds" of the fit.
2. Does the fit.
3. Does error checking. (Are any of the fit coefficient variables WAY too big or WAY too small?)
3.1 If fit variables ARE wrong, change wMod which will affect the position of the fit "window."
3.2 If fit variables are OK, go on to the next fit. (This fit runs on 100s of graphs.)
Basically what I want to do is display the waves I'm doing the fit on, w_wiNm and w_wnNm, then display the fit once it reaches the "fitDone=1" part. Right before it moves on outside the while loop. Then I want to have a window with an OK button on it saying "Is this fit OK." Heck, I'd settle for a DoPrompt window. I looked at the pauseforuser tutorial, but I didn't want the button on the control panel to call a function, I wanted it to simply continue with the program. Even if I do something like this... it's still not great.
<br />
Display/N=TEMPP w_wiNm vs w_wnNm<br />
CurveFit/W=1/NTHR=0 gauss kwCWave=coeffWave 'w_wiNm'[rightLocPt2,leftLocPt2] /X='w_wnNm' /D/C=T_Constraints<br />
Pauseforuser TEMPP<br />
Display/N=TEMPP w_wiNm vs w_wnNm<br />
CurveFit/W=1/NTHR=0 gauss kwCWave=coeffWave 'w_wiNm'[rightLocPt2,leftLocPt2] /X='w_wnNm' /D/C=T_Constraints<br />
Pauseforuser TEMPP<br />
The manual says that the program will only continue once the "main window" is killed. But when I run the above, everything freezes. Sure, I can interact with the window named "TEMPP", but I can't kill it. It won't let me. And I can't do anything else in the program. If I could kill the window, it'd be fine, because that could act as my "OK" button (figuratively.)
Any help?
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
February 20, 2015 at 04:53 pm - Permalink
Prompt select,"Is this fit good enough?",popup,"yup;nah, keep going"
DoPrompt "what to do next", select
if (!V_Flag && StringMatch(select,"yup"))
fitDone = 1
endif
February 24, 2015 at 02:13 am - Permalink