Ignore:
Timestamp:
May 23, 2013 9:43:12 AM (10 years ago)
Author:
srkline
Message:

Updated the NGB attenuator tables with Katie's new measurements from May 2013.

Made some changes to Auto-Fit to make it more useable. Will turn it "on" when documentation is finished.

Changed how the random deviate function is calculated to improve the estimates of multiple scattering. Now the q-range of integration is shifted to lower q for the USANS calculation (using very large objects). Also, the number of points used in the integration is chosen adaptively until a constant value of scattering cross section is obtained. There are still some functions where the integration fails (power laws). These will always fail. My best solution currently is to flag the times when the XS>100. Then the estimates are invalid. The 1D simulation is fine, the 2D is reasonably fine, but anything to do with multile scattering is incorrect.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Analysis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Auto_Fit.ipf

    r902 r911  
    22 
    33 
    4 // This was originally written 2001-2003 ish. This works very differently than SANSview, and I havne't 
     4// This was originally written 2001-2003 ish. This works very differently than SANSview, and I haven't 
    55// mentioned that this exists, so that their ideas will be new. Still, some of this may be  
    66// serviceable for use within the Igor package, with some cleanup of the interface and functionality. 
     
    1111// 
    1212// X- smeared models don't work at all (now they work) 
    13 // -- the report is good, but the parsing is not great - the format 
     13// x- the report is good, but the parsing is not great - the format 
    1414//      could be more convenient to read back in to a table (text col, num cols (matrix that can be plotted?) 
    15 //      -- Maybe the report could be compiled as waves. Then they would be numeric. Nothing to plot them against 
     15//      x- Maybe the report could be compiled as waves. Then they would be numeric. Nothing to plot them against 
    1616//                      other than file names, but with a table of values and names, one could manually enter a meaningful 
    1717//                      column of values to plot against. 
    18 // -- Make_HoldConstraintEps_Waves() is  currently disabled, both on the macros menu and the checkbox on the panel 
    19 //                      Constraints and holds are part of the matrix already, soo this would only be for epsilon 
    20 // -- Many of the items on the Macros menu are just junk. 
    21 // 
     18// x- Make_HoldConstraintEps_Waves() is  currently disabled, both on the macros menu and the checkbox on the panel 
     19//                      Constraints and holds are part of the matrix already, so this would only be for epsilon 
     20// x- Many of the items on the Macros menu are just junk. Remove them. 
     21// 
     22// x- savePath is obsolete. Remove the button. Report saving is sent to the procedure defined in Wrapper.ipf, and uses the home path 
     23// x- add a checkbox for "all" to select all data files (function is already set -- CheckAllFiles()) 
     24// 
     25// x- make it easy for the user to save the results in a whole table. 
     26// x- remind to rename the results (or move to a folder?) before another batch is run 
     27// x- what to plot against? 
     28// 
     29// x- add a little text box of explanation on each of the tabs at the bottom - to give simple 
     30//    instructions of what to do on each tab. This will need to change with each tab. 
     31// 
     32// x- need a help button to link to the help file 
    2233// -- Comprehensive instructions (after features are finalized) 
    23 // 
    24 // -- savePath seems to be obsolete. Report saving is sent to the procedure defined in Wrapper.ipf, and uses the home path 
    25 // 
     34 
    2635 
    2736 
    2837Menu "Macros" 
    29         SubMenu "Auto-Fit" 
    30                 "InitializeAutoFitPanel" 
     38        SubMenu "Auto Fit" 
     39                "Initialize AutoFit Panel" 
    3140                "-" 
    32                 "Generate_Data_Checklist" 
     41//              "Generate_Data_Checklist" 
    3342//              "Make_HoldConstraintEps_Waves"          //this is currently disabled 
     43//              "-" 
     44//              "CompileAndLoadReports" 
     45                "Compile_Reports" 
     46                "Load Compiled Reports" 
     47//              "Compile_GlobalFit_Reports" 
    3448                "-" 
    35                 "CompileAndLoadReports" 
    36                 "LoadCompiledReports" 
    37                 "Compile_GlobalFit_Reports" 
     49                "Close Open Notebooks" 
     50                "Print Open Notebooks" 
    3851                "-" 
    39                 "PrintOpenNotebooks" 
    40                 "Close Open Notebooks" 
    41                 "-" 
    42                 "Generate_PICTS_list" 
    43                 "Layout_PICTS" 
     52                "Generate_PNG_list" 
     53                "Layout_PNGs" 
    4454                 
    4555        End 
     
    106116        return(0) 
    107117End 
     118 
     119 
     120//currently set up to toggle state, based on the first row 
     121// 
     122Function CheckAllFiles(ctrlName,checked) : CheckBoxControl 
     123        String ctrlName 
     124        Variable checked 
     125 
     126        WAVE sel = root:AutoFit:fileSelWave 
     127        if( (sel[0][1] & 0x10) == 16 ) //first box is checked 
     128                sel[][1] = 2^5                  // uncheck them all 
     129        else 
     130                sel[][1] = 2^5 + 2^4            //bit 5== checkbox, bit 4== checked 
     131        endif 
     132        return(0) 
     133End 
     134 
    108135 
    109136//  
     
    264291        Make/O/T/N=(1,1) constrMatrix                                   //constraint matrix is text 
    265292        Make/O/B/N=1 guessSel,holdSel,ConstrSel,rangeSel                                                //SelWave is byte data 
    266         Variable/G numPar=5,ptLow=0,ptHigh=0,fitTol=1e-3,curProgress=0,endProgress=10 
     293        Variable/G numPar=0,ptLow=0,ptHigh=0,fitTol=1e-3,curProgress=0,endProgress=10 
    267294        Variable/G startTicks=0 
    268295         
     
    270297        String/G gStatus=gStatFormat+"the fit engine is currently idle" 
    271298        string/g gExt="ABC" 
     299         
     300        String/G guessStr = "Guess is based on\rthe unsmeared\rcoefficients on the\rCurve Fit Setup\rpanel" 
     301        String/G holdStr = "Enter 0 to fit\rEnter 1 to hold" 
     302        String/G constStr = "Enter low and\rhigh range as:\rlow;high\rfor each parameter\rLeave blank if\rno constraints" 
     303        String/G rangeStr = "Enter the point\rrange as:\rfirst pt in 1st row\rlast pt in 2nd row\rLeave blank to\r fit all data" 
     304         
    272305         
    273306        fileListWave = "" 
     
    297330//      Button DelButton,pos={245,61},size={40,20},proc=DelButtonProc,title="Del",disable=2 
    298331        Button PathButton,pos={6,61},size={50,20},proc=PDPButton,title="Path..." 
    299         Button FileListButton,pos={182,61},size={50,20},proc=FileListButtonProc,title="List" 
    300         ListBox guessBox,pos={24,398},size={139,208},disable=1,proc=UpdateGuessMatrixProc 
     332        Button FileListButton,pos={82,61},size={50,20},proc=FileListButtonProc,title="List" 
     333        CheckBox AllFilesCheck,pos={182,64},size={32,14},proc=CheckAllFiles,title="Select All Files" 
     334        CheckBox AllFilesCheck,value= 0 
     335        ListBox guessBox,pos={24,398},size={145,208},disable=1,proc=UpdateGuessMatrixProc 
    301336        ListBox guessBox,frame=2,listWave=root:AutoFit:guessList 
    302337        ListBox guessBox,selWave=root:AutoFit:guessSel,mode= 2,selRow= 0 
     
    305340        Button FillAllConstrButton,pos={196,406},size={50,20},proc=FillAllConstrButtonProc,title="Fill All" 
    306341        Button FillAllRangeB,pos={196,406},size={50,20},disable=1,proc=FillAllRangeButtonProc,title="Fill All" 
    307         SetVariable NumParams,pos={7,31},size={161,15},proc=SetNumParamProc,title="Number of Parameters" 
     342        SetVariable NumParams,pos={7,34},size={150,15},proc=SetNumParamProc,title="Number of Parameters" 
    308343        SetVariable NumParams,limits={2,Inf,0},value= root:AutoFit:numPar 
    309344//      CheckBox typeCheck,pos={207,31},size={32,14},title="NSE Data?",value=0 
     
    316351//      CheckBox rangeCheck,pos={92,404},size={32,14},proc=RangeCheckProc,title="All" 
    317352//      CheckBox rangeCheck,value= 1,disable=2 
     353 
    318354        SetVariable lowPt,pos={136,404},size={60,15},title="low" 
    319355        SetVariable lowPt,limits={0,Inf,0},value= root:AutoFit:ptLow,noedit=1,disable=1 
    320356        SetVariable highPt,pos={201,404},size={60,15},title=" to " 
    321357        SetVariable highPt,limits={0,Inf,0},value= root:AutoFit:ptHigh,noedit=1,disable=1 
    322         ListBox holdBox,pos={24,398},size={139,208},disable=1,proc=UpdateHoldMatrixProc 
     358        ListBox holdBox,pos={24,398},size={145,208},disable=1,proc=UpdateHoldMatrixProc 
    323359        ListBox holdBox,frame=2,listWave=root:AutoFit:holdList 
    324360        ListBox holdBox,selWave=root:AutoFit:holdSel,mode= 2,selRow= 2 
    325         ListBox ConstrBox,pos={24,398},size={170,208},proc=UpdateConstrMatrixProc 
     361        ListBox ConstrBox,pos={24,398},size={145,208},proc=UpdateConstrMatrixProc 
    326362        ListBox ConstrBox,frame=2,listWave=root:AutoFit:ConstrList 
    327363        ListBox ConstrBox,selWave=root:AutoFit:ConstrSel,mode= 2,selRow= 2 
    328         ListBox RangeBox,pos={24,398},size={139,208},proc=UpdateRangeMatrixProc 
     364        ListBox RangeBox,pos={24,398},size={145,208},proc=UpdateRangeMatrixProc 
    329365        ListBox RangeBox,frame=2,listWave=root:AutoFit:rangeList 
    330366        ListBox RangeBox,selWave=root:AutoFit:RangeSel,mode= 2,selRow= 2 
    331367//      Button MatrixButton,pos={12,205},size={60,20},proc=ToMatrixButtonProc,title="Matrix",disable=2 
    332368        Button DoItButton,pos={21,632},size={80,20},proc=DoTheFitsButtonProc,title="Do the fits" 
    333         Button savePathButton,pos={82,61},size={80,20},proc=SavePathButtonProc,title="Save Path..." 
     369//      Button savePathButton,pos={82,61},size={80,20},proc=SavePathButtonProc,title="Save Path..." 
    334370        TitleBox tb1,pos={139,634},size={128,12},anchor=MC,variable=root:AutoFit:gStatus,frame=0 
    335371        Button button0,pos={14,331},size={40,20},title="Plot",proc=LoadForGuessProc 
     
    340376        Button GuessConstrB,pos={198,440},size={50,20},title="Guess",disable=1,proc=UseConstraintsAsGuess 
    341377         
     378        TitleBox infoTitleBox pos={180,470},fixedSize=1,size={96,130},variable=root:AutoFit:guessStr 
     379         
    342380        ValDisplay progressValdisp,pos={113,663},size={161,7},title="00:00" 
    343381        ValDisplay progressValdisp,limits={0,root:AutoFit:endProgress,0},barmisc={0,0},value= root:AutoFit:curProgress 
     382         
     383        Button AF_DoneButton,pos={174,30},size={70,20},proc=AF_DoneButtonProc,title="Done" 
     384        Button AF_HelpButton,pos={260,30},size={30,20},proc=AF_HelpButtonProc,title="?" 
     385 
    344386EndMacro 
     387 
     388// close the panel 
     389// + other windows? 
     390// 
     391Proc AF_DoneButtonProc(ctrlName): ButtonControl 
     392        String ctrlName 
     393        DoWindow/K AutoFitPanel 
     394end 
     395 
     396//open the Help file for the AutoFit Panel 
     397Function AF_HelpButtonProc(ba) : ButtonControl 
     398        STRUCT WMButtonAction &ba 
     399 
     400        switch( ba.eventCode ) 
     401                case 2: // mouse up 
     402                        // click code here 
     403                        DisplayHelpTopic/Z/K=1 "Auto Fit" 
     404                        if(V_flag !=0) 
     405                                DoAlert 0,"The Auto Fit Help file could not be found" 
     406                        endif 
     407                        break 
     408        endswitch 
     409 
     410        return 0 
     411End 
    345412 
    346413 
     
    395462        Variable tab 
    396463         
     464        String infoStr="",guessStr,holdStr,constStr,rangeStr 
     465        SVAR str0 = root:AutoFit:guessStr 
     466        SVAR str1 = root:AutoFit:holdStr 
     467        SVAR str2 = root:AutoFit:constStr 
     468        SVAR str3 = root:AutoFit:rangeStr 
     469         
     470         
     471         
    397472        Button FillAllGuessButton disable= (tab!=0) 
    398473        Button GuessCoefB disable=(tab!=0) 
    399474        ListBox guessBox disable= (tab!=0) 
    400475         
     476         
    401477        Button FillAllHoldButton disable= (tab!=1) 
    402478        Button GuessHoldB disable=(tab!=1) 
     
    410486        ListBox RangeBox disable=(tab!=3) 
    411487        Button FillAllRangeB disable= (tab!=3) 
     488         
     489        if(tab==0) 
     490                TitleBox infoTitleBox variable=str0 
     491        endif 
     492        if(tab==1) 
     493                TitleBox infoTitleBox variable=str1 
     494        endif 
     495        if(tab==2) 
     496                TitleBox infoTitleBox variable=str2 
     497        endif 
     498        if(tab==3) 
     499                TitleBox infoTitleBox variable=str3 
     500        endif 
     501         
    412502         
    413503        return(0) 
     
    13861476                namestr = namestr[0,30]         //if shorter than 31, this will NOT pad to 31 characters 
    13871477                Print "file saved as ",nameStr 
    1388                 SaveNotebook /O/P=savePath/S=2 Report as nameStr 
     1478//              SaveNotebook /O/P=savePath/S=2 Report as nameStr 
     1479                SaveNotebook /O/P=home/S=2 Report as nameStr 
    13891480        Endif 
    13901481 
    13911482        //save a pict file, just of the graph 
    1392         namestr = "PICT_" + namestr 
     1483        namestr = "PNG_" + namestr 
    13931484        namestr = namestr[0,28]         //PICT names in IGOR must be shorter, to allow auto-naming? 
    13941485        DoWindow/F AutoGraph_NSE 
    1395         SavePICT /E=2/O/I/P=savePath /W=(0,0,3,3) as nameStr 
     1486//      SavePICT /E=2/O/I/P=savePath /W=(0,0,3,3) as nameStr 
     1487        SavePICT /E=2/O/I/P=home /W=(0,0,3,3) as nameStr 
    13961488End 
    13971489 
     
    14941586End 
    14951587 
    1496 Proc Generate_PICTS_list() 
    1497         fGenerate_PICTS_list() 
    1498 End 
    1499  
    1500 //spits up a list of PICTS 
    1501 Function fGenerate_PICTS_list() 
    1502  
    1503         String List=IndexedFile(savePath, -1, "PICT") 
    1504         List2TextWave(List,";","PICT_files") 
    1505         WAVE/T picts=$"PICT_files" 
    1506         Edit/K=1 picts 
    1507 End 
    1508  
    1509 Proc Layout_PICTS(pStr) 
     1588Proc Generate_PNG_list() 
     1589        fGenerate_PNG_list() 
     1590End 
     1591 
     1592//spits up a list of PNGS 
     1593Function fGenerate_PNG_list() 
     1594 
     1595//      String List=IndexedFile(savePath, -1, ".png") 
     1596        String List=IndexedFile(home, -1, ".png") 
     1597        List2TextWave(List,";","PNG_files") 
     1598        WAVE/T PNGs=$"PNG_files" 
     1599        Edit/K=1 PNGs 
     1600End 
     1601 
     1602Proc Layout_PNGS(pStr) 
    15101603        String pStr="" 
    1511         Prompt pStr,"wave of PICTs to use",popup,WaveList("PICT_f*", ";", "") 
     1604        Prompt pStr,"wave of PNGs to use",popup,WaveList("PNG_f*", ";", "") 
    15121605                 
    15131606        String List=TextWave2List($pStr,";") 
    15141607        String item = "" 
    1515         //kill old picts 
     1608        //kill old picts from memory 
    15161609        KillPicts/A/Z 
    15171610        //make a new layout 
    1518         Layout/C=1 as "PICT_Layout" 
    1519         DoWindow/C PICTLayout 
     1611        Layout/C=1 as "PNG_Layout" 
     1612        DoWindow/C PNGLayout 
    15201613        do 
    15211614                item=StringFromList(0,List,";") 
    1522                 //load each PICT, and append it to the layout 
     1615                //load each PNG, and append it to the layout 
    15231616                Print "load item = ",item 
    1524                 LoadPICT /O/Q/P=savePath item 
    1525                 DoWindow/F PICTLayout           //be sure layout is on top 
    1526                 AppendLayoutObject /F=1/W=PICTLayout picture  $item 
     1617//              LoadPICT /O/Q/P=savePath item 
     1618                LoadPICT /O/Q/P=home item 
     1619                DoWindow/F PNGLayout            //be sure layout is on top 
     1620                AppendLayoutObject /F=1/W=PNGLayout picture  $CleanupName(item,0) 
    15271621                //AppendToLayout $item 
    15281622                //Print item 
    15291623                List = RemoveFromList(item, List, ";") 
    15301624        while(ItemsInList(List, ";")>0) 
    1531         //tile the PICTs in the layout 
     1625        //tile the PNGs in the layout 
    15321626        Tile/O=8 
    15331627End 
     
    15561650Proc CompileAndLoadReports() 
    15571651        Compile_Reports() 
    1558         SaveNotebook /O/P=savePath/S=2 Compilation 
     1652//      SaveNotebook /O/P=savePath/S=2 Compilation 
     1653        SaveNotebook /O/P=home/S=2 Compilation 
    15591654//      Print "Saved as:  ",S_Path 
    15601655        DoWindow/K Compilation 
     
    15671662End 
    15681663 
    1569 Proc Compile_Reports(Number_of_Parameters) 
    1570         Variable Number_of_Parameters=7 
     1664Proc Compile_Reports(Number_of_Parameters,tagStr) 
     1665        Variable Number_of_Parameters=(root:AutoFit:numPar) 
     1666        String tagStr="v1" 
     1667 
     1668        fCompile_ReportsTable(Number_of_Parameters,tagStr) 
     1669 
    15711670        fCompile_Reports(Number_of_Parameters) 
    1572         fCompile_ReportsTable(Number_of_Parameters) 
     1671         
     1672        DoWindow/F AutoFitResults 
     1673 
    15731674End 
    15741675 
     
    16241725                GetSelection notebook,$item,2 
    16251726                textStr=S_Selection 
    1626                 Print textStr 
     1727                 
     1728//              Print textStr 
    16271729                 
    16281730                sscanf textStr,"Npnts = %g\t\tSqrt(X^2/N) = %g\r",dum,chi 
     
    16411743//// 
    16421744// compiles the results into a table. 
    1643 Function fCompile_ReportsTable(nPar) 
     1745// add tagStr to the end to (try) to make sure that the compilations are unique 
     1746Function fCompile_ReportsTable(nPar,tagStr) 
    16441747        Variable nPar 
     1748        String tagStr 
    16451749         
    16461750        String list=WinList("*", ";", "WIN:16") 
     
    16511755        numRep=ItemsInList(list,";") 
    16521756         
    1653         Make/O/T/N=(numRep) fittedFiles 
    1654         Make/O/D/N=(numRep) chiSQ 
    1655         Edit fittedFiles,chiSQ 
     1757        Make/O/T/N=(numRep) $("fittedFiles"+"_"+tagStr) 
     1758        Make/O/D/N=(numRep) $("chiSQ"+"_"+tagStr) 
     1759        Wave/T fittedFiles = $("fittedFiles"+"_"+tagStr) 
     1760        Wave chiSq = $("chiSQ"+"_"+tagStr) 
     1761        Edit/N=AutoFitResults fittedFiles,chiSQ 
    16561762         
    16571763        for(ii=0;ii<nPar;ii+=1)         //waves for the parameters 
    1658                 Make/O/D/N=(numRep) $("par"+num2str(ii)),$("par"+num2str(ii)+"_err") 
    1659                 AppendToTable $("par"+num2str(ii)),$("par"+num2str(ii)+"_err") 
     1764                Make/O/D/N=(numRep) $("par"+num2str(ii)+"_"+tagStr),$("par"+num2str(ii)+"_err"+"_"+tagStr) 
     1765                AppendToTable $("par"+num2str(ii)+"_"+tagStr),$("par"+num2str(ii)+"_err"+"_"+tagStr) 
    16601766        endfor 
    16611767         
     
    16841790                        sscanf textStr,"= \t%g\t ± \t%g\r",val1,val2 
    16851791                         
    1686                         Print textStr 
     1792//                      Print textStr 
    16871793                                                 
    1688                         Wave w1 = $("par"+num2str(ii)) 
    1689                         Wave w2 = $("par"+num2str(ii)+"_err") 
     1794                        Wave w1 = $("par"+num2str(ii)+"_"+tagStr) 
     1795                        Wave w2 = $("par"+num2str(ii)+"_err"+"_"+tagStr) 
    16901796                         
    16911797                        w1[jj] = val1 
     
    17031809                GetSelection notebook,$item,2 
    17041810                textStr=S_Selection 
    1705                 Print textStr 
     1811                 
     1812//              Print textStr 
    17061813                 
    17071814                sscanf textStr,"Npnts = %g\t\tSqrt(X^2/N) = %g\r",dum,chi 
     
    17091816                chiSQ[jj] = chi  
    17101817        endfor 
     1818         
    17111819         
    17121820        return(0) 
  • sans/Dev/trunk/NCNR_User_Procedures/Analysis/Packages/Wrapper_v40.ipf

    r901 r911  
    11971197                //save the graph separately as a PNG file, 2x screen 
    11981198                pictStr += nameStr 
    1199                 pictStr = pictStr[0,28]         //need a shorter name - why? 
     1199                pictStr = pictStr[0,24]+".png"          //need a shorter name - only 29 characters allowed - why? 
    12001200//              DoWindow/F $topGraph 
    12011201                // E=-5 is png @screen resolution 
Note: See TracChangeset for help on using the changeset viewer.