Changeset 982 for sans/Dev


Ignore:
Timestamp:
Feb 25, 2016 4:30:38 PM (7 years ago)
Author:
srkline
Message:

more changes and additons to display VSANS data

adding functions for IvsQ plotting

coverted much of VCALC to have similar folder structure as HDF to allow re-use of the Q-binning procedures from VCALC with real data in work files.

re-working the beam center finder to get it to work with work file data rather then only VCALC.

new plotting routines for the panels to rescale to the beam center (still in pixels, though)

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

Legend:

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

    r981 r982  
    1313 
    1414 
     15Function V_FindBeamCenter() 
     16        DoWindow/F PanelFit 
     17        if(V_flag==0) 
     18                Execute "DetectorPanelFit()" 
     19        endif 
     20End 
    1521// 
    1622// TODO - may need to adjust the display for the different pixel dimensions 
     
    2733        NewPanel /W=(662,418,1586,960)/N=PanelFit/K=1 
    2834//      ShowTools/A 
    29                  
     35         
    3036        PopupMenu popup_0,pos={20,20},size={109,20},proc=SetDetPanelPopMenuProc,title="Detector Panel" 
    3137        PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;MR;ML;MT;MB;B;\"" 
     
    3844 
    3945 
    40         duplicate/O root:Packages:NIST:VSANS:VCALC:Front:det_FL curDispPanel 
     46        duplicate/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FL:det_FL curDispPanel 
    4147        SetScale/P x 0,1, curDispPanel 
    4248        SetScale/P y 0,1, curDispPanel 
     
    155161                        NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_L_pixelX 
    156162                        NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_L_pixelY 
    157                         wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 
     163//                      wave newW = $("root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_"+str+":det_"+str) 
    158164                        break 
    159165                case "FR": 
     
    162168                        NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_R_pixelX 
    163169                        NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_R_pixelY 
    164                         wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 
     170//                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 
    165171                        break 
    166172                case "ML": 
     
    169175                        NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_L_pixelX 
    170176                        NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_L_pixelY 
    171                         wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 
     177//                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 
    172178                        break 
    173179                case "MR": 
     
    176182                        NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_R_pixelX 
    177183                        NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_R_pixelY 
    178                         wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 
     184//                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 
    179185                        break    
    180186 
     
    184190                        NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_T_pixelX 
    185191                        NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_T_pixelY 
    186                         wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 
     192//                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 
    187193                        break 
    188194                case "FB": 
     
    191197                        NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gFront_B_pixelX 
    192198                        NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gFront_B_pixelY 
    193                         wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 
     199//                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Front:det_"+str) 
    194200                        break 
    195201                case "MT": 
     
    198204                        NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_T_pixelX 
    199205                        NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_T_pixelY 
    200                         wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 
     206//                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 
    201207                        break 
    202208                case "MB": 
     
    205211                        NVAR pixSize_X = root:Packages:NIST:VSANS:VCALC:gMiddle_B_pixelX 
    206212                        NVAR pixSize_Y = root:Packages:NIST:VSANS:VCALC:gMiddle_B_pixelY 
    207                         wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 
     213//                      wave newW = $("root:Packages:NIST:VSANS:VCALC:Middle:det_"+str) 
    208214                        break    
    209215                         
     
    215221        endswitch 
    216222         
    217  
    218          
    219          
     223        wave newW = $("root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_"+str+":det_"+str) 
     224 
    220225        Variable scale = 5 
    221226         
     
    395400        return 0 
    396401End 
     402 
     403 
     404// TODO 
     405// -- some of this is hard-wired in 
     406// -- this is still alll in terms of pixels, which still may not be what I want 
     407// -- the x-scale of the T/B panels is artificially compressed to "fake" 4mm per pixel in x-direction 
     408// 
     409Function V_RescaleToBeamCenter(folderStr,detStr,xCtr,yCtr) 
     410        String folderStr,detStr 
     411        Variable xCtr,yCtr 
     412         
     413        Wave w = $("root:Packages:NIST:VSANS:"+folderStr+":entry:entry:instrument:detector_"+detStr+":data") 
     414         
     415        Variable nPix = 128 
     416        Variable nTubes = 48 
     417         
     418        strswitch(detStr)       // string switch 
     419                case "MT":              // top panels 
     420                case "FT": 
     421//                      SetScale/I x -xCtr,npix-xCtr,"",w 
     422                        SetScale/I x -xCtr/2,(npix-xCtr)/2,"",w         // fake 4mm by compressing the scale 
     423                        SetScale/I y -yCtr,nTubes-yCtr,"",w 
     424                        break                                           // exit from switch 
     425                case "MB":              // bottom panels 
     426                case "FB": 
     427//                      SetScale/I x -xCtr,npix-xCtr,"",w 
     428                        SetScale/I x -xCtr/2,(npix-xCtr)/2,"",w 
     429                        SetScale/I y -yCtr,nTubes-yCtr,"",w 
     430                        break                                           // exit from switch 
     431                case "ML":              // left panels 
     432                case "FL": 
     433                        SetScale/I x -xCtr,nTubes-xCtr,"",w 
     434                        SetScale/I y -yCtr,npix-yCtr,"",w 
     435                        break                                           // exit from switch 
     436                case "MR":              // Right panels 
     437                case "FR": 
     438                        SetScale/I x -xCtr,nTubes-xCtr,"",w 
     439                        SetScale/I y -yCtr,npix-yCtr,"",w 
     440                        break                                           // exit from switch 
     441                                         
     442                default:                                                        // optional default expression executed 
     443                        Print "Error in V_RescaleToBeamCenter()" 
     444        endswitch 
     445         
     446        return(0) 
     447end 
     448 
     449Function V_RestorePanels() 
     450 
     451        V_RescaleToBeamCenter("RAW","MB",64,55) 
     452        V_RescaleToBeamCenter("RAW","MT",64,-8.7) 
     453        V_RescaleToBeamCenter("RAW","MR",-8.1,64) 
     454        V_RescaleToBeamCenter("RAW","ML",55,64) 
     455        V_RescaleToBeamCenter("RAW","FB",64,55) 
     456        V_RescaleToBeamCenter("RAW","FT",64,-8.7) 
     457        V_RescaleToBeamCenter("RAW","FR",-8.1,64) 
     458        V_RescaleToBeamCenter("RAW","FL",55,64) 
     459 
     460 
     461        return(0) 
     462end 
     463 
     464Function V_SpreadOutPanels() 
     465 
     466        V_RescaleToBeamCenter("RAW","MB",64,78) 
     467        V_RescaleToBeamCenter("RAW","MT",64,-30) 
     468        V_RescaleToBeamCenter("RAW","MR",-30,64) 
     469        V_RescaleToBeamCenter("RAW","ML",78,64) 
     470        V_RescaleToBeamCenter("RAW","FB",64,78) 
     471        V_RescaleToBeamCenter("RAW","FT",64,-30) 
     472        V_RescaleToBeamCenter("RAW","FR",-30,64) 
     473        V_RescaleToBeamCenter("RAW","FL",78,64) 
     474        return(0) 
     475end 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Q.ipf

    r963 r982  
    4747        // space is allocated for all of the detectors and Q's on initialization 
    4848        // calculate Qtot, qxqyqz arrays from geometry 
    49         V_CalculateQFrontPanels() 
     49        VC_CalculateQFrontPanels() 
    5050         
    5151        // fill the panels with fake sphere scattering data 
    5252        // TODO: am I in the right data folder?? 
    53         SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
    54  
    55         WAVE det_FL = det_FL 
    56         WAVE det_FR = det_FR 
    57         WAVE det_FT = det_FT 
    58         WAVE det_FB = det_FB 
    59          
    60         WAVE qTot_FL = qTot_FL 
    61         WAVE qTot_FR = qTot_FR 
    62         WAVE qTot_FT = qTot_FT 
    63         WAVE qTot_FB = qTot_FB 
     53//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
     54 
     55        String folderStr = "VCALC" 
     56        String detStr = "" 
     57 
     58        String folderPath = "root:Packages:NIST:VSANS:"+folderStr 
     59        String instPath = ":entry:entry:instrument:detector_"    
     60 
     61        detStr = "FL" 
     62        WAVE det_FL = $(folderPath+instPath+detStr+":det_"+detStr)       
     63        WAVE qTot_FL = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     64         
     65        detStr = "FR" 
     66        WAVE det_FR = $(folderPath+instPath+detStr+":det_"+detStr)       
     67        WAVE qTot_FR = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     68         
     69        detStr = "FT" 
     70        WAVE det_FT = $(folderPath+instPath+detStr+":det_"+detStr)       
     71        WAVE qTot_FT = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     72         
     73        detStr = "FB" 
     74        WAVE det_FB = $(folderPath+instPath+detStr+":det_"+detStr)       
     75        WAVE qTot_FB = $(folderPath+instPath+detStr+":qTot_"+detStr) 
    6476 
    6577        FillPanel_wModelData(det_FL,qTot_FL,"FL") 
     
    7486        // -- I can get the separation L/R from the panel - only this "open" width is visible. 
    7587        //TODO - make this a proper shadow - TB extent of the LR panels matters too, not just the LR separation 
    76         V_SetShadow_TopBottom("Front","FT")             // TODO: -- be sure the data folder is properly set (within the function...) 
    77         V_SetShadow_TopBottom("Front","FB") 
     88        VC_SetShadow_TopBottom("VCALC","FT")            // TODO: -- be sure the data folder is properly set (within the function...) 
     89        VC_SetShadow_TopBottom("VCALC","FB") 
    7890         
    7991        // do the q-binning for each of the panels to get I(Q) 
     
    8294        // plot the results 
    8395        Execute "Front_IQ_Graph()" 
    84         Execute "FrontPanels_AsQ()" 
     96        FrontPanels_AsQ() 
    8597         
    8698        return(0) 
     
    102114//     when anything changes 
    103115// 
    104 Function V_CalculateQFrontPanels() 
     116// TODO 
     117// NOTE -- this is VCALC ONLY. data is not referenced for hdf here, and data is rescaled based on VCALC assumptions 
     118// 
     119Function VC_CalculateQFrontPanels() 
    105120 
    106121        Variable xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY,nPix_X,nPix_Y 
    107122        Variable F_LR_sep,F_TB_sep,F_offset,F_sdd_offset 
     123 
     124        String folderPath = "root:Packages:NIST:VSANS:VCALC" 
     125        String instPath = ":entry:entry:instrument:detector_" 
     126        String detStr="" 
    108127 
    109128// get the values from the panel + constants     
     
    125144        F_sdd_offset = VCALC_getTopBottomSDDOffset("FT")        //T/B are 300 mm farther back  //TODO: make all detector parameters global, not hard-wired 
    126145 
    127         SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
    128         Wave det_FL,det_FR                      // these are (48,128)           (nominal, may change) 
    129         Wave det_FT,det_FB                      // these are (128,48) 
    130  
    131 //FRONT/LEFT     
    132         WAVE qTot_FL,qx_FL,qy_FL,qz_FL 
     146// detector data to bin 
     147//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
     148        Wave det_FL = $(folderPath+instPath+"FL"+":det_FL") 
     149        Wave det_FR = $(folderPath+instPath+"FR"+":det_FR")             // these are (48,128)           (nominal, may change) 
     150 
     151        Wave det_FT = $(folderPath+instPath+"FT"+":det_FT") 
     152        Wave det_FB = $(folderPath+instPath+"FB"+":det_FB")             // these are (128,48) 
     153 
     154//FRONT/LEFT 
     155        detStr = "FL" 
     156        Wave qTot_FL = $(folderPath+instPath+detStr+":qTot_"+detStr)                    // 2D q-values 
     157        Wave qx_FL = $(folderPath+instPath+detStr+":qx_"+detStr) 
     158        Wave qy_FL = $(folderPath+instPath+detStr+":qy_"+detStr)         
     159        Wave qz_FL = $(folderPath+instPath+detStr+":qz_"+detStr)         
     160 
    133161        qTot_FL = 0 
    134162        qx_FL = 0 
     
    147175        xCtr = nPix_X+(F_LR_sep/2/pixSizeX)             // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 
    148176        yCtr = nPix_Y/2  
    149         V_Detector_2Q(det_FL,qTot_FL,qx_FL,qy_FL,qz_FL,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
     177        VC_Detector_2Q(det_FL,qTot_FL,qx_FL,qy_FL,qz_FL,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
    150178//      Print "xy for FL = ",xCtr,yCtr 
    151179         
     
    159187 
    160188//FRONT/RIGHT 
    161         SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
    162         WAVE qTot_FR,qx_FR,qy_FR,qz_FR 
     189//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
     190        detStr = "FR" 
     191        Wave qTot_FR = $(folderPath+instPath+detStr+":qTot_"+detStr)                    // 2D q-values 
     192        Wave qx_FR = $(folderPath+instPath+detStr+":qx_"+detStr) 
     193        Wave qy_FR = $(folderPath+instPath+detStr+":qy_"+detStr)         
     194        Wave qz_FR = $(folderPath+instPath+detStr+":qz_"+detStr)         
     195         
    163196        qTot_FR = 0 
    164197        qx_FR = 0 
     
    175208        xCtr = -(F_LR_sep/2/pixSizeX)-1          
    176209        yCtr = nPix_Y/2  
    177         V_Detector_2Q(det_FR,qTot_FR,qx_FR,qy_FR,qz_FR,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
     210        VC_Detector_2Q(det_FR,qTot_FR,qx_FR,qy_FR,qz_FR,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
    178211//      Print "xy for FR = ",xCtr,yCtr 
    179212        SetScale/I x WaveMin(qx_FR),WaveMax(qx_FR),"", det_FR           //this sets the left and right ends of the data scaling 
     
    182215 
    183216//FRONT/TOP 
    184         SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
    185         WAVE qTot_FT,qx_FT,qy_FT,qz_FT 
     217//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
     218        detStr = "FT" 
     219        Wave qTot_FT = $(folderPath+instPath+detStr+":qTot_"+detStr)                    // 2D q-values 
     220        Wave qx_FT = $(folderPath+instPath+detStr+":qx_"+detStr) 
     221        Wave qy_FT = $(folderPath+instPath+detStr+":qy_"+detStr)         
     222        Wave qz_FT = $(folderPath+instPath+detStr+":qz_"+detStr)         
     223 
    186224        qTot_FT = 0 
    187225        qx_FT = 0 
     
    199237        yCtr = -(F_TB_sep/2/pixSizeY)-1    
    200238        // global sdd_offset is in (mm), convert to meters here for the Q-calculation 
    201         V_Detector_2Q(det_FT,qTot_FT,qx_FT,qy_FT,qz_FT,xCtr,yCtr,sdd+F_sdd_offset/1000,lam,pixSizeX,pixSizeY) 
     239        VC_Detector_2Q(det_FT,qTot_FT,qx_FT,qy_FT,qz_FT,xCtr,yCtr,sdd+F_sdd_offset/1000,lam,pixSizeX,pixSizeY) 
    202240//      Print "xy for FT = ",xCtr,yCtr 
    203241        SetScale/I x WaveMin(qx_FT),WaveMax(qx_FT),"", det_FT           //this sets the left and right ends of the data scaling 
     
    206244 
    207245//FRONT/BOTTOM 
    208         SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
    209         WAVE qTot_FB,qx_FB,qy_FB,qz_FB 
     246//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
     247        detStr = "FB" 
     248        Wave qTot_FB = $(folderPath+instPath+detStr+":qTot_"+detStr)                    // 2D q-values 
     249        Wave qx_FB = $(folderPath+instPath+detStr+":qx_"+detStr) 
     250        Wave qy_FB = $(folderPath+instPath+detStr+":qy_"+detStr)         
     251        Wave qz_FB = $(folderPath+instPath+detStr+":qz_"+detStr)         
     252 
    210253        qTot_FB = 0 
    211254        qx_FB = 0 
     
    223266        yCtr = nPix_Y+(F_TB_sep/2/pixSizeY)             // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 
    224267        // global sdd_offset is in (mm), convert to meters here for the Q-calculation 
    225         V_Detector_2Q(det_FB,qTot_FB,qx_FB,qy_FB,qz_FB,xCtr,yCtr,sdd+F_sdd_offset/1000,lam,pixSizeX,pixSizeY) 
     268        VC_Detector_2Q(det_FB,qTot_FB,qx_FB,qy_FB,qz_FB,xCtr,yCtr,sdd+F_sdd_offset/1000,lam,pixSizeX,pixSizeY) 
    226269//      Print "xy for FB = ",xCtr,yCtr 
    227270        SetScale/I x WaveMin(qx_FB),WaveMax(qx_FB),"", det_FB           //this sets the left and right ends of the data scaling 
     
    239282// ? skip the masking? but then I bin the detector data directly to get I(q), skipping the masked NaN values... 
    240283// 
    241 Function V_SetShadow_TopBottom(folderStr,type) 
     284Function VC_SetShadow_TopBottom(folderStr,type) 
    242285        String folderStr,type 
    243286         
     
    258301 
    259302//detector data 
    260         Wave det = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":det_"+type) 
     303        Wave det = $("root:Packages:NIST:VSANS:"+folderStr+":entry:entry:instrument:detector_"+type+":det_"+type) 
    261304 
    262305// TODO - these are to be set from globals, not hard-wired 
     
    290333// are rescaled as needed 
    291334// 
    292 Window FrontPanels_AsQ() : Graph 
    293  
    294         SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
    295  
     335Function FrontPanels_AsQ() 
     336 
     337        String frontStr = "root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:" 
     338//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
     339        SetDataFolder $(frontStr+"detector_FB") 
     340        Wave det_FB = det_FB 
     341        SetDataFolder $(frontStr+"detector_FT") 
     342        Wave det_FT = det_FT 
     343        SetDataFolder $(frontStr+"detector_FL") 
     344        Wave det_FL = det_FL 
     345        SetDataFolder $(frontStr+"detector_FR") 
     346        Wave det_FR = det_FR 
     347         
    296348        CheckDisplayed /W=VCALC#Panels_Q det_FB 
    297349        if(V_flag == 0) 
     
    346398Proc BinAllFrontPanels() 
    347399 
    348         SetDeltaQ("Front","FL") 
    349         SetDeltaQ("Front","FT") 
     400        SetDeltaQ("VCALC","FL") 
     401        SetDeltaQ("VCALC","FR") 
     402        SetDeltaQ("VCALC","FT") 
     403        SetDeltaQ("VCALC","FB") 
    350404 
    351405        Variable binType         
     
    354408 
    355409        if(binType == 1) 
    356                 V_BinQxQy_to_1D("","FL") 
    357                 V_BinQxQy_to_1D("","FR") 
    358                 V_BinQxQy_to_1D("","FT") 
    359                 V_BinQxQy_to_1D("","FB") 
     410                VC_BinQxQy_to_1D("VCALC","FL") 
     411                VC_BinQxQy_to_1D("VCALC","FR") 
     412                VC_BinQxQy_to_1D("VCALC","FT") 
     413                VC_BinQxQy_to_1D("VCALC","FB") 
    360414        endif 
    361415         
    362416        if(binType == 2)         
    363                 V_BinQxQy_to_1D("","FLR") 
    364                 V_BinQxQy_to_1D("","FTB") 
     417                VC_BinQxQy_to_1D("VCALC","FLR") 
     418                VC_BinQxQy_to_1D("VCALC","FTB") 
    365419        endif 
    366420 
    367421        if(binType == 3) 
    368                 V_BinQxQy_to_1D("","FLRTB") 
     422                VC_BinQxQy_to_1D("VCALC","FLRTB") 
    369423        endif 
    370424 
     
    372426        if(binType == 4) 
    373427                /// this is for a tall, narrow slit mode         
    374                 V_fBinDetector_byRows("Front","FL") 
    375                 V_fBinDetector_byRows("Front","FR") 
    376                 V_fBinDetector_byRows("Front","FT") 
    377                 V_fBinDetector_byRows("Front","FB") 
     428                VC_fBinDetector_byRows("VCALC","FL") 
     429                VC_fBinDetector_byRows("VCALC","FR") 
     430                VC_fBinDetector_byRows("VCALC","FT") 
     431                VC_fBinDetector_byRows("VCALC","FB") 
    378432        endif 
    379433                 
     
    398452        // space is allocated for all of the detectors and Q's on initialization 
    399453        // calculate Qtot, qxqyqz arrays from geometry 
    400         V_CalculateQMiddlePanels() 
     454        VC_CalculateQMiddlePanels() 
    401455         
    402456        // fill the panels with fake sphere scattering data 
    403457        // TODO: am I in the right data folder?? 
    404         SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
    405  
    406         WAVE det_ML = det_ML 
    407         WAVE det_MR = det_MR 
    408         WAVE det_MT = det_MT 
    409         WAVE det_MB = det_MB 
    410          
    411         WAVE qTot_ML = qTot_ML 
    412         WAVE qTot_MR = qTot_MR 
    413         WAVE qTot_MT = qTot_MT 
    414         WAVE qTot_MB = qTot_MB 
     458//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
     459 
     460        String folderStr = "VCALC" 
     461        String detStr = "" 
     462 
     463        String folderPath = "root:Packages:NIST:VSANS:"+folderStr 
     464        String instPath = ":entry:entry:instrument:detector_"    
     465 
     466        detStr = "ML" 
     467        WAVE det_ML = $(folderPath+instPath+detStr+":det_"+detStr)       
     468        WAVE qTot_ML = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     469 
     470        detStr = "MR" 
     471        WAVE det_MR = $(folderPath+instPath+detStr+":det_"+detStr)       
     472        WAVE qTot_MR = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     473 
     474        detStr = "MT" 
     475        WAVE det_MT = $(folderPath+instPath+detStr+":det_"+detStr)       
     476        WAVE qTot_MT = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     477 
     478        detStr = "MB" 
     479        WAVE det_MB = $(folderPath+instPath+detStr+":det_"+detStr)       
     480        WAVE qTot_MB = $(folderPath+instPath+detStr+":qTot_"+detStr) 
    415481 
    416482        FillPanel_wModelData(det_ML,qTot_ML,"ML") 
     
    424490        // view of how much of the detectors are actually collecting data 
    425491        // -- I can get the separation L/R from the panel - only this "open" width is visible. 
    426         V_SetShadow_TopBottom("Middle","MT")            // TODO: -- be sure the data folder is properly set (within the function...) 
    427         V_SetShadow_TopBottom("Middle","MB") 
     492        VC_SetShadow_TopBottom("VCALC","MT")            // TODO: -- be sure the data folder is properly set (within the function...) 
     493        VC_SetShadow_TopBottom("VCALC","MB") 
    428494         
    429495        // do the q-binning for each of the panels to get I(Q) 
     
    432498        // plot the results 
    433499        Execute "Middle_IQ_Graph()" 
    434         Execute "MiddlePanels_AsQ()" 
     500        MiddlePanels_AsQ() 
    435501         
    436502        return(0) 
     
    451517//     when anything changes 
    452518// 
    453 Function V_CalculateQMiddlePanels() 
     519Function VC_CalculateQMiddlePanels() 
    454520 
    455521        Variable xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY,nPix_X,nPix_Y 
    456522        Variable M_LR_sep,M_TB_sep,M_offset, M_sdd_offset 
    457523 
     524 
     525        String folderPath = "root:Packages:NIST:VSANS:VCALC" 
     526        String instPath = ":entry:entry:instrument:detector_" 
     527        String detStr="" 
     528         
    458529        M_LR_sep = VCALC_getPanelSeparation("MLR") 
    459530        M_TB_sep = VCALC_getPanelSeparation("MTB") 
     
    472543        M_sdd_offset = VCALC_getTopBottomSDDOffset("MT")        //T/B are 30 cm farther back  //TODO: make all detector parameters global, not hard-wired 
    473544 
    474         SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
    475         Wave det_ML,det_MR                      // these are (48,128)           nominal, may change 
    476         Wave det_MT,det_MB                      // these are (128,48) 
    477  
    478 //Middle/LEFT    
    479         WAVE qTot_ML,qx_ML,qy_ML,qz_ML 
     545 
     546//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
     547        Wave det_ML = $(folderPath+instPath+"ML"+":det_ML") 
     548        Wave det_MR = $(folderPath+instPath+"MR"+":det_MR")             // these are (48,128)           (nominal, may change) 
     549 
     550        Wave det_MT = $(folderPath+instPath+"MT"+":det_MT") 
     551        Wave det_MB = $(folderPath+instPath+"MB"+":det_MB")             // these are (128,48) 
     552 
     553//Middle/LEFT 
     554        detStr = "ML" 
     555        Wave qTot_ML = $(folderPath+instPath+detStr+":qTot_"+detStr)                    // 2D q-values 
     556        Wave qx_ML = $(folderPath+instPath+detStr+":qx_"+detStr) 
     557        Wave qy_ML = $(folderPath+instPath+detStr+":qy_"+detStr)         
     558        Wave qz_ML = $(folderPath+instPath+detStr+":qz_"+detStr)         
     559         
    480560        qTot_ML = 0 
    481561        qx_ML = 0 
     
    492572        xCtr = nPix_X+(M_LR_sep/2/pixSizeX)             // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 
    493573        yCtr = nPix_Y/2  
    494         V_Detector_2Q(det_ML,qTot_ML,qx_ML,qy_ML,qz_ML,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
     574        VC_Detector_2Q(det_ML,qTot_ML,qx_ML,qy_ML,qz_ML,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
    495575//      Print "xy for ML = ",xCtr,yCtr 
    496576         
     
    505585 
    506586//Middle/RIGHT 
    507         SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
    508         WAVE qTot_MR,qx_MR,qy_MR,qz_MR 
     587//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
     588        detStr = "MR" 
     589        Wave qTot_MR = $(folderPath+instPath+detStr+":qTot_"+detStr)                    // 2D q-values 
     590        Wave qx_MR = $(folderPath+instPath+detStr+":qx_"+detStr) 
     591        Wave qy_MR = $(folderPath+instPath+detStr+":qy_"+detStr)         
     592        Wave qz_MR = $(folderPath+instPath+detStr+":qz_"+detStr) 
     593         
    509594        qTot_MR = 0 
    510595        qx_MR = 0 
     
    522607        xCtr = -(M_LR_sep/2/pixSizeX)-1          
    523608        yCtr = nPix_Y/2 
    524         V_Detector_2Q(det_MR,qTot_MR,qx_MR,qy_MR,qz_MR,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
     609        VC_Detector_2Q(det_MR,qTot_MR,qx_MR,qy_MR,qz_MR,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
    525610//      Print "xy for MR = ",xCtr,yCtr 
    526611        SetScale/I x WaveMin(qx_MR),WaveMax(qx_MR),"", det_MR           //this sets the left and right ends of the data scaling 
     
    529614 
    530615//Middle/TOP 
    531         SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
    532         WAVE qTot_MT,qx_MT,qy_MT,qz_MT 
     616//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
     617        detStr = "MT" 
     618        Wave qTot_MT = $(folderPath+instPath+detStr+":qTot_"+detStr)                    // 2D q-values 
     619        Wave qx_MT = $(folderPath+instPath+detStr+":qx_"+detStr) 
     620        Wave qy_MT = $(folderPath+instPath+detStr+":qy_"+detStr)         
     621        Wave qz_MT = $(folderPath+instPath+detStr+":qz_"+detStr) 
     622 
    533623        qTot_MT = 0 
    534624        qx_MT = 0 
     
    545635        xCtr = nPix_X/2 
    546636        yCtr = -(M_TB_sep/2/pixSizeY)-1  
    547                 // global sdd_offset is in (mm), convert to meters here for the Q-calculation   
    548         V_Detector_2Q(det_MT,qTot_MT,qx_MT,qy_MT,qz_MT,xCtr,yCtr,sdd+M_sdd_offset/1000,lam,pixSizeX,pixSizeY) 
     637        // global sdd_offset is in (mm), convert to meters here for the Q-calculation   
     638        VC_Detector_2Q(det_MT,qTot_MT,qx_MT,qy_MT,qz_MT,xCtr,yCtr,sdd+M_sdd_offset/1000,lam,pixSizeX,pixSizeY) 
    549639//      Print "xy for MT = ",xCtr,yCtr 
    550         SetScale/I x WaveMin(qx_MT),WaveMax(qx_MT),"", det_MT           //this sets the leMT and right ends of the data scaling 
     640        SetScale/I x WaveMin(qx_MT),WaveMax(qx_MT),"", det_MT           //this sets the left and right ends of the data scaling 
    551641        SetScale/I y WaveMin(qy_MT),WaveMax(qy_MT),"", det_MT 
    552642////////////////// 
    553643 
    554644//Middle/BOTTOM 
    555         SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
    556         WAVE qTot_MB,qx_MB,qy_MB,qz_MB 
     645//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
     646        detStr = "MB" 
     647        Wave qTot_MB = $(folderPath+instPath+detStr+":qTot_"+detStr)                    // 2D q-values 
     648        Wave qx_MB = $(folderPath+instPath+detStr+":qx_"+detStr) 
     649        Wave qy_MB = $(folderPath+instPath+detStr+":qy_"+detStr)         
     650        Wave qz_MB = $(folderPath+instPath+detStr+":qz_"+detStr) 
     651 
    557652        qTot_MB = 0 
    558653        qx_MB = 0 
     
    570665        yCtr = nPix_Y+(M_TB_sep/2/pixSizeY)             // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 
    571666                // global sdd_offset is in (mm), convert to meters here for the Q-calculation 
    572         V_Detector_2Q(det_MB,qTot_MB,qx_MB,qy_MB,qz_MB,xCtr,yCtr,sdd+M_sdd_offset/1000,lam,pixSizeX,pixSizeY) 
     667        VC_Detector_2Q(det_MB,qTot_MB,qx_MB,qy_MB,qz_MB,xCtr,yCtr,sdd+M_sdd_offset/1000,lam,pixSizeX,pixSizeY) 
    573668//      Print "xy for MB = ",xCtr,yCtr 
    574669        SetScale/I x WaveMin(qx_MB),WaveMax(qx_MB),"", det_MB           //this sets the left and right ends of the data scaling 
     
    582677 
    583678 
    584 Window MiddlePanels_AsQ() : Graph 
     679Function MiddlePanels_AsQ() 
    585680//      DoWindow/F MiddlePanels_AsQ 
    586681//      if(V_flag == 0) 
     
    588683//      Display /W=(1477,44,1978,517) 
    589684 
    590         SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
     685        String midStr = "root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:" 
     686//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
     687        SetDataFolder $(midStr+"detector_MB") 
     688        Wave det_MB = det_MB 
     689        SetDataFolder $(midStr+"detector_MT") 
     690        Wave det_MT = det_MT 
     691        SetDataFolder $(midStr+"detector_ML") 
     692        Wave det_ML = det_ML 
     693        SetDataFolder $(midStr+"detector_MR") 
     694        Wave det_MR = det_MR 
    591695 
    592696        CheckDisplayed /W=VCALC#Panels_Q det_MB 
     697         
    593698        if(V_flag == 0) 
    594699                AppendImage/W=VCALC#Panels_Q det_MB 
     
    643748Proc BinAllMiddlePanels() 
    644749 
    645         SetDeltaQ("Middle","ML") 
    646         SetDeltaQ("Middle","MT") 
     750        SetDeltaQ("VCALC","ML") 
     751        SetDeltaQ("VCALC","MR") 
     752        SetDeltaQ("VCALC","MT") 
     753        SetDeltaQ("VCALC","MB") 
    647754 
    648755        Variable binType         
     
    651758 
    652759        if(binType == 1) 
    653                 V_BinQxQy_to_1D("","ML") 
    654                 V_BinQxQy_to_1D("","MR") 
    655                 V_BinQxQy_to_1D("","MT") 
    656                 V_BinQxQy_to_1D("","MB") 
     760                VC_BinQxQy_to_1D("VCALC","ML") 
     761                VC_BinQxQy_to_1D("VCALC","MR") 
     762                VC_BinQxQy_to_1D("VCALC","MT") 
     763                VC_BinQxQy_to_1D("VCALC","MB") 
    657764        endif 
    658765         
    659766        if(binType == 2)         
    660                 V_BinQxQy_to_1D("","MLR") 
    661                 V_BinQxQy_to_1D("","MTB") 
     767                VC_BinQxQy_to_1D("VCALC","MLR") 
     768                VC_BinQxQy_to_1D("VCALC","MTB") 
    662769        endif 
    663770 
    664771        if(binType == 3) 
    665                 V_BinQxQy_to_1D("","MLRTB") 
     772                VC_BinQxQy_to_1D("VCALC","MLRTB") 
    666773        endif 
    667774         
     
    669776        if(binType == 4) 
    670777                /// this is for a tall, narrow slit mode         
    671                 V_fBinDetector_byRows("Middle","ML") 
    672                 V_fBinDetector_byRows("Middle","MR") 
    673                 V_fBinDetector_byRows("Middle","MT") 
    674                 V_fBinDetector_byRows("Middle","MB") 
     778                VC_fBinDetector_byRows("VCALC","ML") 
     779                VC_fBinDetector_byRows("VCALC","MR") 
     780                VC_fBinDetector_byRows("VCALC","MT") 
     781                VC_fBinDetector_byRows("VCALC","MB") 
    675782        endif 
    676783End 
     
    687794 
    688795        if(binType==1) 
    689                 ClearIQIfDisplayed("MLRTB") 
    690                 ClearIQIfDisplayed("MLR") 
    691                 ClearIQIfDisplayed("MTB") 
     796                ClearIQIfDisplayed("VCALC","MLRTB") 
     797                ClearIQIfDisplayed("VCALC","MLR") 
     798                ClearIQIfDisplayed("VCALC","MTB") 
    692799                 
    693800                SetDataFolder root:Packages:NIST:VSANS:VCALC 
     
    711818         
    712819        if(binType==2) 
    713                 ClearIQIfDisplayed("MLRTB") 
    714                 ClearIQIfDisplayed("MT")         
    715                 ClearIQIfDisplayed("ML")         
    716                 ClearIQIfDisplayed("MR")         
    717                 ClearIQIfDisplayed("MB") 
     820                ClearIQIfDisplayed("VCALC","MLRTB") 
     821                ClearIQIfDisplayed("VCALC","MT")         
     822                ClearIQIfDisplayed("VCALC","ML")         
     823                ClearIQIfDisplayed("VCALC","MR")         
     824                ClearIQIfDisplayed("VCALC","MB") 
    718825         
    719826 
     
    739846         
    740847        if(binType==3) 
    741                 ClearIQIfDisplayed("MLR") 
    742                 ClearIQIfDisplayed("MTB")        
    743                 ClearIQIfDisplayed("MT")         
    744                 ClearIQIfDisplayed("ML")         
    745                 ClearIQIfDisplayed("MR")         
    746                 ClearIQIfDisplayed("MB")         
     848                ClearIQIfDisplayed("VCALC","MLR") 
     849                ClearIQIfDisplayed("VCALC","MTB")        
     850                ClearIQIfDisplayed("VCALC","MT")         
     851                ClearIQIfDisplayed("VCALC","ML")         
     852                ClearIQIfDisplayed("VCALC","MR")         
     853                ClearIQIfDisplayed("VCALC","MB")         
    747854         
    748855                SetDataFolder root:Packages:NIST:VSANS:VCALC 
     
    765872 
    766873        if(binType==4)          // slit aperture binning - Mt, ML, MR, MB are averaged 
    767                 ClearIQIfDisplayed("MLRTB") 
    768                 ClearIQIfDisplayed("MLR") 
    769                 ClearIQIfDisplayed("MTB") 
     874                ClearIQIfDisplayed("VCALC","MLRTB") 
     875                ClearIQIfDisplayed("VCALC","MLR") 
     876                ClearIQIfDisplayed("VCALC","MTB") 
    770877                 
    771878                SetDataFolder root:Packages:NIST:VSANS:VCALC 
     
    805912        // space is allocated for all of the detectors and Q's on initialization 
    806913        // calculate Qtot, qxqyqz arrays from geometry 
    807         V_CalculateQBackPanels() 
     914        VC_CalculateQBackPanels() 
    808915         
    809916        // fill the panels with fake sphere scattering data 
    810917        // TODO: am I in the right data folder?? 
    811         SetDataFolder root:Packages:NIST:VSANS:VCALC:Back 
     918        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B 
    812919 
    813920        WAVE det_B = det_B 
     
    821928        // view of how much of the detectors are actually collecting data 
    822929        // -- I can get the separation L/R from the panel - only this "open" width is visible. 
    823 //      V_SetShadow_TopBottom("","MT")          // TODO: -- be sure the data folder is properly set (within the function...) 
    824 //      V_SetShadow_TopBottom("","MB") 
     930//      VC_SetShadow_TopBottom("","MT")         // TODO: -- be sure the data folder is properly set (within the function...) 
     931//      VC_SetShadow_TopBottom("","MB") 
    825932         
    826933        // do the q-binning for each of the panels to get I(Q) 
     
    849956//     when anything changes 
    850957// 
    851 Function V_CalculateQBackPanels() 
     958Function VC_CalculateQBackPanels() 
    852959 
    853960        Variable xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY 
    854961        Variable B_offset 
    855962 
     963        String folderPath = "root:Packages:NIST:VSANS:VCALC" 
     964        String instPath = ":entry:entry:instrument:detector_" 
     965        String detStr = "" 
     966         
    856967        B_offset = VCALC_getLateralOffset("B") 
    857968         
     
    860971 
    861972// TODO (make the N along the tube length a variable, since this can be reset @ acquisition) 
    862         SetDataFolder root:Packages:NIST:VSANS:VCALC:Back 
    863         Wave det_B                      // this is (320,320) 
     973//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Back 
     974        WAVE det_B = $(folderPath+instPath+"B"+":det_B")                        // this is nominally (320,320) 
    864975 
    865976//Back detector 
    866         WAVE qTot_B,qx_B,qy_B,qz_B 
     977//root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B:qTot_B 
     978        detStr = "B" 
     979        Wave qTot_B = $(folderPath+instPath+detStr+":qTot_"+detStr)                     // 2D q-values 
     980        Wave qx_B = $(folderPath+instPath+detStr+":qx_"+detStr) 
     981        Wave qy_B = $(folderPath+instPath+detStr+":qy_"+detStr)  
     982        Wave qz_B = $(folderPath+instPath+detStr+":qz_"+detStr) 
     983 
    867984        qTot_B = 0 
    868985        qx_B = 0 
     
    877994        xCtr = trunc( DimSize(det_B,0)/2 )              //should be 160 
    878995        yCtr = trunc( DimSize(det_B,1)/2 )              //should be 160  
    879         V_Detector_2Q(det_B,qTot_B,qx_B,qy_B,qz_B,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
     996        VC_Detector_2Q(det_B,qTot_B,qx_B,qy_B,qz_B,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
    880997         
    881998        //set the wave scaling for the detector image so that it can be plotted in q-space 
     
    8981015//      Display /W=(1477,44,1978,517) 
    8991016 
    900         SetDataFolder root:Packages:NIST:VSANS:VCALC:Back 
     1017        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B 
    9011018 
    9021019        CheckDisplayed /W=VCALC#Panels_Q det_B 
     
    9431060Proc BinAllBackPanels() 
    9441061 
    945         SetDeltaQ("Back","B") 
     1062        SetDeltaQ("VCALC","B") 
    9461063 
    9471064        Variable binType         
     
    9491066        binType = V_Value               // V_value counts menu items from 1, so 1=1, 2=2, 3=4 
    9501067         
    951         V_BinQxQy_to_1D("","B") 
     1068        VC_BinQxQy_to_1D("VCALC","B") 
    9521069 
    9531070// TODO -- this is only a temporary fix for slit mode    
    9541071        if(binType == 4) 
    9551072                /// this is for a tall, narrow slit mode         
    956                 V_fBinDetector_byRows("Back","B") 
     1073                VC_fBinDetector_byRows("VCALC","B") 
    9571074        endif    
    9581075         
     
    9621079Window Back_IQ_Graph() : Graph 
    9631080 
    964         SetDataFolder root:Packages:NIST:VSANS:VCALC 
     1081        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B 
    9651082 
    9661083        Variable binType 
     
    10221139 
    10231140        Variable binType 
     1141        String fldr = "VCALC" 
    10241142         
    10251143        ControlInfo/W=VCALC popup_b 
     
    10291147 
    10301148        if(binType==1) 
    1031                 ClearIQIfDisplayed("FLRTB") 
    1032                 ClearIQIfDisplayed("FLR") 
    1033                 ClearIQIfDisplayed("FTB") 
     1149                ClearIQIfDisplayed("VCALC","FLRTB") 
     1150                ClearIQIfDisplayed("VCALC","FLR") 
     1151                ClearIQIfDisplayed("VCALC","FTB") 
    10341152                 
    10351153                SetDataFolder root:Packages:NIST:VSANS:VCALC 
     
    10561174 
    10571175        if(binType==2) 
    1058                 ClearIQIfDisplayed("FLRTB") 
    1059                 ClearIQIfDisplayed("FT")         
    1060                 ClearIQIfDisplayed("FL")         
    1061                 ClearIQIfDisplayed("FR")         
    1062                 ClearIQIfDisplayed("FB") 
     1176                ClearIQIfDisplayed("VCALC","FLRTB") 
     1177                ClearIQIfDisplayed("VCALC","FT")         
     1178                ClearIQIfDisplayed("VCALC","FL")         
     1179                ClearIQIfDisplayed("VCALC","FR")         
     1180                ClearIQIfDisplayed("VCALC","FB") 
    10631181         
    10641182 
     
    10841202         
    10851203        if(binType==3) 
    1086                 ClearIQIfDisplayed("FLR") 
    1087                 ClearIQIfDisplayed("FTB")        
    1088                 ClearIQIfDisplayed("FT")         
    1089                 ClearIQIfDisplayed("FL")         
    1090                 ClearIQIfDisplayed("FR")         
    1091                 ClearIQIfDisplayed("FB")         
     1204                ClearIQIfDisplayed("VCALC","FLR") 
     1205                ClearIQIfDisplayed("VCALC","FTB")        
     1206                ClearIQIfDisplayed("VCALC","FT")         
     1207                ClearIQIfDisplayed("VCALC","FL")         
     1208                ClearIQIfDisplayed("VCALC","FR")         
     1209                ClearIQIfDisplayed("VCALC","FB")         
    10921210         
    10931211                SetDataFolder root:Packages:NIST:VSANS:VCALC 
     
    11111229 
    11121230        if(binType==4)          //slit mode 
    1113                 ClearIQIfDisplayed("FLRTB") 
    1114                 ClearIQIfDisplayed("FLR") 
    1115                 ClearIQIfDisplayed("FTB") 
     1231                ClearIQIfDisplayed("VCALC","FLRTB") 
     1232                ClearIQIfDisplayed("VCALC","FLR") 
     1233                ClearIQIfDisplayed("VCALC","FTB") 
    11161234                 
    11171235                SetDataFolder root:Packages:NIST:VSANS:VCALC 
     
    11421260EndMacro 
    11431261 
    1144 Function        ClearIQIfDisplayed(type) 
    1145         String type 
    1146          
    1147         SetDataFolder root:Packages:NIST:VSANS:VCALC 
    1148         CheckDisplayed/W=VCALC#Panels_IQ $("iBin_qxqy_"+type) 
    1149         if(V_flag==1) 
    1150                 RemoveFromGraph/W=VCALC#Panels_IQ $("iBin_qxqy_"+type) 
    1151         endif 
     1262 
     1263Function ClearIQIfDisplayed(fldr,type) 
     1264        String fldr,type 
     1265 
     1266        SetDataFolder $("root:Packages:NIST:VSANS:"+fldr) 
     1267 
     1268        if(cmpstr(fldr,"VCALC") == 0) 
     1269                CheckDisplayed/W=VCALC#Panels_IQ $("iBin_qxqy_"+type) 
     1270                if(V_flag==1) 
     1271                        RemoveFromGraph/W=VCALC#Panels_IQ $("iBin_qxqy_"+type) 
     1272                endif 
     1273        else 
     1274                CheckDisplayed/W=V_1D_Data $("iBin_qxqy_"+type) 
     1275                if(V_flag==1) 
     1276                        RemoveFromGraph/W=V_1D_Data $("iBin_qxqy_"+type) 
     1277                endif 
     1278        endif 
     1279 
    11521280        SetDataFolder root: 
    11531281         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Slit.ipf

    r955 r982  
    2828// LR banks are defined as (48,256) (n,m), sumRows gives sum w/ dimension (n x 1) 
    2929// 
    30 Function V_fBinDetector_byRows(folderStr,type) 
    31         String folderStr,type 
     30// updated to new folder structure Feb 2016 
     31// folderStr = RAW,SAM, VCALC or other 
     32// detStr is the panel identifer "ML", etc. 
     33Function VC_fBinDetector_byRows(folderStr,detStr) 
     34        String folderStr,detStr 
    3235         
    33         SetDataFolder root:Packages:NIST:VSANS:VCALC     
     36//      SetDataFolder root:Packages:NIST:VSANS:VCALC     
    3437         
    3538        Variable pixSizeX,pixSizeY,delQx, delQy 
     39        Variable isVCALC=0 
     40         
     41        if(cmpstr(folderStr,"VCALC") == 0) 
     42                isVCALC = 1 
     43        endif 
    3644 
    37         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":det_"+type)                // 2D detector data 
    38         WAVE/Z iErr = $("iErr_"+type)                   // 2D errors -- may not exist, especially for simulation 
    39         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":qTot_"+type)                      // 2D q-values 
    40         Wave qx = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":qx_"+type) 
    41         Wave qy = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":qy_"+type) 
     45        String folderPath = "root:Packages:NIST:VSANS:"+folderStr 
     46        String instPath = ":entry:entry:instrument:detector_"    
    4247         
    43         pixSizeX = VCALC_getPixSizeX(type) 
    44         pixSizeY = VCALC_getPixSizeY(type) 
     48        if(isVCALC) 
     49                WAVE inten = $(folderPath+instPath+detStr+":det_"+detStr)               // 2D detector data 
     50                WAVE/Z iErr = $("asdf_iErr_"+detStr)                    // TODO: 2D errors -- may not exist, especially for simulation 
     51        else 
     52                Wave inten = V_getDetectorDataW(folderStr,detStr) 
     53                Wave iErr = V_getDetectorDataErrW(folderStr,detStr) 
     54        endif 
     55 
     56        Wave qTotal = $(folderPath+instPath+detStr+":qTot_"+detStr)                     // 2D q-values 
     57        Wave qx = $(folderPath+instPath+detStr+":qx_"+detStr) 
     58        Wave qy = $(folderPath+instPath+detStr+":qy_"+detStr) 
     59 
     60// ?? TODO not needed here?      
     61//      pixSizeX = VCALC_getPixSizeX(detStr) 
     62//      pixSizeY = VCALC_getPixSizeY(detStr) 
    4563         
    4664        delQx = abs(qx[0][0] - qx[1][0]) 
     
    5270        nq = DimSize(inten,0)           //nq == the number of columns (x dimension) 
    5371         
    54         SetDataFolder root:Packages:NIST:VSANS:VCALC     
     72//      SetDataFolder $(folderPath+instPath+detStr)      
    5573 
    56         Make/O/D/N=(nq)  $("iBin_qxqy_"+type) 
    57         Make/O/D/N=(nq)  $("qBin_qxqy_"+type) 
    58         Make/O/D/N=(nq)  $("nBin_qxqy_"+type) 
    59         Make/O/D/N=(nq)  $("iBin2_qxqy_"+type) 
    60         Make/O/D/N=(nq)  $("eBin_qxqy_"+type) 
    61         Make/O/D/N=(nq)  $("eBin2D_qxqy_"+type) 
     74        Make/O/D/N=(nq)  $(folderPath+":"+"iBin_qxqy_"+detStr) 
     75        Make/O/D/N=(nq)  $(folderPath+":"+"qBin_qxqy_"+detStr) 
     76        Make/O/D/N=(nq)  $(folderPath+":"+"nBin_qxqy_"+detStr) 
     77        Make/O/D/N=(nq)  $(folderPath+":"+"iBin2_qxqy_"+detStr) 
     78        Make/O/D/N=(nq)  $(folderPath+":"+"eBin_qxqy_"+detStr) 
     79        Make/O/D/N=(nq)  $(folderPath+":"+"eBin2D_qxqy_"+detStr) 
    6280         
    63         Wave iBin_qxqy = $("iBin_qxqy_"+type) 
    64         Wave qBin_qxqy = $("qBin_qxqy_"+type) 
    65         Wave nBin_qxqy = $("nBin_qxqy_"+type) 
    66         Wave iBin2_qxqy = $("iBin2_qxqy_"+type) 
    67         Wave eBin_qxqy = $("eBin_qxqy_"+type) 
    68         Wave eBin2D_qxqy = $("eBin2D_qxqy_"+type) 
     81        Wave iBin_qxqy = $(folderPath+":"+"iBin_qxqy_"+detStr) 
     82        Wave qBin_qxqy = $(folderPath+":"+"qBin_qxqy_"+detStr) 
     83        Wave nBin_qxqy = $(folderPath+":"+"nBin_qxqy_"+detStr) 
     84        Wave iBin2_qxqy = $(folderPath+":"+"iBin2_qxqy_"+detStr) 
     85        Wave eBin_qxqy = $(folderPath+":"+"eBin_qxqy_"+detStr) 
     86        Wave eBin2D_qxqy = $(folderPath+":"+"eBin2D_qxqy_"+detStr) 
    6987 
    7088// sum the rows  
     
    96114 
    97115 
     116// TODO -- update to new folder structure 
     117// unused -- update if necessary 
    98118Proc CopyIQWaves() 
    99119 
     
    124144End 
    125145 
     146// TODO -- update to new folder structure 
     147// unused -- update if necessary 
    126148Window slit_vs_pin_graph() : Graph 
    127149        PauseUpdate; Silent 1           // building window... 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Utils.ipf

    r955 r982  
    1515// TODO: hard wired for a sphere - change this to allow minimal selections and altering of coefficients 
    1616// TODO: add the "fake" 2D simulation to fill the panels which are then later averaged as I(Q) 
     17// 
     18// NOTE - this is a VCALC only routine, so it's not been made completely generic 
     19// 
    1720Function FillPanel_wModelData(det,qTot,type) 
    1821        Wave det,qTot 
    1922        String type 
    2023 
    21         SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
     24//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
    2225 
    2326        // q-values and detector arrays already allocated and calculated 
     
    2629        Variable imon,trans,thick,sdd,pixSizeX,pixSizeY,sdd_offset 
    2730 
    28         //imon = V_BeamIntensity()*CountTime 
     31        //imon = VC_BeamIntensity()*CountTime 
    2932        imon = VCALC_getImon()          //TODO: currently from the panel, not calculated 
    3033        trans = 0.8 
     
    5053        strswitch(funcStr) 
    5154                case "Big Debye": 
    52                         tmpInten = V_Debye(10,3000,0.0001,qTot[p][q]) 
     55                        tmpInten = VC_Debye(10,3000,0.0001,qTot[p][q]) 
    5356                        break 
    5457                case "Big Sphere": 
    55                         tmpInten = V_SphereForm(1,900,1e-6,0.01,qTot[p][q])      
     58                        tmpInten = VC_SphereForm(1,900,1e-6,0.01,qTot[p][q])     
    5659                        break 
    5760                case "Debye": 
    58                         tmpInten = V_Debye(10,300,0.0001,qTot[p][q]) 
     61                        tmpInten = VC_Debye(10,300,0.0001,qTot[p][q]) 
    5962                        break 
    6063                case "Sphere": 
    61                         tmpInten = V_SphereForm(1,60,1e-6,0.001,qTot[p][q])      
     64                        tmpInten = VC_SphereForm(1,60,1e-6,0.001,qTot[p][q])     
    6265                        break 
    6366                case "AgBeh": 
    64                         tmpInten = V_BroadPeak(1e-9,3,20,100.0,0.1,3,0.1,qTot[p][q]) 
     67                        tmpInten = VC_BroadPeak(1e-9,3,20,100.0,0.1,3,0.1,qTot[p][q]) 
    6568                        break 
    6669                case "Vycor": 
    67                         tmpInten = V_BroadPeak(1e-9,3,20,500.0,0.015,3,0.1,qTot[p][q]) 
     70                        tmpInten = VC_BroadPeak(1e-9,3,20,500.0,0.015,3,0.1,qTot[p][q]) 
    6871                        break    
    6972                case "Empty Cell": 
    70                         tmpInten = V_EC_Empirical(2.2e-8,3.346,0.0065,9.0,0.016,qTot[p][q]) 
     73                        tmpInten = VC_EC_Empirical(2.2e-8,3.346,0.0065,9.0,0.016,qTot[p][q]) 
    7174                        break 
    7275                case "Blocked Beam": 
    73                         tmpInten = V_BlockedBeam(1,qTot[p][q]) 
     76                        tmpInten = VC_BlockedBeam(1,qTot[p][q]) 
    7477                        break 
    7578                default: 
    76                         tmpInten = V_Debye(10,300,0.1,qTot[p][q]) 
     79                        tmpInten = VC_Debye(10,300,0.1,qTot[p][q]) 
    7780        endswitch 
    7881 
     
    154157// -- sdd in meters 
    155158// -- lambda in Angstroms 
    156 Function V_Detector_2Q(data,qTot,qx,qy,qz,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
     159Function VC_Detector_2Q(data,qTot,qx,qy,qz,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
    157160        Wave data,qTot,qx,qy,qz 
    158161        Variable xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY 
     
    160163        // loop over the array and calculate the values - this is done as a wave assignment 
    161164// TODO -- be sure that it's p,q -- or maybe p+1,q+1 as used in WriteQIS.ipf     
    162         qTot = V_CalcQval(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    163         qx = V_CalcQX(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    164         qy = V_CalcQY(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    165         qz = V_CalcQZ(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     165        qTot = VC_CalcQval(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     166        qx = VC_CalcQX(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     167        qy = VC_CalcQY(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     168        qz = VC_CalcQZ(p,q,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    166169         
    167170        return(0) 
     
    183186//returned magnitude of Q is in 1/Angstroms 
    184187// 
    185 Function V_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     188Function VC_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    186189        Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY 
    187190         
     
    210213// now properly accounts for qz 
    211214// 
    212 Function V_CalcQX(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     215Function VC_CalcQX(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    213216        Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY 
    214217 
    215218        Variable qx,qval,phi,dx,dy,dist,two_theta 
    216219         
    217         qval = V_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     220        qval = VC_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    218221         
    219222        sdd *=100               //convert to cm 
     
    240243// now properly accounts for qz 
    241244// 
    242 Function V_CalcQY(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     245Function VC_CalcQY(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    243246        Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY 
    244247         
    245248        Variable dy,qval,dx,phi,qy,dist,two_theta 
    246249         
    247         qval = V_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     250        qval = VC_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    248251         
    249252        sdd *=100               //convert to cm 
     
    269272// not actually used, but here for completeness if anyone asks 
    270273// 
    271 Function V_CalcQZ(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     274Function VC_CalcQZ(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    272275        Variable xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY 
    273276         
    274277        Variable dy,qval,dx,phi,qz,dist,two_theta 
    275278         
    276         qval = V_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     279        qval = VC_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    277280         
    278281        sdd *=100               //convert to cm 
     
    328331end 
    329332 
    330 Function V_SphereForm(scale,radius,delrho,bkg,x)                                 
     333Function VC_SphereForm(scale,radius,delrho,bkg,x)                                
    331334        Variable scale,radius,delrho,bkg 
    332335        Variable x 
     
    369372End 
    370373 
    371 Function V_Debye(scale,rg,bkg,x) 
     374Function VC_Debye(scale,rg,bkg,x) 
    372375        Variable scale,rg,bkg 
    373376        Variable x 
     
    394397//      make/O/D coef_ECEmp = {2.2e-8,3.346,0.0065,9.0,0.016} 
    395398// 
    396 Function V_EC_Empirical(aa,mm,scale,rg,bkg,x) 
     399Function VC_EC_Empirical(aa,mm,scale,rg,bkg,x) 
    397400        Variable aa,mm,scale,rg,bkg 
    398401        Variable x 
     
    427430// blocked beam 
    428431// 
    429 Function V_BlockedBeam(bkg,x) 
     432Function VC_BlockedBeam(bkg,x) 
    430433        Variable bkg 
    431434        Variable x 
     
    446449// 
    447450// 
    448 Function V_BroadPeak(aa,nn,cc,LL,Qzero,mm,bgd,x) 
     451Function VC_BroadPeak(aa,nn,cc,LL,Qzero,mm,bgd,x) 
    449452        Variable aa,nn,cc,LL,Qzero,mm,bgd 
    450453        Variable x 
     
    471474End 
    472475 
    473  
    474  
    475 Function SetDeltaQ(folderStr,type) 
    476         String folderStr,type 
    477  
    478         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + folderStr + ":det_"+type)            // 2D detector data 
     476// 
     477// updated to new folder structure Feb 2016 
     478// folderStr = RAW,SAM, VCALC or other 
     479// detStr is the panel identifer "ML", etc. 
     480// 
     481Function SetDeltaQ(folderStr,detStr) 
     482        String folderStr,detStr 
     483 
     484        Variable isVCALC 
     485        if(cmpstr(folderStr,"VCALC") == 0) 
     486                isVCALC = 1 
     487        endif 
     488         
     489        String folderPath = "root:Packages:NIST:VSANS:"+folderStr 
     490        String instPath = ":entry:entry:instrument:detector_" 
     491                 
     492        if(isVCALC) 
     493                WAVE inten = $(folderPath+instPath+detStr+":det_"+detStr)               // 2D detector data 
     494        else 
     495                Wave inten = V_getDetectorDataW(folderStr,detStr) 
     496        endif 
     497 
     498        Wave qx = $(folderPath+instPath+detStr+":qx_"+detStr) 
     499        Wave qy = $(folderPath+instPath+detStr+":qy_"+detStr) 
    479500         
    480501        Variable xDim,yDim,delQ 
     
    484505         
    485506        if(xDim<yDim) 
    486                 WAVE qx = $("root:Packages:NIST:VSANS:VCALC:" + folderStr + ":qx_"+type) 
    487507                delQ = abs(qx[0][0] - qx[1][0])/2 
    488508        else 
    489                 WAVE qy = $("root:Packages:NIST:VSANS:VCALC:" + folderStr + ":qy_"+type) 
    490509                delQ = abs(qy[0][1] - qy[0][0])/2 
    491510        endif 
    492511         
    493512        // set the global 
    494         Variable/G $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_"+type) = delQ 
     513        Variable/G $(folderPath+instPath+detStr+":gDelQ_"+detStr) = delQ 
    495514//      Print "SET delQ = ",delQ," for ",type 
    496515         
    497         return(0) 
     516        return(delQ) 
    498517end 
    499518 
    500519 
    501520//TODO -- need a switch here to dispatch to the averaging type 
    502 Proc V_BinQxQy_to_1D(folderStr,type) 
     521Proc VC_BinQxQy_to_1D(folderStr,type) 
    503522        String folderStr 
    504523        String type 
     
    507526 
    508527 
    509         V_fDoBinning_QxQy2D(folderStr, type) 
     528        VC_fDoBinning_QxQy2D(folderStr, type) 
    510529 
    511530 
    512531/// this is for a tall, narrow slit mode         
    513 //      V_fBinDetector_byRows(folderStr,type) 
    514          
    515 End 
    516  
    517  
    518 Proc V_Graph_1D_detType(folderStr,type) 
     532//      VC_fBinDetector_byRows(folderStr,type) 
     533         
     534End 
     535 
     536 
     537// folderStr is RAW, VCALC, SAM, etc. 
     538// type is "B", "FL" for single binning, "FLR", or "MLRTB" or similar if multiple panels are combined 
     539// 
     540Proc VC_Graph_1D_detType(folderStr,type) 
    519541        String folderStr,type 
    520542         
    521         SetDataFolder root:Packages:NIST:VSANS:VCALC 
     543        SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
    522544         
    523545        Display $("iBin_qxqy"+"_"+type) vs $("qBin_qxqy"+"_"+type) 
     
    551573// TODO "iErr" is not always defined correctly since it doesn't really apply here for data that is not 2D simulation 
    552574// 
    553 Function V_fDoBinning_QxQy2D(folderStr,type) 
     575// 
     576// updated Feb2016 to take new folder structure 
     577// TODO 
     578// -- VERIFY 
     579// -- figure out what the best location is to put the averaged data? currently @ top level of WORK folder 
     580//    but this is a lousy choice. 
     581// 
     582Function VC_fDoBinning_QxQy2D(folderStr,type) 
    554583        String folderStr,type 
    555584         
     
    558587        Variable ii,jj 
    559588        Variable qVal,nq,var,avesq,aveisq 
    560         Variable binIndex,val 
    561  
    562          
    563         SetDataFolder root:Packages:NIST:VSANS:VCALC 
     589        Variable binIndex,val,isVCALC=0 
     590 
     591        String folderPath = "root:Packages:NIST:VSANS:"+folderStr 
     592        String instPath = ":entry:entry:instrument:detector_" 
     593        String detStr 
     594                 
     595        if(cmpstr(folderStr,"VCALC") == 0) 
     596                isVCALC = 1 
     597        endif 
    564598         
    565599// now switch on the type to determine which waves to declare and create 
     
    570604                case "FL":              // execute if case matches expression 
    571605                case "FR": 
    572                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_FL") 
    573                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+type)              // 2D detector data 
    574                         WAVE/Z iErr = $("iErr_"+type)                   // 2D errors -- may not exist, especially for simulation 
    575                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+type)                     // 2D q-values 
     606                        detStr = type 
     607                        if(isVCALC) 
     608                                WAVE inten = $(folderPath+instPath+detStr+":det_"+detStr) 
     609                                WAVE/Z iErr = $("iErr_"+detStr)                 // 2D errors -- may not exist, especially for simulation 
     610                        else 
     611                                Wave inten = V_getDetectorDataW(folderStr,detStr) 
     612                                Wave iErr = V_getDetectorDataErrW(folderStr,detStr) 
     613                        endif 
     614                        NVAR delQ = $(folderPath+instPath+detStr+":gDelQ_"+detStr) 
     615                        Wave qTotal = $(folderPath+instPath+detStr+":qTot_"+detStr)                     // 2D q-values 
    576616                        nSets = 1 
    577617                        break    
     
    579619                case "FT":               
    580620                case "FB": 
    581                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_FT") 
    582                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+type)              // 2D detector data 
    583                         WAVE/Z iErr = $("iErr_"+type)                   // 2D errors -- may not exist, especially for simulation 
    584                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+type)                     // 2D q-values 
     621                        detStr = type 
     622                        if(isVCALC) 
     623                                WAVE inten = $(folderPath+instPath+detStr+":det_"+detStr) 
     624                                WAVE/Z iErr = $("iErr_"+detStr)                 // 2D errors -- may not exist, especially for simulation                 
     625                        else 
     626                                Wave inten = V_getDetectorDataW(folderStr,detStr) 
     627                                Wave iErr = V_getDetectorDataErrW(folderStr,detStr) 
     628                        endif 
     629                        NVAR delQ = $(folderPath+instPath+detStr+":gDelQ_"+detStr) 
     630                        Wave qTotal = $(folderPath+instPath+detStr+":qTot_"+detStr)                     // 2D q-values 
    585631                        nSets = 1 
    586632                        break 
    587633                         
    588634                case "ML":               
    589                 case "MR":               
    590                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_ML") 
    591                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+type)             // 2D detector data 
    592                         WAVE/Z iErr = $("iErr_"+type)                   // 2D errors -- may not exist, especially for simulation 
    593                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+type)                    // 2D q-values 
     635                case "MR": 
     636                        detStr = type 
     637                        if(isVCALC) 
     638                                WAVE inten = $(folderPath+instPath+detStr+":det_"+detStr) 
     639                                WAVE/Z iErr = $("iErr_"+detStr)                 // 2D errors -- may not exist, especially for simulation                 
     640                        else 
     641                                Wave inten = V_getDetectorDataW(folderStr,detStr) 
     642                                Wave iErr = V_getDetectorDataErrW(folderStr,detStr) 
     643                        endif    
     644                        //TODO: 
     645                        // -- decide on the proper deltaQ for binning. either nominal value for LR, or one  
     646                        //    determined specifically for that panel (currently using one tube width as deltaQ) 
     647                        // -- this is repeated multiple times in this switch 
     648                        NVAR delQ = $(folderPath+instPath+detStr+":gDelQ_"+detStr) 
     649//                      NVAR delQ = $(folderPath+instPath+"ML"+":gDelQ_ML") 
     650                        Wave qTotal = $(folderPath+instPath+detStr+":qTot_"+detStr)                     // 2D q-values 
    594651                        nSets = 1 
    595652                        break    
    596653                                         
    597654                case "MT":               
    598                 case "MB":               
    599                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_MT") 
    600                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+type)             // 2D detector data 
    601                         WAVE/Z iErr = $("iErr_"+type)                   // 2D errors -- may not exist, especially for simulation 
    602                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+type)                    // 2D q-values 
     655                case "MB": 
     656                        detStr = type 
     657                        if(isVCALC) 
     658                                WAVE inten = $(folderPath+instPath+detStr+":det_"+detStr) 
     659                                WAVE/Z iErr = $("iErr_"+detStr)                 // 2D errors -- may not exist, especially for simulation                 
     660                        else 
     661                                Wave inten = V_getDetectorDataW(folderStr,detStr) 
     662                                Wave iErr = V_getDetectorDataErrW(folderStr,detStr) 
     663                        endif    
     664                        NVAR delQ = $(folderPath+instPath+detStr+":gDelQ_"+detStr) 
     665                        Wave qTotal = $(folderPath+instPath+detStr+":qTot_"+detStr)                     // 2D q-values 
    603666                        nSets = 1 
    604667                        break    
    605668                                         
    606                 case "B":                
    607                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_B") 
    608                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Back" + ":det_"+type)               // 2D detector data 
    609                         WAVE/Z iErr = $("iErr_"+type)                   // 2D errors -- may not exist, especially for simulation 
    610                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Back" +":qTot_"+type)                      // 2D q-values 
     669                case "B":        
     670                        detStr = type 
     671                        if(isVCALC) 
     672                                WAVE inten = $(folderPath+instPath+detStr+":det_"+detStr) 
     673                                WAVE/Z iErr = $("iErr_"+detStr)                 // 2D errors -- may not exist, especially for simulation                 
     674                        else 
     675                                Wave inten = V_getDetectorDataW(folderStr,detStr) 
     676                                Wave iErr = V_getDetectorDataErrW(folderStr,detStr) 
     677                        endif    
     678                        NVAR delQ = $(folderPath+instPath+detStr+":gDelQ_B") 
     679                        Wave qTotal = $(folderPath+instPath+detStr+":qTot_"+detStr)                     // 2D q-values   
    611680                        nSets = 1 
    612681                        break    
    613682                         
    614683                case "FLR": 
    615                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_FL") 
    616                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+"FL")              // 2D detector data 
    617                         WAVE/Z iErr = $("iErr_"+"FL")                   // 2D errors -- may not exist, especially for simulation 
    618                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+"FL")                     // 2D q-values 
    619                         WAVE inten2 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+"FR")             // 2D detector data 
    620                         WAVE/Z iErr2 = $("iErr_"+"FR")                  // 2D errors -- may not exist, especially for simulation 
    621                         Wave qTotal2 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+"FR")                    // 2D q-values 
     684                // detStr has multiple values now, so unfortuntely, I'm hard-wiring things... 
     685                // TODO 
     686                // -- see if I can un-hard-wire some of this below when more than one panel is combined 
     687                        if(isVCALC) 
     688                                WAVE inten = $(folderPath+instPath+"FL"+":det_"+"FL") 
     689                                WAVE/Z iErr = $("iErr_"+"FL")                   // 2D errors -- may not exist, especially for simulation                 
     690                                WAVE inten2 = $(folderPath+instPath+"FR"+":det_"+"FR") 
     691                                WAVE/Z iErr2 = $("iErr_"+"FR")                  // 2D errors -- may not exist, especially for simulation         
     692                        else 
     693                                Wave inten = V_getDetectorDataW(folderStr,"FL") 
     694                                Wave iErr = V_getDetectorDataErrW(folderStr,"FL") 
     695                                Wave inten2 = V_getDetectorDataW(folderStr,"FR") 
     696                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"FR") 
     697                        endif    
     698                        NVAR delQ = $(folderPath+instPath+"FL"+":gDelQ_FL") 
     699                         
     700                        Wave qTotal = $(folderPath+instPath+"FL"+":qTot_"+"FL")                 // 2D q-values   
     701                        Wave qTotal2 = $(folderPath+instPath+"FR"+":qTot_"+"FR")                        // 2D q-values   
     702                 
    622703                        nSets = 2 
    623704                        break                    
    624705                 
    625706                case "FTB": 
    626                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_FT") 
    627                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+"FT")              // 2D detector data 
    628                         WAVE/Z iErr = $("iErr_"+"FT")                   // 2D errors -- may not exist, especially for simulation 
    629                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+"FT")                     // 2D q-values 
    630                         WAVE inten2 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+"FB")             // 2D detector data 
    631                         WAVE/Z iErr2 = $("iErr_"+"FB")                  // 2D errors -- may not exist, especially for simulation 
    632                         Wave qTotal2 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+"FB")                    // 2D q-values 
     707                        if(isVCALC) 
     708                                WAVE inten = $(folderPath+instPath+"FT"+":det_"+"FT") 
     709                                WAVE/Z iErr = $("iErr_"+"FT")                   // 2D errors -- may not exist, especially for simulation                 
     710                                WAVE inten2 = $(folderPath+instPath+"FB"+":det_"+"FB") 
     711                                WAVE/Z iErr2 = $("iErr_"+"FB")                  // 2D errors -- may not exist, especially for simulation         
     712                        else 
     713                                Wave inten = V_getDetectorDataW(folderStr,"FT") 
     714                                Wave iErr = V_getDetectorDataErrW(folderStr,"FT") 
     715                                Wave inten2 = V_getDetectorDataW(folderStr,"FB") 
     716                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"FB") 
     717                        endif    
     718                        NVAR delQ = $(folderPath+instPath+"FT"+":gDelQ_FT") 
     719                         
     720                        Wave qTotal = $(folderPath+instPath+"FT"+":qTot_"+"FT")                 // 2D q-values   
     721                        Wave qTotal2 = $(folderPath+instPath+"FB"+":qTot_"+"FB")                        // 2D q-values   
     722         
    633723                        nSets = 2 
    634724                        break            
    635725                 
    636726                case "FLRTB": 
    637                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_FL") 
    638                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+"FL")              // 2D detector data 
    639                         WAVE/Z iErr = $("iErr_"+"FL")                   // 2D errors -- may not exist, especially for simulation 
    640                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+"FL")                     // 2D q-values 
    641                         WAVE inten2 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+"FR")             // 2D detector data 
    642                         WAVE/Z iErr2 = $("iErr_"+"FR")                  // 2D errors -- may not exist, especially for simulation 
    643                         Wave qTotal2 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+"FR")                    // 2D q-values 
    644                         WAVE inten3 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+"FT")             // 2D detector data 
    645                         WAVE/Z iErr3 = $("iErr_"+"FT")                  // 2D errors -- may not exist, especially for simulation 
    646                         Wave qTotal3 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+"FT")                    // 2D q-values 
    647                         WAVE inten4 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" + ":det_"+"FB")             // 2D detector data 
    648                         WAVE/Z iErr4 = $("iErr_"+"FB")                  // 2D errors -- may not exist, especially for simulation 
    649                         Wave qTotal4 = $("root:Packages:NIST:VSANS:VCALC:" + "Front" +":qTot_"+"FB")                    // 2D q-values 
     727                        if(isVCALC) 
     728                                WAVE inten = $(folderPath+instPath+"FL"+":det_"+"FL") 
     729                                WAVE/Z iErr = $("iErr_"+"FL")                   // 2D errors -- may not exist, especially for simulation                 
     730                                WAVE inten2 = $(folderPath+instPath+"FR"+":det_"+"FR") 
     731                                WAVE/Z iErr2 = $("iErr_"+"FR")                  // 2D errors -- may not exist, especially for simulation         
     732                                WAVE inten3 = $(folderPath+instPath+"FT"+":det_"+"FT") 
     733                                WAVE/Z iErr3 = $("iErr_"+"FT")                  // 2D errors -- may not exist, especially for simulation                 
     734                                WAVE inten4 = $(folderPath+instPath+"FB"+":det_"+"FB") 
     735                                WAVE/Z iErr4 = $("iErr_"+"FB")                  // 2D errors -- may not exist, especially for simulation         
     736                        else 
     737                                Wave inten = V_getDetectorDataW(folderStr,"FL") 
     738                                Wave iErr = V_getDetectorDataErrW(folderStr,"FL") 
     739                                Wave inten2 = V_getDetectorDataW(folderStr,"FR") 
     740                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"FR") 
     741                                Wave inten3 = V_getDetectorDataW(folderStr,"FT") 
     742                                Wave iErr3 = V_getDetectorDataErrW(folderStr,"FT") 
     743                                Wave inten4 = V_getDetectorDataW(folderStr,"FB") 
     744                                Wave iErr4 = V_getDetectorDataErrW(folderStr,"FB") 
     745                        endif    
     746                        NVAR delQ = $(folderPath+instPath+"FL"+":gDelQ_FL") 
     747                         
     748                        Wave qTotal = $(folderPath+instPath+"FL"+":qTot_"+"FL")                 // 2D q-values   
     749                        Wave qTotal2 = $(folderPath+instPath+"FR"+":qTot_"+"FR")                        // 2D q-values   
     750                        Wave qTotal3 = $(folderPath+instPath+"FT"+":qTot_"+"FT")                        // 2D q-values   
     751                        Wave qTotal4 = $(folderPath+instPath+"FB"+":qTot_"+"FB")                        // 2D q-values   
     752                 
    650753                        nSets = 4 
    651754                        break            
    652755                         
    653  
    654756                case "MLR": 
    655                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_ML") 
    656                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+"ML")             // 2D detector data 
    657                         WAVE/Z iErr = $("iErr_"+"ML")                   // 2D errors -- may not exist, especially for simulation 
    658                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+"ML")                    // 2D q-values 
    659                         WAVE inten2 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+"MR")            // 2D detector data 
    660                         WAVE/Z iErr2 = $("iErr_"+"MR")                  // 2D errors -- may not exist, especially for simulation 
    661                         Wave qTotal2 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+"MR")                   // 2D q-values 
     757                        if(isVCALC) 
     758                                WAVE inten = $(folderPath+instPath+"ML"+":det_"+"ML") 
     759                                WAVE/Z iErr = $("iErr_"+"ML")                   // 2D errors -- may not exist, especially for simulation                 
     760                                WAVE inten2 = $(folderPath+instPath+"MR"+":det_"+"MR") 
     761                                WAVE/Z iErr2 = $("iErr_"+"MR")                  // 2D errors -- may not exist, especially for simulation         
     762                        else 
     763                                Wave inten = V_getDetectorDataW(folderStr,"ML") 
     764                                Wave iErr = V_getDetectorDataErrW(folderStr,"ML") 
     765                                Wave inten2 = V_getDetectorDataW(folderStr,"MR") 
     766                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"MR") 
     767                        endif    
     768                        NVAR delQ = $(folderPath+instPath+"ML"+":gDelQ_ML") 
     769                         
     770                        Wave qTotal = $(folderPath+instPath+"ML"+":qTot_"+"ML")                 // 2D q-values   
     771                        Wave qTotal2 = $(folderPath+instPath+"MR"+":qTot_"+"MR")                        // 2D q-values   
     772                 
    662773                        nSets = 2 
    663774                        break                    
    664775                 
    665776                case "MTB": 
    666                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_MT") 
    667                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+"MT")             // 2D detector data 
    668                         WAVE/Z iErr = $("iErr_"+"MT")                   // 2D errors -- may not exist, especially for simulation 
    669                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+"MT")                    // 2D q-values 
    670                         WAVE inten2 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+"MB")            // 2D detector data 
    671                         WAVE/Z iErr2 = $("iErr_"+"MB")                  // 2D errors -- may not exist, especially for simulation 
    672                         Wave qTotal2 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+"MB")                   // 2D q-values 
     777                        if(isVCALC) 
     778                                WAVE inten = $(folderPath+instPath+"MT"+":det_"+"MT") 
     779                                WAVE/Z iErr = $("iErr_"+"MT")                   // 2D errors -- may not exist, especially for simulation                 
     780                                WAVE inten2 = $(folderPath+instPath+"MB"+":det_"+"MB") 
     781                                WAVE/Z iErr2 = $("iErr_"+"MB")                  // 2D errors -- may not exist, especially for simulation         
     782                        else 
     783                                Wave inten = V_getDetectorDataW(folderStr,"MT") 
     784                                Wave iErr = V_getDetectorDataErrW(folderStr,"MT") 
     785                                Wave inten2 = V_getDetectorDataW(folderStr,"MB") 
     786                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"MB") 
     787                        endif    
     788                        NVAR delQ = $(folderPath+instPath+"MT"+":gDelQ_MT") 
     789                         
     790                        Wave qTotal = $(folderPath+instPath+"MT"+":qTot_"+"MT")                 // 2D q-values   
     791                        Wave qTotal2 = $(folderPath+instPath+"MB"+":qTot_"+"MB")                        // 2D q-values   
     792                 
    673793                        nSets = 2 
    674794                        break                            
    675795                 
    676796                case "MLRTB": 
    677                         NVAR delQ = $("root:Packages:NIST:VSANS:VCALC:" + "gDelQ_ML") 
    678                         WAVE inten = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+"ML")             // 2D detector data 
    679                         WAVE/Z iErr = $("iErr_"+"ML")                   // 2D errors -- may not exist, especially for simulation 
    680                         Wave qTotal = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+"ML")                    // 2D q-values 
    681                         WAVE inten2 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+"MR")            // 2D detector data 
    682                         WAVE/Z iErr2 = $("iErr_"+"MR")                  // 2D errors -- may not exist, especially for simulation 
    683                         Wave qTotal2 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+"MR")                   // 2D q-values 
    684                         WAVE inten3 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+"MT")            // 2D detector data 
    685                         WAVE/Z iErr3 = $("iErr_"+"MT")                  // 2D errors -- may not exist, especially for simulation 
    686                         Wave qTotal3 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+"MT")                   // 2D q-values 
    687                         WAVE inten4 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" + ":det_"+"MB")            // 2D detector data 
    688                         WAVE/Z iErr4 = $("iErr_"+"MB")                  // 2D errors -- may not exist, especially for simulation 
    689                         Wave qTotal4 = $("root:Packages:NIST:VSANS:VCALC:" + "Middle" +":qTot_"+"MB")                   // 2D q-values 
     797                        if(isVCALC) 
     798                                WAVE inten = $(folderPath+instPath+"ML"+":det_"+"ML") 
     799                                WAVE/Z iErr = $("iErr_"+"ML")                   // 2D errors -- may not exist, especially for simulation                 
     800                                WAVE inten2 = $(folderPath+instPath+"MR"+":det_"+"MR") 
     801                                WAVE/Z iErr2 = $("iErr_"+"MR")                  // 2D errors -- may not exist, especially for simulation         
     802                                WAVE inten3 = $(folderPath+instPath+"MT"+":det_"+"MT") 
     803                                WAVE/Z iErr3 = $("iErr_"+"MT")                  // 2D errors -- may not exist, especially for simulation                 
     804                                WAVE inten4 = $(folderPath+instPath+"MB"+":det_"+"MB") 
     805                                WAVE/Z iErr4 = $("iErr_"+"MB")                  // 2D errors -- may not exist, especially for simulation         
     806                        else 
     807                                Wave inten = V_getDetectorDataW(folderStr,"ML") 
     808                                Wave iErr = V_getDetectorDataErrW(folderStr,"ML") 
     809                                Wave inten2 = V_getDetectorDataW(folderStr,"MR") 
     810                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"MR") 
     811                                Wave inten3 = V_getDetectorDataW(folderStr,"MT") 
     812                                Wave iErr3 = V_getDetectorDataErrW(folderStr,"MT") 
     813                                Wave inten4 = V_getDetectorDataW(folderStr,"MB") 
     814                                Wave iErr4 = V_getDetectorDataErrW(folderStr,"MB") 
     815                        endif    
     816                        NVAR delQ = $(folderPath+instPath+"ML"+":gDelQ_ML") 
     817                         
     818                        Wave qTotal = $(folderPath+instPath+"ML"+":qTot_"+"ML")                 // 2D q-values   
     819                        Wave qTotal2 = $(folderPath+instPath+"MR"+":qTot_"+"MR")                        // 2D q-values   
     820                        Wave qTotal3 = $(folderPath+instPath+"MT"+":qTot_"+"MT")                        // 2D q-values   
     821                        Wave qTotal4 = $(folderPath+instPath+"MB"+":qTot_"+"MB")                        // 2D q-values   
     822                 
    690823                        nSets = 4 
    691824                        break                                                                    
     
    699832 
    700833        if(nSets == 0) 
     834                SetDataFolder root: 
    701835                return(0) 
    702836        endif 
     
    736870//******TODO****** -- where to put the averaged data -- right now, folderStr is forced to ""     
    737871//      SetDataFolder $("root:"+folderStr)              //should already be here, but make sure...       
    738         Make/O/D/N=(nq)  $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"iBin_qxqy"+"_"+type) 
    739         Make/O/D/N=(nq)  $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"qBin_qxqy"+"_"+type) 
    740         Make/O/D/N=(nq)  $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"nBin_qxqy"+"_"+type) 
    741         Make/O/D/N=(nq)  $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"iBin2_qxqy"+"_"+type) 
    742         Make/O/D/N=(nq)  $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"eBin_qxqy"+"_"+type) 
    743         Make/O/D/N=(nq)  $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"eBin2D_qxqy"+"_"+type) 
    744          
    745         Wave iBin_qxqy = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"iBin_qxqy_"+type) 
    746         Wave qBin_qxqy = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"qBin_qxqy"+"_"+type) 
    747         Wave nBin_qxqy = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"nBin_qxqy"+"_"+type) 
    748         Wave iBin2_qxqy = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"iBin2_qxqy"+"_"+type) 
    749         Wave eBin_qxqy = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"eBin_qxqy"+"_"+type) 
    750         Wave eBin2D_qxqy = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+"eBin2D_qxqy"+"_"+type) 
     872        Make/O/D/N=(nq)  $(folderPath+":"+"iBin_qxqy"+"_"+type) 
     873        Make/O/D/N=(nq)  $(folderPath+":"+"qBin_qxqy"+"_"+type) 
     874        Make/O/D/N=(nq)  $(folderPath+":"+"nBin_qxqy"+"_"+type) 
     875        Make/O/D/N=(nq)  $(folderPath+":"+"iBin2_qxqy"+"_"+type) 
     876        Make/O/D/N=(nq)  $(folderPath+":"+"eBin_qxqy"+"_"+type) 
     877        Make/O/D/N=(nq)  $(folderPath+":"+"eBin2D_qxqy"+"_"+type) 
     878         
     879        Wave iBin_qxqy = $(folderPath+":"+"iBin_qxqy_"+type) 
     880        Wave qBin_qxqy = $(folderPath+":"+"qBin_qxqy"+"_"+type) 
     881        Wave nBin_qxqy = $(folderPath+":"+"nBin_qxqy"+"_"+type) 
     882        Wave iBin2_qxqy = $(folderPath+":"+"iBin2_qxqy"+"_"+type) 
     883        Wave eBin_qxqy = $(folderPath+":"+"eBin_qxqy"+"_"+type) 
     884        Wave eBin2D_qxqy = $(folderPath+":"+"eBin2D_qxqy"+"_"+type) 
    751885         
    752886         
     
    818952        endif 
    819953 
    820 // add in set 3 and 4 (set 1 and 2already done) 
     954// add in set 3 and 4 (set 1 and 2 already done) 
    821955        if(nSets == 4) 
    822956                xDim=DimSize(inten3,0) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_UtilityProcedures.ipf

    r963 r982  
    216216                default:                                                         
    217217                        Print "Detector type mismatch in        V_getPixSizeX(type)" 
     218                        setDataFolder root: 
    218219                        return(NaN) 
    219220        endswitch 
     
    263264                default:                                                         
    264265                        Print "Detector type mismatch in        V_getPixSizeY(type)" 
     266                        SetDataFolder root: 
    265267                        return(NaN) 
    266268        endswitch 
     
    311313                default:                                                         
    312314                        Print "Detector type mismatch in        VCALC_get_nPix_X(type)" 
     315                        SetDataFolder root: 
    313316                        return(NaN) 
    314317        endswitch 
     
    358361                default:                                                         
    359362                        Print "Detector type mismatch in        VCALC_get_nPix_Y(type)" 
     363                        SetDataFolder root: 
    360364                        return(NaN) 
    361365        endswitch 
    362366 
    363         setDataFolder root: 
     367        SetDataFolder root: 
    364368                 
    365369        return(nPix) 
     
    379383                case "FL": 
    380384                case "FR": 
     385                        SetDataFolder root: 
    381386                        return(0)                
    382387                        break           //already zero, do nothing 
     
    388393                case "ML": 
    389394                case "MR": 
     395                        SetDataFolder root: 
    390396                        return(0) 
    391397                        break           //already zero, do nothing 
     
    396402                                                 
    397403                case "B": 
     404                        SetDataFolder root: 
    398405                        return(0) 
    399406                        break           //already zero, do nothing 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf

    r979 r982  
    2121         
    2222                //initialize space = folders, parameters, instrument constants, etc. 
    23                 V_Initialize_Space() 
     23                VC_Initialize_Space() 
    2424                 
    2525                //open the panel 
     
    4646//      sva.dval = 0.3 
    4747 
    48         V_BDet_SDD_SetVarProc(sva)               
    49         V_MDet_SDD_SetVarProc(sva) 
    50         V_FDet_SDD_SetVarProc(sva) 
     48        VC_BDet_SDD_SetVarProc(sva)              
     49        VC_MDet_SDD_SetVarProc(sva) 
     50        VC_FDet_SDD_SetVarProc(sva) 
    5151 
    5252        return(0) 
     
    7272        PopupMenu popup_a,mode=1,popvalue="Low Q",value= root:Packages:NIST:VSANS:VCALC:gPresetPopStr 
    7373 
    74         PopupMenu popup_b,pos={690,310},size={142,20},title="Binning type",proc=V_RebinIQ_PopProc 
     74        PopupMenu popup_b,pos={690,310},size={142,20},title="Binning type",proc=VC_RebinIQ_PopProc 
    7575        PopupMenu popup_b,mode=1,popvalue="One",value= root:Packages:NIST:VSANS:VCALC:gBinTypeStr 
    7676         
     
    145145        Slider VCALCCtrl_0a,pos={223,324},size={200,45},limits={0,10,1},value= 1,vert= 0 
    146146        SetVariable VCALCCtrl_0b,pos={25,294},size={120,15},title="wavelength" 
    147         SetVariable VCALCCtrl_0b,limits={4,20,1},value=_NUM:8,proc=V_Lambda_SetVarProc 
     147        SetVariable VCALCCtrl_0b,limits={4,20,1},value=_NUM:8,proc=VC_Lambda_SetVarProc 
    148148        PopupMenu VCALCCtrl_0c,pos={26,257},size={150,20},title="monochromator" 
    149149        PopupMenu VCALCCtrl_0c,mode=1,popvalue="Velocity Selector",value= root:Packages:NIST:VSANS:VCALC:gMonochromatorType 
     
    166166 
    167167// tab(2) - Front detector panels, initially not visible 
    168         SetVariable VCALCCtrl_2a,pos={30,260},size={150,15},title="L/R Separation (mm)",proc=V_FDet_LR_SetVarProc 
     168        SetVariable VCALCCtrl_2a,pos={30,260},size={150,15},title="L/R Separation (mm)",proc=VC_FDet_LR_SetVarProc 
    169169        SetVariable VCALCCtrl_2a,limits={0,400,1},disable=1,value=_NUM:100 
    170         SetVariable VCALCCtrl_2b,pos={30,290},size={150,15},title="T/B Separation (mm)",proc=V_FDet_LR_SetVarProc 
     170        SetVariable VCALCCtrl_2b,pos={30,290},size={150,15},title="T/B Separation (mm)",proc=VC_FDet_LR_SetVarProc 
    171171        SetVariable VCALCCtrl_2b,limits={0,400,1},disable=1,value=_NUM:100 
    172172        SetVariable VCALCCtrl_2c,pos={205,290},size={150,15},title="Lateral Offset (mm)" 
    173173        SetVariable VCALCCtrl_2c,limits={0,200,0.1},disable=1,value=_NUM:0 
    174         SetVariable VCALCCtrl_2d,pos={205,260},size={230,15},title="Sample to Detector Distance (m)",proc=V_FDet_SDD_SetVarProc 
     174        SetVariable VCALCCtrl_2d,pos={205,260},size={230,15},title="Sample to Detector Distance (m)",proc=VC_FDet_SDD_SetVarProc 
    175175        SetVariable VCALCCtrl_2d,limits={1,8,0.1},disable=1     ,value=_NUM:1.5 
    176176         
    177177 
    178178// tab(3) - Middle detector panels, initially not visible 
    179         SetVariable VCALCCtrl_3a,pos={30,260},size={150,15},title="L/R Separation (mm)",proc=V_MDet_LR_SetVarProc 
     179        SetVariable VCALCCtrl_3a,pos={30,260},size={150,15},title="L/R Separation (mm)",proc=VC_MDet_LR_SetVarProc 
    180180        SetVariable VCALCCtrl_3a,limits={0,400,1},disable=1,value=_NUM:120 
    181         SetVariable VCALCCtrl_3b,pos={30,290},size={150,15},title="T/B Separation (mm)",proc=V_MDet_LR_SetVarProc 
     181        SetVariable VCALCCtrl_3b,pos={30,290},size={150,15},title="T/B Separation (mm)",proc=VC_MDet_LR_SetVarProc 
    182182        SetVariable VCALCCtrl_3b,limits={0,400,1},disable=1,value=_NUM:120 
    183183        SetVariable VCALCCtrl_3c,pos={205,290},size={150,15},title="Lateral Offset (mm)" 
    184184        SetVariable VCALCCtrl_3c,limits={0,200,0.1},disable=1,value=_NUM:0 
    185         SetVariable VCALCCtrl_3d,pos={205,260},size={230,15},title="Sample to Detector Distance (m)",proc=V_MDet_SDD_SetVarProc 
     185        SetVariable VCALCCtrl_3d,pos={205,260},size={230,15},title="Sample to Detector Distance (m)",proc=VC_MDet_SDD_SetVarProc 
    186186        SetVariable VCALCCtrl_3d,limits={8,20,0.1},disable=1,value=_NUM:10 
    187187         
     
    189189        SetVariable VCALCCtrl_4a,pos={188,290},size={150,15},title="Lateral Offset (mm)" 
    190190        SetVariable VCALCCtrl_4a,limits={0,200,0.1},disable=1,value=_NUM:0 
    191         SetVariable VCALCCtrl_4b,pos={188,260},size={230,15},title="Sample to Detector Distance (m)",proc=V_BDet_SDD_SetVarProc 
     191        SetVariable VCALCCtrl_4b,pos={188,260},size={230,15},title="Sample to Detector Distance (m)",proc=VC_BDet_SDD_SetVarProc 
    192192        SetVariable VCALCCtrl_4b,limits={20,25,0.1},disable=1,value=_NUM:22 
    193193        PopupMenu VCALCCtrl_4c,pos={40,260},size={180,20},title="Detector type",disable=1 
     
    196196// tab(5) - Simulation setup 
    197197        SetVariable VCALCCtrl_5a,pos={40,290},size={200,15},title="Neutrons on Sample (imon)" 
    198         SetVariable VCALCCtrl_5a,limits={1e7,1e15,1e7},disable=1,value=_NUM:1e10,proc=V_SimImon_SetVarProc 
     198        SetVariable VCALCCtrl_5a,limits={1e7,1e15,1e7},disable=1,value=_NUM:1e10,proc=VC_SimImon_SetVarProc 
    199199        PopupMenu VCALCCtrl_5b,pos={40,260},size={180,20},title="Model Function",disable=1 
    200         PopupMenu VCALCCtrl_5b,mode=1,popvalue="Debye",value= root:Packages:NIST:VSANS:VCALC:gModelFunctionType,proc=V_SimModelFunc_PopProc 
     200        PopupMenu VCALCCtrl_5b,mode=1,popvalue="Debye",value= root:Packages:NIST:VSANS:VCALC:gModelFunctionType,proc=VC_SimModelFunc_PopProc 
    201201         
    202202End 
     
    297297// recalculate the detectors with a preset model function 
    298298// 
    299 Function V_SimModelFunc_PopProc(ctrlName,popNum,popStr) : PopupMenuControl 
     299Function VC_SimModelFunc_PopProc(ctrlName,popNum,popStr) : PopupMenuControl 
    300300        String ctrlName 
    301301        Variable popNum // which item is currently selected (1-based) 
     
    312312// just rebin 
    313313// 
    314 Function V_RebinIQ_PopProc(ctrlName,popNum,popStr) : PopupMenuControl 
     314Function VC_RebinIQ_PopProc(ctrlName,popNum,popStr) : PopupMenuControl 
    315315        String ctrlName 
    316316        Variable popNum // which item is currently selected (1-based) 
     
    339339// setVar for the wavelength 
    340340// 
    341 Function V_Lambda_SetVarProc(sva) : SetVariableControl 
     341Function VC_Lambda_SetVarProc(sva) : SetVariableControl 
    342342        STRUCT WMSetVariableAction &sva 
    343343 
     
    367367// setVar for the simulation monitor count 
    368368// 
    369 Function V_SimImon_SetVarProc(sva) : SetVariableControl 
     369Function VC_SimImon_SetVarProc(sva) : SetVariableControl 
    370370        STRUCT WMSetVariableAction &sva 
    371371 
     
    439439// of the intensity and a redraw of the banks 
    440440// 
    441 Function V_FDet_SDD_SetVarProc(sva) : SetVariableControl 
     441Function VC_FDet_SDD_SetVarProc(sva) : SetVariableControl 
    442442        STRUCT WMSetVariableAction &sva 
    443443 
     
    476476// of the intensity and a redraw of the banks 
    477477// 
    478 Function V_MDet_SDD_SetVarProc(sva) : SetVariableControl 
     478Function VC_MDet_SDD_SetVarProc(sva) : SetVariableControl 
    479479        STRUCT WMSetVariableAction &sva 
    480480 
     
    513513// of the intensity and a redraw of the banks 
    514514// 
    515 Function V_BDet_SDD_SetVarProc(sva) : SetVariableControl 
     515Function VC_BDet_SDD_SetVarProc(sva) : SetVariableControl 
    516516        STRUCT WMSetVariableAction &sva 
    517517 
     
    550550// of the intensity and a redraw of the banks 
    551551// 
    552 Function V_FDet_LR_SetVarProc(sva) : SetVariableControl 
     552Function VC_FDet_LR_SetVarProc(sva) : SetVariableControl 
    553553        STRUCT WMSetVariableAction &sva 
    554554 
     
    588588// of the intensity and a redraw of the banks 
    589589// 
    590 Function V_MDet_LR_SetVarProc(sva) : SetVariableControl 
     590Function VC_MDet_LR_SetVarProc(sva) : SetVariableControl 
    591591        STRUCT WMSetVariableAction &sva 
    592592 
     
    633633// -- parameters and constants need to be defined in their own space 
    634634// 
    635 // 
    636 Proc V_Initialize_Space() 
     635// FEB 2016 -- changed the data folder space to mimic the HDF folder structure 
     636// so that the averaging routines could be re-used (along with everything else) 
     637// -- painful, but better in the long run 
     638// 
     639// -- I have not re-named the detector arrays to all be "data" since that is very difficult to 
     640//   deal with on images. Added a global "gVCALC_Active" as a crude workaround as needed. Turn it 
     641//   on when needed and then immediately off 
     642// 
     643Proc VC_Initialize_Space() 
    637644// 
    638645        NewDataFolder/O root:Packages 
     
    640647        NewDataFolder/O root:Packages:NIST:VSANS 
    641648        NewDataFolder/O root:Packages:NIST:VSANS:VCALC 
    642         NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Front 
    643         NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Middle 
    644         NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Back 
     649                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry 
     650                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry 
     651                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument 
     652                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B 
     653                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MB 
     654                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MT 
     655                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_ML 
     656                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MR 
     657                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FB 
     658                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FT 
     659                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FL 
     660                NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FR 
     661 
     662//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Front 
     663//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Middle 
     664//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Back 
     665 
    645666        NewDataFolder/O root:Packages:NIST:VSANS:RawVSANS 
    646667         
     668        Variable/G root:Packages:NIST:VSANS:VCALC:gVCALC_Active = 1 
    647669         
    648670        SetDataFolder root:Packages:NIST:VSANS:VCALC 
     
    729751// TODO: the detector dimensions need to be properly defined here... 
    730752// FRONT 
    731         SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
    732  
    733         Make/O/D/N=(::gFront_L_nPix_X,::gFront_L_nPix_Y) det_FL 
    734         Make/O/D/N=(::gFront_R_nPix_X,::gFront_R_nPix_Y) det_FR 
    735         Make/O/D/N=(::gFront_T_nPix_X,::gFront_T_nPix_Y) det_FT 
    736         Make/O/D/N=(::gFront_B_nPix_X,::gFront_B_nPix_Y) det_FB 
     753//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front 
     754 
     755        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FL 
     756        Make/O/D/N=(root:Packages:NIST:VSANS:VCALC:gFront_L_nPix_X,root:Packages:NIST:VSANS:VCALC:gFront_L_nPix_Y) det_FL 
    737757        Duplicate/O det_FL qTot_FL,qx_FL,qy_FL,qz_FL 
     758 
     759        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FR 
     760        Make/O/D/N=(root:Packages:NIST:VSANS:VCALC:gFront_R_nPix_X,root:Packages:NIST:VSANS:VCALC:gFront_R_nPix_Y) det_FR 
    738761        Duplicate/O det_FR qTot_FR,qx_FR,qy_FR,qz_FR 
     762 
     763        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FT 
     764        Make/O/D/N=(root:Packages:NIST:VSANS:VCALC:gFront_T_nPix_X,root:Packages:NIST:VSANS:VCALC:gFront_T_nPix_Y) det_FT 
    739765        Duplicate/O det_FT qTot_FT,qx_FT,qy_FT,qz_FT 
     766         
     767        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FB 
     768        Make/O/D/N=(root:Packages:NIST:VSANS:VCALC:gFront_B_nPix_X,root:Packages:NIST:VSANS:VCALC:gFront_B_nPix_Y) det_FB 
    740769        Duplicate/O det_FB qTot_FB,qx_FB,qy_FB,qz_FB 
     770 
    741771 
    742772//MIDDLE 
    743773// TODO: the detector dimensions need to be properly defined here... 
    744         SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
    745  
    746         Make/O/D/N=(::gMiddle_L_nPix_X,::gMiddle_L_nPix_Y) det_ML 
    747         Make/O/D/N=(::gMiddle_R_nPix_X,::gMiddle_R_nPix_Y) det_MR 
    748         Make/O/D/N=(::gMiddle_T_nPix_X,::gMiddle_T_nPix_Y) det_MT 
    749         Make/O/D/N=(::gMiddle_B_nPix_X,::gMiddle_B_nPix_Y) det_MB 
     774//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle 
     775 
     776        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_ML 
     777        Make/O/D/N=(root:Packages:NIST:VSANS:VCALC:gMiddle_L_nPix_X,root:Packages:NIST:VSANS:VCALC:gMiddle_L_nPix_Y) det_ML 
    750778        Duplicate/O det_ML qTot_ML,qx_ML,qy_ML,qz_ML 
     779         
     780        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MR 
     781        Make/O/D/N=(root:Packages:NIST:VSANS:VCALC:gMiddle_R_nPix_X,root:Packages:NIST:VSANS:VCALC:gMiddle_R_nPix_Y) det_MR 
    751782        Duplicate/O det_MR qTot_MR,qx_MR,qy_MR,qz_MR 
     783 
     784        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MT 
     785        Make/O/D/N=(root:Packages:NIST:VSANS:VCALC:gMiddle_T_nPix_X,root:Packages:NIST:VSANS:VCALC:gMiddle_T_nPix_Y) det_MT 
    752786        Duplicate/O det_MT qTot_MT,qx_MT,qy_MT,qz_MT 
     787         
     788        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MB 
     789        Make/O/D/N=(root:Packages:NIST:VSANS:VCALC:gMiddle_B_nPix_X,root:Packages:NIST:VSANS:VCALC:gMiddle_B_nPix_Y) det_MB 
    753790        Duplicate/O det_MB qTot_MB,qx_MB,qy_MB,qz_MB 
    754791 
    755792// BACK 
    756793// TODO: the detector dimensions need to be properly defined here... 
    757         SetDataFolder root:Packages:NIST:VSANS:VCALC:Back 
    758          
    759         Make/O/D/N=(::gBack_nPix_X,::gBack_nPix_Y) det_B 
     794//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Back 
     795 
     796        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B 
     797        Make/O/D/N=(root:Packages:NIST:VSANS:VCALC:gBack_nPix_X,root:Packages:NIST:VSANS:VCALC:gBack_nPix_Y) det_B 
    760798        Duplicate/O det_B qTot_B,qx_B,qy_B,qz_B 
    761799 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VSANS_Includes.ipf

    r979 r982  
    5151#include "V_Test_RAW_Panel"             // rename this later when it's done 
    5252#include "V_Utilities_General"          // 
     53#include "V_DataPlotting" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_BroadPeak_Pix_2D.ipf

    r975 r982  
    3232        Prompt yDim "Enter Y dimension: " 
    3333                 
    34         Make/O/D coef_PeakPix2D = {10, 3, 10, 0.3, 10, 2, 0.1, 8,4, 100, 100} 
     34        Make/O/D coef_PeakPix2D = {10, 3, 10, 0.3, 10, 2, 0.1, 8, 8, 100, 100} 
    3535//      Make/O/D tmp_Pix2D =    {10, 3, 10, 0.3, 10, 2, 0.1}            //without the pixel ctrs                                         
    3636        make/o/t parameters_PeakPix2D = {"Porod Scale", "Porod Exponent","Lorentzian Scale","Lor Screening Length","Peak position","Lorentzian Exponent","Bgd [1/cm]", "xPix size (mm)","yPix size (mm)", "xCtr (pixels)", "yCtr (pixels)"}              
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf

    r981 r982  
    9292// -- do I want this to return a wave? 
    9393// -- do I need to write a separate function that returns the distance wave for later calculations? 
    94 // -- do I want to make the distance array 2D to keep the x and y dims together? Calculate them all right now? 
     94// -- do I want to make the distance array 3D to keep the x and y dims together? Calculate them all right now? 
    9595// -- what else do I need to pass to the function? (fname=folder? detStr?) 
    9696// 
    9797// 
    9898// 
    99 Function NonLinearCorrection(dataW,data_errW,coefW) 
    100         Wave dataW,data_errW,coefW 
    101          
     99Function NonLinearCorrection(dataW,coefW,tube_width,detStr,destPath) 
     100        Wave dataW,coefW 
     101        Variable tube_width 
     102        String detStr,destPath 
     103         
     104          
    102105        // do I count on the orientation as an input, or do I just figure it out on my own? 
    103106        String orientation 
     
    112115 
    113116        // make a wave of the same dimensions, in the same data folder for the distance 
    114         // ?? or a 2D wave? 
     117        // ?? or a 3D wave? 
     118        Make/O/D/N=(dimX,dimY) $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistX") 
     119        Make/O/D/N=(dimX,dimY) $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistY") 
     120        Wave data_realDistX = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistX") 
     121        Wave data_realDistY = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistY") 
    115122         
    116123        // then per tube, do the quadratic calculation to get the real space distance along the tube 
     
    119126        if(cmpstr(orientation,"vertical")==0) 
    120127                //      this is data dimensioned as (Ntubes,Npix) 
    121                  
    122  
     128                data_realDistY[][] = coefW[0][p] + coefW[1][p]*q + coefW[2][p]*q*q 
     129 
     130                data_realDistX[][] = tube_width*p 
     131                 
    123132        elseif(cmpstr(orientation,"horizontal")==0) 
    124133                //      this is data (horizontal) dimensioned as (Npix,Ntubes) 
    125  
    126          
     134                data_realDistX[][] = coefW[0][q] + coefW[1][q]*p + coefW[2][q]*p*p 
     135         
     136                data_realDistY[][] = tube_width*q 
     137 
    127138        else             
    128139                DoAlert 0,"Orientation not correctly passed in NonLinearCorrection(). No correction done." 
     
    165176        // -- only for the tube, not the Back det 
    166177         
    167         DoAlert 0, "re-do this and do a better job of filling the fake data" 
     178        DoAlert 0, "re-do this and do a better job of filling the fake calibration data" 
    168179         
    169180        fMakeFakeCalibrationWaves() 
     
    200211                //      this is vertical tube data dimensioned as (Ntubes,Npix) 
    201212                        pixSize = 8                     //V_getDet_y_pixel_size(fname,detStr) 
     213                         
    202214                elseif(cmpstr(orientation,"horizontal")==0) 
    203215                //      this is data (horizontal) dimensioned as (Npix,Ntubes) 
    204216                        pixSize = 4                     //V_getDet_x_pixel_size(fname,detStr) 
     217                         
    205218                else             
    206219                        DoAlert 0,"Orientation not correctly passed in NonLinearCorrection(). No correction done." 
    207220                endif 
    208221                 
    209                 calib[0][] = -64 
     222                calib[0][] = -(128/2)*pixSize                   //approx (n/2)*pixSixe 
    210223                calib[1][] = pixSize 
    211224                calib[2][] = 2e-4 
     
    215228        return(0) 
    216229End 
     230 
     231 
     232 
     233Function V_Detector_CalcQVals(fname,detStr,destPath) 
     234        String fname,detStr,destPath 
     235 
     236        String orientation 
     237        Variable xCtr,yCtr,lambda,sdd 
     238         
     239// get all of the geometry information   
     240        orientation = V_getDet_tubeOrientation(fname,detStr) 
     241        sdd = V_getDet_distance(fname,detStr) 
     242        xCtr = V_getDet_beam_center_x(fname,detStr) 
     243        yCtr = V_getDet_beam_center_y(fname,detStr) 
     244        lambda = V_getWavelength(fname) 
     245        Wave data_realDistX = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistX") 
     246        Wave data_realDistY = $(destPath + ":entry:entry:instrument:detector_"+detStr+":data_realDistY") 
     247 
     248// make the new waves 
     249        Duplicate/O data_realDistX $(destPath + ":entry:entry:instrument:detector_"+detStr+":qTot_"+detStr) 
     250        Duplicate/O data_realDistX $(destPath + ":entry:entry:instrument:detector_"+detStr+":qx_"+detStr) 
     251        Duplicate/O data_realDistX $(destPath + ":entry:entry:instrument:detector_"+detStr+":qy_"+detStr) 
     252        Duplicate/O data_realDistX $(destPath + ":entry:entry:instrument:detector_"+detStr+":qz_"+detStr) 
     253        Wave qTot = $(destPath + ":entry:entry:instrument:detector_"+detStr+":qTot_"+detStr) 
     254        Wave qx = $(destPath + ":entry:entry:instrument:detector_"+detStr+":qx_"+detStr) 
     255        Wave qy = $(destPath + ":entry:entry:instrument:detector_"+detStr+":qy_"+detStr) 
     256        Wave qz = $(destPath + ":entry:entry:instrument:detector_"+detStr+":qz_"+detStr) 
     257 
     258// calculate all of the q-values 
     259        qTot = V_CalcQval(p,q,xCtr,yCtr,sdd,lambda,data_realDistX,data_realDistY) 
     260        qx = V_CalcQX(p,q,xCtr,yCtr,sdd,lambda,data_realDistX,data_realDistY) 
     261        qy = V_CalcQY(p,q,xCtr,yCtr,sdd,lambda,data_realDistX,data_realDistY) 
     262        qz = V_CalcQZ(p,q,xCtr,yCtr,sdd,lambda,data_realDistX,data_realDistY) 
     263         
     264         
     265        return(0) 
     266End 
     267 
     268 
     269//function to calculate the overall q-value, given all of the necesary trig inputs 
     270// 
     271// TODO: 
     272// -- verify the calculation (accuracy - in all input conditions) 
     273// -- verify the units of everything here, it's currently all jumbled an wrong... 
     274// -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
     275//    to each pixel 
     276// 
     277//sdd is in meters 
     278//wavelength is in Angstroms 
     279// 
     280//returned magnitude of Q is in 1/Angstroms 
     281// 
     282Function V_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,distX,distY) 
     283        Variable xaxval,yaxval,xctr,yctr,sdd,lam 
     284        Wave distX,distY 
     285         
     286        Variable dx,dy,qval,two_theta,dist 
     287                 
     288        sdd *=100               //convert to cm 
     289        dx = (distX[xaxval][yaxval] - xctr)             //delta x in cm 
     290        dy = (distY[xaxval][yaxval] - yctr)             //delta y in cm 
     291        dist = sqrt(dx^2 + dy^2) 
     292         
     293        two_theta = atan(dist/sdd) 
     294 
     295        qval = 4*Pi/lam*sin(two_theta/2) 
     296         
     297        return qval 
     298End 
     299 
     300//calculates just the q-value in the x-direction on the detector 
     301// TODO: 
     302// -- verify the calculation (accuracy - in all input conditions) 
     303// -- verify the units of everything here, it's currently all jumbled an wrong... 
     304// -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
     305//    to each pixel 
     306// 
     307// 
     308// this properly accounts for qz 
     309// 
     310Function V_CalcQX(xaxval,yaxval,xctr,yctr,sdd,lam,distX,distY) 
     311        Variable xaxval,yaxval,xctr,yctr,sdd,lam 
     312        Wave distX,distY 
     313 
     314        Variable qx,qval,phi,dx,dy,dist,two_theta 
     315         
     316        qval = V_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,distX,distY) 
     317         
     318        sdd *=100               //convert to cm 
     319        dx = (distX[xaxval][yaxval] - xctr)             //delta x in cm 
     320        dy = (distY[xaxval][yaxval] - yctr)             //delta y in cm 
     321        phi = V_FindPhi(dx,dy) 
     322         
     323        //get scattering angle to project onto flat detector => Qr = qval*cos(theta) 
     324        dist = sqrt(dx^2 + dy^2) 
     325        two_theta = atan(dist/sdd) 
     326 
     327        qx = qval*cos(two_theta/2)*cos(phi) 
     328         
     329        return qx 
     330End 
     331 
     332//calculates just the q-value in the y-direction on the detector 
     333// TODO: 
     334// -- verify the calculation (accuracy - in all input conditions) 
     335// -- verify the units of everything here, it's currently all jumbled an wrong... 
     336// -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
     337//    to each pixel 
     338// 
     339// 
     340// this properly accounts for qz 
     341// 
     342Function V_CalcQY(xaxval,yaxval,xctr,yctr,sdd,lam,distX,distY) 
     343        Variable xaxval,yaxval,xctr,yctr,sdd,lam 
     344        Wave distX,distY 
     345 
     346        Variable qy,qval,phi,dx,dy,dist,two_theta 
     347         
     348        qval = V_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,distX,distY) 
     349         
     350        sdd *=100               //convert to cm 
     351        dx = (distX[xaxval][yaxval] - xctr)             //delta x in cm 
     352        dy = (distY[xaxval][yaxval] - yctr)             //delta y in cm 
     353        phi = V_FindPhi(dx,dy) 
     354         
     355        //get scattering angle to project onto flat detector => Qr = qval*cos(theta) 
     356        dist = sqrt(dx^2 + dy^2) 
     357        two_theta = atan(dist/sdd) 
     358 
     359        qy = qval*cos(two_theta/2)*sin(phi) 
     360         
     361        return qy 
     362End 
     363 
     364//calculates just the q-value in the z-direction on the detector 
     365// TODO: 
     366// -- verify the calculation (accuracy - in all input conditions) 
     367// -- verify the units of everything here, it's currently all jumbled an wrong... 
     368// -- the input data_realDistX and Y are essentially lookup tables of the real space distance corresponding 
     369//    to each pixel 
     370// 
     371// not actually used for anything, but here for completeness if anyone asks 
     372// 
     373// this properly accounts for qz 
     374// 
     375Function V_CalcQZ(xaxval,yaxval,xctr,yctr,sdd,lam,distX,distY) 
     376        Variable xaxval,yaxval,xctr,yctr,sdd,lam 
     377        Wave distX,distY 
     378 
     379        Variable qz,qval,phi,dx,dy,dist,two_theta 
     380         
     381        qval = V_CalcQval(xaxval,yaxval,xctr,yctr,sdd,lam,distX,distY) 
     382         
     383        sdd *=100               //convert to cm 
     384        dx = (distX[xaxval][yaxval] - xctr)             //delta x in cm 
     385        dy = (distY[xaxval][yaxval] - yctr)             //delta y in cm 
     386         
     387        //get scattering angle to project onto flat detector => Qr = qval*cos(theta) 
     388        dist = sqrt(dx^2 + dy^2) 
     389        two_theta = atan(dist/sdd) 
     390 
     391        qz = qval*sin(two_theta/2) 
     392         
     393        return qz 
     394End 
     395 
    217396 
    218397 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_RW_Utils.ipf

    r981 r982  
    4040// 
    4141// TODO: -- is there an extra "entry" heading? Am I adding this by mistake by setting base_name="entry" for RAW data? 
    42 // 
     42//                      -- as dumb as it is -- do I just leave it now, or break everything. ont the plus side, removing the extra entry 
     43//          layer may catch a lot of the hard-wired junk that is present... 
    4344Function V_LoadHDF5Data(file,folder) 
    4445        String file,folder 
    4546 
    46         String base_name 
     47        String base_name,detStr 
     48        String destPath 
     49        Variable ii 
     50         
    4751        SetDataFolder $("root:Packages:NIST:VSANS:"+folder) 
    48 //      SetDataFolder root: 
     52        destPath = "root:Packages:NIST:VSANS:"+folder 
     53 
    4954        if(cmpstr(folder,"RAW")==0) 
    5055                base_name="entry" 
     56//              base_name="RAW"         // this acts as a flag to remove the duplicate "entry" level 
    5157        else 
    52                 base_name="entry"               //TODO -- remove this / change behavior in V_LoadHDF5_NoAtt() 
     58        // null will use the file name as the top level (above entry) 
     59                base_name=""            //TODO -- remove this / change behavior in V_LoadHDF5_NoAtt() 
    5360        endif 
    5461         
     
    5764        // if RAW data, then generate the errors and linear data copy 
    5865        // do this 9x 
     66        // then do any "massaging" needed to redimension, fake values, etc. 
     67        // 
    5968        string tmpStr = "root:Packages:NIST:VSANS:RAW:entry:entry:instrument:"  
     69 
    6070        if(cmpstr(folder,"RAW")==0) 
    61                 V_MakeDataError(tmpStr+"detector_B") 
    62                 V_MakeDataError(tmpStr+"detector_MB") 
    63                 V_MakeDataError(tmpStr+"detector_MT") 
    64                 V_MakeDataError(tmpStr+"detector_ML") 
    65                 V_MakeDataError(tmpStr+"detector_MR") 
    66                 V_MakeDataError(tmpStr+"detector_FB") 
    67                 V_MakeDataError(tmpStr+"detector_FT") 
    68                 V_MakeDataError(tmpStr+"detector_FL") 
    69                 V_MakeDataError(tmpStr+"detector_FR") 
    70  
    71 // TODO -- once I get "real" data, get rid of this call to force the data to be proper dimensions. 
     71         
     72                // TODO -- once I get "real" data, get rid of this call to force the data to be proper dimensions. 
    7273                V_RedimFakeData() 
    73 // 
    74 // TODO -- for the "real" data, may need a step in here to convert integer detector data to DP, or I'll 
    75 //          get really odd results from the calculations, and may not even notice. 
    76  
    77 // TODO 
    78 //  -- get rid of these fake calibration waves as "real" ones are filled in 
     74 
     75                // makes data error and linear copy -- DP waves if V_RedimFakeData() called above  
     76                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     77                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
     78                        V_MakeDataError(tmpStr+"detector_"+detStr)       
     79                endfor 
     80 
     81 
     82                // TODO -- for the "real" data, may need a step in here to convert integer detector data to DP, or I'll 
     83                //          get really odd results from the calculations, and may not even notice. 
     84                // !!!! Where do I actually do this? - this is currently done in Raw_to_work() 
     85                // -- is is better to do here, right as the data is loaded? 
     86                // TODO -- some of this is done in V_RedimFakeData() above - which will disappear once I get real data 
     87 
     88         
     89                // TODO 
     90                //  -- get rid of these fake calibration waves as "real" ones are filled in by NICE 
    7991                Execute "MakeFakeCalibrationWaves()" 
    80 //              fMakeFakeCalibrationWaves()             //skips the alert 
    81                  
     92                //              fMakeFakeCalibrationWaves()             //skips the alert 
     93 
     94 
     95                // TODO -- do I want to calculate the nonlinear x/y arrays and the q-values here? 
     96                // -- otherwise the mouse-over doesn't calculate the correct Q_values 
     97                // the display currently is not shifted or altered at all to account for the non-linearity 
     98                // or for display in q-values -- so why bother with this? 
     99                NVAR gDoNonLinearCor = root:Packages:NIST:VSANS:Globals:gDoNonLinearCor 
     100                // generate a distance matrix for each of the detectors 
     101                if (gDoNonLinearCor == 1) 
     102                        Print "Calculating Non-linear correction at RAW load time"// for "+ detStr 
     103                        for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
     104                                detStr = StringFromList(ii, ksDetectorListNoB, ";") 
     105                                Wave w = V_getDetectorDataW(folder,detStr) 
     106        //                      Wave w_err = V_getDetectorDataErrW(fname,detStr) 
     107                                Wave w_calib = V_getDetTube_spatialCalib(folder,detStr) 
     108                                Variable tube_width = V_getDet_tubeWidth(folder,detStr) 
     109                                NonLinearCorrection(w,w_calib,tube_width,detStr,destPath) 
    82110                                 
    83 /// END FAKE DATA CORRECTIONS            
    84                  
     111                                // (2.5) Calculate the q-values 
     112                                // calculating q-values can't be done unless the non-linear corrections are calculated 
     113                                // so go ahead and put it in this loop. 
     114                                // TODO :  
     115                                // -- make sure that everything is present before the calculation 
     116                                // -- beam center must be properly defined in terms of real distance 
     117                                // -- distances/zero location/ etc. must be clearly documented for each detector 
     118                                //      ** this assumes that NonLinearCorrection() has been run to generate data_RealDistX and Y 
     119                                // ** this routine Makes the waves QTot, qx, qy, qz in each detector folder. 
     120                                // 
     121                                V_Detector_CalcQVals(folder,detStr,destPath) 
     122                                 
     123                        endfor 
     124                else 
     125                        Print "Non-linear correction not done" 
     126                endif 
     127                                         
     128                                         
     129                /// END FAKE DATA CORRECTIONS            
     130                         
    85131        endif 
    86132         
     
    90136 
    91137// 
    92 // TODO -- this is all FAKED since all the data arrays are (1,128,128) 
    93 // I'm intentionally using the wrong number of pixels so I'm more likely to go back and get rid of this later. 
     138// TODO -- this is all FAKED since all the data arrays are written to hdf as (1,128,128) 
     139//  -- try to fill in the bits from VCALC, if it exists (or force it) 
    94140// 
    95141// the SetScale parts may be useful later. 
     
    97143Function V_RedimFakeData() 
    98144         
    99                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_B 
    100                 Wave det_B=data 
    101                 Redimension/N=(320,320)/E=1 det_B 
    102                 det_B = p+q+2 
    103                  
    104                 Variable ctr=20,npix=128 
    105                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MT 
    106                 Wave det_MT=data 
    107                 Redimension/N=(npix,48)/E=1 det_MT               
    108                 SetScale/I x -npix/2,npix/2,"",det_MT 
    109                 SetScale/I y ctr,ctr+48,"",det_MT 
    110 //              det_mt[][20] = 50 
    111         det_MT *= 10 
     145        // check for fake data in VCALC folder... 
     146        wave/Z tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B:det_B" 
     147        if(WaveExists(tmpw) == 0) 
     148                Execute "VCALC_Panel()" 
     149        endif 
     150         
     151        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_B 
     152        Wave det_B=data 
     153        Redimension/N=(320,320)/E=1 det_B        
     154        Redimension/D det_B 
     155//      det_B = p+q+2 
     156        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_B:det_B" 
     157        det_B=tmpw 
     158        det_B += 2 
     159                         
     160        Variable ctr=20,npix=128 
     161        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MT 
     162        Wave det_MT=data 
     163        Redimension/N=(npix,48)/E=1 det_MT 
     164        Redimension/D det_MT             
     165        SetScale/I x -npix/2,npix/2,"",det_MT 
     166        SetScale/I y ctr,ctr+48,"",det_MT 
     167//      det_MT *= 10 
     168//      det_MT += 2 
     169        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MT:det_MT" 
     170        det_MT=tmpw 
    112171        det_MT += 2 
    113  
    114                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MB 
    115                 Wave det_MB=data 
    116                 Redimension/N=(npix,48)/E=1 det_MB               
    117                 SetScale/I x -npix/2,npix/2,"",det_MB 
    118                 SetScale/I y -ctr,-ctr-48,"",det_MB 
    119         det_MB *= 5 
     172         
     173        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MB 
     174        Wave det_MB=data 
     175        Redimension/N=(npix,48)/E=1 det_MB               
     176        Redimension/D det_MB 
     177        SetScale/I x -npix/2,npix/2,"",det_MB 
     178        SetScale/I y -ctr-48,-ctr,"",det_MB 
     179//      det_MB *= 5 
     180//      det_MB += 2 
     181        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MB:det_MB" 
     182        det_MB=tmpw 
    120183        det_MB += 2 
    121                  
    122                 ctr=30 
    123                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_ML 
    124                 Wave det_ML=data 
    125                 Redimension/N=(48,npix)/E=1 det_ML               
    126                 SetScale/I x -ctr-48,-ctr,"",det_ML 
    127                 SetScale/I y -npix/2,npix/2,"",det_ML 
    128         det_ML *= 2 
     184         
     185        ctr=30 
     186        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_ML 
     187        Wave det_ML=data 
     188        Redimension/N=(48,npix)/E=1 det_ML               
     189        Redimension/D det_ML 
     190        SetScale/I x -ctr-48,-ctr,"",det_ML 
     191        SetScale/I y -npix/2,npix/2,"",det_ML 
     192//      det_ML *= 2 
     193//      det_ML += 2 
     194        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_ML:det_ML" 
     195        det_ML=tmpw 
    129196        det_ML += 2 
    130          
    131                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MR 
    132                 Wave det_MR=data 
    133                 Redimension/N=(48,npix)/E=1 det_MR               
    134                 SetScale/I x ctr,ctr+48,"",det_MR 
    135                 SetScale/I y -npix/2,npix/2,"",det_MR 
    136         det_MR +=2 
    137                  
    138                 ctr=30 
    139                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FT 
    140                 Wave det_FT=data 
    141                 Redimension/N=(npix,48)/E=1 det_FT               
    142                 SetScale/I x -npix/2,npix/2,"",det_FT 
    143                 SetScale/I y ctr,ctr+48,"",det_FT 
    144  
    145                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FB 
    146                 Wave det_FB=data 
    147                 Redimension/N=(npix,48)/E=1 det_FB               
    148                 SetScale/I x -npix/2,npix/2,"",det_FB 
    149                 SetScale/I y -ctr,-ctr-48,"",det_FB 
    150                  
    151                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FL 
    152                 Wave det_FL=data 
    153                 Redimension/N=(48,npix)/E=1 det_FL               
    154                 SetScale/I x -ctr-48,-ctr,"",det_FL 
    155                 SetScale/I y -npix/2,npix/2,"",det_FL 
    156                  
    157                 SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FR 
    158                 Wave det_FR=data 
    159                 Redimension/N=(48,npix)/E=1 det_FR               
    160                 SetScale/I x ctr,ctr+48,"",det_FR 
    161                 SetScale/I y -npix/2,npix/2,"",det_FR 
    162  
     197                 
     198        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_MR 
     199        Wave det_MR=data 
     200        Redimension/N=(48,npix)/E=1 det_MR               
     201        Redimension/D det_MR 
     202        SetScale/I x ctr,ctr+48,"",det_MR 
     203        SetScale/I y -npix/2,npix/2,"",det_MR 
     204//      det_MR +=2 
     205        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_MR:det_MR" 
     206        det_MR=tmpw 
     207        det_MR += 2 
     208         
     209        ctr=30 
     210        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FT 
     211        Wave det_FT=data 
     212        Redimension/N=(npix,48)/E=1 det_FT               
     213        Redimension/D det_FT 
     214        SetScale/I x -npix/2,npix/2,"",det_FT 
     215        SetScale/I y ctr,ctr+48,"",det_FT 
     216        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FT:det_FT" 
     217        det_FT=tmpw 
     218 
     219        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FB 
     220        Wave det_FB=data 
     221        Redimension/N=(npix,48)/E=1 det_FB               
     222        Redimension/D det_FB 
     223        SetScale/I x -npix/2,npix/2,"",det_FB 
     224        SetScale/I y -ctr-48,-ctr,"",det_FB 
     225        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FB:det_FB" 
     226        det_FB=tmpw 
     227                         
     228        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FL 
     229        Wave det_FL=data 
     230        Redimension/N=(48,npix)/E=1 det_FL               
     231        Redimension/D det_FL 
     232        SetScale/I x -ctr-48,-ctr,"",det_FL 
     233        SetScale/I y -npix/2,npix/2,"",det_FL 
     234        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FL:det_FL" 
     235        det_FL=tmpw 
     236         
     237        SetDataFolder root:Packages:NIST:VSANS:RAW:entry:entry:instrument:detector_FR 
     238        Wave det_FR=data 
     239        Redimension/N=(48,npix)/E=1 det_FR               
     240        Redimension/D det_FR 
     241        SetScale/I x ctr,ctr+48,"",det_FR 
     242        SetScale/I y -npix/2,npix/2,"",det_FR 
     243        wave tmpw=$"root:Packages:NIST:VSANS:VCALC:entry:entry:instrument:detector_FR:det_FR" 
     244        det_FR=tmpw 
     245         
    163246// get rid of zeros 
    164                 det_FL += 2 
    165                 det_FR += 2 
    166                 det_FT += 2 
    167                 det_FB += 2 
     247        det_FL += 2 
     248        det_FR += 2 
     249        det_FT += 2 
     250        det_FB += 2 
     251 
     252V_RescaleToBeamCenter("RAW","MB",64,55) 
     253V_RescaleToBeamCenter("RAW","MT",64,-8.7) 
     254V_RescaleToBeamCenter("RAW","MR",-8.1,64) 
     255V_RescaleToBeamCenter("RAW","ML",55,64) 
     256V_RescaleToBeamCenter("RAW","FL",55,64) 
     257V_RescaleToBeamCenter("RAW","FR",-8.1,64) 
     258V_RescaleToBeamCenter("RAW","FT",64,-8.7) 
     259V_RescaleToBeamCenter("RAW","FB",64,55) 
     260 
     261 
    168262 
    169263        return(0) 
     
    217311        if(cmpstr(base_name,"") == 0) 
    218312                base_name = StringFromList(0,FileName,".") 
     313        endif 
     314        if(cmpstr(base_name,"RAW") == 0) 
     315                base_name = "" 
    219316        endif 
    220317        //base_name = "entry" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MainPanel.ipf

    r981 r982  
    5555 
    5656        Variable err=   V_LoadHDF5Data("","RAW")                        // load the data into RawVSANS storage folder (why am I doing this?) 
    57         Print "Load err = "+num2str(err) 
     57//      Print "Load err = "+num2str(err) 
    5858        if(!err) 
    5959                String hdfDF = root:file_name                   // last file loaded, may not be the safest way to pass 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Menu.ipf

    r977 r982  
    1616        "-" 
    1717        "Main Control Panel",DoWindow/F Main_VSANS_Panel 
    18         "Data Display",UpdateDisplayInformation("") 
     18        "Data Display",DoWindow/F VSANS_Data 
    1919        "VCALC",VCALC_Panel() 
    2020        "-" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Test_RAW_Panel.ipf

    r981 r982  
    9191        PauseUpdate; Silent 1           // building window... 
    9292        NewPanel /W=(37,45,1038,719) /N=VSANS_Data 
    93         ShowTools/A 
     93//      ShowTools/A 
    9494        ModifyPanel cbRGB=(65535,60076,49151) 
    9595 
     
    222222                case 3:         //mouse down 
    223223//                      Print "mouse down" 
     224// 
     225// TODO (Way in the future -- I could make the small graphs into "buttons" by responding to a "mouse up" (not down) 
     226//    that hits in one of the small graph areas, and treat that as a click on that tab 
     227// 
    224228                        break 
    225229                         
     
    335339                                        pixSizeX = V_getDet_x_pixel_size(gCurDispType,detStr)/10                // written mm? need cm 
    336340                                        pixSizeY = V_getDet_y_pixel_size(gCurDispType,detStr)/10                // written mm? need cm 
    337                                          
    338                                         gQQ = V_CalcQval(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    339                                         gQX = V_CalcQX(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    340                                         gQY = V_CalcQY(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     341// 
     342// TODO: these q-values ignore the non-linear corrections!!! 
     343// -- What can I do about this?                                  
     344                                        gQQ = VC_CalcQval(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     345                                        gQX = VC_CalcQX(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
     346                                        gQY = VC_CalcQY(xaxval+1,yaxval+1,xctr,yctr,sdd,lam,pixSizeX,pixSizeY) 
    341347 
    342348                                        ii = -1         //look no further, set ii to bad value to exit the for loop 
     
    381387                         
    382388                        SVAR dataType = root:Packages:NIST:VSANS:Globals:gCurDispType 
     389// make sure log scaling is correct                      
     390                        NVAR state = root:Packages:NIST:VSANS:Globals:gIsLogScale 
     391                         
    383392                         
    384393                        //************ 
     
    411420                                MoveSubWindow/W=VSANS_Data#det_panelsM fnum=(320,70,430,160) 
    412421                                MoveSubWindow/W=VSANS_Data#det_panelsF fnum=(200,70,310,160) 
     422 
     423                                ModifyImage/W=VSANS_Data#det_panelsB ''#0 log=State 
     424                                 
     425                                // make the plot square 
     426                                ModifyGraph/W=VSANS_Data#det_panelsB width={Aspect,1} 
    413427                                 
    414428                                SetActiveSubWindow VSANS_Data#det_panelsB 
     
    450464                                MoveSubWindow/W=VSANS_Data#det_panelsB fnum=(440,70,550,160) 
    451465                                MoveSubWindow/W=VSANS_Data#det_panelsF fnum=(200,70,310,160) 
    452                                  
     466 
     467                                ModifyImage/W=VSANS_Data#det_panelsM ''#0 log=State 
     468                                ModifyImage/W=VSANS_Data#det_panelsM ''#1 log=State 
     469                                ModifyImage/W=VSANS_Data#det_panelsM ''#2 log=State 
     470                                ModifyImage/W=VSANS_Data#det_panelsM ''#3 log=State 
     471                                 
     472                                // make the plot square 
     473                                ModifyGraph/W=VSANS_Data#det_panelsM width={Aspect,1} 
     474                                                         
    453475                                SetActiveSubWindow VSANS_Data#det_panelsM 
    454476                                SetDataFolder root: 
     
    490512                                MoveSubWindow/W=VSANS_Data#det_panelsM fnum=(320,70,430,160) 
    491513                                 
     514                                ModifyImage/W=VSANS_Data#det_panelsF ''#0 log=State 
     515                                ModifyImage/W=VSANS_Data#det_panelsF ''#1 log=State 
     516                                ModifyImage/W=VSANS_Data#det_panelsF ''#2 log=State 
     517                                ModifyImage/W=VSANS_Data#det_panelsF ''#3 log=State 
     518 
     519                                // make the plot square 
     520                                ModifyGraph/W=VSANS_Data#det_panelsF width={Aspect,1}                            
     521         
    492522                                SetActiveSubWindow VSANS_Data#det_panelsF 
    493523                                SetDataFolder root: 
    494524                        endif 
    495525 
    496 // make sure log scaling is correct                      
    497                         NVAR state = root:Packages:NIST:VSANS:Globals:gIsLogScale 
    498                          
    499                         // on the front:                         
    500                         ModifyImage/W=VSANS_Data#det_panelsF ''#0 log=State 
    501                         ModifyImage/W=VSANS_Data#det_panelsF ''#1 log=State 
    502                         ModifyImage/W=VSANS_Data#det_panelsF ''#2 log=State 
    503                         ModifyImage/W=VSANS_Data#det_panelsF ''#3 log=State 
    504                         //on the middle: 
    505                         ModifyImage/W=VSANS_Data#det_panelsM ''#0 log=State 
    506                         ModifyImage/W=VSANS_Data#det_panelsM ''#1 log=State 
    507                         ModifyImage/W=VSANS_Data#det_panelsM ''#2 log=State 
    508                         ModifyImage/W=VSANS_Data#det_panelsM ''#3 log=State 
    509                         // on the back: 
    510                         ModifyImage/W=VSANS_Data#det_panelsB ''#0 log=State 
    511 //// 
    512          
    513526                                                 
    514527                        break 
     
    630643                case 2: // mouse up 
    631644                        // click code here 
     645                         
     646                        V_PlotData_Panel() 
     647                         
    632648                        break 
    633649                case -1: // control being killed 
     
    743759                case 2: // mouse up 
    744760                        // click code here 
     761                        V_FindBeamCenter() 
    745762                        break 
    746763                case -1: // control being killed 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf

    r981 r982  
    382382        // TODO 
    383383        // -- currently only redimensioning the data and linear_data_error - What else??? 
    384         // 
     384        // -- ?? some of this is done at load time for RAW data 
    385385        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    386386                detStr = StringFromList(ii, ksDetectorListAll, ";") 
     
    400400                // if not in DIV folder, load. 
    401401                // if unable to load, skip correction and report error (Alert?) (Ask to Load?) 
    402                  
     402                Print "Doing DIV correction"// for "+ detStr 
    403403                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    404404                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
    405405                        Wave w = V_getDetectorDataW(fname,detStr) 
    406406                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    407                         Print "Doing DIV correction for "+ detStr 
     407                         
    408408                        DIVCorrection(w,w_err,detStr,newType) 
    409409                endfor 
     
    413413         
    414414        // (2) non-linear correction     
     415        // TODO: 
     416        // -- currently, the "B" detector is skipped 
     417        // -- document what is generated here: 
     418        //    **in each detector folder: data_realDistX and data_realDistY (2D waves of the mm? position of the pixel) 
     419        // -- still not sure whether to duplicate these calculations as the RAW data is loaded. It would allow the RAW 
     420        //    data to be properly displayed, but without all of the (complete) set of corrections 
     421        // * the corrected distances are calculated into arrays, but nothing is done with them yet 
     422        // * there is enough information now to calculate the q-arrays -other corrections modify the data 
    415423        NVAR gDoNonLinearCor = root:Packages:NIST:VSANS:Globals:gDoNonLinearCor 
    416424        // generate a distance matrix for each of the detectors 
    417425        if (gDoNonLinearCor == 1) 
    418                 for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    419                         detStr = StringFromList(ii, ksDetectorListAll, ";") 
     426                Print "Doing Non-linear correction"// for "+ detStr 
     427                for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) 
     428                        detStr = StringFromList(ii, ksDetectorListNoB, ";") 
    420429                        Wave w = V_getDetectorDataW(fname,detStr) 
    421                         Wave w_err = V_getDetectorDataErrW(fname,detStr) 
     430//                      Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    422431                        Wave w_calib = V_getDetTube_spatialCalib(fname,detStr) 
    423                         Print "Doing Non-linear correction for "+ detStr 
    424 //                      NonLinearCorrection(fill this in) 
     432                        Variable tube_width = V_getDet_tubeWidth(fname,detStr) 
     433                        NonLinearCorrection(w,w_calib,tube_width,detStr,destPath) 
     434                         
     435                        // (2.5) Calculate the q-values 
     436                        // calculating q-values can't be done unless the non-linear corrections are calculated 
     437                        // so go ahead and put it in this loop. 
     438                        // TODO :  
     439                        // -- make sure that everything is present before the calculation 
     440                        // -- beam center must be properly defined in terms of real distance 
     441                        // -- distances/zero location/ etc. must be clearly documented for each detector 
     442                        //      ** this assumes that NonLinearCorrection() has been run to generate data_RealDistX and Y 
     443                        // ** this routine Makes the waves QTot, qx, qy, qz in each detector folder. 
     444                        // 
     445                        V_Detector_CalcQVals(fname,detStr,destPath) 
    425446                         
    426447                endfor 
     
    428449                Print "Non-linear correction not done" 
    429450        endif 
    430          
     451 
    431452        // (3) solid angle correction 
    432453        NVAR gDoSolidAngleCor = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor 
    433454        if (gDoSolidAngleCor == 1) 
     455                Print "Doing Solid Angle correction"// for "+ detStr 
    434456                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    435457                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
     
    437459                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    438460                        Wave w_dt = V_getDetector_deadtime(fname,detStr) 
    439                         Print "Doing Solid Angle correction for "+ detStr 
    440461//                      SolidAngleCorrection(fill this in) 
    441462                         
     
    453474        ctTime = V_getCount_time(fname) 
    454475        if (gDoDeadTimeCor == 1) 
     476                Print "Doing DeadTime correction"// for "+ detStr 
    455477                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    456478                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
     
    458480                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    459481                        Wave w_dt = V_getDetector_deadtime(fname,detStr) 
    460                         Print "Doing DeadTime correction for "+ detStr 
    461482//                      DeadTimeCorrectionTubes(w,w_err,w_dt,ctTime) 
    462483                                //deadtime corrections 
     
    488509        NVAR gDoTrans = root:Packages:NIST:VSANS:Globals:gDoTransmissionCor 
    489510        if (gDoTrans == 1) 
     511                Print "Doing Large-angle transmission correction"// for "+ detStr 
    490512                for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
    491513                        detStr = StringFromList(ii, ksDetectorListAll, ";") 
     
    493515                        Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    494516                        Wave w_dt = V_getDetector_deadtime(fname,detStr) 
    495                         Print "Doing Large-angle transmission correction for "+ detStr 
    496517//                      TransmissionCorrection(fill this in) 
    497518                         
     
    505526        // TODO -- but there are TWO monitors - so how to switch? 
    506527        // TODO -- what do I really need to save? 
     528        Print "Doing monitor normalization"// for "+ detStr 
     529 
    507530        defmon=1e8                      //default monitor counts 
    508531        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     
    511534                Wave w_err = V_getDetectorDataErrW(fname,detStr) 
    512535                Variable monCt = V_getBeamMonNormData(fname) 
    513                 Print "Doing monitor normalization for "+ detStr 
    514536//                      MonitorNormalization(fill this in) 
    515537        //scale the data to the default montor counts 
Note: See TracChangeset for help on using the changeset viewer.