Changeset 210


Ignore:
Timestamp:
Nov 28, 2007 12:37:24 PM (15 years ago)
Author:
srkline
Message:

Moved the large angle transmission correction to the 2D stage in DetCorr?(), where the solid angle correction and detector efficiency correction are currently made. The trans correction was previously located in the 1D averaging, but needed to be relocated for 2D analysis. The location in DetCorr?() was selected after talking with John. Results were tested vs. apoferritin, H2O, D2O, and samples in the NIST pressure cell. No noticeable difference was found with the correction in the new location.

Global variables have been added that can be used to (0/1 off/on) the efficiency or trans corrections. The defaults are for both on.

Location:
sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/CircSectAve.ipf

    r143 r210  
    277277        lambda = reals[26] 
    278278        trans = reals[4] 
    279          
    280         ////this section is the trans_correct() VAX routine 
    281         if(trans<0.1) 
    282                 Print "***transmission is less than 0.1*** and is a significant correction" 
    283         endif 
    284         if(trans==0) 
    285                 Print "***transmission is ZERO*** and has been reset to 1.0 for the averaging calculation" 
    286                 trans = 1 
    287         endif 
    288         //optical thickness 
    289         uval = -ln(trans)               //use natural logarithm 
    290         //apply correction to aveint[] 
    291         //index from zero here, since only working with IGOR waves 
    292         ii=0 
    293         do 
    294                 theta = 2*asin(lambda*qval[ii]/(4*pi)) 
    295                 cos_th = cos(theta) 
    296                 arg = (1-cos_th)/cos_th 
    297                 if((uval<0.01) || (cos_th>0.99))                //OR 
    298                         //small arg, approx correction 
    299                         aveint[ii] /= 1-0.5*uval*arg 
    300                 else 
    301                         //large arg, exact correction 
    302                         aveint[ii] /= (1-exp(-uval*arg))/(uval*arg) 
    303                 endif 
    304                 ii+=1 
    305         while(ii<nq) 
    306         //end of transmission/pathlength correction 
     279 
     280// 
     281//  The transmission correction is now done at the ADD step, in DetCorr() 
     282//       
     283//      ////this section is the trans_correct() VAX routine 
     284//      if(trans<0.1) 
     285//              Print "***transmission is less than 0.1*** and is a significant correction" 
     286//      endif 
     287//      if(trans==0) 
     288//              Print "***transmission is ZERO*** and has been reset to 1.0 for the averaging calculation" 
     289//              trans = 1 
     290//      endif 
     291//      //optical thickness 
     292//      uval = -ln(trans)               //use natural logarithm 
     293//      //apply correction to aveint[] 
     294//      //index from zero here, since only working with IGOR waves 
     295//      ii=0 
     296//      do 
     297//              theta = 2*asin(lambda*qval[ii]/(4*pi)) 
     298//              cos_th = cos(theta) 
     299//              arg = (1-cos_th)/cos_th 
     300//              if((uval<0.01) || (cos_th>0.99))                //OR 
     301//                      //small arg, approx correction 
     302//                      aveint[ii] /= 1-0.5*uval*arg 
     303//              else 
     304//                      //large arg, exact correction 
     305//                      aveint[ii] /= (1-exp(-uval*arg))/(uval*arg) 
     306//              endif 
     307//              ii+=1 
     308//      while(ii<nq) 
     309//      //end of transmission/pathlength correction 
    307310 
    308311// *************************************************************** 
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/Initialize.ipf

    r116 r210  
    9797        Variable/G root:myGlobals:gBinWidth=1 
    9898        Variable/G root:myGlobals:gNPhiSteps=72 
     99         
     100        // flags to turn detector corrections on/off for testing (you should leave these ON) 
     101        Variable/G root:myGlobals:gDoDetectorEffCorr = 1 
     102        Variable/G root:myGlobals:gDoTransmissionCorr = 1 
    99103 
    100104        //set flag if Demo Version is detected 
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/RectAnnulAvg.ipf

    r143 r210  
    277277        lambda = reals[26] 
    278278        trans = reals[4] 
    279          
    280         ////this section is the trans_correct() VAX routine 
    281         if(trans<0.1) 
    282                 Print "***transmission is less than 0.1*** and is a significant correction" 
    283         endif 
    284         if(trans==0) 
    285                 Print "***transmission is ZERO*** and has been reset to 1.0 for the averaging calculation" 
    286                 trans = 1 
    287         endif 
    288         //optical thickness 
    289         uval = -ln(trans) 
    290         //apply correction to aveint[] 
    291         //index from zero here, since only working with IGOR waves 
    292         ii=0 
    293         do 
    294                 theta = 2*asin(lambda*qval[ii]/(4*pi)) 
    295                 cos_th = cos(theta) 
    296                 arg = (1-cos_th)/cos_th 
    297                 if((uval<0.01) || (cos_th>0.99))                //OR 
    298                         //small arg, approx correction 
    299                         aveint[ii] /= 1-0.5*uval*arg 
    300                 else 
    301                         //large arg, exact correction 
    302                         aveint[ii] /= (1-exp(-uval*arg))/(uval*arg) 
    303                 endif 
    304                 ii+=1 
    305         while(ii<nq) 
    306         //end of transmission/pathlength correction 
    307          
     279// 
     280//  The transmission correction is now done at the ADD step, in DetCorr() 
     281//               
     282//      ////this section is the trans_correct() VAX routine 
     283//      if(trans<0.1) 
     284//              Print "***transmission is less than 0.1*** and is a significant correction" 
     285//      endif 
     286//      if(trans==0) 
     287//              Print "***transmission is ZERO*** and has been reset to 1.0 for the averaging calculation" 
     288//              trans = 1 
     289//      endif 
     290//      //optical thickness 
     291//      uval = -ln(trans) 
     292//      //apply correction to aveint[] 
     293//      //index from zero here, since only working with IGOR waves 
     294//      ii=0 
     295//      do 
     296//              theta = 2*asin(lambda*qval[ii]/(4*pi)) 
     297//              cos_th = cos(theta) 
     298//              arg = (1-cos_th)/cos_th 
     299//              if((uval<0.01) || (cos_th>0.99))                //OR 
     300//                      //small arg, approx correction 
     301//                      aveint[ii] /= 1-0.5*uval*arg 
     302//              else 
     303//                      //large arg, exact correction 
     304//                      aveint[ii] /= (1-exp(-uval*arg))/(uval*arg) 
     305//              endif 
     306//              ii+=1 
     307//      while(ii<nq) 
     308//      //end of transmission/pathlength correction 
     309//       
    308310// *************************************************************** 
    309311// 
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/Tile_2D.ipf

    r201 r210  
    587587                        endif 
    588588                        if(GraspASCII) 
    589                                 fullPath=pathStr+newFileName+"_G.ASC" 
     589                                fullPath=pathStr+newFileName+".GSP" 
    590590                                Fast2dExport_OldStyle("RAW",fullpath,0) 
    591591                        endif 
  • sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/WorkFileUtils.ipf

    r206 r210  
    117117        ConvertFolderToLinearScale("RAW") 
    118118         
    119         DetCorr(raw_data,raw_reals)     //applies correction to raw_data, and overwrites it 
     119        // switches to control what is done, don't do the transmission correction for the BGD measurement 
     120        NVAR doEfficiency = root:myGlobals:gDoDetectorEffCorr 
     121        NVAR gDoTrans = root:myGlobals:gDoTransmissionCorr 
     122        Variable doTrans = gDoTrans 
     123        if(cmpstr("BGD",newtype) == 0) 
     124                doTrans = 0             //skip the trans correction for the BGD file but don't change the value of the global 
     125        endif    
     126         
     127        DetCorr(raw_data,raw_reals,doEfficiency,doTrans)        //applies correction to raw_data, and overwrites it 
    120128         
    121129        //if RAW data is ILL type detector, correct raw_data for same counts being written to 4 pixels 
     
    257265         
    258266        //apply nonlinear, Jacobian corrections --- 
    259         DetCorr(data,realsread)         //the parameters are waves, and will be changed by the function 
     267        // switches to control what is done, don't do the transmission correction for the BGD measurement 
     268        NVAR doEfficiency = root:myGlobals:gDoDetectorEffCorr 
     269        NVAR gDoTrans = root:myGlobals:gDoTransmissionCorr 
     270        Variable doTrans = gDoTrans 
     271        if(cmpstr("BGD",newtype) == 0) 
     272                doTrans = 0             //skip the trans correction for the BGD file but don't change the value of the global 
     273        endif 
     274         
     275        DetCorr(data,realsread,doEfficiency,doTrans)            //the parameters are waves, and will be changed by the function 
    260276         
    261277        //if ILL type detector, correct for same counts being written to 4 pixels 
     
    361377//works on the actual data array, assumes that is is already on LINEAR scale 
    362378// 
    363 Function DetCorr(data,realsread) 
     379Function DetCorr(data,realsread,doEfficiency,doTrans) 
    364380        Wave data,realsread 
     381        Variable doEfficiency,doTrans 
    365382         
    366383        Variable xcenter,ycenter,x0,y0,sx,sx3,sy,sy3,xx0,yy0 
    367384        Variable ii,jj,dtdist,dtdis2 
    368385        Variable xi,xd,yd,rad,ratio,domega,xy 
    369         Variable lambda 
     386        Variable lambda,trans 
    370387         
    371388//      Print "...doing jacobian and non-linear corrections" 
     389 
    372390        NVAR pixelsX = root:myGlobals:gNPixelsX 
    373391        NVAR pixelsY = root:myGlobals:gNPixelsY 
     
    388406         
    389407        lambda = realsRead[26] 
     408        trans = RealsRead[4] 
    390409         
    391410        xx0 = dc_fx(x0,sx,sx3,xcenter) 
     
    404423        while(ii<pixelsX) 
    405424         
    406 //      Make/O/N=(pixelsX,pixelsX) SolidAngle           // testing only 
     425        Make/O/N=(pixelsX,pixelsY) SolidAngle           // testing only 
    407426         
    408427        ii=0 
     
    424443                        // multiplicative correction for detector efficiency JBG memo det_eff_cor2.doc 3/20/07 
    425444                        // correction inserted 11/2007 SRK 
     445                        // large angle detector efficiency correction is >= 1 and will "bump up" the highest angles 
     446                        if(doEfficiency) 
     447                                data[ii][jj] *= DetEffCorr(lambda,dtdist,xd,yd) 
     448        //                      solidAngle[ii][jj] = DetEffCorr(lambda,dtdist,xd,yd)            //testing only 
     449                        endif 
    426450                         
    427                         data[ii][jj] *= DetEffCorr(lambda,dtdist,xd,yd) 
    428                          
    429 //                      solidAngle[ii][jj] = DetEffCorr(lambda,dtdist,xd,yd)            //testing only 
     451                        // large angle transmission correction is <= 1 and will "bump up" the highest angles 
     452                        if(doTrans) 
     453                                data[ii][jj] /= LargeAngleTransmissionCorr(trans,dtdist,xd,yd)          //moved from 1D avg SRK 11/2007 
     454                                solidAngle[ii][jj] = LargeAngleTransmissionCorr(trans,dtdist,xd,yd)             //testing only 
     455                        endif 
    430456                         
    431457                        jj+=1 
     
    499525        return(ff) 
    500526End 
     527 
     528// DIVIDE the intensity by this correction to get the right answer 
     529Function LargeAngleTransmissionCorr(trans,dtdist,xd,yd) 
     530        Variable trans,dtdist,xd,yd 
     531 
     532        //angle dependent transmission correction  
     533        Variable uval,arg,cos_th,correction,theta 
     534         
     535        ////this section is the trans_correct() VAX routine 
     536        if(trans<0.1) 
     537                Print "***transmission is less than 0.1*** and is a significant correction" 
     538        endif 
     539        if(trans==0) 
     540                Print "***transmission is ZERO*** and has been reset to 1.0 for the averaging calculation" 
     541                trans = 1 
     542        endif 
     543         
     544        theta = atan( (sqrt(xd^2 + yd^2))/dtdist )              //theta at the input pixel 
     545         
     546        //optical thickness 
     547        uval = -ln(trans)               //use natural logarithm 
     548 
     549//      theta = 2*asin(lambda*qval/(4*pi)) 
     550 
     551        cos_th = cos(theta) 
     552        arg = (1-cos_th)/cos_th 
     553        if((uval<0.01) || (cos_th>0.99))                //OR 
     554                //small arg, approx correction 
     555                correction= 1-0.5*uval*arg 
     556        else 
     557                //large arg, exact correction 
     558                correction = (1-exp(-uval*arg))/(uval*arg) 
     559        endif 
     560 
     561        //end of transmission/pathlength correction 
     562 
     563        return(correction) 
     564end 
     565 
    501566//****************** 
    502567//direct port of the FORTRAN code for calculating the weighted 
Note: See TracChangeset for help on using the changeset viewer.