Changeset 762 for sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtils2D_v40.ipf
- Timestamp:
- Oct 27, 2010 6:11:50 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtils2D_v40.ipf
r754 r762 103 103 w1 = CleanupName((S_fileName + "_qy"),0) 104 104 w2 = CleanupName((S_fileName + "_i"),0) 105 105 w3 = CleanupName((S_fileName + "_iErr"),0) //make a name for the error wave, to be generated here 106 106 107 String baseStr=w1[0,strlen(w1)-4] 107 108 if(DataFolderExists("root:"+baseStr)) … … 135 136 Duplicate/O $("root:"+n1), $w1 136 137 Duplicate/O $("root:"+n2), $w2 138 139 140 141 // generate my own error wave for I(qx,qy). This is exactly the same procedure that is used in the QxQy_Export function 142 Duplicate/O $("root:"+n0), $w3 143 $w3 = sqrt($w2) //assumes Poisson statistics for each cell (counter) 144 // sw = 0.05*sw // uniform 5% error? tends to favor the low intensity too strongly 145 // get rid of the "bad" errorsby replacing the NaN, Inf, and zero with V_avg 146 // THIS IS EXTREMEMLY IMPORTANT - if this is not done, there are some "bad" values in the 147 // error wave (things that are not numbers) - and this wrecks the smeared model fitting. 148 // It appears to have no effect on the unsmeared model. 149 WaveStats/Q $w3 150 $w3 = numtype($w3[p]) == 0 ? $w3[p] : V_avg 151 $w3 = $w3[p] != 0 ? $w3[p] : V_avg 137 152 138 153 endif //3-columns … … 569 584 // 570 585 // Currently the limitations are: 571 // - I have no error waves for the intensity 572 // - There is no smeared model 586 // - I have no error waves for the intensity (fixed 10/2010) 587 // - There is no smeared model (coming soon after 10/2010) 573 588 // - Cursors can't be used 574 // - the report *probably* won't work 589 // - the report works OK, but I have little control over the graphics 590 // - the mask is generated here with a default radius of 8 pixels around the beam center 591 // 575 592 Function FitWrapper2D(folderStr,funcStr,coefStr,useCursors,useEps,useConstr) 576 593 String folderStr,funcStr,coefStr 577 594 Variable useCursors,useEps,useConstr 578 595 596 //These only make sense for the 1D fits, but put them here so keep the look of the dispatching the same 597 Variable useResiduals, useTextBox 598 useResiduals = 0 599 useTextBox = 0 600 579 601 String suffix=getModelSuffix(funcStr) 580 602 … … 596 618 597 619 // fill a struct instance whether I need one or not 620 // note that the resolution waves may or may not exist, and may or may not be used in the fitting 598 621 String DF="root:"+folderStr+":" 599 622 … … 602 625 WAVE qx=$(DF+folderStr+"_qx") 603 626 WAVE qy=$(DF+folderStr+"_qy") 604 WAVE qz=$(DF+folderStr+"_qz")605 WAVE sQpl=$(DF+folderStr+"_sQpl")606 WAVE sQpp=$(DF+folderStr+"_sQpp")607 WAVE shad=$(DF+folderStr+"_fs")627 WAVE/Z qz=$(DF+folderStr+"_qz") 628 WAVE/Z sQpl=$(DF+folderStr+"_sQpl") 629 WAVE/Z sQpp=$(DF+folderStr+"_sQpp") 630 WAVE/Z shad=$(DF+folderStr+"_fs") 608 631 609 632 //just a dummy - I shouldn't need this … … 616 639 WAVE s.xw[0] = qx 617 640 WAVE s.xw[1] = qy 618 WAVE s.qz = qz619 WAVE s.sQpl = sQpl620 WAVE s.sQpp = sQpp621 WAVE s.fs = shad641 WAVE/Z s.qz = qz 642 WAVE/Z s.sQpl = sQpl 643 WAVE/Z s.sQpp = sQpp 644 WAVE/Z s.fs = shad 622 645 623 646 … … 637 660 638 661 //for now, use res will always be 0 for 2D functions 639 Variable useRes =0662 Variable useResol=0 640 663 if(stringmatch(funcStr, "Smear*")) // if it's a smeared function, need a struct 641 useRes =1664 useResol=1 642 665 endif 643 666 … … 648 671 useConstr = 0 649 672 endif 673 WAVE/Z constr=constr //will be a null reference 650 674 651 675 // // do not construct constraints for any of the coefficients that are being held … … 671 695 // endif 672 696 697 if(useCursors) 698 Print "Cursors not yet implemented" 699 useCursors = 0 700 endif 673 701 ///// NO CURSORS for 2D waves 674 702 //if useCursors, and the data is USANS, need to feed a (reassigned) trimmed matrix to the fit 675 // Variable pt1,pt2,newN 703 Variable pt1,pt2,newN 704 pt1 = 0 705 pt2 = numpnts(inten)-1 676 706 // if(useCursors && (dimsize(resW,1) > 4) ) 677 707 // if(pcsr(A) > pcsr(B)) … … 698 728 // FuncFit/H="11110111111"/NTHR=0 Cylinder2D_D :cyl2d_c_txt:coef_Cyl2D_D :cyl2d_c_txt:cyl2d_c_txt_i /X={:cyl2d_c_txt:cyl2d_c_txt_qy,:cyl2d_c_txt:cyl2d_c_txt_qx} /W=:cyl2d_c_txt:sw /I=1 /M=:cyl2d_c_txt:mask /D 699 729 Variable t1=StopMSTimer(-2) 700 730 Variable tb = 0 //no textbox 701 731 702 732 // /NTHR=1 means just one thread for the fit (since the function itself is threaded) 733 // NTHR = 0 == "Auto" mode, using as many processors as are available (not appropriate here since the function itself is threaded?) 703 734 704 735 do 705 if(useRes && useEps && useCursors && useConstr) //do it all 706 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten[pcsr(A),pcsr(B)] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /STRC=s 736 737 // now useCursors, useEps, and useConstr are all handled w/ /NWOK, just like FitWrapper 738 739 740 // if(useResol && useResiduals && useTextBox) //do it all 741 // FuncFit/H=getHStr(hold) /NTHR=0 /TBOX=(tb) $funcStr cw, inten[pt1,pt2] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /STRC=s /R /NWOK 742 // break 743 // endif 744 // 745 // if(useResol && useResiduals) //res + resid 746 // FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, inten[pt1,pt2] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /STRC=s /R /NWOK 747 // break 748 // endif 749 // 750 // 751 // if(useResol && useTextBox) //res + text 752 // FuncFit/H=getHStr(hold) /NTHR=0 /TBOX=(tb) $funcStr cw, inten[pt1,pt2] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /STRC=s /NWOK 753 // break 754 // endif 755 756 if(useResol) //res only 757 Print "useRes only" 758 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, inten[pt1,pt2] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /STRC=s /NWOK 707 759 break 708 760 endif 709 710 if(useRes && useEps && useCursors) //no constr 711 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten[pcsr(A),pcsr(B)] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /STRC=s 761 762 763 ///// same as above, but all without useResol (no /STRC flag) 764 if(useResiduals && useTextBox) //resid+ text 765 FuncFit/H=getHStr(hold) /NTHR=0 /TBOX=(tb) $funcStr cw, inten[pt1,pt2] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /R /NWOK 712 766 break 713 767 endif 714 768 715 if(useRes && useEps && useConstr) //no crsr716 FuncFit/H=getHStr(hold) /NTHR= 1 $funcStr cw, inten /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /STRC=s769 if(useResiduals) //resid 770 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, inten[pt1,pt2] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /R /NWOK 717 771 break 718 772 endif 719 720 if(useRes && useCursors && useConstr) //no eps 721 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten[pcsr(A),pcsr(B)] /X={Qx,Qy} /M=mask /W=sw /I=1 /C=constr /STRC=s 773 774 775 if(useTextBox) //text 776 FuncFit/H=getHStr(hold) /NTHR=0 /TBOX=(tb) $funcStr cw, inten[pt1,pt2] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /NWOK 722 777 break 723 778 endif 724 779 725 if(useRes && useCursors) //no eps, no constr726 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten[pcsr(A),pcsr(B)] /X={Qx,Qy} /M=mask /W=sw /I=1 /STRC=s727 break728 endif729 730 if(useRes && useEps) //no crsr, no constr731 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /STRC=s732 break733 endif734 735 if(useRes && useConstr) //no crsr, no eps736 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /M=mask /W=sw /I=1 /C=constr /STRC=s737 break738 endif739 740 if(useRes) //just res741 Print "useRes only"742 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /M=mask /W=sw /I=1 /STRC=s743 // FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /W=sw /I=1 /STRC=s744 // FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /M=mask /W=sw /I=1745 // FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten_masked /X={Qx,Qy} /W=sw /I=1 /STRC=s746 break747 endif748 749 ///// same as above, but all without useRes (no /STRC flag)750 if(useEps && useCursors && useConstr) //do it all751 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten[pcsr(A),pcsr(B)] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr752 break753 endif754 755 if(useEps && useCursors) //no constr756 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten[pcsr(A),pcsr(B)] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps757 break758 endif759 760 761 if(useEps && useConstr) //no crsr762 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr763 break764 endif765 766 if(useCursors && useConstr) //no eps767 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten[pcsr(A),pcsr(B)] /X={Qx,Qy} /M=mask /W=sw /I=1 /C=constr768 break769 endif770 771 if(useCursors) //no eps, no constr772 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten[pcsr(A),pcsr(B)] /X={Qx,Qy} /M=mask /W=sw /I=1773 break774 endif775 776 if(useEps) //no crsr, no constr777 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps778 break779 endif780 781 if(useConstr) //no crsr, no eps782 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /M=mask /W=sw /I=1 /C=constr783 break784 endif785 786 780 //just a plain vanilla fit 787 print "unsmeared vanilla" 788 FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /M=mask /W=sw /I=1 789 // FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten /X={Qx,Qy} /W=sw /I=1 790 // FuncFit/H=getHStr(hold) /NTHR=1 $funcStr cw, inten_masked /X={Qx,Qy} /W=sw /I=1 791 781 782 FuncFit/H=getHStr(hold) /NTHR=0 $funcStr cw, inten[pt1,pt2] /X={Qx,Qy} /M=mask /W=sw /I=1 /E=eps /C=constr /NWOK 783 792 784 while(0) 793 785 … … 814 806 print w_sigma 815 807 String resultStr="" 808 809 if(waveexists(W_sigma)) 810 //append it to the table, if it's not already there 811 CheckDisplayed/W=WrapperPanel#T0 W_sigma 812 if(V_flag==0) 813 //not there, append it 814 AppendtoTable/W=wrapperPanel#T0 W_sigma 815 else 816 //remove it, and put it back on to make sure it's the right one (do I need to do this?) 817 // -- not really, since any switch of the function menu takes W_Sigma off 818 endif 819 endif 816 820 817 821 //now re-write the results
Note: See TracChangeset
for help on using the changeset viewer.