Ignore:
Timestamp:
Jan 5, 2018 10:32:55 AM (5 years ago)
Author:
srkline
Message:

more utilities and bug fixes to handle:
(1) generation of DIV files
(2) generation and loading of slit-smeared VSANS data sets

Loading of VSANS data sets and generating the resolution smearing matrix required adding a conditional compile statement to the PlotUtilsMacro? file, to distinguish VSANS data - crudely done now by checking to see that VSANS is defined (which will NOT be the case for a "normal" Analysis experiment. This will need to be revisited in the future.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Slit.ipf

    r1077 r1078  
    175175//      eBin_qxqy = tmp[0][p] 
    176176 
    177         Variable ii,jj,ntube,npix,sum_inten, sum_n, sum_inten2,avesq,aveisq,var,mask_val 
     177        Variable ii,jj,ntube,nYpix,sum_inten, sum_n, sum_inten2,avesq,aveisq,var,mask_val 
    178178        ntube = DimSize(inten,0) 
    179         npix = DimSize(inten,1) 
     179        nYpix = DimSize(inten,1) 
    180180         
    181181        for(ii=0;ii<ntube;ii+=1) 
     
    184184                sum_inten2 = 0 
    185185                 
    186                 for(jj=0;jj<npix;jj+=1) 
     186                for(jj=0;jj<nYpix;jj+=1) 
    187187                                val = inten[ii][jj] 
    188188                                if(isVCALC || maskMissing)              // mask_val == 0 == keep, mask_val == 1 = YES, mask out the point 
     
    199199                iBin_qxqy[ii] = sum_inten/sum_n         //the average value 
    200200                 
    201                 avesq = sum_inten 
     201                avesq = (sum_inten/sum_n)^2 
    202202                aveisq = sum_inten2/sum_n 
    203203                var = aveisq-avesq 
     
    211211 
    212212//TODO:  use only the Qx component in the y-center of the detector, not Qtotal 
    213         qBin_qxqy =  abs(qx[p][npix/2])          
    214  
    215 // if the detectors are "L", then the values are all negative...         
    216         qBin_qxqy = abs(qBin_qxqy) 
     213// if the detectors are "L", then the values are all negative, so take the absolute value here 
     214        qBin_qxqy =  abs(qx[p][nYpix/2])                 
    217215 
    218216// for the L panels, sort the q-values (and data) after the abs() step, otherwise the data is reversed 
    219 // won't hurt to sort the R data 
     217// won't hurt to sort the R panel data 
    220218        Sort qBin_qxqy, qBin_qxqy,iBin_qxqy,eBin_qxqy 
    221          
    222         // not needed to corrrect data, but put in the file??? 
    223         delQy = abs(qy[0][npix-1] - qy[0][0])   // TODO: do I use dQ for the height of the panel? 
     219 
     220 
     221        // TODO: do I use dQ for the height of the panel? 
     222        // TODO : do I use 1/2 of dQ due to the symmetry of my smearing calculation?     
     223        delQy = abs(qy[0][nYpix-1] - qy[0][0]) 
     224 
    224225//      iBin_qxqy *= delQy 
    225226//      eBin_qxqy *= delQy 
     
    247248//      DeletePoints 0, val, iBin_qxqy,qBin_qxqy,eBin_qxqy 
    248249 
    249  
    250 // TODO: 
    251 // -- calculate the slit resolution here. don't really have any idea how to represent this in VSANS 
    252 //    since it's not an infinite slit, and not anything that I expect could be represented as a Gaussian 
    253250 
    254251        // TODO: 
     
    266263        Wave fsubs = $(folderPath+":"+"fSubS_qxqy_"+detStr) 
    267264 
    268 // TODO 
    269 // -- these are DUMMY VALUES!!! 
    270         sigmaq = -delQy 
    271         qbar = -delQy 
    272         fsubs = -delQy 
     265// TODO: 
     266// -- calculate the slit resolution here. don't really have any idea how to represent this in VSANS 
     267//    since it's not an infinite slit, and not anything that I expect could be represented as a Gaussian 
     268// -- there is also wavelength smearing present 
     269 
     270// ASSUMPTION: As a first approximation, ignore the wavelength smearing component        
     271        // TODO : do I use 1/2 of dQy due to the symmetry of my smearing calculation?    
     272        sigmaq = -delQy/2 
     273        qbar = -delQy/2 
     274        fsubs = -delQy/2 
    273275 
    274276 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf

    r1076 r1078  
    111111#include "V_Attenuation" 
    112112 
     113// for loading of slit-smeared VSANS data 
     114// and generating the smearing matrix 
     115#include "V_USANS_SlitSmearing_v40" 
    113116 
    114117 
    115118 
    116119 
     120 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DIVUtils.ipf

    r1075 r1078  
    3333 
    3434 
     35 
     36 
    3537/// TODO: 
    3638// -- need a way to view the DIV data (each panel) and see the stats on the values 
     
    5052// Basic function: 
    5153// -- Setup_VSANS_DIV_Struct() 
    52 // -- then, reduce the data (to the COR level?) 
    53 // -- next, V_NormalizeDIV() (one panel at a time, using the mask) 
    54 // -- next, V_CopyDIVToSave() -or- V_CopyDIVToSave_OnePanel() 
    55 // -- last, Save_VSANS_DIV_Nexus()  
    56 // 
    57  
    58  
    59  
    60  
    61  
    62  
    63  
    64 Proc V_NormalizeDIV_proc(type,detStr) 
    65         String type,detStr 
    66         V_NormalizeDIV_onePanel(type,detStr) 
     54// 
     55// -- Clear the DIV data folder: V_KillWavesInFolder("DIV") 
     56// 
     57// -- reduce the data (to the COR level?) 
     58 
     59// -- V_NormalizeDIV() (one panel at a time, using the mask) 
     60// -- V_CopyDIVToSave() -or- V_CopyDIVToSave_OnePanel() 
     61 
     62// -- Save_VSANS_DIV_Nexus()  
     63// 
     64 
     65 
     66// 
     67// Simple panel to walk through the steps of generating a DIV file 
     68// 
     69Proc DIV_Setup_Panel() : Panel 
     70        PauseUpdate; Silent 1           // building window... 
     71        NewPanel /W=(1207,593,1444,953)/N=DIV_Setup_Panel/K=1 
     72        DoWindow/C DIV_Setup_Panel 
     73        Button button0,pos={54.00,10.00},size={120.00,20.00},proc=V_DIVSetupButtonProc,title="Setup Folder" 
     74        Button button1,pos={54.00,40.00},size={120.00,20.00},proc=V_DIVClearOldButtonProc,title="Clear Old DIV" 
     75 
     76        DrawText 36,110,"Reduce data for one carriage"   
     77        DrawText 36,200,"Repeat for the other carriage" 
     78        Button button1_2,pos={74.00,130.00},size={120.00,20.00},proc=V_DIVMaskButtonProc,title="Mask for DIV" 
     79        Button button2,pos={74.00,160.00},size={120.00,20.00},proc=V_DIVNormalizeButtonProc,title="Normalize+Copy" 
     80 
     81        DrawText 36,290,"Once data for both carriages has\rbeen normalized, save the file"       
     82         
     83        Button button3,pos={54.00,300.00},size={120.00,20.00},proc=V_DIVSaveButtonProc,title="Save DIV" 
     84EndMacro 
     85 
     86 
     87 
     88// set up the folder structure for the DIV file to fill in 
     89Function V_DIVSetupButtonProc(ba) : ButtonControl 
     90        STRUCT WMButtonAction &ba 
     91 
     92        switch( ba.eventCode ) 
     93                case 2: // mouse up 
     94                        // click code here 
     95                        Execute "Setup_VSANS_DIV_Struct()" 
     96                        break 
     97                case -1: // control being killed 
     98                        break 
     99        endswitch 
     100 
     101        return 0 
     102End 
     103 
     104 
     105// clear out whatever is in the current DIV folder to ensure that it is not  
     106// accidentally applied during the reduction of the DIV file 
     107// 
     108Function V_DIVClearOldButtonProc(ba) : ButtonControl 
     109        STRUCT WMButtonAction &ba 
     110 
     111        switch( ba.eventCode ) 
     112                case 2: // mouse up 
     113                        // click code here 
     114                        V_KillWavesInFolder("DIV") 
     115                        break 
     116                case -1: // control being killed 
     117                        break 
     118        endswitch 
     119 
     120        return 0 
     121End 
     122 
     123 
     124Function V_DIVNormalizeButtonProc(ba) : ButtonControl 
     125        STRUCT WMButtonAction &ba 
     126 
     127        switch( ba.eventCode ) 
     128                case 2: // mouse up 
     129                        // click code here 
     130                        Execute "V_NormalizeDIV_proc()" 
     131                        break 
     132                case -1: // control being killed 
     133                        break 
     134        endswitch 
     135 
     136        return 0 
     137End 
     138 
     139Function V_DIVMaskButtonProc(ba) : ButtonControl 
     140        STRUCT WMButtonAction &ba 
     141 
     142        switch( ba.eventCode ) 
     143                case 2: // mouse up 
     144                        // click code here 
     145                        Execute "V_Edit_a_Mask()" 
     146                        break 
     147                case -1: // control being killed 
     148                        break 
     149        endswitch 
     150 
     151        return 0 
     152End 
     153 
     154Function V_DIVSaveButtonProc(ba) : ButtonControl 
     155        STRUCT WMButtonAction &ba 
     156 
     157        switch( ba.eventCode ) 
     158                case 2: // mouse up 
     159                        // click code here 
     160                        Execute "Save_VSANS_DIV_Nexus()" 
     161                        break 
     162                case -1: // control being killed 
     163                        break 
     164        endswitch 
     165 
     166        return 0 
     167End 
     168 
     169 
     170 
     171 
     172Proc V_NormalizeDIV_proc(reducedFolderType,carriageStr) 
     173        String reducedFolderType="SAM",carriageStr="F" 
     174        if(cmpstr(carriageStr,"F")==0) 
     175                V_NormalizeDIV_onePanel(reducedFolderType,"FL") 
     176                V_NormalizeDIV_onePanel(reducedFolderType,"FR") 
     177                V_NormalizeDIV_onePanel(reducedFolderType,"FT") 
     178                V_NormalizeDIV_onePanel(reducedFolderType,"FB") 
     179        else 
     180                V_NormalizeDIV_onePanel(reducedFolderType,"ML") 
     181                V_NormalizeDIV_onePanel(reducedFolderType,"MR") 
     182                V_NormalizeDIV_onePanel(reducedFolderType,"MT") 
     183                V_NormalizeDIV_onePanel(reducedFolderType,"MB")  
     184        endif 
     185         
    67186end 
     187 
    68188 
    69189// Normalizes a single panel 
     
    406526        Display/W=(10,45,210,425)/HOST=#  
    407527        AppendImage/T/G=1 :Packages:NIST:VSANS:RAW:entry:instrument:detector_FL:data            //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
     528 
    408529        ModifyImage data ctab= {*,*,ColdWarm,0} 
    409530        ModifyImage data ctabAutoscale=3 
     
    675796end 
    676797 
     798// if there is no operation called, immediately exit 
     799// 
    677800// if there is a simple operation called, do it 
     801// TODO -- if there are more than these two simple operations, a more sophisticated switch will be necessary 
     802// 
    678803Function V_DoDIVOperation() 
    679804 
     
    732857 
    733858 
    734 // 
    735 // Simple panel to walk through the steps of generating a DIV file 
    736 // 
    737  
    738  
    739  
    740  
    741 Proc DIV_Setup_Panel() : Panel 
    742         PauseUpdate; Silent 1           // building window... 
    743         NewPanel /W=(1207,593,1444,953)/N=DIV_Setup_Panel/K=1 
    744         DoWindow/C DIV_Setup_Panel 
    745         Button button0,pos={54.00,10.00},size={120.00,20.00},proc=V_DIVSetupButtonProc,title="Setup Folder" 
    746         Button button1,pos={54.00,100.00},size={120.00,20.00},proc=V_DIVNormalizeButtonProc,title="Normalize" 
    747         Button button2,pos={54.00,200.00},size={120.00,20.00},proc=V_DIVSaveButtonProc,title="Save DIV" 
    748 EndMacro 
    749  
    750 // set up the folder structure for the DIV file to fill in 
    751 Function V_DIVSetupButtonProc(ba) : ButtonControl 
    752         STRUCT WMButtonAction &ba 
    753  
    754         switch( ba.eventCode ) 
    755                 case 2: // mouse up 
    756                         // click code here 
    757                         Execute "Setup_VSANS_DIV_Struct()" 
    758                         break 
    759                 case -1: // control being killed 
    760                         break 
    761         endswitch 
    762  
    763         return 0 
    764 End 
    765  
    766  
    767 Function V_DIVNormalizeButtonProc(ba) : ButtonControl 
    768         STRUCT WMButtonAction &ba 
    769  
    770         switch( ba.eventCode ) 
    771                 case 2: // mouse up 
    772                         // click code here 
    773                         Execute "V_NormalizeDIV_proc()" 
    774                         break 
    775                 case -1: // control being killed 
    776                         break 
    777         endswitch 
    778  
    779         return 0 
    780 End 
    781  
    782 Function V_DIVSaveButtonProc(ba) : ButtonControl 
    783         STRUCT WMButtonAction &ba 
    784  
    785         switch( ba.eventCode ) 
    786                 case 2: // mouse up 
    787                         // click code here 
    788                         Execute "Save_VSANS_DIV_Nexus()" 
    789                         break 
    790                 case -1: // control being killed 
    791                         break 
    792         endswitch 
    793  
    794         return 0 
    795 End 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf

    r1076 r1078  
    160160// both beam conditions (+/- 0.0 mm). FTB was +/- 0.8 mm, MTB +/- 2 mm 
    161161        if(cmpstr(detStr,"FL") == 0 || cmpstr(detStr,"FR") == 0) 
    162                 gap = 3.2               //mm 
     162                gap = 3.8               //mm (measured, JB 1/4/18) 
    163163        endif 
    164164        if(cmpstr(detStr,"FT") == 0 || cmpstr(detStr,"FB") == 0) 
     
    166166        endif 
    167167        if(cmpstr(detStr,"ML") == 0 || cmpstr(detStr,"MR") == 0) 
    168                 gap = 5.4               //mm 
     168                gap = 5.9               //mm (measured, JB 1/4/18) 
    169169        endif 
    170170        if(cmpstr(detStr,"MT") == 0 || cmpstr(detStr,"MB") == 0) 
     
    12281228                Wave data_err = V_getDetectorDataErrW("ABS",detStr) 
    12291229                 
    1230                 data *= s1*s2*s3*s4 
     1230                data *= scale 
    12311231                data_err = sqrt(scale^2*data_err^2 + scale^2*data^2*(kappa_err^2/s_izero^2 +trans_err^2/w_trans^2)) 
    12321232        endfor 
    12331233         
    12341234        //********* 15APR02 
    1235         // DO NOT correct for atenuators here - the COR step already does this, putting all of the data one equal 
     1235        // DO NOT correct for atenuators here - the COR step already does this, putting all of the data on equal 
    12361236        // footing (zero atten) before doing the subtraction. 
    12371237         
Note: See TracChangeset for help on using the changeset viewer.