Ignore:
Timestamp:
Mar 28, 2019 11:12:06 AM (4 years ago)
Author:
srkline
Message:

1) speed improvement (2x + faster) in recalculation of VCALC configuration by using multithreading where possible.

2) Important bug fix for USANS to account for data collected in q-values, where each point is collected for a different lenght of time. This change had unintended consequences for normalization and dead time corrections.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/BT5_Loader.ipf

    r1133 r1137  
    3737        Make/O/D/N=(num) $(USANSFolder+":"+type+":MonCts") 
    3838        Make/O/D/N=(num) $(USANSFolder+":"+type+":TransCts") 
     39        Make/O/D/N=(num) $(USANSFolder+":"+type+":CtTime") 
    3940        Wave Angle = $(USANSFolder+":"+type+":Angle") 
    4041        Wave DetCts = $(USANSFolder+":"+type+":DetCts") 
     
    4243        Wave MonCts = $(USANSFolder+":"+type+":MonCts") 
    4344        Wave TransCts = $(USANSFolder+":"+type+":TransCts") 
     45        Wave CtTime = $(USANSFolder+":"+type+":CtTime") 
    4446         
    4547        Open/R refNum as fname          //if fname is "", a dialog will be presented 
     
    8587         
    8688        Variable useNewDataFormat 
    87  
     89        NVAR    gRawUSANSisQvalues = root:Packages:NIST:gRawUSANSisQvalues 
     90         
     91         
    8892// test by date 
    8993        Variable thisFileSecs 
     
    98102         
    99103        USANS_DetectorDeadtime(filedt,MainDeadTime,TransDeadTime) 
     104         
     105//      Print "Overriding Transmission DeadTime, set to 1e-9 s" 
     106//      TransDeadTime = 1e-9 
     107//      MainDeadTime = 1e-9 
     108         
    100109         
    101110        //skip line 2 
     
    119128                        break                                                   // Hit blank line. End of data in the file. 
    120129                endif 
     130                //1st line of pair 
    121131                sscanf buffer,"%g%g%g%g%g",v1,v2,v3,v4,v5               // 5 values here now 
    122132                angle[numlinesloaded] = v1              //[0] is the ANGLE 
     133                if(gRawUSANSisQvalues==1) 
     134                        // in this mode, each data point is collected for a different time 
     135                        countTime = v2 * 60             // convert MIN to seconds 
     136                endif 
     137                 
    123138                 
    124139                FReadLine refNum,buffer //assume a 2nd line is there, w/16 values 
     
    152167                endif 
    153168                 
     169                CtTime[numlinesloaded] = countTime 
     170                 
    154171                numlinesloaded += 1             //2 lines in file read, one "real" line of data 
    155172        while(1) 
     
    158175        //Print "numlines = ",numlinesloaded 
    159176        //trim the waves to the correct number of points 
    160         Redimension/N=(numlinesloaded) Angle,MonCts,DetCts,TransCts,ErrDetCts 
     177        Redimension/N=(numlinesloaded) Angle,MonCts,DetCts,TransCts,ErrDetCts,CtTime 
    161178         
    162179        //remove LF from end of filelabel 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/Main_USANS.ipf

    r1133 r1137  
    456456// note that trans detector counts are NOT normalized to 1E6 mon cts (not necessary) 
    457457// 
     458// 28 Mar 2019 
     459//  converted CtTime to be a wave, loaded in with the raw data 
     460// for old-style data, this is a constant value. for new q-value data, each point 
     461// can be counted for a different time. 
     462// 
    458463Function Convert2Countrate(type,doNorm) 
    459464        String type 
     
    463468         
    464469        String noteStr = note($(USANSFolder+":"+Type+":DetCts")) 
    465         Variable ctTime 
    466         ctTime = NumberByKey("TIMEPT",noteStr,":",";") 
     470         
     471        Variable ctTimeVal 
     472//      Variable ctTime 
     473//      ctTime = NumberByKey("TIMEPT",noteStr,":",";") 
     474 
    467475//      print ctTime 
    468476        //normalize by counting time 
     
    471479        Wave MonCts = $(USANSFolder+":"+Type+":MonCts") 
    472480        Wave TransCts = $(USANSFolder+":"+Type+":TransCts") 
     481        Wave ctTime = $(USANSFolder+":"+Type+":ctTime") 
    473482         
    474483        detCts /= ctTime 
     
    486495         
    487496        //adjust the note (now on basis of 1 second) 
    488         ctTime = 1 
    489         noteStr = ReplaceNumberByKey("TIMEPT",noteStr,ctTime,":",";") 
     497        ctTimeVal = 1 
     498        noteStr = ReplaceNumberByKey("TIMEPT",noteStr,ctTimeVal,":",";") 
    490499        Note/K detCts 
    491500        Note detCts,noteStr 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Utils.ipf

    r1134 r1137  
    153153//////////////////// 
    154154         
    155         prob_i = trans*thick*pixSizeX*pixSizeY/(sdd)^2*tmpInten                 //probability of a neutron in q-bin(i)  
     155        MultiThread prob_i = trans*thick*pixSizeX*pixSizeY/(sdd)^2*tmpInten                     //probability of a neutron in q-bin(i)  
    156156                 
    157157        tmpInten = (imon)*prob_i                //tmpInten is not the model calculation anymore!! 
     
    159159 
    160160/// **** can I safely assume a Gaussian error in the count rate?? 
    161         tmpSig = sqrt(tmpInten)         // corrected based on John's memo, from 8/9/99 
    162  
    163         tmpInten += gnoise(tmpSig) 
    164         tmpInten = (tmpInten[p][q] < 0) ? 0 : tmpInten[p][q]                    // MAR 2013 -- is this the right thing to do 
     161        MultiThread tmpSig = sqrt(tmpInten)             // corrected based on John's memo, from 8/9/99 
     162 
     163        MultiThread tmpInten += gnoise(tmpSig) 
     164        MultiThread tmpInten = (tmpInten[p][q] < 0) ? 0 : tmpInten[p][q]                        // MAR 2013 -- is this the right thing to do 
    165165        tmpInten = trunc(tmpInten) 
    166166                 
     
    205205        // loop over the array and calculate the values - this is done as a wave assignment 
    206206// TODO -- be sure that it's p,q -- or maybe p+1,q+1 as used in WriteQIS.ipf     
    207         qTot = VC_CalcQval(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    208         qx = VC_CalcQX(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    209         qy = VC_CalcQY(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    210         qz = VC_CalcQZ(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     207        MultiThread qTot = VC_CalcQval(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     208        MultiThread     qx = VC_CalcQX(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     209        MultiThread     qy = VC_CalcQY(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     210        MultiThread     qz = VC_CalcQZ(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    211211         
    212212        return(0) 
     
    411411// 
    412412// 
    413 Function VC_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     413Threadsafe Function VC_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    414414        Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY 
    415415         
     
    438438// now properly accounts for qz 
    439439// 
    440 Function VC_CalcQX(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     440Threadsafe Function VC_CalcQX(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    441441        Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY 
    442442 
     
    468468// now properly accounts for qz 
    469469// 
    470 Function VC_CalcQY(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     470Threadsafe Function VC_CalcQY(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    471471        Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY 
    472472         
     
    497497// not actually used, but here for completeness if anyone asks 
    498498// 
    499 Function VC_CalcQZ(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     499Threadsafe Function VC_CalcQZ(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    500500        Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY 
    501501         
Note: See TracChangeset for help on using the changeset viewer.