Ignore:
Timestamp:
Jan 22, 2013 4:34:14 PM (10 years ago)
Author:
srkline
Message:

Changes to utility functions to properly list the raw data from the 10m SANS (SA4)

Added a utility function to patch BS xPos in 10m data files so that they will be recognized as transmission files. ICE is currently not writing out the BS xPos to the file. This is done in batch mode, similar to what was done for the 8m SANS.

Some changes to the simulation code to permit easier scripting.

Additions to SASCALC for the 10m SANS. Dimensions from John. Still need attenuator table and flux.

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

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/MultScatter_MonteCarlo_2D.ipf

    r887 r888  
    966966Function/S MC_FunctionPopupList() 
    967967        String list,tmp 
    968         list = User_FunctionPopupList() 
     968        list = User_FunctionPopupList()// + "EC_Empirical;" 
    969969         
    970970        //simplify the display, forcing smeared calculations behind the scenes 
     
    14671467        t0 = (stopMSTimer(-2) - t0)*1e-6 
    14681468        t0 *= imon/1000/ThreadProcessorCount                    //projected time, in seconds (using threads for the calculation) 
    1469         t0 *= 2         //empirical correction 
     1469        t0 *= 2         //empirical correction, since processor count returns 8 for (4 real + 4 virtual) 
    14701470        Print "Estimated Simulation time (s) = ",t0 
    14711471         
     
    22592259 
    22602260 
     2261//// 
     2262//// plots an empirical empty cell scattering, also have a Two Level implementation in  
     2263//// the main MonteCarlo procedure file. The TwoLevel version is "calibrated" to give a more realistic 
     2264//// count rate, but neither are suitable to be incorporated into a 2D simulation 
     2265//// 
     2266// -- 2.2e-9 was the fitted value, again, empirically using 2.2e-8 to take into account 
     2267//   that I need "enough" empty cell scattering from a sample that is say 1mm thick 
     2268// 
     2269Proc PlotEC_Empirical(num,qmin,qmax) 
     2270        Variable num=256,qmin=0.001,qmax=0.7 
     2271        Prompt num "Enter number of data points for model: " 
     2272        Prompt qmin "Enter minimum q-value (A^-1) for model: " 
     2273        Prompt qmax "Enter maximum q-value (A^-1) for model: " 
     2274         
     2275        make/O/D/N=(num) xwave_ECEmp,ywave_ECEmp 
     2276        xwave_ECEmp = alog( log(qmin) + x*((log(qmax)-log(qmin))/num) ) 
     2277        make/O/D coef_ECEmp = {2.2e-8,3.346,0.0065,9.0,0.016} 
     2278        make/O/T parameters_ECEmp = {"A","power","scale","Rg (A)","bkg (cm-1)"} 
     2279        Edit parameters_ECEmp,coef_ECEmp 
     2280         
     2281        Variable/G root:g_ECEmp 
     2282        g_ECEmp := EC_Empirical(coef_ECEmp,ywave_ECEmp,xwave_ECEmp) 
     2283        Display ywave_ECEmp vs xwave_ECEmp 
     2284        ModifyGraph marker=29,msize=2,mode=4,log=1 
     2285        Label bottom "q (A\\S-1\\M)" 
     2286        Label left "Intensity (cm\\S-1\\M)" 
     2287        AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) 
     2288         
     2289        AddModelToStrings("EC_Empirical","coef_ECEmp","parameters_ECEmp","ECEmp") 
     2290End 
     2291 
     2292 
     2293// as AAO for smeared version which is necessary 
     2294Function EC_Empirical(cw,yw,xw) : FitFunc 
     2295        Wave cw,yw,xw 
     2296         
     2297        yw = fEC_Empirical(cw,xw) 
     2298 
     2299        return(0) 
     2300End 
     2301// a sum of a power law and debye to approximate the scattering from a real empty cell 
     2302// 
     2303Function fEC_Empirical(w,x) : FitFunc 
     2304        Wave w 
     2305        Variable x 
     2306         
     2307        // variables are: 
     2308        //[0] = A 
     2309        //[1] = power m 
     2310        //[2] scale factor 
     2311        //[3] radius of gyration [A] 
     2312        //[4] background        [cm-1] 
     2313         
     2314        Variable scale,rg,bkg,aa,mm,Iq 
     2315        aa = w[0] 
     2316        mm = w[1] 
     2317        scale = w[2] 
     2318        rg = w[3] 
     2319        bkg = w[4] 
     2320         
     2321        // calculates (scale*debye)+bkg 
     2322        Variable Pq,qr2 
     2323         
     2324//      if(x*Rg < 1e-3)         //added Oct 2008 to avoid numerical errors at low arg values 
     2325//              return(scale+bkg) 
     2326//      endif 
     2327         
     2328        Iq = aa*x^-mm 
     2329         
     2330        qr2=(x*rg)^2 
     2331        Pq = 2*(exp(-(qr2))-1+qr2)/qr2^2 
     2332         
     2333        //scale 
     2334        Pq *= scale 
     2335        // then add the terms up 
     2336        return (Iq + Pq + bkg) 
     2337End 
     2338 
     2339//wrapper to calculate the smeared model as an AAO-Struct 
     2340// fills the struct and calls the ususal function with the STRUCT parameter 
     2341// 
     2342// used only for the dependency, not for fitting 
     2343// 
     2344Function fSmearedEC_Empirical(coefW,yW,xW) 
     2345        Wave coefW,yW,xW 
     2346         
     2347        String str = getWavesDataFolder(yW,0) 
     2348        String DF="root:"+str+":" 
     2349         
     2350        WAVE resW = $(DF+str+"_res") 
     2351         
     2352        STRUCT ResSmearAAOStruct fs 
     2353        WAVE fs.coefW = coefW    
     2354        WAVE fs.yW = yW 
     2355        WAVE fs.xW = xW 
     2356        WAVE fs.resW = resW 
     2357         
     2358        Variable err 
     2359        err = SmearedEC_Empirical(fs) 
     2360         
     2361        return (0) 
     2362End 
     2363 
     2364// this is all there is to the smeared calculation! 
     2365Function SmearedEC_Empirical(s) :FitFunc 
     2366        Struct ResSmearAAOStruct &s 
     2367 
     2368//      the name of your unsmeared model (AAO) is the first argument 
     2369        Smear_Model_20(EC_Empirical,s.coefW,s.xW,s.yW,s.resW) 
     2370 
     2371        return(0) 
     2372End 
     2373         
     2374 
     2375 
     2376 
     2377 
     2378 
     2379/////////////// end empirical EC model 
     2380 
     2381 
    22612382 
    22622383 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NCNR_Utils.ipf

    r887 r888  
    18631863        list = RemoveFromList(ListMatch(list,"*.SA2*",";"), list, ";", 0) 
    18641864        list = RemoveFromList(ListMatch(list,"*.SA3*",";"), list, ";", 0) 
     1865        list = RemoveFromList(ListMatch(list,"*.SA4*",";"), list, ";", 0)               // added JAN 2013 for new guide hall 
     1866        list = RemoveFromList(ListMatch(list,"*.SA5*",";"), list, ";", 0) 
    18651867        list = RemoveFromList(ListMatch(list,".*",";"), list, ";", 0) 
    18661868        list = RemoveFromList(ListMatch(list,"*.pxp",";"), list, ";", 0) 
     
    19071909                        newlist += item + ";" 
    19081910                endif 
     1911                if( stringmatch(item,"*.sa4*") )                // added JAN 2013 for new guide hall 
     1912                        newlist += item + ";" 
     1913                endif 
     1914                if( stringmatch(item,"*.sa5*") ) 
     1915                        newlist += item + ";" 
     1916                endif 
    19091917                //print "ii=",ii 
    19101918        endfor 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/SASCALC.ipf

    r887 r888  
    21242124                         
    21252125        endswitch 
    2126         Print "Ng = ",Ng 
     2126//      Print "Ng = ",Ng 
    21272127 
    21282128        Ng = abs(round(Ng)) 
     
    21342134// slider and setVar are linked to the same global 
    21352135// updates the wave and changes the beamcenter (x,y) in the wave 
     2136// 
     2137// does not account for the fall due to gravity in y-direction 
    21362138Function detectorOffset() 
    21372139         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Transmission.ipf

    r887 r888  
    16291629EndMacro 
    16301630 
     1631// 
     1632// The proper list of transmission files MUST be present in the Patch Popup list 
     1633// -- using Grep for "trans" is a possible choice 
     1634// 
     1635// testing only TODO_10m -- a quick fix for the missing BS xpos to identify trans 
     1636Function BatchConvert_10mTrans(xPos) 
     1637        Variable xPos                   //pass -10 to make it trans, pass 0 to make it scattering again 
     1638         
     1639        //this will change (checked) values in ALL of the headers in the popup list 
     1640        SVAR list = root:myGlobals:Patch:gPatchList 
     1641        String partialName="", tempName = "" 
     1642        Variable numitems,ii,ok 
     1643        numitems = ItemsInList(list,";") 
     1644         
     1645        //loop through all of the files in the list, applying changes as dictated by w and wt waves 
     1646        ii=0 
     1647        do 
     1648                //get current item in the list 
     1649                partialName = StringFromList(ii, list, ";") 
     1650                    
     1651                //get a valid file based on this partialName and catPathName 
     1652                tempName = FindValidFilename(partialName) 
     1653         
     1654                //prepend path to tempName for read routine  
     1655                PathInfo catPathName 
     1656                tempName = S_path + tempName 
     1657         
     1658                //make sure the file is really a RAW data file 
     1659                ok = CheckIfRawData(tempName) 
     1660                if (!ok) 
     1661                   Print "this file is not recognized as a RAW SANS data file = ",tempName 
     1662                else 
     1663                   //go write the changes to the file 
     1664                   ChangeBSXPos(tempName,xPos) 
     1665                Endif 
     1666                 
     1667                ii+=1 
     1668        while(ii<numitems) 
     1669         
     1670End 
    16311671 
    16321672///// 
Note: See TracChangeset for help on using the changeset viewer.