Changeset 495 for sans


Ignore:
Timestamp:
Apr 29, 2009 2:31:07 PM (14 years ago)
Author:
srkline
Message:

Added a procedure file that does the necessary wrapping for GenCurveFit?, since it's not a perfect drop-in replacement for FuncFit?. Required modification of the FitWrapper? to switch to GenCurveFit? as needed.
Switch between regular L-M and GenOp? using a menu item.a (sets a gobal)
Still ridiculously slow to use.
Can't yet be used with global fitting. Would be a real pain to implement. Can't imagine how slow that would be to use...

Bug fixes in PatchFiles? (default button for filter type) and Correct (use tolerance of +/- 0.01 pixel for determining of what is a "mismatch" of the beam centers. Problem cropped up with ICE, but should be fixed anyways)

Location:
sans/Dev/trunk/NCNR_User_Procedures
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/GlobalFit/SimpleGlobalFit_NCNR_v40.ipf

    r477 r495  
    113113        ListBox list0 widths={30,50,80,80} 
    114114         
    115         Button button_0,pos={344,13},size={100,20},title="Do Fit" 
     115        Button button_0,pos={344,13},size={100,20},title="Do The Fit" 
    116116        Button button_0 proc=SGF_DoFitButtonProc 
    117117        Button button_1,pos={369,173},size={50,20},proc=SaveCheckStateButtonProc,title="Save" 
    118118        Button button_2,pos={429,173},size={70,20},proc=RestoreCheckStateButtonProc,title="Restore" 
     119        Button button_3,pos={500,13},size={100,20},proc=SGFitHelpButtonProc,title="Help" 
    119120         
    120121        Edit/W=(14,174,348,495)/HOST=#  
     
    124125         
    125126EndMacro 
     127 
     128//open the Help file for the Simple Global Fit 
     129Function SGFitHelpButtonProc(ba) : ButtonControl 
     130        STRUCT WMButtonAction &ba 
     131 
     132        switch( ba.eventCode ) 
     133                case 2: // mouse up 
     134                        // click code here 
     135                        DisplayHelpTopic/Z/K=1 "Simple Global Fit" 
     136                        if(V_flag !=0) 
     137                                DoAlert 0,"The Simple Global Fit Help file could not be found" 
     138                        endif 
     139                        break 
     140        endswitch 
     141 
     142        return 0 
     143End 
     144 
    126145 
    127146// save the state of the checkboxes 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/Wrapper_v40.ipf

    r494 r495  
    2424        Variable/G root:Packages:NIST:USANSUseTrap = 0 
    2525        Variable/G root:Packages:NIST:USANS_dQv = 0.117 
    26          
     26        Variable/G root:Packages:NIST:gUseGenCurveFit = 0                       //set to 1 to use genetic optimization 
     27                         
    2728        //Ugly. Put this here to make sure things don't break 
    2829        String/G root:Packages:NIST:gXMLLoader_Title 
     
    217218         
    218219        // MOTOFIT/GenFit bits 
    219         tmp = "GEN_allatoncefitfunc;GEN_fitfunc;GetCheckBoxesState;MOTO_GFFitAllAtOnceTemplate;MOTO_GFFitFuncTemplate;MOTO_NewGF_SetXWaveInList;MOTO_NewGlblFitFunc;MOTO_NewGlblFitFuncAllAtOnce;" 
     220        tmp = "GEN_allatoncefitfunc;GEN_fitfunc;GetCheckBoxesState;MOTO_GFFitAllAtOnceTemplate;MOTO_GFFitFuncTemplate;MOTO_NewGF_SetXWaveInList;MOTO_NewGlblFitFunc;MOTO_NewGlblFitFuncAllAtOnce;GeneticFit_UnSmearedModel;GeneticFit_SmearedModel;" 
    220221        list = RemoveFromList(tmp, list  ,";") 
    221222 
     
    758759        fitYw = NaN 
    759760         
    760         Variable useRes=0 
     761        Variable useRes=0,isUSANS=0,val 
    761762        if(stringmatch(funcStr, "Smear*"))              // if it's a smeared function, need a struct 
    762763                useRes=1 
    763764        endif 
    764          
     765        if(dimsize(resW,1) > 4) 
     766                isUSANS=1 
     767        endif 
    765768        // do not construct constraints for any of the coefficients that are being held 
    766769        // -- this will generate an "unknown error" from the curve fitting 
     
    793796        Variable pt1,pt2,newN,mPt1,mPt2 
    794797        String noteStr 
    795         if(useCursors && (dimsize(resW,1) > 4) ) 
     798        if(useCursors && isUSANS ) 
    796799                //where are the cursors, and what is the status of the current matrix? 
    797800                if(pcsr(A) > pcsr(B)) 
     
    814817                Wave trimResW=$(DF+folderStr+"_res"+"t")        //put the trimmed resW in the struct for the fit! 
    815818                Wave fs.resW=trimResW 
    816  
     819        endif 
     820        if(useCursors) 
     821                //find the points so that genetic optimization can use them 
     822                if(pcsr(A) > pcsr(B)) 
     823                        pt1 = pcsr(B) 
     824                        pt2 = pcsr(A) 
     825                else 
     826                        pt1 = pcsr(A) 
     827                        pt2 = pcsr(B) 
     828                endif 
    817829        endif 
    818830                 
     
    821833        Variable/G V_FitQuitReason=0            //0=ok,1=maxiter,2=user stop,3=no chisq decrease 
    822834 
    823          
     835        NVAR useGenCurveFit = root:Packages:NIST:gUseGenCurveFit 
    824836// don't use the auto-destination with no flag, it doesn't appear to work correctly 
    825837// dispatch the fit 
     
    834846        do 
    835847//              Variable t0 = stopMStimer(-2)           // corresponding print is at the end of the do-while loop (outside) 
     848 
     849 
     850                if(useGenCurveFit) 
     851                 
     852#if !(exists("GenCurveFit")) 
     853                        // XOP not available 
     854                        useGenCurveFit = 0 
     855                        Abort "Genetic Optimiztion XOP not available. Reverting to normal optimization."         
     856#endif 
     857                        //send everything to a function, to reduce the clutter 
     858                        // useEps and useConstr are not needed 
     859                        // pass the structure to get the current waves, including the trimmed USANS matrix 
     860                        Variable chi,pt 
     861 
     862                        chi = DoGenCurveFit(useRes,useCursors,sw,fitYw,fs,funcStr,getHStr(hold),val,lolim,hilim,pt1,pt2) 
     863                        pt = val 
     864 
     865                        break 
     866                         
     867                endif 
     868                 
    836869                 
    837870                if(useRes && useEps && useCursors && useConstr)         //do it all 
     
    940973        String traces=TraceNameList("", ";", 1 )                //"" as first parameter == look on the target graph 
    941974        if(strsearch(traces,"FitYw",0) == -1) 
    942                 AppendToGraph FitYw vs xw 
     975                if(useGenCurveFit && useCursors) 
     976                        WAVE trimX = trimX 
     977                        AppendtoGraph fitYw vs trimX 
     978                else 
     979                        AppendToGraph FitYw vs xw 
     980                endif 
    943981        else 
    944982                RemoveFromGraph FitYw 
    945                 AppendToGraph FitYw vs xw 
     983                if(useGenCurveFit && useCursors) 
     984                        WAVE trimX = trimX 
     985                        AppendtoGraph fitYw vs trimX 
     986                else 
     987                        AppendToGraph FitYw vs xw 
     988                endif 
    946989        endif 
    947990        ModifyGraph lsize(FitYw)=2,rgb(FitYw)=(0,0,0) 
     
    950993         
    951994        // report the results (to the panel?) 
     995        if(useGenCurveFit) 
     996                V_chisq = chi 
     997                V_npnts = pt 
     998        endif 
    952999        print "V_chisq = ",V_chisq 
    9531000        print cw 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/SA_includes_v400.ipf

    r475 r495  
    1616#include "PlotUtilsMacro_v40"                   version>=4.00 
    1717#include "PlotManager_v40"                              version>=4.00 
     18#include "NCNR_GenFitUtils"                     // April 2009, compiles OK if XOP not present 
    1819 
    1920#include "USANS_SlitSmearing_v40" 
     
    3940                "Determine Invariant",Execute/P "INSERTINCLUDE \"Invariant_v40\"";Execute/P "COMPILEPROCEDURES ";Execute/P "Make_Invariant_Panel()" 
    4041                "Do Linear Fits",Execute/P "INSERTINCLUDE \"LinearizedFits_v40\"";Execute/P "COMPILEPROCEDURES ";Execute/P "A_OpenFitPanel()" 
     42                GenOpFlagEnable()+"Genetic Optimization Enabled", Init_GenOp() 
     43                GenOpFlagDisable()+"Genetic Optimization Disabled", UnSet_GenOp() 
    4144        End 
    4245        "-" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Correct.ipf

    r451 r495  
    895895        noadd_mat = 1           //initialize to 1 
    896896         
    897         If((xshift != 0) || (yshift != 0)) 
     897        If((abs(xshift) >= 0.01) || (abs(yshift) >= 0.01))                      //APR09 - change tolerance to handle ICE "precision" 
    898898                DoAlert 1,"Do you want to ignore the beam center mismatch?" 
    899899                if(V_flag==1)           //yes -> just go on 
     
    901901                        yshift=0 
    902902                endif 
     903        else 
     904                // "mismatch" is simply a python type conversion error 
     905                xshift=0 
     906                yshift=0 
    903907        endif 
    904908         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/PatchFiles.ipf

    r494 r495  
    8181        Variable/G root:myGlobals:Patch:gPV19 = 0 
    8282        Variable/G root:myGlobals:Patch:gTransCts = 0 
    83         Variable/G root:myGlobals:Patch:gRadioVal = 0 
     83        Variable/G root:myGlobals:Patch:gRadioVal = 1 
    8484End 
    8585 
     
    301301        ControlUpdate PatchPopup 
    302302        PopupMenu PatchPopup,mode=1 
     303        ShowHeaderButtonProc("SHButton") 
    303304End 
    304305 
Note: See TracChangeset for help on using the changeset viewer.