Changeset 743
- Timestamp:
- Sep 16, 2010 5:13:31 PM (12 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/Wrapper_v40.ipf
r728 r743 79 79 PopupMenu popup_2,pos={30,93},size={123,20},title="Coefficients" 80 80 PopupMenu popup_2,mode=1,value= #"W_CoefPopupList()",proc=Coef_PopMenuProc 81 CheckBox check_0,pos={4 40,19},size={79,14},title="Use Cursors?",value= 081 CheckBox check_0,pos={430,19},size={79,14},title="Use Cursors?",value= 0 82 82 CheckBox check_0,proc=UseCursorsWrapperProc 83 CheckBox check_1,pos={4 40,42},size={74,14},title="Use Epsilon?",value= 084 CheckBox check_2,pos={4 40,65},size={95,14},title="Use Constraints?",value= 083 CheckBox check_1,pos={430,42},size={74,14},title="Use Epsilon?",value= 0 84 CheckBox check_2,pos={430,65},size={95,14},title="Use Constraints?",value= 0 85 85 CheckBox check_3,pos={530,18},size={72,14},title="2D Functions?",value= 0 86 86 CheckBox check_3 proc=Toggle2DControlsCheckProc 87 CheckBox check_4,pos={440,85},size={72,14},title="Report?",value= 0 88 CheckBox check_5,pos={454,103},size={72,14},title="Save it?",value= 0 87 CheckBox check_4,pos={430,85},size={72,14},title="Report?",value= 0 88 CheckBox check_5,pos={444,103},size={72,14},title="Save it?",value= 0 89 CheckBox check_6,pos={530,42},size={72,14},title="Use Residuals?",value= 0 90 CheckBox check_6,proc=UseResidualsCheckProc 91 CheckBox check_7,pos={530,65},size={72,14},title="Info Box?",value= 0 92 CheckBox check_7,proc=UseInfoTextBoxCheckProc 89 93 //change draw order to put button over text of checkbox 90 94 Button button_0,pos={520,93},size={100,20},proc=DoTheFitButton,title="Do 1D Fit" … … 679 683 680 684 String folderStr,funcStr,coefStr 681 Variable useCursors,useEps,useConstr 685 Variable useCursors,useEps,useConstr,useResiduals,useTextBox 682 686 683 687 switch( ba.eventCode ) … … 699 703 useConstr=V_Value 700 704 705 ControlInfo/W=WrapperPanel check_6 706 useResiduals=V_Value 707 708 ControlInfo/W=WrapperPanel check_7 709 useTextBox = V_Value 710 701 711 if(!CheckFunctionAndCoef(funcStr,coefStr)) 702 712 DoAlert 0,"The coefficients and function type do not match. Please correct the selections in the popup menus." … … 704 714 endif 705 715 706 FitWrapper(folderStr,funcStr,coefStr,useCursors,useEps,useConstr )716 FitWrapper(folderStr,funcStr,coefStr,useCursors,useEps,useConstr,useResiduals,useTextBox) 707 717 708 718 // DoUpdate (does not work!) … … 743 753 // 744 754 // 745 Function FitWrapper(folderStr,funcStr,coefStr,useCursors,useEps,useConstr )755 Function FitWrapper(folderStr,funcStr,coefStr,useCursors,useEps,useConstr,useResiduals,useTextBox) 746 756 String folderStr,funcStr,coefStr 747 Variable useCursors,useEps,useConstr 757 Variable useCursors,useEps,useConstr,useResiduals,useTextBox 748 758 749 759 String suffix=getModelSuffix(funcStr) … … 763 773 Wave/T lolim=$("LoLim_"+suffix) 764 774 Wave/T hilim=$("HiLim_"+suffix) 765 Wave eps=$("epsilon_"+suffix) 766 775 776 if(useEps) 777 Wave eps=$("epsilon_"+suffix) 778 endif 767 779 // fill a struct instance whether I need one or not 768 780 String DF="root:"+folderStr+":" … … 789 801 isUSANS=1 790 802 endif 803 791 804 // do not construct constraints for any of the coefficients that are being held 792 805 // -- this will generate an "unknown error" from the curve fitting 793 Make/O/T/N=0 constr806 // -- if constraints are not used, the constr wave is killed (null), but that's OK 794 807 if(useConstr) 808 Make/O/T/N=0 constr 795 809 String constraintExpression 796 810 Variable i, nPnts=DimSize(lolim, 0),nextRow=0 … … 809 823 endif 810 824 endfor 825 else 826 KillWaves/Z constr 811 827 endif 812 828 … … 850 866 pt2 = pcsr(B) 851 867 endif 868 else 869 //if cursors are not being used, find the first and last points of the data set, and pass them 870 pt1 = 0 871 pt2 = numpnts(yw) 852 872 endif 853 873 … … 866 886 // The textwave would have to be parsed into a constraint matrix first, then passed as /C={cMat,cVec}. 867 887 // -- just something to watch out for. 888 889 // now two more flags... ,useResiduals,useTextBox 890 Variable tb = 1+2+4+8+16+256+512 //See CurveFit docs for bit settings for /TBOX flag 868 891 869 892 do … … 881 904 // useEps and useConstr are not needed 882 905 // pass the structure to get the current waves, including the trimmed USANS matrix 906 // 907 // I don't know that GetCurveFit can do residuals, so I'm not passing that flag, or the text box flag 908 // 883 909 Variable chi,pt 884 910 … … 890 916 endif 891 917 892 893 if(useRes && useEps && useCursors && useConstr) //do it all 894 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pcsr(A),pcsr(B)] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /STRC=fs 895 break 896 endif 897 898 if(useRes && useEps && useCursors) //no constr 899 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pcsr(A),pcsr(B)] /X=xw /W=sw /I=1 /E=eps /D=fitYw /STRC=fs 900 break 901 endif 902 903 if(useRes && useEps && useConstr) //no crsr 904 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /STRC=fs 905 break 906 endif 907 908 if(useRes && useCursors && useConstr) //no eps 909 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pcsr(A),pcsr(B)] /X=xw /W=sw /I=1 /D=fitYw /C=constr /STRC=fs 910 break 911 endif 912 913 if(useRes && useCursors) //no eps, no constr 914 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pcsr(A),pcsr(B)] /X=xw /W=sw /I=1 /D=fitYw /STRC=fs 915 break 916 endif 917 918 if(useRes && useEps) //no crsr, no constr 919 // Print "timing test for Cylinder_PolyRadius --- the supposedly threaded version ---" 918 // now useCursors, useEps, and useConstr are all handled w/ /NWOK 919 // so there are only three conditions to test == 1 + 3 + 3 + 1 = 8 conditions 920 921 if(useRes && useResiduals && useTextBox) //do it all 922 FuncFit/H=getHStr(hold) /NTHR=0 /TBOX=(tb) $funcStr cw, yw[pt1,pt2] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /STRC=fs /R /NWOK 923 break 924 endif 925 926 if(useRes && useResiduals) //res + resid 927 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pt1,pt2] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /STRC=fs /R /NWOK 928 break 929 endif 930 931 932 if(useRes && useTextBox) //res + text 933 FuncFit/H=getHStr(hold) /NTHR=0 /TBOX=(tb) $funcStr cw, yw[pt1,pt2] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /STRC=fs /NWOK 934 break 935 endif 936 937 if(useRes) //res only 938 // Print "timing test for Cylinder_PolyRadius---" 920 939 // Variable t0 = stopMStimer(-2) 921 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw /X=xw /W=sw /I=1 /E=eps /D=fitYw /STRC=fs 940 941 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pt1,pt2] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /STRC=fs /NWOK 942 922 943 // t0 = (stopMSTimer(-2) - t0)*1e-6 923 944 // Printf "CylPolyRad fit time using res and eps and /NTHR=0 time = %g seconds\r\r",t0 924 925 945 // cw[0] = .01 926 946 // cw[1] = 20 … … 931 951 // 932 952 // t0 = stopMSTimer(-2) 933 // FuncFit/H=getHStr(hold) $funcStr cw, yw /X=xw /W=sw /I=1 /E=eps /D=fitYw /STRC=fs953 // FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pt1,pt2] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /STRC=fs /NWOK 934 954 // t0 = (stopMSTimer(-2) - t0)*1e-6 935 955 // Printf "CylPolyRad fit time using res and eps and NO THREADING time = %g seconds\r\r",t0 936 956 break 937 957 endif 938 939 if(useRes && useConstr) //no crsr, no eps 940 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw /X=xw /W=sw /I=1 /D=fitYw /C=constr /STRC=fs 941 break 942 endif 943 944 if(useRes) //just res 945 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw /X=xw /W=sw /I=1 /D=fitYw /STRC=fs 946 break 947 endif 958 959 948 960 949 961 ///// same as above, but all without useRes (no /STRC flag) 950 if(useEps && useCursors && useConstr) //do it all 951 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pcsr(A),pcsr(B)] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr 952 break 953 endif 954 955 if(useEps && useCursors) //no constr 956 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pcsr(A),pcsr(B)] /X=xw /W=sw /I=1 /E=eps /D=fitYw 957 break 958 endif 959 960 if(useEps && useConstr) //no crsr 961 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr 962 break 963 endif 964 965 if(useCursors && useConstr) //no eps 966 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pcsr(A),pcsr(B)] /X=xw /W=sw /I=1 /D=fitYw /C=constr 967 break 968 endif 969 970 if(useCursors) //no eps, no constr 971 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pcsr(A),pcsr(B)] /X=xw /W=sw /I=1 /D=fitYw 972 break 973 endif 974 975 if(useEps) //no crsr, no constr 976 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw /X=xw /W=sw /I=1 /E=eps /D=fitYw 977 break 978 endif 979 980 if(useConstr) //no crsr, no eps 981 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw /X=xw /W=sw /I=1 /D=fitYw /C=constr 962 if(useResiduals && useTextBox) //resid+ text 963 FuncFit/H=getHStr(hold) /NTHR=0 /TBOX=(tb) $funcStr cw, yw[pt1,pt2] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /R /NWOK 964 break 965 endif 966 967 if(useResiduals) //resid 968 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pt1,pt2] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /R /NWOK 969 break 970 endif 971 972 973 if(useTextBox) //text 974 FuncFit/H=getHStr(hold) /NTHR=0 /TBOX=(tb) $funcStr cw, yw[pt1,pt2] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /NWOK 982 975 break 983 976 endif 984 977 985 978 //just a plain vanilla fit 986 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw /X=xw /W=sw /I=1 /D=fitYw 987 979 980 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, yw[pt1,pt2] /X=xw /W=sw /I=1 /E=eps /D=fitYw /C=constr /NWOK 981 988 982 while(0) 989 983 990 984 t0 = (stopMSTimer(-2) - t0)*1e-6 991 985 Printf "fit time = %g seconds\r\r",t0 986 992 987 993 988 // append the fit … … 1240 1235 endswitch 1241 1236 end 1237 1238 Function UseInfoTextBoxCheckProc(cba) : CheckBoxControl 1239 STRUCT WMCheckboxAction &cba 1240 1241 switch( cba.eventCode ) 1242 case 2: // mouse up 1243 Variable checked = cba.checked 1244 if(checked) 1245 //print "checked, use textBox in the next fit" 1246 else 1247 //print "unchecked, ask to remove TextBox from the graph" 1248 ControlInfo/W=WrapperPanel popup_0 1249 RemoveTextBox(S_value) 1250 endif 1251 break 1252 endswitch 1253 1254 return 0 1255 End 1256 1257 //does not report an error if the text box is not there 1258 // -- so I'll just be lazy and not check to see if it's there 1259 // 1260 Function RemoveTextBox(folderStr) 1261 String folderStr 1262 1263 DoAlert 1,"Remove the TextBox from the graph?" 1264 if(V_flag == 1) 1265 String str = "CF_"+folderStr+"_i" 1266 TextBox/K/N=$str 1267 endif 1268 return(0) 1269 End 1270 1271 Function UseResidualsCheckProc(cba) : CheckBoxControl 1272 STRUCT WMCheckboxAction &cba 1273 1274 switch( cba.eventCode ) 1275 case 2: // mouse up 1276 Variable checked = cba.checked 1277 if(checked) 1278 //print "checked, use them in the next fit" 1279 else 1280 //print "unchecked, ask to remove residuals from the graph" 1281 ControlInfo/W=WrapperPanel popup_0 1282 RemoveResiduals(S_value) 1283 endif 1284 break 1285 endswitch 1286 1287 return 0 1288 End 1289 1290 // the default name from the /R flag is "Res_" + yWaveName 1291 // 1292 // better to find the wave that starts with "Res_" and remove that one in case the 1293 // wave names get too long 1294 // 1295 // the difficulty now is that the residual wave ends up in root: and not with the data.... 1296 // -- not really a problem, but adds to clutter 1297 Function RemoveResiduals(folderStr) 1298 String folderStr 1299 1300 String list="",topWin="" 1301 Variable num,ii 1302 String str 1303 1304 DoAlert 1,"Remove the residuals from the graph?" 1305 if(V_flag == 1) 1306 // String topGraph= WinName(0,1) //this is the topmost graph 1307 list=TraceNameList("", ";", 1 ) //"" as first parameter == look on the target graph 1308 num=ItemsInList(list) 1309 1310 for(ii=0;ii<num;ii+=1) 1311 str = StringFromList(ii, list ,";") 1312 if(strsearch(str, "Res_", 0) != -1) 1313 RemoveFromGraph $str 1314 endif 1315 endfor 1316 1317 SetDataFolder root: 1318 endif 1319 1320 return(0) 1321 End 1242 1322 1243 1323 Function Toggle2DControlsCheckProc(cba) : CheckBoxControl -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/COR_Graph.ipf
r624 r743 360 360 SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 361 361 362 Wave samCts=$(USANSFolder+":SAM:DetCts")363 Wave empCts=$(USANSFolder+":EMP:DetCts")362 Wave/Z samCts=$(USANSFolder+":SAM:DetCts") 363 Wave/Z empCts=$(USANSFolder+":EMP:DetCts") 364 364 if((WaveExists(samCts)==0) || (WaveExists(empCts)==0)) 365 DoAlert 0,"Sample and Empty data must both be plotted before you can calculate the transmission" 365 366 Variable/G $(USANSFolder+":Globals:MainPanel:gTransWide")=NaN //error 366 367 Variable/G $(USANSFolder+":Globals:MainPanel:gTransRock")=NaN
Note: See TracChangeset
for help on using the changeset viewer.