- Timestamp:
- May 23, 2013 9:43:12 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Analysis/Alpha/Auto_Fit.ipf
r902 r911 2 2 3 3 4 // This was originally written 2001-2003 ish. This works very differently than SANSview, and I hav ne't4 // This was originally written 2001-2003 ish. This works very differently than SANSview, and I haven't 5 5 // mentioned that this exists, so that their ideas will be new. Still, some of this may be 6 6 // serviceable for use within the Igor package, with some cleanup of the interface and functionality. … … 11 11 // 12 12 // X- smeared models don't work at all (now they work) 13 // -- the report is good, but the parsing is not great - the format13 // x- the report is good, but the parsing is not great - the format 14 14 // 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 against15 // x- Maybe the report could be compiled as waves. Then they would be numeric. Nothing to plot them against 16 16 // other than file names, but with a table of values and names, one could manually enter a meaningful 17 17 // 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 22 33 // -- 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 26 35 27 36 28 37 Menu "Macros" 29 SubMenu "Auto -Fit"30 "Initialize AutoFitPanel"38 SubMenu "Auto Fit" 39 "Initialize AutoFit Panel" 31 40 "-" 32 "Generate_Data_Checklist"41 // "Generate_Data_Checklist" 33 42 // "Make_HoldConstraintEps_Waves" //this is currently disabled 43 // "-" 44 // "CompileAndLoadReports" 45 "Compile_Reports" 46 "Load Compiled Reports" 47 // "Compile_GlobalFit_Reports" 34 48 "-" 35 "CompileAndLoadReports" 36 "LoadCompiledReports" 37 "Compile_GlobalFit_Reports" 49 "Close Open Notebooks" 50 "Print Open Notebooks" 38 51 "-" 39 "PrintOpenNotebooks" 40 "Close Open Notebooks" 41 "-" 42 "Generate_PICTS_list" 43 "Layout_PICTS" 52 "Generate_PNG_list" 53 "Layout_PNGs" 44 54 45 55 End … … 106 116 return(0) 107 117 End 118 119 120 //currently set up to toggle state, based on the first row 121 // 122 Function 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) 133 End 134 108 135 109 136 // … … 264 291 Make/O/T/N=(1,1) constrMatrix //constraint matrix is text 265 292 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=10293 Variable/G numPar=0,ptLow=0,ptHigh=0,fitTol=1e-3,curProgress=0,endProgress=10 267 294 Variable/G startTicks=0 268 295 … … 270 297 String/G gStatus=gStatFormat+"the fit engine is currently idle" 271 298 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 272 305 273 306 fileListWave = "" … … 297 330 // Button DelButton,pos={245,61},size={40,20},proc=DelButtonProc,title="Del",disable=2 298 331 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 301 336 ListBox guessBox,frame=2,listWave=root:AutoFit:guessList 302 337 ListBox guessBox,selWave=root:AutoFit:guessSel,mode= 2,selRow= 0 … … 305 340 Button FillAllConstrButton,pos={196,406},size={50,20},proc=FillAllConstrButtonProc,title="Fill All" 306 341 Button FillAllRangeB,pos={196,406},size={50,20},disable=1,proc=FillAllRangeButtonProc,title="Fill All" 307 SetVariable NumParams,pos={7,3 1},size={161,15},proc=SetNumParamProc,title="Number of Parameters"342 SetVariable NumParams,pos={7,34},size={150,15},proc=SetNumParamProc,title="Number of Parameters" 308 343 SetVariable NumParams,limits={2,Inf,0},value= root:AutoFit:numPar 309 344 // CheckBox typeCheck,pos={207,31},size={32,14},title="NSE Data?",value=0 … … 316 351 // CheckBox rangeCheck,pos={92,404},size={32,14},proc=RangeCheckProc,title="All" 317 352 // CheckBox rangeCheck,value= 1,disable=2 353 318 354 SetVariable lowPt,pos={136,404},size={60,15},title="low" 319 355 SetVariable lowPt,limits={0,Inf,0},value= root:AutoFit:ptLow,noedit=1,disable=1 320 356 SetVariable highPt,pos={201,404},size={60,15},title=" to " 321 357 SetVariable highPt,limits={0,Inf,0},value= root:AutoFit:ptHigh,noedit=1,disable=1 322 ListBox holdBox,pos={24,398},size={1 39,208},disable=1,proc=UpdateHoldMatrixProc358 ListBox holdBox,pos={24,398},size={145,208},disable=1,proc=UpdateHoldMatrixProc 323 359 ListBox holdBox,frame=2,listWave=root:AutoFit:holdList 324 360 ListBox holdBox,selWave=root:AutoFit:holdSel,mode= 2,selRow= 2 325 ListBox ConstrBox,pos={24,398},size={1 70,208},proc=UpdateConstrMatrixProc361 ListBox ConstrBox,pos={24,398},size={145,208},proc=UpdateConstrMatrixProc 326 362 ListBox ConstrBox,frame=2,listWave=root:AutoFit:ConstrList 327 363 ListBox ConstrBox,selWave=root:AutoFit:ConstrSel,mode= 2,selRow= 2 328 ListBox RangeBox,pos={24,398},size={1 39,208},proc=UpdateRangeMatrixProc364 ListBox RangeBox,pos={24,398},size={145,208},proc=UpdateRangeMatrixProc 329 365 ListBox RangeBox,frame=2,listWave=root:AutoFit:rangeList 330 366 ListBox RangeBox,selWave=root:AutoFit:RangeSel,mode= 2,selRow= 2 331 367 // Button MatrixButton,pos={12,205},size={60,20},proc=ToMatrixButtonProc,title="Matrix",disable=2 332 368 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..." 334 370 TitleBox tb1,pos={139,634},size={128,12},anchor=MC,variable=root:AutoFit:gStatus,frame=0 335 371 Button button0,pos={14,331},size={40,20},title="Plot",proc=LoadForGuessProc … … 340 376 Button GuessConstrB,pos={198,440},size={50,20},title="Guess",disable=1,proc=UseConstraintsAsGuess 341 377 378 TitleBox infoTitleBox pos={180,470},fixedSize=1,size={96,130},variable=root:AutoFit:guessStr 379 342 380 ValDisplay progressValdisp,pos={113,663},size={161,7},title="00:00" 343 381 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 344 386 EndMacro 387 388 // close the panel 389 // + other windows? 390 // 391 Proc AF_DoneButtonProc(ctrlName): ButtonControl 392 String ctrlName 393 DoWindow/K AutoFitPanel 394 end 395 396 //open the Help file for the AutoFit Panel 397 Function 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 411 End 345 412 346 413 … … 395 462 Variable tab 396 463 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 397 472 Button FillAllGuessButton disable= (tab!=0) 398 473 Button GuessCoefB disable=(tab!=0) 399 474 ListBox guessBox disable= (tab!=0) 400 475 476 401 477 Button FillAllHoldButton disable= (tab!=1) 402 478 Button GuessHoldB disable=(tab!=1) … … 410 486 ListBox RangeBox disable=(tab!=3) 411 487 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 412 502 413 503 return(0) … … 1386 1476 namestr = namestr[0,30] //if shorter than 31, this will NOT pad to 31 characters 1387 1477 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 1389 1480 Endif 1390 1481 1391 1482 //save a pict file, just of the graph 1392 namestr = "P ICT_" + namestr1483 namestr = "PNG_" + namestr 1393 1484 namestr = namestr[0,28] //PICT names in IGOR must be shorter, to allow auto-naming? 1394 1485 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 1396 1488 End 1397 1489 … … 1494 1586 End 1495 1587 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) 1588 Proc Generate_PNG_list() 1589 fGenerate_PNG_list() 1590 End 1591 1592 //spits up a list of PNGS 1593 Function 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 1600 End 1601 1602 Proc Layout_PNGS(pStr) 1510 1603 String pStr="" 1511 Prompt pStr,"wave of P ICTs to use",popup,WaveList("PICT_f*", ";", "")1604 Prompt pStr,"wave of PNGs to use",popup,WaveList("PNG_f*", ";", "") 1512 1605 1513 1606 String List=TextWave2List($pStr,";") 1514 1607 String item = "" 1515 //kill old picts 1608 //kill old picts from memory 1516 1609 KillPicts/A/Z 1517 1610 //make a new layout 1518 Layout/C=1 as "P ICT_Layout"1519 DoWindow/C P ICTLayout1611 Layout/C=1 as "PNG_Layout" 1612 DoWindow/C PNGLayout 1520 1613 do 1521 1614 item=StringFromList(0,List,";") 1522 //load each P ICT, and append it to the layout1615 //load each PNG, and append it to the layout 1523 1616 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) 1527 1621 //AppendToLayout $item 1528 1622 //Print item 1529 1623 List = RemoveFromList(item, List, ";") 1530 1624 while(ItemsInList(List, ";")>0) 1531 //tile the P ICTs in the layout1625 //tile the PNGs in the layout 1532 1626 Tile/O=8 1533 1627 End … … 1556 1650 Proc CompileAndLoadReports() 1557 1651 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 1559 1654 // Print "Saved as: ",S_Path 1560 1655 DoWindow/K Compilation … … 1567 1662 End 1568 1663 1569 Proc Compile_Reports(Number_of_Parameters) 1570 Variable Number_of_Parameters=7 1664 Proc 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 1571 1670 fCompile_Reports(Number_of_Parameters) 1572 fCompile_ReportsTable(Number_of_Parameters) 1671 1672 DoWindow/F AutoFitResults 1673 1573 1674 End 1574 1675 … … 1624 1725 GetSelection notebook,$item,2 1625 1726 textStr=S_Selection 1626 Print textStr 1727 1728 // Print textStr 1627 1729 1628 1730 sscanf textStr,"Npnts = %g\t\tSqrt(X^2/N) = %g\r",dum,chi … … 1641 1743 //// 1642 1744 // 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 1746 Function fCompile_ReportsTable(nPar,tagStr) 1644 1747 Variable nPar 1748 String tagStr 1645 1749 1646 1750 String list=WinList("*", ";", "WIN:16") … … 1651 1755 numRep=ItemsInList(list,";") 1652 1756 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 1656 1762 1657 1763 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) 1660 1766 endfor 1661 1767 … … 1684 1790 sscanf textStr,"= \t%g\t ± \t%g\r",val1,val2 1685 1791 1686 Print textStr1792 // Print textStr 1687 1793 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) 1690 1796 1691 1797 w1[jj] = val1 … … 1703 1809 GetSelection notebook,$item,2 1704 1810 textStr=S_Selection 1705 Print textStr 1811 1812 // Print textStr 1706 1813 1707 1814 sscanf textStr,"Npnts = %g\t\tSqrt(X^2/N) = %g\r",dum,chi … … 1709 1816 chiSQ[jj] = chi 1710 1817 endfor 1818 1711 1819 1712 1820 return(0)
Note: See TracChangeset
for help on using the changeset viewer.