Changeset 432 for sans


Ignore:
Timestamp:
Oct 24, 2008 3:48:54 PM (14 years ago)
Author:
srkline
Message:

Bug fixes to USANS procedures to clean up changes with new Packages:NIST: subfolder structure.

Location:
sans/Dev/trunk/NCNR_User_Procedures
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtilsMacro_v40.ipf

    r431 r432  
    6565        Variable doPlot 
    6666         
    67         Variable rr,gg,bb,refnum 
     67        Variable rr,gg,bb,refnum,dQv 
    6868        String w0,w1,w2,n0,n1,n2 
    6969        String w3,w4,w5,n3,n4,n5                        //3 extra waves to load 
    7070        SetDataFolder root:             //build sub-folders for each data set under root 
    71          
    72         if (exists("root:Packages:NIST:USANS:Globals:MainPanel:dQv")) 
    73                 //Running from USANS reduction 
    74                 Variable dQv = root:Packages:NIST:USANS:Globals:MainPanel:dQv 
    75         endif 
    76         if(exists("root:Packages:NIST:USANS_dQv")) 
    77                 //Running from SANS Analysis 
    78                 Variable dQv = root:Packages:NIST:USANS_dQv 
    79         else 
    80                 //running from somewhere else, probably SANS Reduction, which uses common loaders 
    81                 Variable/G root:Packages:NIST:USANS_dQv = 0.117 
    82         endif 
     71 
     72// I can't see that we need to find dQv here.    
     73//      if (exists("root:Packages:NIST:USANS:Globals:MainPanel:gDQv")) 
     74//              //Running from USANS reduction 
     75//              Variable dQv = root:Packages:NIST:USANS:Globals:MainPanel:gDQv 
     76//      endif 
     77//      if(exists("root:Packages:NIST:USANS_dQv")) 
     78//              //Running from SANS Analysis 
     79//              Variable dQv = root:Packages:NIST:USANS_dQv 
     80//      else 
     81//              //running from somewhere else, probably SANS Reduction, which uses common loaders 
     82//              Variable/G root:Packages:NIST:USANS_dQv = 0.117 
     83//      endif 
    8384                 
    8485        if (cmpStr(fileStr,"") == 0) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/LakeDesmearing_JB.ipf

    r404 r432  
    4949// Igor 4 routines are currently used. 
    5050 
    51  
    5251//////////////////////////////////////////////////////////////////////// 
    5352 
     
    5554Proc Desmear() 
    5655 
    57         SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
     56        String USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
    5857 
    5958        //check for the correct data folder, initialize if necessary 
    6059        // 
    61         if(DataFolderExists($(USANSFolder+":DSM")) == 0) 
     60        if(DataFolderExists(USANSFolder+":DSM") == 0) 
    6261                Execute "Init_Desmearing()" 
    6362        endif 
    6463         
    65         //always initialize these 
    66         String/G $(USANSFolder+":DSM:gStr1") = "" 
    67         String/G $(USANSFolder+":DSM:gStr2") = "" 
    68         String/G $(USANSFolder+":DSM:gIterStr") = "" 
     64        SetDataFolder $(USANSFolder+":DSM") 
     65        //always initialize these global variables 
     66        gStr1 = "" 
     67        gStr2 = "" 
     68        gIterStr = "" 
     69        SetDataFolder root: 
    6970         
    7071        DoWindow/F Desmear_Graph 
     
    7576 
    7677Proc Init_Desmearing() 
     78 
     79        String USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
     80 
    7781        //set up the folder(s) needed 
    7882        NewDataFolder/O $(USANSFolder+":DSM") 
    7983        NewDataFolder/O $(USANSFolder+":myGlobals")             //in case it wasn't created elsewhere 
    8084         
    81         String/G $(USANSFolder+":DSM:gCurFile")="" 
    82          
    83         Variable/G $(USANSFolder+":DSM:gMaxFastIter") = 100                     //max number of iter in Fast convergence 
    84         Variable/G $(USANSFolder+":DSM:gMaxSlowIter") = 10000 
    85          
    86         Variable/G $(USANSFolder+":DSM:gNptsExtrap") = 10               //points for high q extrapolation 
    87         Variable/G $(USANSFolder+":DSM:gChi2Target") = 1                //chi^2 target 
    88         Variable/G $(USANSFolder+":DSM:gPowerM") = -4 
    89         Variable/G $(USANSFolder+":DSM:gDqv") = 0.117                   //2005 measured slit height - see John 
    90         Variable/G $(USANSFolder+":DSM:gNq") = 1 
    91         Variable/G $(USANSFolder+":DSM:gS") = 0         // global varaible for Midpnt() 
    92         Variable/G $(USANSFolder+":DSM:gSmoothFac")=0.03 
    93          
    94         Variable/G $(USANSFolder+":DSM:gChi2Final") = 0         //chi^2 final 
    95         Variable/G $(USANSFolder+":DSM:gIterations") = 0                //total number of iterations 
    96          
    97         String/G $(USANSFolder+":DSM:gStr1") = ""                               //information strings 
    98         String/G $(USANSFolder+":DSM:gStr2") = "" 
    99         String/G $(USANSFolder+":DSM:gIterStr") = "" 
    100         Variable/G $(USANSFolder+":DSM:gChi2Smooth") = 0 
    101          
    102         Variable/G $(USANSFolder+":DSM:gFreshMask")=1 
     85        SetDataFolder $(USANSFolder+":DSM") 
     86         
     87        String/G gCurFile="" 
     88         
     89        Variable/G gMaxFastIter = 100                   //max number of iter in Fast convergence 
     90        Variable/G gMaxSlowIter = 10000 
     91         
     92        Variable/G gNptsExtrap = 10             //points for high q extrapolation 
     93        Variable/G gChi2Target = 1              //chi^2 target 
     94        Variable/G gPowerM = -4 
     95        Variable/G gDqv = 0.117                 //2005 measured slit height - see John 
     96        Variable/G gNq = 1 
     97        Variable/G gS = 0               // global varaible for Midpnt() 
     98        Variable/G gSmoothFac=0.03 
     99         
     100        Variable/G gChi2Final = 0               //chi^2 final 
     101        Variable/G gIterations = 0              //total number of iterations 
     102         
     103        String/G gStr1 = ""                             //information strings 
     104        String/G gStr2 = "" 
     105        String/G gIterStr = "" 
     106        Variable/G gChi2Smooth = 0 
     107         
     108        Variable/G gFreshMask=1 
     109         
     110        SetDataFolder root: 
    103111End 
    104112 
     
    230238        FW[NN-1][NN-1] = R_wave[NN-1] 
    231239// 
    232         SetDataFolder root: 
    233240        Return (0) 
    234241End 
     
    570577        NVAR m = $(USANSFolder+":DSM:gPowerM")                          // power law exponent 
    571578        NVAR chiFinal = $(USANSFolder+":DSM:gChi2Final")                //chi^2 final 
    572         NVAR iter = $(USANSFolder+":DSM:gIterations:")          //total number of iterations 
     579        NVAR iter = $(USANSFolder+":DSM:gIterations")           //total number of iterations 
    573580         
    574581        //get the number of spline passes from the wave note 
     
    773780 
    774781Proc Desmear_Graph()  
    775         SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
     782        String USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
    776783 
    777784        PauseUpdate; Silent 1           // building window... 
     
    863870        SetVariable DSMControl_3f,help={"Smoothing factor for the smoothing spline"} 
    864871        SetVariable DSMControl_3f format="%5.4f" 
    865         SetVariable DSMControl_3f,limits={0.01,2,0.01},value= $(USANSFolder+"DSM:gSmoothFac") 
     872        SetVariable DSMControl_3f,limits={0.01,2,0.01},value= $(USANSFolder+":DSM:gSmoothFac") 
    866873        SetVariable DSMControl_3f,disable=1 
    867874        CheckBox DSMControl_3g,pos={268,39},size={90,14},title="Log-scale smoothing?" 
     
    869876        CheckBox DSMControl_3g,value=0 
    870877        CheckBox DSMControl_3g,disable=1 
    871         ValDisplay DSMControl_3h pos={235,97},title="Chi^2",size={80,20},value=root:DSM:gChi2Smooth 
     878        ValDisplay DSMControl_3h pos={235,97},title="Chi^2",size={80,20},value=root:Packages:NIST:USANS:DSM:gChi2Smooth 
    872879        ValDisplay DSMControl_3h,help={"This is the Chi^2 value for the smoothed data vs experimental data"} 
    873880        ValDisplay DSMControl_3h,disable=1 
     
    945952 
    946953Proc AppendSmeared() 
    947         SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
     954        String USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
    948955 
    949956        SetDataFolder $(USANSFolder+":DSM") 
     
    962969        TextBox/K/N=text1 
    963970//      TextBox/C/N=text1/F=0/A=MT/E=2/X=5.50/Y=0.00 root:DSM:gCurFile                  //Igor 5 
    964         TextBox/C/N=text1/F=0/A=MT/E=1/X=5.50/Y=0.00 $(USANSFolder+"DSM:gCurFile") 
     971        TextBox/C/N=text1/F=0/A=MT/E=1/X=5.50/Y=0.00 $(USANSFolder+":DSM:gCurFile") 
    965972End 
    966973 
    967974Proc AppendMask() 
    968         SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
     975        String USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
    969976 
    970977//      if( strsearch(TraceNameList("Desmear_Graph", "", 1),"MaskData",0,2) == -1)                      //Igor 5 
     
    979986 
    980987Proc AppendSmoothed() 
    981         SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
     988        String USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
    982989 
    983990//      if( strsearch(TraceNameList("Desmear_Graph", "", 1),"I_smth",0,2) == -1)                        //Igor 5 
     
    10071014 
    10081015Proc AppendDesmeared() 
    1009         SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
     1016        String USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder 
    10101017 
    10111018//      if( strsearch(TraceNameList("Desmear_Graph", "", 1),"I_dsm",0,2) == -1)         //Igor 5 
     
    10671074         
    10681075        SetDataFolder root: 
    1069         Execute "U_LoadOneDDataWithName(\"\")" 
     1076        Execute "A_LoadOneDDataWithName(\"\",0)" 
    10701077        //define the waves that the smoothing will be looking for... 
    1071         SVAR fname = $(USANSFolder+":myGlobals:gLastFileName")          //this changes as any data is loaded 
     1078        SVAR fname = $("root:Packages:NIST:gLastFileName")              //this changes as any data is loaded 
    10721079        SVAR curFile = $(USANSFolder+":DSM:gCurFile")                                   //keep this for title, save 
    10731080        curFile = fname 
     
    10781085        sqStr = CleanupName((fName + "sq"),0)           //the sq-wave, which should have -dQv as the elements 
    10791086 
    1080         Duplicate/O $qStr $(USANSFolder+":DSM:Q_exp     ")               
    1081         Duplicate/O $iStr $(USANSFolder+":DSM:I_exp")            
    1082         Duplicate/O $sStr $(USANSFolder+":DSM:S_exp     ")       
     1087        String DFStr= CleanupName(fname,0) 
     1088         
     1089        Duplicate/O $("root:"+DFStr+":"+qStr) $(USANSFolder+":DSM:Q_exp ")               
     1090        Duplicate/O $("root:"+DFStr+":"+iStr) $(USANSFolder+":DSM:I_exp")                
     1091        Duplicate/O $("root:"+DFStr+":"+sStr) $(USANSFolder+":DSM:S_exp ")       
    10831092        wave Q_exp = $(USANSFolder+":DSM:Q_exp") 
    10841093        Wave I_exp = $(USANSFolder+":DSM:I_exp") 
    10851094        Wave S_exp = $(USANSFolder+":DSM:S_exp") 
    1086         Wave/Z sigQ = $sqStr 
    10871095         
    10881096        // remove any negative q-values (and q=0 values!)(and report this) 
     
    11051113        nq = numpnts($(USANSFolder+":DSM:Q_exp")) 
    11061114         
    1107         if(WaveExists(sigQ))                    //try to read dQv 
    1108                 dqv = -sigQ[0] 
    1109 //              DoAlert 0,"Found dQv value of " + num2str(dqv) 
    1110         else 
    1111                 dqv = 0.117 
    1112         //      dqv = 0.037             //old value 
    1113                 DoAlert 0,"Could not find dQv in the data file - using " + num2str(dqv) 
    1114         endif 
     1115        dQv = NumVarOrDefault("root:"+DFStr+":USANS_dQv", 0.117 ) 
     1116//      if(WaveExists(sigQ))                    //try to read dQv 
     1117////            dqv = -sigQ[0][0] 
     1118////            DoAlert 0,"Found dQv value of " + num2str(dqv) 
     1119//      else 
     1120//              dqv = 0.117 
     1121//      //      dqv = 0.037             //old value 
     1122//              DoAlert 0,"Could not find dQv in the data file - using " + num2str(dqv) 
     1123//      endif 
    11151124        NVAR gDqv = $(USANSFolder+":DSM:gDqv")                          //needs to be global for Weights_L() 
    11161125        NVAR gNq = $(USANSFolder+":DSM:gNq") 
     
    13161325// need to get rid of old smoothed data if data is re-masked 
    13171326        Execute "RemoveSmoothed()" 
    1318         SetDataFolder root:DSM 
     1327        SetDataFolder $(USANSFolder+":DSM") 
    13191328        Killwaves/Z I_smth,Q_smth,S_smth 
    13201329 
     
    15051514        endif 
    15061515 
    1507         NVAR sParam = $(USANSFolder+":DSM:gSmoothFac") 
     1516        NVAR sParam = gSmoothFac                //already in the right DF 
    15081517         
    15091518        ControlInfo/W=Desmear_Graph DSMControl_3c               //SSCheck 
     
    15191528//              Interpolate2/T=3/N=(nq_ext)/I=1/F=(sParam)/Y=Yi_SS/X=Yq_SS Q_ext, I_ext 
    15201529        // end Igor 4    
    1521                 wave yi_ss = root:DSM:yi_ss 
    1522                 wave yq_ss = root:DSM:yq_ss 
     1530                wave yi_ss = yi_ss              // already in the right DF 
     1531                wave yq_ss = yq_ss 
    15231532                // reassign the "working" waves with the result of interpolate, which has the same I/Q values 
    15241533                I_ext = yi_ss 
     
    15501559//      Print "end of smoothed, note = ",note(I_smth) 
    15511560         
    1552         Variable nq = numpnts(root:DSM:Q_smth) 
     1561        Variable nq = numpnts($(USANSFolder+":DSM:Q_smth")) 
    15531562//      Print "nq after smoothing = ",nq 
    15541563 
    15551564        //reset the global 
    1556         NVAR gNq = $(USANSFolder+":DSM:gNq") 
     1565        NVAR gNq = gNq 
    15571566        gNq = nq 
    15581567        //report the chi^2 difference between the smoothed curve and the experimental data 
    1559         NVAR chi2 = root:DSM:gChi2Smooth 
     1568        NVAR chi2 = gChi2Smooth 
    15601569        chi2 = SmoothedChi2(I_smth) 
    15611570         
     
    17211730//      y_old = I_old, y_new = I_dsm, I_dsm_sm = ys_new, 
    17221731// duplicate preserves the wave note! 
    1723         Duplicate/O I_work I_old,Is_old,root:DSM:I_dsm,root:DSM:I_dsm_sm 
     1732        Duplicate/O I_work I_old,Is_old,I_dsm,I_dsm_sm 
    17241733        Duplicate/O Q_work Q_dsm,S_dsm          //sets Q_dsm correctly 
    17251734        wave S_dsm,I_old,Is_old,I_dsm,I_dsm_sm 
     
    17681777        Execute "AppendDesmeared()" 
    17691778        DoUpdate 
     1779         
    17701780        SetDataFolder $(USANSFolder+":DSM") 
    17711781 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/Main_USANS.ipf

    r404 r432  
    542542Function PickBT5Path() 
    543543         
    544         NVAR isChecked = root:Globals:MainPanel:gUseCurrentData 
     544        NVAR isChecked = root:Packages:NIST:USANS:Globals:MainPanel:gUseCurrentData 
    545545         
    546546        //set the global string to the selected pathname 
     
    11491149        newList = SortList(newList,";",0)       //get them in order 
    11501150        num=ItemsInList(newlist,";") 
    1151         Wave/T curWave = $(USANSFolder+" :Globals:MainPanel:curWave") 
     1151        Wave/T curWave = $(USANSFolder+":Globals:MainPanel:curWave") 
    11521152        Redimension/N=(num) curWave 
    11531153        curWave="" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/USANS_Includes.ipf

    r405 r432  
    1919#include "USANSCatNotebook",version >= 2.20      
    2020#include "CheckVersionFTP"                              //added June 2008 
     21#include "GaussUtils_v40"                               //added Oct 2008 for unified file loading 
Note: See TracChangeset for help on using the changeset viewer.