Changeset 1133 for sans/Dev


Ignore:
Timestamp:
Mar 22, 2019 2:52:55 PM (4 years ago)
Author:
srkline
Message:

many changes to the VCALC procedures to add in the hard/soft shadowing to the calculation, visualization of the shadowed regions, and the actual q-values. Added a separate panel to view the shadowed regions.

simpe fix to the real time routine to allow easy updating of both the raw 2D data and 1-D average

update to the USANS package to handle the new NICE generated data where the data is collected in terms of q-values rather than angle. On startup asks user which style of data they have. Sets a preference that can be un-checked if you have old-style ICP data. (there is nothing in the data file that I can key on).

Location:
sans/Dev/trunk/NCNR_User_Procedures
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtilsMacro_v40.ipf

    r1124 r1133  
    14281428         
    14291429        /// items for USANS Reduction 
    1430         // now keys on date in the file -- see LoadBT5File() 
    1431 //      val = NumVarOrDefault("root:Packages:NIST:gUseNICEDataFormat", 1 ) 
    1432 //      Variable/G root:Packages:NIST:gUseNICEDataFormat=val     
     1430// is the data file from NICE and in terms of QValues rather than angle 
     1431        val = NumVarOrDefault("root:Packages:NIST:gRawUSANSisQvalues", 1 ) 
     1432        Variable/G root:Packages:NIST:gRawUSANSisQvalues=val     
    14331433         
    14341434        /// items for everyone 
     
    14971497End 
    14981498 
    1499 Function UseNICEDataFormat(ctrlName,checked) : CheckBoxControl 
     1499//set the angle->Q conversion factor 
     1500// or set the Q->Q "conversion" factor 
     1501// this is the same value that is set in Init_USANS_Facility() 
     1502// Mar 2019 
     1503Function RawUSANSisQPref(ctrlName,checked) : CheckBoxControl 
    15001504        String ctrlName 
    15011505        Variable checked 
    15021506         
    1503         NVAR gVal = root:Packages:NIST:gUseNICEDataFormat 
     1507        NVAR gVal = root:Packages:NIST:gRawUSANSisQvalues 
    15041508        gVal = checked 
     1509         
     1510        if(checked == 1) 
     1511                Variable/G root:Packages:NIST:USANS:Globals:MainPanel:deg2QConv = 1             //so that the q-values are unchanged 
     1512        else 
     1513                Variable/G root:Packages:NIST:USANS:Globals:MainPanel:deg2QConv=5.55e-5         //JGB -- 2/24/01 
     1514        endif 
    15051515End 
    15061516 
     
    15671577//      GroupBox PrefCtrl_2a pos={21,100},size={1,1},title="nothing to set",fSize=12 
    15681578//      GroupBox PrefCtrl_2a,disable=1 
    1569         CheckBox PrefCtrl_2a,pos={21,100},size={171,14},proc=UseNICEDataFormat,title="Read New NICE data format" 
    1570         CheckBox PrefCtrl_2a,help={"Check this if raw data was collected using NICE. If data was collected using ICP, leave this unchecked."} 
    1571         CheckBox PrefCtrl_2a,value= root:Packages:NIST:gUseNICEDataFormat 
     1579        CheckBox PrefCtrl_2a,pos={21,100},size={171,14},proc=RawUSANSisQPref,title="Raw USANS Data is Q-values" 
     1580        CheckBox PrefCtrl_2a,help={"Check this if raw data was collected using NICE (q-values). If data was collected using ICP (angle), leave this unchecked."} 
     1581        CheckBox PrefCtrl_2a,value= root:Packages:NIST:gRawUSANSisQvalues 
    15721582 
    15731583 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/BT5_Loader.ipf

    r1124 r1133  
    9696        endif 
    9797 
    98 // or use the global 
    99 //      NVAR gVal = root:Packages:NIST:gUseNICEDataFormat        
    100 //      useNewDataFormat = gVal 
    101          
    10298         
    10399        USANS_DetectorDeadtime(filedt,MainDeadTime,TransDeadTime) 
     
    188184// !can't return -1,0,1, since these may be the peak angle! 
    189185// 
     186// MAR 2019 
     187// if the data is colleced with NICE, the "angle" is really q-values. 
     188// in this case the returned value is a q-value, and when this shift is applied to the 
     189// nominal (raw) q-values, the peak value is not converted from angle to q 
     190// 
     191// 
    190192Function FindZeroAngle(type) 
    191193        String type 
     
    211213        Endif 
    212214        pkAngle = Angle[pkPt] 
    213         //Print "Peak Angle = ",pkAngle 
     215         
     216        Print "Peak Angle = ",pkAngle 
    214217        //update the note 
    215218        String str="" 
     
    228231// Uses a conversion constant supplied by John Barker, and is hard-wired in 
    229232// 
     233//      Mar 2019 
     234// if the data is collected from NICE, the data is in terms of Q, not angle since the 
     235// conversion factor has already been applied. In this case, the "angle" and pkAngle 
     236// are actually in terms of Q, and the deg2QConv value is set to == 1 
     237// -- then nothing needs to be changed 
     238// 
    230239Function ConvertAngle2Qvals(type,pkAngle) 
    231240        String type 
     
    277286         
    278287        FindLevel/Q/P Qvals,1e-4                //use angles greater than 2 deg = 2*5.55e-5 = 1e-4 (1/A) 
    279         Print "Using Qval, pt = ",V_levelX 
     288//      Print "Using Qval, pt = ",V_levelX 
    280289 
    281290        levNotFound=V_Flag              //V_Flag==1 if no pk found 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/Main_USANS.ipf

    r807 r1133  
    252252        ModifyGraph axisEnab(bottom1)={0.1,1},gridEnab(bottom1)={0.1,1} 
    253253        ErrorBars/T=0 DetCts Y,wave=(ErrDetCts,ErrDetCts) 
    254         TextBox/F=0/E=2/A=MB/Y=2/N=text1 "Angle" 
     254         
     255        if(root:Packages:NIST:gRawUSANSisQvalues == 1) 
     256                TextBox/F=0/E=2/A=MB/Y=2/N=text1 "Q (1/A)" 
     257                ModifyGraph log(bottom1)=1 
     258        else 
     259                TextBox/F=0/E=2/A=MB/Y=2/N=text1 "Angle" 
     260        endif 
     261         
     262         
    255263        TextBox/F=0/O=90/E=2/A=LC/X=2/N=text2 "Counts" 
    256264        //TextBox/N=text1/A=RC/X=0.50/Y=-2 textStr 
     
    397405         
    398406        //find the peak and convert to Q-values 
     407        // MAR 2019 
     408        // for new NICE raw data collected in terms of q-values rather than angle, all of these function still  
     409        // work correctly, even though they are named "angle". The conversion is simply set to == 1 so that 
     410        // q == q 
    399411        Variable zeroAngle = FindZeroAngle("SAM") 
    400412        if(zeroAngle == -9999) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/USANS/NCNR_USANS_Utils.ipf

    r1124 r1133  
    2424         
    2525         
     26 
     27// is the data file from NICE and in terms of QValues rather than angle? 
     28        Variable/G root:Packages:NIST:gRawUSANSisQvalues=1              //== 1 means raw data is in Q, not angle 
     29 
     30        DoAlert 0,"The data loader is set to interpret raw data in Q-values (from NICE), not angle (from ICP). If your raw data was collected from ICP, change this setting using the menu item USANS->NCNR Preferences" 
     31         
    2632        // to convert from angle (in degrees) to Q (in 1/Angstrom) 
    27         Variable/G root:Packages:NIST:USANS:Globals:MainPanel:deg2QConv=5.55e-5         //JGB -- 2/24/01 
     33        // -- or to disable the conversion if the data is "new NICE" (approx Mar 2019) 
     34        NVAR gRawUSANSisQvalues = root:Packages:NIST:gRawUSANSisQvalues 
     35        if(gRawUSANSisQvalues == 1) 
     36                Variable/G root:Packages:NIST:USANS:Globals:MainPanel:deg2QConv = 1             //so that the q-values are unchanged 
     37        else 
     38                Variable/G root:Packages:NIST:USANS:Globals:MainPanel:deg2QConv = 5.55e-5               //JGB -- 2/24/01 
     39        endif 
     40 
     41 
    2842         
    2943        // extension string for the raw data files 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Q.ipf

    r1129 r1133  
    3535 
    3636// 
    37 // Plot the front panels in 2D and 1D 
     37// Plot the front panels in 2D  
    3838//              calcualate Q 
    3939//              fill w/model data 
    40 //              "shadow" the T/B detectors 
    41 //              bin the data to I(q) 
    42 //              draw I(q) graph 
    4340//              draw 2D panel graph 
    4441// 
     
    8784        SetDataFolder root: 
    8885                 
    89         // set any "shadowed" area of the T/B detectors to NaN to get a realistic 
    90         // view of how much of the detectors are actually collecting data 
    91         // -- I can get the separation L/R from the panel - only this "open" width is visible. 
    92         //TODO - make this a proper shadow - TB extent of the LR panels matters too, not just the LR separation 
    93         VC_SetShadow_TopBottom("VCALC","FT")            // TODO: -- be sure the data folder is properly set (within the function...) 
    94         VC_SetShadow_TopBottom("VCALC","FB") 
    95          
    96         // do the q-binning for each of the panels to get I(Q) 
    97 //      BinAllFrontPanels() 
    98  
    99         String popStr 
    100 //      String collimationStr = "pinhole" 
    101 //      ControlInfo/W=VCALC popup_b 
    102 //      popStr = S_Value                // 
    103 //      V_QBinAllPanels_Circular("VCALC",V_BinTypeStr2Num(popStr),collimationStr) 
    104  
    105         // plot the results 
    106 //      String type = "VCALC" 
    107 //      String str,winStr="VCALC#Panels_IQ",workTypeStr 
    108 //      workTypeStr = "root:Packages:NIST:VSANS:"+type 
    109 // 
    110 //      ControlInfo/W=VCALC popup_b 
    111 //      popStr = S_Value                // 
    112 //       
    113 //      sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,V_BinTypeStr2Num(popStr),winStr 
    114 // 
    115 //      Execute ("V_Front_IQ_Graph"+str) 
    116                  
    117 //      Execute "Front_IQ_Graph()" 
    118  
    11986        FrontPanels_AsQ() 
    12087         
     
    198165        nPix_Y = VCALC_get_nPix_Y("FL") 
    199166 
    200         if(kBCTR_CM) 
    201                 xCtr = 0 
    202                 yCtr = 0                        //values in cm 
    203         else     
    204                 xCtr = nPix_X-(F_L_sep/pixSizeX)                // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 
    205                 yCtr = nPix_Y/2  
     167        //approx beam center in pixels 
     168        xCtr = nPix_X-(F_L_sep/pixSizeX)                // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 
     169        yCtr = nPix_Y/2 
     170         
     171        if(kBCTR_CM)            //convert to cm 
     172                Wave data_realDistX = $(folderPath+instPath+detStr+":data_realDistX") 
     173                Wave data_realDistY = $(folderPath+instPath+detStr+":data_realDistY")    
     174                //vertical (left) panel 
     175                xCtr = (data_realDistX[nPix_X-1][0]/10 + (xCtr-nPix_X-1)*pixSizeX) 
     176                yCtr = data_realDistY[0][yCtr]/10       //this should be close to zero 
    206177        endif 
    207178        //put these  beam center values into the local folder 
     
    213184//      VC_Detector_2Q(det_FL,qTot_FL,qx_FL,qy_FL,qz_FL,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
    214185        VC_Detector_2Q_NonLin(det_FL,qTot_FL,qx_FL,qy_FL,qz_FL,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY,"FL") 
    215         Print "xy for FL = ",xCtr,yCtr 
     186//      Print "xy ctr for FL = ",xCtr,yCtr 
    216187         
    217188        //set the wave scaling for the detector image so that it can be plotted in q-space 
     
    243214        nPix_Y = VCALC_get_nPix_Y("FR") 
    244215 
     216// beam center in pixels 
     217        xCtr = -(F_R_sep/pixSizeX)-1             
     218        yCtr = nPix_Y/2  
    245219        if(kBCTR_CM) 
    246                 xCtr = 0 
    247                 yCtr = 0                        //values in cm 
    248         else     
    249                 xCtr = -(F_R_sep/pixSizeX)-1             
    250                 yCtr = nPix_Y/2  
     220                Wave data_realDistX = $(folderPath+instPath+detStr+":data_realDistX")           //in mm 
     221                Wave data_realDistY = $(folderPath+instPath+detStr+":data_realDistY")    
     222                //vertical (right) panel 
     223                xCtr = (data_realDistX[0][0]/10 + (xCtr)*pixSizeX) 
     224                yCtr = data_realDistY[0][yCtr]/10               //this should be close to zero 
    251225        endif 
    252226 
     
    259233//      VC_Detector_2Q(det_FR,qTot_FR,qx_FR,qy_FR,qz_FR,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) 
    260234        VC_Detector_2Q_NonLin(det_FR,qTot_FR,qx_FR,qy_FR,qz_FR,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY,"FR") 
     235//      Print "xy ctr for FR = ",xCtr,yCtr 
    261236 
    262237//      Print "xy for FR = ",xCtr,yCtr 
     
    285260        nPix_Y = VCALC_get_nPix_Y("FT") 
    286261 
     262// beam center in pixels 
     263        xCtr = nPix_X/2 
     264        yCtr = -(F_T_sep/2/pixSizeY)-1  
     265                 
    287266        if(kBCTR_CM) 
    288                 xCtr = 0 
    289                 yCtr = 0                        //values in cm 
    290         else     
    291                 xCtr = nPix_X/2 
    292                 yCtr = -(F_T_sep/2/pixSizeY)-1  
     267                Wave data_realDistX = $(folderPath+instPath+detStr+":data_realDistX") 
     268                Wave data_realDistY = $(folderPath+instPath+detStr+":data_realDistY")    
     269                //horizontal (top) panel 
     270                xCtr = data_realDistX[xCtr][0]/10               //this should be close to zero          //in cm 
     271                yCtr = data_realDistY[0][0]/10 + yCtr*pixSizeY 
    293272        endif    
    294273 
     
    328307        nPix_Y = VCALC_get_nPix_Y("FB") 
    329308 
     309// beam center in pixels 
     310        xCtr = nPix_X/2 
     311        yCtr = nPix_Y+(F_B_sep/2/pixSizeY)               
     312         
    330313        if(kBCTR_CM) 
    331                 xCtr = 0 
    332                 yCtr = 0                        //values in cm 
    333         else     
    334                 xCtr = nPix_X/2 
    335                 yCtr = nPix_Y+(F_B_sep/2/pixSizeY)              // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 
     314                Wave data_realDistX = $(folderPath+instPath+detStr+":data_realDistX") 
     315                Wave data_realDistY = $(folderPath+instPath+detStr+":data_realDistY")    
     316                //horizontal (bottom) panel 
     317                xCtr = data_realDistX[xCtr][0]/10                       //this should be close to zero 
     318                yCtr = data_realDistY[0][nPix_Y-1]/10 + (yCtr-nPix_Y-1)*pixSizeY 
    336319        endif    
    337320                         
     
    356339End 
    357340 
    358  
    359 // TODO - this doesn't quite mask things out as they should be (too much is masked L/R of center) 
    360 // and the outer edges of the detector are masked even if the TB panels extend past the TB of the LR panels. 
    361 // ? skip the masking? but then I bin the detector data directly to get I(q), skipping the masked NaN values... 
    362 // 
    363 Function VC_SetShadow_TopBottom(folderStr,type) 
    364         String folderStr,type 
    365          
    366         Variable L_sep,R_sep,nPix_L,nPix_R,xCtr,ii,jj,numCol,pixSizeX,pixSizeY,nPix_X,nPix_Y 
    367  
    368 /// !! type passed in will be FT, FB, MT, MB, so I can't ask for the panel separation -- or I'll get the TB separation... 
    369 // translation in [cm] 
    370         if(cmpstr("F",type[0]) == 0)            // FT or FB passed in 
    371                 L_sep = VCALC_getPanelTranslation("FL") 
    372                 R_sep = VCALC_getPanelTranslation("FR") 
    373         else 
    374                 L_sep = VCALC_getPanelTranslation("ML") 
    375                 R_sep = VCALC_getPanelTranslation("MR")  
    376         endif 
    377  
    378  
    379 //detector data 
    380         Wave det = $("root:Packages:NIST:VSANS:"+folderStr+":entry:instrument:detector_"+type+":det_"+type) 
    381  
    382 // TODO - these are to be set from globals, not hard-wired 
    383 // pixel sizes are in cm for T/B detector 
    384 // TODO - the "FT" check is hard wired for FRONT -- get rid of this... 
    385  
    386         pixSizeX = VCALC_getPixSizeX(type) 
    387         pixSizeY = VCALC_getPixSizeY(type) 
    388  
    389         nPix_X = VCALC_get_nPix_X(type) 
    390         nPix_Y = VCALC_get_nPix_Y(type) 
    391          
    392         //TODO -- get this from a global 
    393         xCtr = nPix_X/2 
    394         nPix_L = trunc(abs(L_sep)/pixSizeX)             // approx # of pixels Left of center that are not obscured by L/R panels 
    395         nPix_R = trunc(abs(R_sep)/pixSizeX)             // approx # of pixels Right of center that are not obscured by L/R panels 
    396          
    397         numCol = DimSize(det,0)         // x dim (columns) 
    398         for(ii=0;ii<(xCtr-nPix_L-4);ii+=1) 
    399                 det[ii][] = NaN 
    400         endfor 
    401         for(ii=(xCtr+nPix_R+6);ii<numCol;ii+=1) 
    402                 det[ii][] = NaN 
    403         endfor 
    404          
    405         return(0) 
    406 end 
    407341 
    408342 
     
    635569        SetDataFolder root: 
    636570                 
    637         // set any "shadowed" area of the T/B detectors to NaN to get a realistic 
    638         // view of how much of the detectors are actually collecting data 
    639         // -- I can get the separation L/R from the panel - only this "open" width is visible. 
    640         VC_SetShadow_TopBottom("VCALC","MT")            // TODO: -- be sure the data folder is properly set (within the function...) 
    641         VC_SetShadow_TopBottom("VCALC","MB") 
    642          
    643         // do the q-binning for each of the panels to get I(Q) 
    644 //      BinAllMiddlePanels() 
    645  
    646 //      String popStr 
    647 //      String collimationStr = "pinhole" 
    648 //      ControlInfo/W=VCALC popup_b 
    649 //      popStr = S_Value                // 
    650 //      V_QBinAllPanels_Circular("VCALC",V_BinTypeStr2Num(popStr),collimationStr) 
    651  
    652         // plot the results 
    653 //      String type = "VCALC" 
    654 //      String str,winStr="VCALC#Panels_IQ",workTypeStr 
    655 //      workTypeStr = "root:Packages:NIST:VSANS:"+type 
    656  
    657 //      ControlInfo/W=VCALC popup_b 
    658 //      popStr = S_Value                // 
    659          
    660 //      sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,V_BinTypeStr2Num(popStr),winStr 
    661 // 
    662 //      Execute ("V_Middle_IQ_Graph"+str) 
    663                  
    664  
    665         // plot the results 
    666 //      Execute "Middle_IQ_Graph()" 
    667  
    668571 
    669572        MiddlePanels_AsQ() 
     
    739642        nPix_Y = VCALC_get_nPix_Y("ML") 
    740643 
     644        xCtr = nPix_X+(M_L_sep/pixSizeX)                // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 
     645        yCtr = nPix_Y/2 
     646                 
    741647        if(kBCTR_CM) 
    742                 xCtr = 0 
    743                 yCtr = 0                        //values in cm 
    744         else     
    745                 xCtr = nPix_X+(M_L_sep/pixSizeX)                // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? 
    746                 yCtr = nPix_Y/2  
     648                Wave data_realDistX = $(folderPath+instPath+detStr+":data_realDistX") 
     649                Wave data_realDistY = $(folderPath+instPath+detStr+":data_realDistY")    
     650                //vertical panel 
     651                xCtr = (data_realDistX[nPix_X-1][0]/10 + (xCtr-nPix_X-1)*pixSizeX) 
     652                yCtr = data_realDistY[0][yCtr]/10       //this should be close to zero 
    747653        endif            
    748654 
     
    788694        nPix_Y = VCALC_get_nPix_Y("MR") 
    789695 
     696        xCtr = -(M_R_sep/pixSizeX)-1             
     697        yCtr = nPix_Y/2  
     698                 
    790699        if(kBCTR_CM) 
    791                 xCtr = 0 
    792                 yCtr = 0                        //values in cm 
    793         else     
    794                 xCtr = -(M_R_sep/pixSizeX)-1             
    795                 yCtr = nPix_Y/2  
     700                Wave data_realDistX = $(folderPath+instPath+detStr+":data_realDistX") 
     701                Wave data_realDistY = $(folderPath+instPath+detStr+":data_realDistY")    
     702                //vertical (right) panel 
     703                xCtr = (data_realDistX[0][0]/10 + (xCtr)*pixSizeX) 
     704                yCtr = data_realDistY[0][yCtr]/10               //this should be close to zero 
    796705        endif    
    797706                 
     
    831740        nPix_Y = VCALC_get_nPix_Y("MT") 
    832741 
     742        xCtr = nPix_X/2 
     743        yCtr = -(M_T_sep/pixSizeY)-1  
     744                 
    833745        if(kBCTR_CM) 
    834                 xCtr = 0 
    835                 yCtr = 0                        //values in cm 
    836         else     
    837                 xCtr = nPix_X/2 
    838                 yCtr = -(M_T_sep/pixSizeY)-1  
     746                Wave data_realDistX = $(folderPath+instPath+detStr+":data_realDistX") 
     747                Wave data_realDistY = $(folderPath+instPath+detStr+":data_realDistY")    
     748                //horizontal (top) panel 
     749                xCtr = data_realDistX[xCtr][0]/10               //this should be close to zero          //in cm 
     750                yCtr = data_realDistY[0][0]/10 + yCtr*pixSizeY 
    839751        endif 
    840752                 
     
    875787        nPix_Y = VCALC_get_nPix_Y("MB") 
    876788 
     789        xCtr = nPix_X/2 
     790        yCtr = nPix_Y+(M_B_sep/pixSizeY)         
     791         
    877792        if(kBCTR_CM) 
    878                 xCtr = 0 
    879                 yCtr = 0                        //values in cm 
    880         else     
    881                 xCtr = nPix_X/2 
    882                 yCtr = nPix_Y+(M_B_sep/pixSizeY)                // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)??  
     793                Wave data_realDistX = $(folderPath+instPath+detStr+":data_realDistX") 
     794                Wave data_realDistY = $(folderPath+instPath+detStr+":data_realDistY")    
     795                //horizontal (bottom) panel 
     796                xCtr = data_realDistX[xCtr][0]/10                       //this should be close to zero 
     797                yCtr = data_realDistY[0][nPix_Y-1]/10 + (yCtr-nPix_Y-1)*pixSizeY 
    883798        endif            
    884799 
     
    12171132        SetDataFolder root: 
    12181133                 
    1219         // set any "shadowed" area of the T/B detectors to NaN to get a realitic 
    1220         // view of how much of the detectors are actually collecting data 
    1221         // -- I can get the separation L/R from the panel - only this "open" width is visible. 
    1222 //      VC_SetShadow_TopBottom("","MT")         // TODO: -- be sure the data folder is properly set (within the function...) 
    1223 //      VC_SetShadow_TopBottom("","MB") 
    1224          
    1225         // do the q-binning for each of the panels to get I(Q) 
    1226  
    1227 //      BinAllBackPanels() 
    1228  
    1229         // plot the results 
    1230 //      String type = "VCALC" 
    1231 //      String str,winStr="VCALC#Panels_IQ",workTypeStr,popStr 
    1232 //      workTypeStr = "root:Packages:NIST:VSANS:"+type 
    1233  
    1234 //      ControlInfo/W=VCALC popup_b 
    1235 //      popStr = S_Value                // 
    1236          
    1237 //      sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,V_BinTypeStr2Num(popStr),winStr 
    1238 // 
    1239 //      Execute ("V_Back_IQ_Graph"+str) 
    1240                  
    1241                  
    1242         // plot the results 
    1243 //      Execute "Back_IQ_Graph()" 
    1244  
    1245  
    12461134 
    12471135        Execute "BackPanels_AsQ()" 
     
    13051193        xCtr = V_getDet_beam_center_x("VCALC","B") 
    13061194        yCtr = V_getDet_beam_center_y("VCALC","B") 
     1195 
     1196//      Print "Xctr B = ",xctr,yctr 
    13071197 
    13081198//      if(kBCTR_CM) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Utils.ipf

    r1128 r1133  
    928928                                Wave inten = V_getDetectorDataW(folderStr,detStr) 
    929929                                Wave iErr = V_getDetectorDataErrW(folderStr,detStr) 
    930                                 Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
    931                                 if(WaveExists(mask) == 1) 
    932                                         maskMissing = 0 
    933                                 endif 
    934930                        endif    
     931                        Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
     932                        if(WaveExists(mask) == 1) 
     933                                maskMissing = 0 
     934                        endif 
    935935                        NVAR delQ = $(folderPath+instPath+detStr+":gDelQ_"+detStr) 
    936936                        Wave qTotal = $(folderPath+instPath+detStr+":qTot_"+detStr)                     // 2D q-values   
     
    952952                                Wave inten2 = V_getDetectorDataW(folderStr,"FR") 
    953953                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"FR") 
    954                                 Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FL"+":data") 
    955                                 Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FR"+":data") 
    956                                 if(WaveExists(mask) == 1 && WaveExists(mask2) == 1) 
    957                                         maskMissing = 0 
    958                                 endif 
    959954                        endif    
     955                        Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FL"+":data") 
     956                        Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FR"+":data") 
     957                        if(WaveExists(mask) == 1 && WaveExists(mask2) == 1) 
     958                                maskMissing = 0 
     959                        endif 
     960                         
    960961                        NVAR delQ = $(folderPath+instPath+"FL"+":gDelQ_FL") 
    961962                         
     
    977978                                Wave inten2 = V_getDetectorDataW(folderStr,"FB") 
    978979                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"FB") 
    979                                 Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FT"+":data") 
    980                                 Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FB"+":data") 
    981                                 if(WaveExists(mask) == 1 && WaveExists(mask2) == 1) 
    982                                         maskMissing = 0 
    983                                 endif 
    984980                        endif    
     981                        Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FT"+":data") 
     982                        Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FB"+":data") 
     983                        if(WaveExists(mask) == 1 && WaveExists(mask2) == 1) 
     984                                maskMissing = 0 
     985                        endif 
     986                         
    985987                        NVAR delQ = $(folderPath+instPath+"FT"+":gDelQ_FT") 
    986988                         
     
    10101012                                Wave inten4 = V_getDetectorDataW(folderStr,"FB") 
    10111013                                Wave iErr4 = V_getDetectorDataErrW(folderStr,"FB") 
    1012                                 Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FL"+":data") 
    1013                                 Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FR"+":data") 
    1014                                 Wave/Z mask3 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FT"+":data") 
    1015                                 Wave/Z mask4 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FB"+":data") 
    1016                                 if(WaveExists(mask) == 1 && WaveExists(mask2) == 1 && WaveExists(mask3) == 1 && WaveExists(mask4) == 1) 
    1017                                         maskMissing = 0 
    1018                                 endif 
     1014                                 
    10191015                        endif    
     1016                        Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FL"+":data") 
     1017                        Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FR"+":data") 
     1018                        Wave/Z mask3 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FT"+":data") 
     1019                        Wave/Z mask4 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"FB"+":data") 
     1020                        if(WaveExists(mask) == 1 && WaveExists(mask2) == 1 && WaveExists(mask3) == 1 && WaveExists(mask4) == 1) 
     1021                                maskMissing = 0 
     1022                        endif 
     1023                         
    10201024                        NVAR delQ = $(folderPath+instPath+"FL"+":gDelQ_FL") 
    10211025                         
     
    10391043                                Wave inten2 = V_getDetectorDataW(folderStr,"MR") 
    10401044                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"MR") 
    1041                                 Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"ML"+":data") 
    1042                                 Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MR"+":data") 
    1043                                 if(WaveExists(mask) == 1 && WaveExists(mask2) == 1) 
    1044                                         maskMissing = 0 
    1045                                 endif 
     1045                                 
    10461046                        endif    
     1047                        Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"ML"+":data") 
     1048                        Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MR"+":data") 
     1049                        if(WaveExists(mask) == 1 && WaveExists(mask2) == 1) 
     1050                                maskMissing = 0 
     1051                        endif 
     1052                         
    10471053                        NVAR delQ = $(folderPath+instPath+"ML"+":gDelQ_ML") 
    10481054                         
     
    10641070                                Wave inten2 = V_getDetectorDataW(folderStr,"MB") 
    10651071                                Wave iErr2 = V_getDetectorDataErrW(folderStr,"MB") 
    1066                                 Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MT"+":data") 
    1067                                 Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MB"+":data") 
    1068                                 if(WaveExists(mask) == 1 && WaveExists(mask2) == 1) 
    1069                                         maskMissing = 0 
    1070                                 endif 
     1072                                 
    10711073                        endif    
     1074                        Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MT"+":data") 
     1075                        Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MB"+":data") 
     1076                        if(WaveExists(mask) == 1 && WaveExists(mask2) == 1) 
     1077                                maskMissing = 0 
     1078                        endif 
     1079                         
    10721080                        NVAR delQ = $(folderPath+instPath+"MT"+":gDelQ_MT") 
    10731081                         
     
    10971105                                Wave inten4 = V_getDetectorDataW(folderStr,"MB") 
    10981106                                Wave iErr4 = V_getDetectorDataErrW(folderStr,"MB") 
    1099                                 Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"ML"+":data") 
    1100                                 Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MR"+":data") 
    1101                                 Wave/Z mask3 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MT"+":data") 
    1102                                 Wave/Z mask4 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MB"+":data") 
    1103                                 if(WaveExists(mask) == 1 && WaveExists(mask2) == 1 && WaveExists(mask3) == 1 && WaveExists(mask4) == 1) 
    1104                                         maskMissing = 0 
    1105                                 endif 
    1106                         endif    
     1107                                 
     1108                        endif 
     1109                        Wave/Z mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"ML"+":data") 
     1110                        Wave/Z mask2 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MR"+":data") 
     1111                        Wave/Z mask3 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MT"+":data") 
     1112                        Wave/Z mask4 = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+"MB"+":data") 
     1113                        if(WaveExists(mask) == 1 && WaveExists(mask2) == 1 && WaveExists(mask3) == 1 && WaveExists(mask4) == 1) 
     1114                                maskMissing = 0 
     1115                        endif 
     1116                                 
    11071117                        NVAR delQ = $(folderPath+instPath+"ML"+":gDelQ_ML") 
    11081118                         
     
    12441254                                val = inten[ii][jj] 
    12451255                                 
    1246                                 if(isVCALC || maskMissing)              // mask_val == 0 == keep, mask_val == 1 = YES, mask out the point 
     1256//                              if(isVCALC || maskMissing)              // mask_val == 0 == keep, mask_val == 1 = YES, mask out the point 
     1257                                if(maskMissing)         // mask_val == 0 == keep, mask_val == 1 = YES, mask out the point 
    12471258                                        mask_val = 0 
    12481259                                else 
     
    12721283                                val = inten2[ii][jj] 
    12731284                                 
    1274                                 if(isVCALC || maskMissing) 
     1285//                              if(isVCALC || maskMissing) 
     1286                                if(maskMissing) 
    12751287                                        mask_val = 0 
    12761288                                else 
     
    13001312                                val = inten3[ii][jj] 
    13011313                                 
    1302                                 if(isVCALC || maskMissing) 
     1314//                              if(isVCALC || maskMissing) 
     1315                                if(maskMissing) 
    13031316                                        mask_val = 0 
    13041317                                else 
     
    13251338                                val = inten4[ii][jj] 
    13261339                                 
    1327                                 if(isVCALC || maskMissing) 
     1340//                              if(isVCALC || maskMissing) 
     1341                                if(maskMissing) 
    13281342                                        mask_val = 0 
    13291343                                else 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_SideView.ipf

    r1128 r1133  
    453453                Label/W=VCALC#TopView left "\\Z10Horizontal position (cm)" 
    454454                Label/W=VCALC#TopView bottom "\\Z10SDD (cm)" 
    455                 SetAxis/W=VCALC#TopView left 80.0,-80.0 
     455                SetAxis/R/W=VCALC#TopView left 80.0,-80.0 
    456456                SetAxis/W=VCALC#TopView bottom 0,2500 
    457457                TextBox/W=VCALC#TopView/C/N=text0/A=MC/X=41.61/Y=43.62 "\\JCTOP VIEW\r= Left/Right panels" 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_UtilityProcedures.ipf

    r1129 r1133  
    522522Function VC_Preset_WhiteBeam() 
    523523 
    524         VC_Preset_FrontMiddle_Ng0()             // moves Middle into contact (but w/ wrong lambda) 
    525524        // monochromator 
    526525        PopupMenu VCALCCtrl_0c,mode=1,popvalue="White Beam" 
     
    533532 
    534533// wavelength 
    535         SetVariable VCALCCtrl_0b,value=_NUM:5.3,disable=0       ,noedit=0       // allow user editing again 
    536          
     534        SetVariable VCALCCtrl_0b,value=_NUM:5.3//,disable=0     ,noedit=0       // allow user editing again 
     535 
     536        // adjust the front carriage 
     537        SetVariable VCALCCtrl_2a,value=_NUM:-20         //Left offset 
     538        SetVariable VCALCCtrl_2aa,value=_NUM:20         //Right offset 
     539        SetVariable VCALCCtrl_2b,value=_NUM:8                   //Top offset 
     540        SetVariable VCALCCtrl_2bb,value=_NUM:-8         //Bottom offset 
     541 
     542        SetVariable VCALCCtrl_2d,value=_NUM:120         //SDD 
     543 
     544        // middle carriage 
     545        SetVariable VCALCCtrl_3a,value=_NUM:-15         //Left offset 
     546        SetVariable VCALCCtrl_3aa,value=_NUM:15         //Right offset 
     547        SetVariable VCALCCtrl_3b,value=_NUM:15                  //Top offset (doesn't matter) 
     548        SetVariable VCALCCtrl_3bb,value=_NUM:-15                //Bottom offset (doesn't matter) 
     549 
     550        SetVariable VCALCCtrl_3d,value=_NUM:1900                //SDD 
     551         
     552// binning mode 
     553        PopupMenu popup_b,mode=1,popValue="F4-M4-B" 
     554 
     555// set preference to USE back detector 
     556        NVAR gIgnoreB = root:Packages:NIST:VSANS:Globals:gIgnoreDetB 
     557        gIgnoreB = 0 
     558         
     559                         
    537560        return(0) 
    538561end 
     
    574597         
    575598        // wavelength 
    576         SetVariable VCALCCtrl_0b,value=_NUM:4.75,disable=0      ,noedit=0       // allow user editing again 
     599        SetVariable VCALCCtrl_0b,value=_NUM:4.75//,disable=0    ,noedit=0       // allow user editing again 
    577600 
    578601        //number of guides 
     
    592615        Variable a2_to_GV,sam_to_GV,sdd,l2 
    593616        sdd = VC_getSDD(detStr)                 //sample pos to detector 
    594         ControlInfo VCALCCtrl_1d 
     617        ControlInfo/W=VCALC VCALCCtrl_1d 
    595618        a2_to_GV = V_Value 
    596         ControlInfo VCALCCtrl_1e 
     619        ControlInfo/W=VCALC VCALCCtrl_1e 
    597620        sam_to_GV = V_Value 
    598621        l2 = sdd - sam_to_GV + a2_to_GV 
     
    631654        Variable a2_to_GV,sam_to_GV,sdd 
    632655        sdd = VC_getSDD(detStr)                 //sample pos to detector 
    633         ControlInfo VCALCCtrl_1d 
     656        ControlInfo/W=VCALC VCALCCtrl_1d 
    634657        a2_to_GV = V_Value 
    635         ControlInfo VCALCCtrl_1e 
     658        ControlInfo/W=VCALC VCALCCtrl_1e 
    636659        sam_to_GV = V_Value 
    637660        l2 = sdd - sam_to_GV + a2_to_GV 
     
    642665     
    643666        // sample aperture diam [cm] 
    644         ControlInfo VCALCCtrl_1c 
     667        ControlInfo/W=VCALC VCALCCtrl_1c 
    645668        a2 = V_Value 
    646669     
     
    685708                case "B": 
    686709                case "B ": 
    687                         ControlInfo VCALCCtrl_4b 
     710                        ControlInfo/W=VCALC VCALCCtrl_4b 
    688711                        break 
    689712                case "ML": 
     
    691714                case "MT": 
    692715                case "MB": 
    693                         ControlInfo VCALCCtrl_3d 
     716                        ControlInfo/W=VCALC VCALCCtrl_3d 
    694717                        break 
    695718                case "FL": 
     
    697720                case "FT": 
    698721                case "FB": 
    699                         ControlInfo VCALCCtrl_2d 
     722                        ControlInfo/W=VCALC VCALCCtrl_2d 
    700723                        break            
    701724                default: 
     
    709732         
    710733        // VCALCCtrl_1e is Sample Pos to Gate Valve (cm) 
    711         ControlInfo VCALCCtrl_1e 
     734        ControlInfo/W=VCALC VCALCCtrl_1e 
    712735        sdd += V_Value 
    713736         
     
    739762        t_special = 1 
    740763 
    741         ControlInfo VCALCCtrl_0a 
     764        ControlInfo/W=VCALC VCALCCtrl_0a 
    742765        ng = V_Value 
    743766  
     
    858881        endswitch 
    859882 
    860  
    861 //      root:Packages:NIST:VSANS:VCALC:fSubS_qxqy_MLR 
    862 //      root:Packages:NIST:VSANS:VCALC:iBin_qxqy_MLR 
     883// TODO: 
     884// -- I had to put a lot of conditions on when not to try to apply the shadow factor 
     885// to avoid errors when iq had no points in the wave, or incorrectly applying the beamstop to the back panel. 
    863886         
    864887        Variable ii 
     
    868891                ext = StringFromList(ii, extStr, ";") 
    869892                Wave iq = $(folderStr+"iBin_qxqy_"+ext) 
    870                 Wave fs = $(folderStr+"fSubS_qxqy_"+ext) 
    871                 iq = (fs < 0.1) ? iq*0.1 : iq*fs 
    872 //              iq *= fs 
     893                Wave/Z fs = $(folderStr+"fSubS_qxqy_"+ext) 
     894                if(WaveExists(fs) && numpnts(iq) > 0 && cmpstr(ext,"B") != 0) 
     895                        iq = (fs < 0.1) ? iq*0.1 : iq*fs 
     896                endif 
    873897        endfor   
    874898         
    875899        return(0) 
    876900end 
     901 
     902 
     903 
     904// 
     905// instead of setting some of the data to NaN to exclude it, draw a proper mask to be used 
     906// during the I(q) averaging 
     907// 
     908// use both the "hard" and "soft" shadowing 
     909// -- chooses the more "conservative" of the shadowing values (soft value at short SDD + T/B) 
     910// 
     911// the MSK data will be in its ususal location from the initialization. 
     912// 
     913// FL shadows FT, FB, ML 
     914// FR shadows FT, FB, MR 
     915// FT shadows ML, MR, MT 
     916// FB shadows ML, MR, MB 
     917// ML shadows MT, MB, B 
     918// MR shadows MT, MB, B 
     919// MT shadows B 
     920// MB shadows B 
     921// 
     922Function VC_DrawVCALCMask() 
     923 
     924        VC_DrawVCALCMask_FL() 
     925        VC_DrawVCALCMask_FR() 
     926        VC_DrawVCALCMask_FT() 
     927        VC_DrawVCALCMask_FB() 
     928         
     929        VC_DrawVCALCMask_ML() 
     930        VC_DrawVCALCMask_MR() 
     931        VC_DrawVCALCMask_MT() 
     932        VC_DrawVCALCMask_MB() 
     933         
     934        return(0) 
     935end 
     936 
     937// FL shadows FT, FB, ML 
     938Function VC_DrawVCALCMask_FL() 
     939         
     940        Variable pixSizeX,pixSizeY,nPix,nt 
     941 
     942        Variable offset,offset_ML,L2_F,L2_M,delta_L,delta_S,D2 
     943        Variable delta_Xh,delta_Xs,delta_X_pix,delta 
     944        String type,target 
     945 
     946// FL shadows FT,FB,ML 
     947        type = "FL" 
     948 
     949        // lateral offset of FL 
     950        offset = VCALC_getPanelTranslation(type) 
     951        // sample aperture diam [cm] 
     952        D2 = VC_sampleApertureDiam() 
     953        // sdd F         [cm] = sample aperture to detector 
     954        L2_F = VC_calc_L2(type) 
     955        // depth of electronics (L/R panels) 
     956        delta_L = 33            //[cm] 
     957        // offset of 80/20 frame 
     958        delta_S = 2.5           //[cm] 
     959         
     960         
     961        // sdd of FT, or FB, or ML 
     962///// 
     963        target = "FT" 
     964        L2_M = VC_calc_L2(target) 
     965        // mask data 
     966        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     967 
     968// extent of shadow in [cm] (starting point of shadow from center of beam) 
     969// hard 
     970        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     971// soft 
     972        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     973 
     974        //use the smaller shadow value (this means closer to the center, a larger shadow) 
     975        delta = min(delta_Xh,delta_Xs) 
     976 
     977// how many detector tubes to mask? 
     978        pixSizeX = VCALC_getPixSizeX(target) 
     979        pixSizeY = VCALC_getPixSizeY(target) 
     980 
     981        //since "target" is FT, use x-position 
     982        // at what "pixel" does the shadow start? 
     983        delta_X_pix = trunc(delta/pixSizeX)             //pixels from the center 
     984        nPix = VCALC_get_nPix_X(target) 
     985 
     986        if(delta_x_pix < trunc(nPix/2) )                        //still on the left side of the FT panel 
     987                nt = trunc(nPix/2) - delta_x_pix 
     988                mask[0,nt][] = 1 
     989        endif 
     990         
     991///// 
     992        target = "FB" 
     993        L2_M = VC_calc_L2(target) 
     994        // mask data 
     995        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     996 
     997// extent of shadow in [cm] (starting point of shadow from center of beam) 
     998// hard 
     999        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1000// soft 
     1001        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1002 
     1003        //use the smaller shadow value 
     1004        delta = min(delta_Xh,delta_Xs) 
     1005         
     1006// how many detector tubes to mask? 
     1007        pixSizeX = VCALC_getPixSizeX(target) 
     1008        pixSizeY = VCALC_getPixSizeY(target) 
     1009 
     1010        //since "target" is FB, use x-position 
     1011        // at what "pixel" does the shadow start? 
     1012        delta_X_pix = trunc(delta/pixSizeX) 
     1013        nPix = VCALC_get_nPix_X(target) 
     1014 
     1015        if(delta_x_pix < trunc(nPix/2) )                        //still on the left side of the FB panel 
     1016                nt = trunc(nPix/2) - delta_x_pix 
     1017                mask[0,nt][] = 1 
     1018        endif 
     1019 
     1020/// 
     1021// for ML, there can also be lateral offset of the ML panel 
     1022        target = "ML" 
     1023 
     1024        L2_M = VC_calc_L2(target) 
     1025        // mask data 
     1026        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1027 
     1028// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1029// hard 
     1030        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1031// soft 
     1032        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1033 
     1034        //use the smaller shadow value 
     1035        delta = min(delta_Xh,delta_Xs) 
     1036//      delta = delta_Xh 
     1037         
     1038// how many detector tubes to mask? 
     1039        pixSizeX = VCALC_getPixSizeX(target) 
     1040        pixSizeY = VCALC_getPixSizeY(target) 
     1041 
     1042// offset of ML, in "pixels" 
     1043        offset_ML = VCALC_getPanelTranslation(target)/pixSizeX          //[cm] 
     1044        offset_ML = -trunc(offset_ML) 
     1045        //since "target" is ML, use x-position 
     1046        // at what "pixel" does the shadow start? 
     1047        delta_X_pix = trunc(delta/pixSizeX) 
     1048        nPix = VCALC_get_nPix_X(target) 
     1049         
     1050        //is the delta_x_pix still on the left edge of ML? 
     1051        if(delta_x_pix < 0)             //entire panel is shadowed 
     1052                nt = nPix-1 
     1053                mask[0,nt][] = 1 
     1054        else 
     1055                if(delta_X_pix < nPix + offset_ML) 
     1056                        nt = nPix + offset_ML - delta_x_pix 
     1057                        mask[0,nt][] = 1 
     1058                endif 
     1059        endif 
     1060         
     1061        return(0) 
     1062end 
     1063 
     1064// FR shadows FT, FB, MR 
     1065Function VC_DrawVCALCMask_FR() 
     1066         
     1067        Variable pixSizeX,pixSizeY,nPix,nt 
     1068 
     1069        Variable offset,offset_MR,L2_F,L2_M,delta_L,delta_S,D2 
     1070        Variable delta_Xh,delta_Xs,delta_X_pix,delta 
     1071        String type,target 
     1072 
     1073// FR shadows FT, FB, MR 
     1074        type = "FR" 
     1075 
     1076        // lateral offset of FR 
     1077        offset = VCALC_getPanelTranslation(type) 
     1078        // sample aperture diam [cm] 
     1079        D2 = VC_sampleApertureDiam() 
     1080        // sdd F         [cm] = sample aperture to detector 
     1081        L2_F = VC_calc_L2(type) 
     1082        // depth of electronics (L/R panels) 
     1083        delta_L = 33            //[cm] 
     1084        // offset of 80/20 frame 
     1085        delta_S = 2.5           //[cm] 
     1086         
     1087         
     1088        // sdd of FT, or FB, or MR 
     1089///// 
     1090        target = "FT" 
     1091        L2_M = VC_calc_L2(target) 
     1092        // mask data 
     1093        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1094 
     1095// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1096// hard 
     1097        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1098// soft 
     1099        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1100 
     1101        //use the smaller shadow value (this means closer to the center, a larger shadow) 
     1102        delta = min(delta_Xh,delta_Xs) 
     1103 
     1104// how many detector tubes to mask? 
     1105        pixSizeX = VCALC_getPixSizeX(target) 
     1106        pixSizeY = VCALC_getPixSizeY(target) 
     1107 
     1108        //since "target" is FT, use x-position 
     1109        // at what "pixel" does the shadow start? 
     1110        delta_X_pix = trunc(delta/pixSizeX) 
     1111        nPix = VCALC_get_nPix_X(target) 
     1112 
     1113        if(delta_x_pix < trunc(nPix/2) )                        //still on the right side of the FT panel 
     1114                nt = trunc(nPix/2) - delta_x_pix 
     1115                mask[nPix-nt,nPix-1][] = 1 
     1116        endif 
     1117         
     1118///// 
     1119        target = "FB" 
     1120        L2_M = VC_calc_L2(target) 
     1121        // mask data 
     1122        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1123 
     1124// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1125// hard 
     1126        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1127// soft 
     1128        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1129 
     1130        //use the smaller shadow value 
     1131        delta = min(delta_Xh,delta_Xs) 
     1132         
     1133// how many detector tubes to mask? 
     1134        pixSizeX = VCALC_getPixSizeX(target) 
     1135        pixSizeY = VCALC_getPixSizeY(target) 
     1136 
     1137        //since "target" is FB, use x-position 
     1138        // at what "pixel" does the shadow start? 
     1139        delta_X_pix = trunc(delta/pixSizeX) 
     1140        nPix = VCALC_get_nPix_X(target) 
     1141 
     1142        if(delta_x_pix < trunc(nPix/2) )                        //still on the right side of the FB panel 
     1143                nt = trunc(nPix/2) - delta_x_pix 
     1144                mask[nPix-nt,nPix-1][] = 1 
     1145        endif 
     1146 
     1147/// 
     1148// for MR, there can also be lateral offset of the panel 
     1149        target = "MR" 
     1150 
     1151        L2_M = VC_calc_L2(target) 
     1152        // mask data 
     1153        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1154 
     1155// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1156// hard 
     1157        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1158// soft 
     1159        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1160 
     1161        //use the smaller shadow value 
     1162        delta = min(delta_Xh,delta_Xs) 
     1163         
     1164// how many detector tubes to mask? 
     1165        pixSizeX = VCALC_getPixSizeX(target) 
     1166        pixSizeY = VCALC_getPixSizeY(target) 
     1167 
     1168// offset of MR, in "pixels" 
     1169        offset_MR = VCALC_getPanelTranslation(target)/pixSizeX          //[cm] 
     1170        offset_MR = trunc(offset_MR) 
     1171        //since "target" is ML, use x-position 
     1172        // at what "pixel" does the shadow start? 
     1173        nPix = VCALC_get_nPix_X(target) 
     1174         
     1175        delta_X_pix = trunc(delta/pixSizeX) 
     1176         
     1177        //is the delta_x_pix still on the right edge of MR? 
     1178        if(delta_x_pix < 0)             //entire panel is shadowed 
     1179                nt = nPix-1 
     1180                mask[0,nt][] = 1 
     1181        else 
     1182                if(delta_X_pix < nPix + offset_MR) 
     1183                        nt = nPix + offset_MR - delta_x_pix 
     1184                        mask[nPix-nt,nPix-1][] = 1 
     1185                endif 
     1186        endif 
     1187                 
     1188        return(0) 
     1189end 
     1190 
     1191// FT shadows ML, MR, MT 
     1192Function VC_DrawVCALCMask_FT() 
     1193         
     1194        Variable pixSizeX,pixSizeY,nPix,nt 
     1195 
     1196        Variable offset,offset_MT,L2_F,L2_M,delta_L,delta_S,D2 
     1197        Variable delta_Xh,delta_Xs,delta_Y_pix,delta 
     1198        String type,target 
     1199 
     1200// FT shadows ML, MR, MT 
     1201        type = "FT" 
     1202 
     1203        //  offset of FT 
     1204        offset = VCALC_getPanelTranslation(type) 
     1205        // sample aperture diam [cm] 
     1206        D2 = VC_sampleApertureDiam() 
     1207        // sdd F         [cm] = sample aperture to detector 
     1208        L2_F = VC_calc_L2(type) 
     1209        // depth of electronics (T/B panels) 
     1210        delta_L = 61            //[cm] 
     1211        // offset of 80/20 frame 
     1212        delta_S = 2.5           //[cm] 
     1213         
     1214         
     1215        // sdd of ML, or MR, or MT 
     1216///// 
     1217        target = "ML" 
     1218        L2_M = VC_calc_L2(target) 
     1219        // mask data 
     1220        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1221 
     1222// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1223// hard 
     1224        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1225// soft 
     1226        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1227 
     1228        //use the smaller shadow value (this means closer to the center, a larger shadow) 
     1229        delta = min(delta_Xh,delta_Xs) 
     1230 
     1231// how many detector tubes to mask? 
     1232        pixSizeX = VCALC_getPixSizeX(target) 
     1233        pixSizeY = VCALC_getPixSizeY(target) 
     1234 
     1235        //since "target" is ML, use Y-position 
     1236        // at what "pixel" does the shadow start? 
     1237        delta_Y_pix = trunc(delta/pixSizeY) 
     1238        nPix = VCALC_get_nPix_Y(target) 
     1239 
     1240        if(delta_y_pix < trunc(nPix/2)) 
     1241                nt = trunc(nPix/2) - delta_y_pix 
     1242                mask[][nPix-nt,nPix-1] = 1 
     1243        endif 
     1244 
     1245///// 
     1246        target = "MR" 
     1247        L2_M = VC_calc_L2(target) 
     1248        // mask data 
     1249        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1250 
     1251// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1252// hard 
     1253        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1254// soft 
     1255        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1256 
     1257        //use the smaller shadow value 
     1258        delta = min(delta_Xh,delta_Xs) 
     1259 
     1260         
     1261// how many detector tubes to mask? 
     1262        pixSizeX = VCALC_getPixSizeX(target) 
     1263        pixSizeY = VCALC_getPixSizeY(target) 
     1264 
     1265        //since "target" is MR, use y-position 
     1266        // at what "pixel" does the shadow start? 
     1267        delta_y_pix = trunc(delta/pixSizey) 
     1268        nPix = VCALC_get_nPix_Y(target) 
     1269 
     1270        if(delta_y_pix < trunc(nPix/2)) 
     1271                nt = trunc(nPix/2) - delta_y_pix 
     1272                mask[][nPix-nt,nPix-1] = 1 
     1273        endif 
     1274         
     1275/// 
     1276// for MT, there can also be lateral offset of the MT panel 
     1277        target = "MT" 
     1278 
     1279        L2_M = VC_calc_L2(target) 
     1280        // mask data 
     1281        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1282 
     1283// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1284// hard 
     1285        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1286// soft 
     1287        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1288 
     1289        //use the smaller shadow value 
     1290        delta = min(delta_Xh,delta_Xs) 
     1291         
     1292// how many detector tubes to mask? 
     1293        pixSizeX = VCALC_getPixSizeX(target) 
     1294        pixSizeY = VCALC_getPixSizeY(target) 
     1295 
     1296// offset of MT, in "pixels" -in Y-direction 
     1297        offset_MT = VCALC_getPanelTranslation(target)/pixSizeY          //[cm] 
     1298        offset_MT = trunc(offset_MT)  
     1299        //since "target" is MT, use y-position 
     1300        // at what "pixel" does the shadow start? 
     1301        delta_Y_pix = trunc(delta/pixSizeY) 
     1302        nPix = VCALC_get_nPix_Y(target) 
     1303 
     1304        if(delta_Y_pix < nPix + offset_MT) 
     1305                nt = nPix + offset_MT - delta_y_pix 
     1306                mask[][nPix-nt,nPix-1] = 1 
     1307        endif 
     1308         
     1309         
     1310        return(0) 
     1311end 
     1312 
     1313// FB shadows ML, MR, MB 
     1314Function VC_DrawVCALCMask_FB() 
     1315         
     1316        Variable pixSizeX,pixSizeY,nPix,nt 
     1317 
     1318        Variable offset,offset_MB,L2_F,L2_M,delta_L,delta_S,D2 
     1319        Variable delta_Xh,delta_Xs,delta_Y_pix,delta 
     1320        String type,target 
     1321 
     1322// FB shadows ML, MR, MB 
     1323        type = "FB" 
     1324 
     1325        //  offset of FB 
     1326        offset = VCALC_getPanelTranslation(type) 
     1327         
     1328        // sample aperture diam [cm] 
     1329        D2 = VC_sampleApertureDiam() 
     1330        // sdd F         [cm] = sample aperture to detector 
     1331        L2_F = VC_calc_L2(type) 
     1332        // depth of electronics (T/B panels) 
     1333        delta_L = 61            //[cm] 
     1334        // offset of 80/20 frame 
     1335        delta_S = 2.5           //[cm] 
     1336         
     1337         
     1338        // sdd of ML, or MR, or MB 
     1339///// 
     1340        target = "ML" 
     1341        L2_M = VC_calc_L2(target) 
     1342        // mask data 
     1343        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1344 
     1345// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1346// hard 
     1347        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1348// soft 
     1349        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1350 
     1351        //use the smaller shadow value (this means closer to the center, a larger shadow) 
     1352        delta = min(delta_Xh,delta_Xs) 
     1353 
     1354         
     1355// how many detector tubes to mask? 
     1356        pixSizeX = VCALC_getPixSizeX(target) 
     1357        pixSizeY = VCALC_getPixSizeY(target) 
     1358 
     1359        //since "target" is ML, use Y-position 
     1360        // at what "pixel" does the shadow start? 
     1361        delta_Y_pix = trunc(delta/pixSizeY) 
     1362        nPix = VCALC_get_nPix_Y(target) 
     1363 
     1364        if(delta_y_pix < trunc(nPix/2)) 
     1365                nt = trunc(nPix/2) - delta_y_pix 
     1366                mask[][0,nt] = 1 
     1367        endif 
     1368         
     1369///// 
     1370        target = "MR" 
     1371        L2_M = VC_calc_L2(target) 
     1372        // mask data 
     1373        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1374 
     1375// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1376// hard 
     1377        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1378// soft 
     1379        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1380 
     1381        //use the smaller shadow value 
     1382        delta = min(delta_Xh,delta_Xs) 
     1383         
     1384// how many detector tubes to mask? 
     1385        pixSizeX = VCALC_getPixSizeX(target) 
     1386        pixSizeY = VCALC_getPixSizeY(target) 
     1387 
     1388        //since "target" is MR, use y-position 
     1389        // at what "pixel" does the shadow start? 
     1390        delta_y_pix = trunc(delta/pixSizeY) 
     1391        nPix = VCALC_get_nPix_Y(target) 
     1392 
     1393        if(delta_y_pix < trunc(nPix/2)) 
     1394                nt = trunc(nPix/2) - delta_y_pix 
     1395                mask[][0,nt] = 1 
     1396        endif 
     1397         
     1398/// 
     1399// for MB, there can also be lateral offset of the MT panel 
     1400        target = "MB" 
     1401 
     1402        L2_M = VC_calc_L2(target) 
     1403        // mask data 
     1404        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1405 
     1406// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1407// hard 
     1408        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1409// soft 
     1410        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1411 
     1412        //use the smaller shadow value 
     1413        delta = min(delta_Xh,delta_Xs) 
     1414         
     1415// how many detector tubes to mask? 
     1416        pixSizeX = VCALC_getPixSizeX(target) 
     1417        pixSizeY = VCALC_getPixSizeY(target) 
     1418 
     1419// offset of MT, in "pixels" -in Y-direction 
     1420        offset_MB = VCALC_getPanelTranslation(target)/pixSizeY          //[cm] 
     1421        offset_MB = -trunc(offset_MB) 
     1422        //since "target" is MT, use y-position 
     1423        // at what "pixel" does the shadow start? 
     1424        delta_Y_pix = trunc(delta/pixSizeY) 
     1425        nPix = VCALC_get_nPix_Y(target) 
     1426 
     1427        if(delta_Y_pix < nPix + offset_MB) 
     1428                nt = nPix + offset_MB - delta_y_pix 
     1429                mask[][0,nt] = 1 
     1430        endif 
     1431         
     1432 
     1433        return(0) 
     1434end 
     1435 
     1436// ML shadows MT, MB, B 
     1437Function VC_DrawVCALCMask_ML() 
     1438         
     1439        Variable pixSizeX,pixSizeY,nPix,nt 
     1440 
     1441        Variable offset,offset_B,L2_F,L2_M,delta_L,delta_S,D2 
     1442        Variable delta_Xh,delta_Xs,delta_X_pix,delta 
     1443        String type,target 
     1444 
     1445// ML shadows MT, MB, B 
     1446        type = "ML" 
     1447 
     1448        // lateral offset of ML 
     1449        offset = VCALC_getPanelTranslation(type) 
     1450        // sample aperture diam [cm] 
     1451        D2 = VC_sampleApertureDiam() 
     1452        // sdd F         [cm] = sample aperture to detector 
     1453        L2_F = VC_calc_L2(type) 
     1454        // depth of electronics (L/R panels) 
     1455        delta_L = 33            //[cm] 
     1456        // offset of 80/20 frame 
     1457        delta_S = 2.5           //[cm] 
     1458         
     1459         
     1460        // sdd of MT, or MB, or B 
     1461///// 
     1462        target = "MT" 
     1463        L2_M = VC_calc_L2(target) 
     1464        // mask data 
     1465        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1466 
     1467// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1468// hard 
     1469        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1470// soft 
     1471        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1472 
     1473        //use the smaller shadow value (this means closer to the center, a larger shadow) 
     1474        delta = min(delta_Xh,delta_Xs) 
     1475 
     1476// how many detector tubes to mask? 
     1477        pixSizeX = VCALC_getPixSizeX(target) 
     1478        pixSizeY = VCALC_getPixSizeY(target) 
     1479 
     1480        //since "target" is FT, use x-position 
     1481        // at what "pixel" does the shadow start? 
     1482        delta_X_pix = trunc(delta/pixSizeX)             //pixels from the center 
     1483        nPix = VCALC_get_nPix_X(target) 
     1484 
     1485        if(delta_x_pix < trunc(nPix/2) )                        //still on the left side of the FT panel 
     1486                nt = trunc(nPix/2) - delta_x_pix 
     1487                mask[0,nt][] = 1 
     1488        endif 
     1489         
     1490///// 
     1491        target = "MB" 
     1492        L2_M = VC_calc_L2(target) 
     1493        // mask data 
     1494        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1495 
     1496// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1497// hard 
     1498        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1499// soft 
     1500        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1501 
     1502        //use the smaller shadow value 
     1503        delta = min(delta_Xh,delta_Xs) 
     1504         
     1505// how many detector tubes to mask? 
     1506        pixSizeX = VCALC_getPixSizeX(target) 
     1507        pixSizeY = VCALC_getPixSizeY(target) 
     1508 
     1509        //since "target" is MB, use x-position 
     1510        // at what "pixel" does the shadow start? 
     1511        delta_X_pix = trunc(delta/pixSizeX) 
     1512        nPix = VCALC_get_nPix_X(target) 
     1513 
     1514        if(delta_x_pix < trunc(nPix/2) )                        //still on the left side of the MB panel 
     1515                nt = trunc(nPix/2) - delta_x_pix 
     1516                mask[0,nt][] = 1 
     1517        endif 
     1518 
     1519/// 
     1520// for B, there can also be lateral offset of the B panel 
     1521        target = "B" 
     1522 
     1523        L2_M = VC_calc_L2(target) 
     1524        // mask data 
     1525        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1526 
     1527// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1528// hard 
     1529        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1530// soft 
     1531        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1532 
     1533        //use the smaller shadow value 
     1534        delta = min(delta_Xh,delta_Xs) 
     1535//      delta = delta_Xh 
     1536         
     1537// how many detector tubes to mask? 
     1538        pixSizeX = VCALC_getPixSizeX(target) 
     1539        pixSizeY = VCALC_getPixSizeY(target) 
     1540 
     1541// offset of B, in "pixels" 
     1542        offset_B = VCALC_getPanelTranslation(target)/pixSizeX           //[cm] 
     1543        offset_B = -trunc(offset_B) 
     1544        //since "target" is B, use x-position 
     1545        // at what "pixel" does the shadow start? 
     1546        delta_X_pix = trunc(delta/pixSizeX) 
     1547        nPix = VCALC_get_nPix_X(target) 
     1548         
     1549        //is the delta_x_pix still on the left edge of B? 
     1550        if(delta_x_pix < 0)             //entire panel is shadowed 
     1551                nt = nPix-1 
     1552                mask[0,nt][] = 1 
     1553        else 
     1554                if(delta_X_pix < nPix + offset_B) 
     1555                        nt = nPix + offset_B - delta_x_pix 
     1556                        mask[0,nt][] = 1 
     1557                endif 
     1558        endif 
     1559         
     1560        return(0) 
     1561end 
     1562 
     1563// MR shadows MT, MB, B 
     1564Function VC_DrawVCALCMask_MR() 
     1565         
     1566        Variable pixSizeX,pixSizeY,nPix,nt 
     1567 
     1568        Variable offset,offset_B,L2_F,L2_M,delta_L,delta_S,D2 
     1569        Variable delta_Xh,delta_Xs,delta_X_pix,delta 
     1570        String type,target 
     1571 
     1572// MR shadows MT, MB, B 
     1573        type = "MR" 
     1574 
     1575        // lateral offset of FR 
     1576        offset = VCALC_getPanelTranslation(type) 
     1577        // sample aperture diam [cm] 
     1578        D2 = VC_sampleApertureDiam() 
     1579        // sdd F         [cm] = sample aperture to detector 
     1580        L2_F = VC_calc_L2(type) 
     1581        // depth of electronics (L/R panels) 
     1582        delta_L = 33            //[cm] 
     1583        // offset of 80/20 frame 
     1584        delta_S = 2.5           //[cm] 
     1585         
     1586         
     1587        // sdd of MT, or MB, or B 
     1588///// 
     1589        target = "MT" 
     1590        L2_M = VC_calc_L2(target) 
     1591        // mask data 
     1592        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1593 
     1594// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1595// hard 
     1596        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1597// soft 
     1598        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1599 
     1600        //use the smaller shadow value (this means closer to the center, a larger shadow) 
     1601        delta = min(delta_Xh,delta_Xs) 
     1602 
     1603// how many detector tubes to mask? 
     1604        pixSizeX = VCALC_getPixSizeX(target) 
     1605        pixSizeY = VCALC_getPixSizeY(target) 
     1606 
     1607        //since "target" is MT, use x-position 
     1608        // at what "pixel" does the shadow start? 
     1609        delta_X_pix = trunc(delta/pixSizeX) 
     1610        nPix = VCALC_get_nPix_X(target) 
     1611 
     1612        if(delta_x_pix < trunc(nPix/2) )                        //still on the right side of the MT panel 
     1613                nt = trunc(nPix/2) - delta_x_pix 
     1614                mask[nPix-nt,nPix-1][] = 1 
     1615        endif 
     1616         
     1617///// 
     1618        target = "MB" 
     1619        L2_M = VC_calc_L2(target) 
     1620        // mask data 
     1621        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1622 
     1623// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1624// hard 
     1625        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1626// soft 
     1627        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1628 
     1629        //use the smaller shadow value 
     1630        delta = min(delta_Xh,delta_Xs) 
     1631         
     1632// how many detector tubes to mask? 
     1633        pixSizeX = VCALC_getPixSizeX(target) 
     1634        pixSizeY = VCALC_getPixSizeY(target) 
     1635 
     1636        //since "target" is FB, use x-position 
     1637        // at what "pixel" does the shadow start? 
     1638        delta_X_pix = trunc(delta/pixSizeX) 
     1639        nPix = VCALC_get_nPix_X(target) 
     1640 
     1641        if(delta_x_pix < trunc(nPix/2) )                        //still on the right side of the MB panel 
     1642                nt = trunc(nPix/2) - delta_x_pix 
     1643                mask[nPix-nt,nPix-1][] = 1 
     1644        endif 
     1645 
     1646/// 
     1647// for B, there can also be lateral offset of the panel 
     1648        target = "B" 
     1649 
     1650        L2_M = VC_calc_L2(target) 
     1651        // mask data 
     1652        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1653 
     1654// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1655// hard 
     1656        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1657// soft 
     1658        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1659 
     1660        //use the smaller shadow value 
     1661        delta = min(delta_Xh,delta_Xs) 
     1662         
     1663// how many detector tubes to mask? 
     1664        pixSizeX = VCALC_getPixSizeX(target) 
     1665        pixSizeY = VCALC_getPixSizeY(target) 
     1666 
     1667// offset of B, in "pixels" 
     1668        offset_B = VCALC_getPanelTranslation(target)/pixSizeX           //[cm] 
     1669        offset_B = trunc(offset_B) 
     1670        //since "target" is B, use x-position 
     1671        // at what "pixel" does the shadow start? 
     1672        nPix = VCALC_get_nPix_X(target) 
     1673         
     1674        delta_X_pix = trunc(delta/pixSizeX) 
     1675         
     1676        //is the delta_x_pix still on the right edge of B? 
     1677        if(delta_x_pix < 0)             //entire panel is shadowed 
     1678                nt = nPix-1 
     1679                mask[0,nt][] = 1 
     1680        else 
     1681                if(delta_X_pix < nPix + offset_B) 
     1682                        nt = nPix + offset_B - delta_x_pix 
     1683                        mask[nPix-nt,nPix-1][] = 1 
     1684                endif 
     1685        endif 
     1686         
     1687        return(0) 
     1688end 
     1689 
     1690 
     1691// MT shadows B 
     1692Function VC_DrawVCALCMask_MT() 
     1693         
     1694        Variable pixSizeX,pixSizeY,nPix,nt 
     1695 
     1696        Variable offset,offset_B,L2_F,L2_M,delta_L,delta_S,D2 
     1697        Variable delta_Xh,delta_Xs,delta_Y_pix,delta 
     1698        String type,target 
     1699 
     1700// MT shadows B 
     1701        type = "MT" 
     1702 
     1703        //  offset of MT 
     1704        offset = VCALC_getPanelTranslation(type) 
     1705        // sample aperture diam [cm] 
     1706        D2 = VC_sampleApertureDiam() 
     1707        // sdd F         [cm] = sample aperture to detector 
     1708        L2_F = VC_calc_L2(type) 
     1709        // depth of electronics (T/B panels) 
     1710        delta_L = 61            //[cm] 
     1711        // offset of 80/20 frame 
     1712        delta_S = 2.5           //[cm] 
     1713         
     1714         
     1715        // sdd of ML, or MR, or MT 
     1716/////// 
     1717//      target = "ML" 
     1718//      L2_M = VC_calc_L2(target) 
     1719//      // mask data 
     1720//      Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1721// 
     1722//// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1723//// hard 
     1724//      delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1725//// soft 
     1726//      delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1727// 
     1728//      //use the smaller shadow value (this means closer to the center, a larger shadow) 
     1729//      delta = min(delta_Xh,delta_Xs) 
     1730// 
     1731//// how many detector tubes to mask? 
     1732//      pixSizeX = VCALC_getPixSizeX(target) 
     1733//      pixSizeY = VCALC_getPixSizeY(target) 
     1734// 
     1735//      //since "target" is ML, use Y-position 
     1736//      // at what "pixel" does the shadow start? 
     1737//      delta_Y_pix = trunc(delta/pixSizeY) 
     1738//      nPix = VCALC_get_nPix_Y(target) 
     1739// 
     1740//      if(delta_y_pix < trunc(nPix/2)) 
     1741//              nt = trunc(nPix/2) - delta_y_pix 
     1742//              mask[][nPix-nt,nPix-1] = 1 
     1743//      endif 
     1744 
     1745///// 
     1746//      target = "MR" 
     1747//      L2_M = VC_calc_L2(target) 
     1748//      // mask data 
     1749//      Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1750// 
     1751//// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1752//// hard 
     1753//      delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1754//// soft 
     1755//      delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1756// 
     1757//      //use the smaller shadow value 
     1758//      delta = min(delta_Xh,delta_Xs) 
     1759// 
     1760//       
     1761//// how many detector tubes to mask? 
     1762//      pixSizeX = VCALC_getPixSizeX(target) 
     1763//      pixSizeY = VCALC_getPixSizeY(target) 
     1764// 
     1765//      //since "target" is MR, use y-position 
     1766//      // at what "pixel" does the shadow start? 
     1767//      delta_y_pix = trunc(delta/pixSizey) 
     1768//      nPix = VCALC_get_nPix_Y(target) 
     1769// 
     1770//      if(delta_y_pix < trunc(nPix/2)) 
     1771//              nt = trunc(nPix/2) - delta_y_pix 
     1772//              mask[][nPix-nt,nPix-1] = 1 
     1773//      endif 
     1774         
     1775/// 
     1776// for B, there can also be lateral offset of the B panel 
     1777        target = "B" 
     1778 
     1779        L2_M = VC_calc_L2(target) 
     1780        // mask data 
     1781        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1782 
     1783// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1784// hard 
     1785        delta_Xh = D2/2 + (offset - D2/2)*(L2_M/L2_F) 
     1786// soft 
     1787        delta_Xs = D2/2 + (offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1788 
     1789        //use the smaller shadow value 
     1790        delta = min(delta_Xh,delta_Xs) 
     1791         
     1792// how many detector tubes to mask? 
     1793        pixSizeX = VCALC_getPixSizeX(target) 
     1794        pixSizeY = VCALC_getPixSizeY(target) 
     1795 
     1796// offset of B, in "pixels" -in Y-direction 
     1797        offset_B = VCALC_getPanelTranslation(target)/pixSizeY           //[cm] 
     1798        offset_B = trunc(offset_B)  
     1799        //since "target" is B, use y-position 
     1800        // at what "pixel" does the shadow start? 
     1801        delta_Y_pix = trunc(delta/pixSizeY) 
     1802        nPix = VCALC_get_nPix_Y(target) 
     1803 
     1804        if(delta_y_pix < trunc(nPix/2)) 
     1805                nt = trunc(nPix/2) - delta_y_pix 
     1806                mask[][nPix-nt,nPix-1] = 1 
     1807        endif 
     1808         
     1809        return(0) 
     1810end 
     1811 
     1812// MB shadows B 
     1813Function VC_DrawVCALCMask_MB() 
     1814         
     1815        Variable pixSizeX,pixSizeY,nPix,nt 
     1816 
     1817        Variable offset,offset_B,L2_F,L2_M,delta_L,delta_S,D2 
     1818        Variable delta_Xh,delta_Xs,delta_Y_pix,delta 
     1819        String type,target 
     1820 
     1821// MB shadows B 
     1822        type = "MB" 
     1823 
     1824        //  offset of MB 
     1825        offset = VCALC_getPanelTranslation(type) 
     1826         
     1827        // sample aperture diam [cm] 
     1828        D2 = VC_sampleApertureDiam() 
     1829        // sdd F         [cm] = sample aperture to detector 
     1830        L2_F = VC_calc_L2(type) 
     1831        // depth of electronics (T/B panels) 
     1832        delta_L = 61            //[cm] 
     1833        // offset of 80/20 frame 
     1834        delta_S = 2.5           //[cm] 
     1835         
     1836         
     1837        // sdd of ML, or MR, or MB 
     1838///// 
     1839//      target = "ML" 
     1840//      L2_M = VC_calc_L2(target) 
     1841//      // mask data 
     1842//      Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1843// 
     1844//// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1845//// hard 
     1846//      delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1847//// soft 
     1848//      delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1849// 
     1850//      //use the smaller shadow value (this means closer to the center, a larger shadow) 
     1851//      delta = min(delta_Xh,delta_Xs) 
     1852// 
     1853//       
     1854//// how many detector tubes to mask? 
     1855//      pixSizeX = VCALC_getPixSizeX(target) 
     1856//      pixSizeY = VCALC_getPixSizeY(target) 
     1857// 
     1858//      //since "target" is ML, use Y-position 
     1859//      // at what "pixel" does the shadow start? 
     1860//      delta_Y_pix = trunc(delta/pixSizeY) 
     1861//      nPix = VCALC_get_nPix_Y(target) 
     1862// 
     1863//      if(delta_y_pix < trunc(nPix/2)) 
     1864//              nt = trunc(nPix/2) - delta_y_pix 
     1865//              mask[][0,nt] = 1 
     1866//      endif 
     1867         
     1868///// 
     1869//      target = "MR" 
     1870//      L2_M = VC_calc_L2(target) 
     1871//      // mask data 
     1872//      Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1873// 
     1874//// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1875//// hard 
     1876//      delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1877//// soft 
     1878//      delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1879// 
     1880//      //use the smaller shadow value 
     1881//      delta = min(delta_Xh,delta_Xs) 
     1882//       
     1883//// how many detector tubes to mask? 
     1884//      pixSizeX = VCALC_getPixSizeX(target) 
     1885//      pixSizeY = VCALC_getPixSizeY(target) 
     1886// 
     1887//      //since "target" is MR, use y-position 
     1888//      // at what "pixel" does the shadow start? 
     1889//      delta_y_pix = trunc(delta/pixSizeY) 
     1890//      nPix = VCALC_get_nPix_Y(target) 
     1891// 
     1892//      if(delta_y_pix < trunc(nPix/2)) 
     1893//              nt = trunc(nPix/2) - delta_y_pix 
     1894//              mask[][0,nt] = 1 
     1895//      endif 
     1896         
     1897/// 
     1898// for B, there can also be lateral offset of the B panel 
     1899        target = "B" 
     1900 
     1901        L2_M = VC_calc_L2(target) 
     1902        // mask data 
     1903        Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+target+":data") 
     1904 
     1905// extent of shadow in [cm] (starting point of shadow from center of beam) 
     1906// hard 
     1907        delta_Xh = D2/2 + (-offset - D2/2)*(L2_M/L2_F) 
     1908// soft 
     1909        delta_Xs = D2/2 + (-offset + delta_S - D2/2)*(L2_M/(L2_F+delta_L)) 
     1910 
     1911        //use the smaller shadow value 
     1912        delta = min(delta_Xh,delta_Xs) 
     1913         
     1914// how many detector tubes to mask? 
     1915        pixSizeX = VCALC_getPixSizeX(target) 
     1916        pixSizeY = VCALC_getPixSizeY(target) 
     1917 
     1918// offset of B, in "pixels" -in Y-direction 
     1919        offset_B = VCALC_getPanelTranslation(target)/pixSizeY           //[cm] 
     1920        offset_B = -trunc(offset_B) 
     1921        //since "target" is MT, use y-position 
     1922        // at what "pixel" does the shadow start? 
     1923        delta_Y_pix = trunc(delta/pixSizeY) 
     1924        nPix = VCALC_get_nPix_Y(target) 
     1925 
     1926        if(delta_y_pix < trunc(nPix/2)) 
     1927                nt = trunc(nPix/2) - delta_y_pix 
     1928                mask[][0,nt] = 1 
     1929        endif 
     1930 
     1931        return(0) 
     1932end 
     1933 
     1934 
     1935 
     1936 
     1937// 
     1938// resets the mask to 0 = (use all) 
     1939// 
     1940Function VC_ResetVCALCMask() 
     1941 
     1942        Variable ii 
     1943        String detStr 
     1944         
     1945        for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) 
     1946                detStr = StringFromList(ii, ksDetectorListAll, ";") 
     1947                Wave mask = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
     1948                mask = 0         
     1949        endfor 
     1950         
     1951        return(0) 
     1952end 
     1953 
     1954 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf

    r1130 r1133  
    2525                //open the panel 
    2626                DrawVCALC_Panel() 
     27 
     28                // check for a mask, if not present, generate a default mask (this will be updated later) 
     29                if(!Exists("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_FT:data")) 
     30                        V_GenerateDefaultMask() 
     31                endif 
    2732                 
    2833                // two graphs with the ray-tracing side/top views 
     
    3338                FrontView_1x() 
    3439                 
    35                 // TODO: fake a "click" on the front SDD to force (almost)everything to update 
    36                 // including the I(q) graph 
    37                 FakeFrontMiddleSDDClick() 
    38  
     40                // pop one of the presets to get everything to update 
     41                VC_Preset_WhiteBeam() 
     42                 
     43                // update the views 
     44                VC_UpdateViews() 
     45                 
     46                // a recalculation is needed after the change 
     47                // this re-bins the I(q) data too 
     48                Recalculate_AllDetectors() 
     49                 
    3950        endif 
    4051End 
     
    6879        TabControl Vtab,tabLabel(4)="Back Det",tabLabel(5)="Simul",value= 0,proc=VCALCTabProc 
    6980        GroupBox group1,pos={460,10},size={762,635},title="Detector Panel Positions + Data" 
     81        Button button_a,pos={250,70},size={100,20},title="Show Mask",proc=V_VCALCShowMaskButtonProc 
     82        Button button_b,pos={250,100},size={100,20},title="Recalculate",proc=V_VCALCRecalcButtonProc 
     83 
    7084 
    7185        PopupMenu popup_a,pos={50,40},size={142,20},title="Presets" 
    72         PopupMenu popup_a,mode=1,popvalue="F+M Ng0 Low Q",value= root:Packages:NIST:VSANS:VCALC:gPresetPopStr 
     86        PopupMenu popup_a,mode=1,popvalue="White Beam",value= root:Packages:NIST:VSANS:VCALC:gPresetPopStr 
    7387        PopupMenu popup_a,proc=VC_PresetConfigPopup 
    7488 
     
    7690        PopupMenu popup_b,mode=1,value= root:Packages:NIST:VSANS:VCALC:gBinTypeStr 
    7791        SetVariable setVar_b,pos={476,313},size={120,15},title="axis Q",proc=Front2DQ_Range_SetVarProc 
    78         SetVariable setVar_b,limits={0.02,1,0.02},value=_NUM:0.3 
     92        SetVariable setVar_b,limits={0.02,1,0.02},value=_NUM:0.52 
    7993        CheckBox check_0a title="Log?",size={60,20},pos={619,313},proc=Front2DQ_Log_CheckProc 
    8094                 
    8195        SetVariable setVar_a,pos={476,26},size={120,15},title="axis degrees",proc=FrontView_Range_SetVarProc 
    82         SetVariable setVar_a,limits={0.3,30,0.2},value=_NUM:20 
    83  
    84         ValDisplay valDisp_a,pos={50,380},size={150,15},title="Beam Intensity",value=root:Packages:NIST:VSANS:VCALC:gBeamIntensity 
    85  
    86         ValDisplay valDisp_b,pos={50,410},size={150,15},title="Q min (Front) (1/A)",value=root:Packages:NIST:VSANS:VCALC:gQmin_F 
    87         ValDisplay valDisp_c,pos={250,410},size={150,15},title="Q max (Front) (1/A)",value=root:Packages:NIST:VSANS:VCALC:gQmax_F 
    88         ValDisplay valDisp_d,pos={50,440},size={150,15},title="Q min (Mid) (1/A)",value=root:Packages:NIST:VSANS:VCALC:gQmin_M 
    89         ValDisplay valDisp_e,pos={250,440},size={150,15},title="Q max (Mid) (1/A)",value=root:Packages:NIST:VSANS:VCALC:gQmax_M 
    90         ValDisplay valDisp_f,pos={50,470},size={150,15},title="Q min (Back) (1/A)",value=root:Packages:NIST:VSANS:VCALC:gQmin_B 
    91         ValDisplay valDisp_g,pos={250,470},size={150,15},title="Q max (Back) (1/A)",value=root:Packages:NIST:VSANS:VCALC:gQmax_B 
    92         ValDisplay valDisp_h,pos={50,500},size={200,15},title="Beam Diam (middle) (cm)",value=root:Packages:NIST:VSANS:VCALC:gBeamDiam 
    93         ValDisplay valDisp_i,pos={50,530},size={200,15},title="Beam Stop Diam (middle) (in)",value=root:Packages:NIST:VSANS:VCALC:gBeamStopDiam 
    94         ValDisplay valDisp_j,pos={50,560},size={200,15},title="Real Q min (1/A)",value=root:Packages:NIST:VSANS:VCALC:gRealQMin 
     96        SetVariable setVar_a,limits={0.3,30,0.2},value=_NUM:28 
     97 
     98        ValDisplay valDisp_a,pos={30,380},size={150,15},fstyle=1,title="Beam Intensity",value=root:Packages:NIST:VSANS:VCALC:gBeamIntensity 
     99 
     100        SetDrawEnv fstyle= 1 
     101        DrawText 30,420,"Back" 
     102        DrawText 80,420,"Q min" 
     103        DrawText 150,420,"Q max" 
     104        ValDisplay valDisp_b,pos={30,420},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmin_B 
     105        ValDisplay valDisp_c,pos={130,420},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmax_B 
     106 
     107        SetDrawEnv fstyle= 1 
     108        DrawText 130,460,"Middle" 
     109        DrawText 180,460,"Q min" 
     110        DrawText 250,460,"Q max"         
     111        ValDisplay valDisp_d,pos={130,460},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmin_M 
     112        ValDisplay valDisp_e,pos={230,460},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmax_M 
     113 
     114        SetDrawEnv fstyle= 1 
     115        DrawText 230,500,"Front"         
     116        DrawText 280,500,"Q min" 
     117        DrawText 350,500,"Q max"         
     118        ValDisplay valDisp_f,pos={230,500},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmin_F 
     119        ValDisplay valDisp_g,pos={330,500},size={100,15},title="",value=root:Packages:NIST:VSANS:VCALC:gQmax_F 
     120 
     121 
     122        ValDisplay valDisp_h,pos={50,530},size={200,15},title="Beam Diam (middle) (cm)",value=root:Packages:NIST:VSANS:VCALC:gBeamDiam 
     123        ValDisplay valDisp_i,pos={50,560},size={200,15},title="Beam Stop Diam (middle) (in)",value=root:Packages:NIST:VSANS:VCALC:gBeamStopDiam 
     124        ValDisplay valDisp_j,pos={50,590},size={200,15},title="Beam Stop Q min (1/A)",value=root:Packages:NIST:VSANS:VCALC:gRealQMin 
    95125 
    96126 
     
    116146        ModifyGraph tick=2,mirror=1 
    117147        Label left "Vertical position (cm)" 
    118         Label bottom "SDD (cm)"  
     148        Label bottom "SDD (cm)" 
     149        SetAxis/A/R left         
    119150        SetActiveSubwindow ##    
    120151         
     
    234265End 
    235266 
     267Function V_VCALCShowMaskButtonProc(ba) : ButtonControl 
     268        STRUCT WMButtonAction &ba 
     269 
     270        switch( ba.eventCode ) 
     271                case 2: // mouse up 
     272                        // click code here 
     273                         
     274                        V_SetupPanelDisplay() 
     275                         
     276                        PopupMenu popup1 win=VSANS_Det_Panels,mode=14,popvalue="VCALC" 
     277                        PopupMenu popup0 win=VSANS_Det_Panels,popvalue="F" 
     278                        ControlUpdate/A/W=VSANS_Det_Panels 
     279 
     280                //pop the carriage menu to refresh the VCALC data 
     281                        STRUCT WMPopupAction pa 
     282                        pa.eventCode = 2                //fake click 
     283                        V_PickCarriagePopMenuProc(pa) 
     284                         
     285// risky, but I can pass the button "click" to the next button to toggle the mask "On"                   
     286                        V_ToggleFourMaskButtonProc(ba) 
     287                         
     288                        break 
     289                case -1: // control being killed 
     290                        break 
     291        endswitch 
     292 
     293        return 0 
     294End 
     295 
     296 
     297 
     298Function V_VCALCRecalcButtonProc(ba) : ButtonControl 
     299        STRUCT WMButtonAction &ba 
     300 
     301        switch( ba.eventCode ) 
     302                case 2: // mouse up 
     303                        // click code here 
     304                         
     305                        Recalculate_AllDetectors() 
     306                                 
     307                        break 
     308                case -1: // control being killed 
     309                        break 
     310        endswitch 
     311 
     312        return 0 
     313End 
     314 
    236315// 
    237316//  recalculates the detector panels, doesn't adjust the views 
     
    241320// calculates Q for each panel 
    242321// and fills 2D panels with model data 
     322// then plots the 2D panel 
    243323        fPlotBackPanels() 
    244324        fPlotMiddlePanels() 
    245325        fPlotFrontPanels() 
    246326 
     327// generate a proper mask based on hard+soft shadowing 
     328        VC_ResetVCALCMask() 
     329        VC_DrawVCALCMask() 
     330 
     331 
     332// generate the 1D I(q) 
    247333        String popStr 
    248334        String collimationStr = "pinhole" 
     
    251337        V_QBinAllPanels_Circular("VCALC",V_BinTypeStr2Num(popStr),collimationStr) 
    252338 
    253  
    254339        // plot the results (1D) 
    255340        String type = "VCALC" 
     
    265350 
    266351 
    267  
    268  
    269          
     352// update values on the panel 
    270353        V_beamIntensity() 
    271354         
    272355//      Print "Beam diam (middle) = ",VC_beamDiameter("horizontal",2)           //middle carriage 
    273356         
    274         // fill in the Qmin and Qmax values 
     357        // fill in the Qmin and Qmax values, based on Q_Tot for the 2D panels (not including mask) 
    275358        V_QMinMax_Back() 
    276359        V_QMinMax_Middle() 
     
    10541137// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing 
    10551138// so keep them as variables 
    1056         Variable/G gFront_LR_w = 38.4           //front bank, nominal LR panel width [cm] 
     1139        Variable/G gFront_LR_w = 40.3           //front bank, nominal LR panel width [cm]  0.84cm/tube*48 = 40.3 cm 
    10571140        Variable/G gFront_LR_h = 100.0 
    10581141        Variable/G gFront_TB_w = 50.0 
    1059         Variable/G gFront_TB_h = 38.4 
     1142        Variable/G gFront_TB_h = 40.3 
    10601143 
    10611144// SDD setback of T/B (decide on units??) 
     
    11041187// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing 
    11051188// so keep them as variables 
    1106         Variable/G gMiddle_LR_w = 38.4          //middle bank, nominal LR panel width (cm) 
     1189        Variable/G gMiddle_LR_w = 40.3                  //middle bank, nominal LR panel width (cm) 0.84cm/tube*48 = 40.3 cm 
    11071190        Variable/G gMiddle_LR_h = 100.0 
    11081191        Variable/G gMiddle_TB_w = 50.0 
    1109         Variable/G gMiddle_TB_h = 38.4 
     1192        Variable/G gMiddle_TB_h = 40.3 
    11101193// SDD offset of T/B (decide on units??) 
    11111194// for the Nexus file, the detector distance should already be corrected for the "setback" 
     
    12841367//      // for the panel 
    12851368 
    1286         Variable/G gNg=0 
     1369//      Variable/G gNg=0 
    12871370//      Variable/G gOffset=0 
    1288         Variable/G gSamAp=1.27          //samAp diameter in cm 
     1371//      Variable/G gSamAp=1.27          //samAp diameter in cm 
    12891372//      String/G gSourceApString = "1.43 cm;2.54 cm;3.81 cm;" 
    1290         String/G gApPopStr = "1/16\";1/8\";3/16\";1/4\";5/16\";3/8\";7/16\";1/2\";9/16\";5/8\";11/16\";3/4\";other;" 
    1291         Variable/G gSamApOther = 10             //non-standard aperture diameter, in mm 
    1292         Variable/G gUsingLenses = 0             //0=no lenses, 1=lenses(or prisms) 
     1373//      String/G gApPopStr = "1/16\";1/8\";3/16\";1/4\";5/16\";3/8\";7/16\";1/2\";9/16\";5/8\";11/16\";3/4\";other;" 
     1374//      Variable/G gSamApOther = 10             //non-standard aperture diameter, in mm 
     1375//      Variable/G gUsingLenses = 0             //0=no lenses, 1=lenses(or prisms) 
    12931376//      Variable/G gModelOffsetFactor = 1 
    12941377//       
     
    13341417//      Variable/G gDoTraceOffset=0             // (1==Yes, offset 2^n), 0==turn off the offset 
    13351418 
    1336  
    1337  
    13381419// 
    13391420// instrument - specific dimensions 
     
    13411422 
    13421423//       
    1343         Variable/G gInstrument = 6              // files (may) be tagged SA6 as the 6th SANS instrument 
    1344         Variable/G gS12 = 54.8 
     1424//      Variable/G gInstrument = 6              // files (may) be tagged SA6 as the 6th SANS instrument 
     1425//      Variable/G gS12 = 54.8 
    13451426//      Variable/G d_det = 0.5 
    13461427//      Variable/G a_pixel = 0.5 
    13471428//      Variable/G del_r = 0.5 
    13481429//      Variable/G det_width = 64.0 
    1349         Variable/G gLambda_t = 5.50 
    1350         Variable/G gL2r_lower = 132.3 
    1351         Variable/G gL2r_upper =  1317 
    1352         Variable/G gLambda_lower = 2.5 
    1353         Variable/G gLambda_upper = 20.0 
    1354         Variable/G gD_upper = 25.0 
    1355         Variable/G gBs_factor = 1.05 
    1356         Variable/G gT1 = 0.63 
    1357         Variable/G gT2 = 1.0 
    1358         Variable/G gT3 = 0.75 
    1359         Variable/G gL_gap = 100.0 
    1360         Variable/G gGuide_width = 6.0 
    1361         Variable/G gIdmax = 100.0 
     1430//      Variable/G gLambda_t = 5.50 
     1431//      Variable/G gL2r_lower = 132.3 
     1432//      Variable/G gL2r_upper =  1317 
     1433//      Variable/G gLambda_lower = 2.5 
     1434//      Variable/G gLambda_upper = 20.0 
     1435//      Variable/G gD_upper = 25.0 
     1436//      Variable/G gBs_factor = 1.05 
     1437//      Variable/G gT1 = 0.63 
     1438//      Variable/G gT2 = 1.0 
     1439//      Variable/G gT3 = 0.75 
     1440//      Variable/G gL_gap = 100.0 
     1441//      Variable/G gGuide_width = 6.0 
     1442//      Variable/G gIdmax = 100.0 
    13621443 
    13631444// 
    13641445//      //new values, from 11/2009 --- BeamFluxReport_2009.ifn 
    1365         Variable/G gPhi_0 = 2.42e13 
    1366         Variable/G gB = 0.0 
    1367         Variable/G gC = -0.0243 
    1368         Variable/G gGuide_loss = 0.924 
     1446//      Variable/G gPhi_0 = 2.42e13 
     1447//      Variable/G gB = 0.0 
     1448//      Variable/G gC = -0.0243 
     1449//      Variable/G gGuide_loss = 0.924 
    13691450//       
    13701451//      //fwhm values (new variables) (+3, 0, -3, calibrated 2009) 
    1371         Variable/G gFwhm_narrow = 0.109 
    1372         Variable/G gFwhm_mid = 0.125 
    1373         Variable/G gFwhm_wide = 0.236 
     1452//      Variable/G gFwhm_narrow = 0.109 
     1453//      Variable/G gFwhm_mid = 0.125 
     1454//      Variable/G gFwhm_wide = 0.236 
    13741455//       
    13751456//      //source apertures (cm) 
    1376         Variable/G gA1_0_0 = 1.43 
    1377         Variable/G gA1_0_1 = 2.54 
    1378         Variable/G gA1_0_2 = 3.81 
    1379         Variable/G gA1_7_0 = 2.5                        // after the polarizer           
    1380         Variable/G gA1_7_1 = 5.0 
    1381         Variable/G gA1_7_1 = 0.95               // 
    1382         Variable/G gA1_def = 5.00 
     1457//      Variable/G gA1_0_0 = 1.43 
     1458//      Variable/G gA1_0_1 = 2.54 
     1459//      Variable/G gA1_0_2 = 3.81 
     1460//      Variable/G gA1_7_0 = 2.5                        // after the polarizer           
     1461//      Variable/G gA1_7_1 = 5.0 
     1462//      Variable/G gA1_7_1 = 0.95               // 
     1463//      Variable/G gA1_def = 5.00 
    13831464//       
    13841465        SetDataFolder root: 
     
    13991480        detStr = "B" 
    14001481        WAVE qTot_B = $(folderPath+instPath+detStr+":qTot_"+detStr) 
    1401  
    1402         min_b = WaveMin(qTot_B) 
    1403         max_b = WaveMax(qTot_B) 
    1404  
     1482        WAVE mask_B = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
     1483 
     1484        Duplicate/O qTot_B tmp_B 
     1485        // for the minimum 
     1486        tmp_B = (mask_B == 0) ? qTot_B : 1e6 
     1487        min_b = WaveMin(tmp_B) 
     1488 
     1489        // for the maximum 
     1490        tmp_B = (mask_B == 0) ? qTot_B : -1e6 
     1491        max_b = WaveMax(tmp_B) 
     1492 
     1493        KillWaves/Z tmp_B 
    14051494 
    14061495        return(0) 
     
    14211510        detStr = "ML" 
    14221511        WAVE qTot_ML = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     1512        WAVE mask_ML = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
    14231513 
    14241514        detStr = "MR" 
    14251515        WAVE qTot_MR = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     1516        WAVE mask_MR = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
    14261517 
    14271518        detStr = "MT" 
    14281519        WAVE qTot_MT = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     1520        WAVE mask_MT = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
    14291521 
    14301522        detStr = "MB" 
    14311523        WAVE qTot_MB = $(folderPath+instPath+detStr+":qTot_"+detStr) 
    1432  
    1433         min_m = min(WaveMin(qTot_ML),WaveMin(qTot_MT),WaveMin(qTot_MR),WaveMin(qTot_MB)) 
    1434         max_m = max(WaveMax(qTot_ML),WaveMax(qTot_MT),WaveMax(qTot_MR),WaveMax(qTot_MB)) 
    1435  
     1524        WAVE mask_MB = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
     1525 
     1526        Variable min1,min2,min3,min4 
     1527        Variable max1,max2,max3,max4 
     1528        // WaveMin(), WaveMax() will report NaN or inf 
     1529        // so for the min, set masked values to 1e6 
     1530        Duplicate/O qTot_ML tmp_ML 
     1531        tmp_ML = (mask_ML == 0) ? qTot_ML : 1e6 
     1532 
     1533        Duplicate/O qTot_MR tmp_MR 
     1534        tmp_MR = (mask_MR == 0) ? qTot_MR : 1e6 
     1535         
     1536        Duplicate/O qTot_MT tmp_MT 
     1537        tmp_MT = (mask_MT == 0) ? qTot_MT : 1e6 
     1538         
     1539        Duplicate/O qTot_MB tmp_MB 
     1540        tmp_MB = (mask_MB == 0) ? qTot_MB : 1e6 
     1541         
     1542        min1 = WaveMin(tmp_ML) 
     1543        min2 = WaveMin(tmp_MR) 
     1544        min3 = WaveMin(tmp_MT) 
     1545        min4 = WaveMin(tmp_MB) 
     1546 
     1547        // so for the max, set masked values to -1e6 
     1548        tmp_ML = (mask_ML == 0) ? qTot_ML : -1e6 
     1549        tmp_MR = (mask_MR == 0) ? qTot_MR : -1e6 
     1550        tmp_MT = (mask_MT == 0) ? qTot_MT : -1e6 
     1551        tmp_MB = (mask_MB == 0) ? qTot_MB : -1e6 
     1552         
     1553        max1 = WaveMax(tmp_ML) 
     1554        max2 = WaveMax(tmp_MR) 
     1555        max3 = WaveMax(tmp_MT) 
     1556        max4 = WaveMax(tmp_MB) 
     1557 
     1558//      print min1,min2,min3,min4 
     1559//      print max1,max2,max3,max4 
     1560                 
     1561        min_m = min(min1,min2,min3,min4) 
     1562        max_m = max(max1,max2,max3,max4) 
     1563 
     1564//      min_m = min(WaveMin(tmp_ML),WaveMin(tmp_MT),WaveMin(tmp_MR),WaveMin(tmp_MB)) 
     1565//      max_m = max(WaveMax(tmp_ML),WaveMax(tmp_MT),WaveMax(tmp_MR),WaveMax(tmp_MB)) 
     1566         
     1567        KillWaves/Z tmp_ML,tmp_MR,tmp_MT,tmp_MB 
    14361568 
    14371569        return(0) 
     
    14521584        detStr = "FL" 
    14531585        WAVE qTot_FL = $(folderPath+instPath+detStr+":qTot_"+detStr) 
    1454  
     1586        WAVE mask_FL = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
     1587         
    14551588        detStr = "FR" 
    14561589        WAVE qTot_FR = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     1590        WAVE mask_FR = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
    14571591 
    14581592        detStr = "FT" 
    14591593        WAVE qTot_FT = $(folderPath+instPath+detStr+":qTot_"+detStr) 
     1594        WAVE mask_FT = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
    14601595 
    14611596        detStr = "FB" 
    14621597        WAVE qTot_FB = $(folderPath+instPath+detStr+":qTot_"+detStr) 
    1463  
    1464         min_f = min(WaveMin(qTot_FL),WaveMin(qTot_FT),WaveMin(qTot_FR),WaveMin(qTot_FB)) 
    1465         max_f = max(WaveMax(qTot_FL),WaveMax(qTot_FT),WaveMax(qTot_FR),WaveMax(qTot_FB)) 
    1466  
    1467  
     1598        WAVE mask_FB = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
     1599 
     1600        Variable min1,min2,min3,min4 
     1601        Variable max1,max2,max3,max4 
     1602        // WaveMin(), WaveMax() will report NaN or inf 
     1603        // so for the min, set masked values to 1e6 
     1604        Duplicate/O qTot_FL tmp_FL 
     1605        tmp_FL = (mask_FL == 0) ? qTot_FL : 1e6 
     1606 
     1607        Duplicate/O qTot_FR tmp_FR 
     1608        tmp_FR = (mask_FR == 0) ? qTot_FR : 1e6 
     1609         
     1610        Duplicate/O qTot_FT tmp_FT 
     1611        tmp_FT = (mask_FT == 0) ? qTot_FT : 1e6 
     1612         
     1613        Duplicate/O qTot_FB tmp_FB 
     1614        tmp_FB = (mask_FB == 0) ? qTot_FB : 1e6 
     1615 
     1616        min1 = WaveMin(tmp_FL) 
     1617        min2 = WaveMin(tmp_FR) 
     1618        min3 = WaveMin(tmp_FT) 
     1619        min4 = WaveMin(tmp_FB) 
     1620         
     1621        // so for the max, set masked values to -1e6 
     1622        tmp_FL = (mask_FL == 0) ? qTot_FL : -1e6 
     1623        tmp_FR = (mask_FR == 0) ? qTot_FR : -1e6 
     1624        tmp_FT = (mask_FT == 0) ? qTot_FT : -1e6 
     1625        tmp_FB = (mask_FB == 0) ? qTot_FB : -1e6 
     1626 
     1627 
     1628        max1 = WaveMax(tmp_FL) 
     1629        max2 = WaveMax(tmp_FR) 
     1630        max3 = WaveMax(tmp_FT) 
     1631        max4 = WaveMax(tmp_FB) 
     1632 
     1633//      print min1,min2,min3,min4 
     1634//      print max1,max2,max3,max4 
     1635                 
     1636        min_f = min(min1,min2,min3,min4) 
     1637        max_f = max(max1,max2,max3,max4) 
     1638         
     1639//      min_f = min(WaveMin(tmp_FL),WaveMin(tmp_FT),WaveMin(tmp_FR),WaveMin(tmp_FB)) 
     1640//      max_f = max(WaveMax(tmp_FL),WaveMax(tmp_FT),WaveMax(tmp_FR),WaveMax(tmp_FB)) 
     1641 
     1642        KillWaves/Z tmp_FL,tmp_FR,tmp_FT,tmp_FB 
    14681643        return(0) 
    14691644end 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DetectorCorrections.ipf

    r1117 r1133  
    345345        WAVE y_mm = $(destPath + ":entry:instrument:detector_"+detStr+":beam_center_y_mm") 
    346346 
    347         Variable tube_width = V_getDet_tubeWidth(folder,detStr) 
    348  
    349 // 
    350         if(cmpstr(orientation,"vertical")==0) 
    351                 //      this is data dimensioned as (Ntubes,Npix) 
    352 //              data_realDistX[][] = tube_width*p 
    353 //              data_realDistY[][] = coefW[0][p] + coefW[1][p]*q + coefW[2][p]*q*q 
    354                 x_mm[0] = tube_width*xCtr 
    355                 y_mm[0] = data_realDistY[0][yCtr] 
    356         else 
    357                 //      this is data (horizontal) dimensioned as (Npix,Ntubes) 
    358 //              data_realDistX[][] = coefW[0][q] + coefW[1][q]*p + coefW[2][q]*p*p 
    359 //              data_realDistY[][] = tube_width*q 
    360                 x_mm[0] = data_realDistX[xCtr][0] 
    361                 y_mm[0] = tube_width*yCtr 
    362         endif 
     347        Variable tube_width = V_getDet_tubeWidth(folder,detStr)         //this is also in mm 
     348 
     349// 
     350        strswitch(detStr)       // string switch 
     351                case "FL": 
     352                case "ML": 
     353                        // for Left/Right 
     354                        // for left 
     355                        x_mm[0] = data_realDistX[dimX-1][0] + (xCtr-dimX-1)*tube_width 
     356                        y_mm[0] = data_realDistY[0][yCtr] 
     357         
     358                        break            
     359                case "FR":       
     360                case "MR": 
     361                        // for Left/Right 
     362                        // for right 
     363                        x_mm[0] = data_realDistX[0][0] + xCtr*tube_width 
     364                        y_mm[0] = data_realDistY[0][yCtr] 
     365                         
     366                        break 
     367                case "FT":       
     368                case "MT": 
     369                        // for Top                       
     370                        x_mm[0] = data_realDistX[xCtr][0] 
     371                        y_mm[0] = data_realDistY[0][0] + yCtr*tube_width 
     372                         
     373                        break            
     374                case "FB":       
     375                case "MB": 
     376                        // for Bottom                    
     377                        x_mm[0] = data_realDistX[xCtr][0] 
     378                        y_mm[0] = data_realDistY[0][dimY-1] + (yCtr-dimY-1)*tube_width 
     379                                                 
     380                        break 
     381                default:                        // optional default expression executed 
     382                        Print "No case matched in V_Convert_FittedPix_2_cm" 
     383                        return(1) 
     384        endswitch 
    363385                 
    364386        return(0) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_FileCatalog.ipf

    r1113 r1133  
    641641         
    642642        //Sample Temperature 
     643        // this reads sample:temperature which is the average temperature reading (may be affected by noise) 
    643644        InsertPoints lastPoint,1,GTemp 
    644645        GTemp[lastPoint]=V_getSampleTemperature(fname) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf

    r1114 r1133  
    21452145End 
    21462146 
     2147// this field is apparently the "average" temperature reading  
     2148// and can be adversely affected by random faulty readings from the sensor 
     2149// to give an average that is far from the expected value 
    21472150Function V_getSampleTemperature(fname) 
    21482151        String fname 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_MaskUtils.ipf

    r1126 r1133  
    11121112        PopupMenu popup0,mode=1,value= #"\"F;M;B;\"" 
    11131113        PopupMenu popup1,pos={100.00,10.00},size={68.00,23.00},proc=V_PickFolderPopMenuProc,title="Folder" 
    1114         PopupMenu popup1,mode=1,popvalue="RAW",value= #"\"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;MSK;ADJ;\"" 
     1114        PopupMenu popup1,mode=1,popvalue="RAW",value= #"\"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;MSK;ADJ;VCALC;\"" 
     1115//      PopupMenu popup1,mode=1,popvalue="RAW",value= #"\"SAM;EMP;BGD;DIV;COR;CAL;RAW;ABS;STO;SUB;DRK;MSK;ADJ;VCALC;\"" 
    11151116        PopupMenu popup2,pos={200.00,10.00},size={83.00,23.00},title="Bin Type"//,proc=V_DummyPopMenuProc 
    11161117        PopupMenu popup2,mode=1,value= ksBinTypeStr 
     
    11341135        PopupMenu popup4,pos={200,100},size={90,23.00},title="Sector Side(s)"//,proc=V_DummyPopMenuProc 
    11351136        PopupMenu popup4,mode=1,value= #"\"both;left;right;\"" 
     1137 
     1138        Make/O/B/N=(48,128) tmpLR 
     1139        Make/O/B/N=(128,48) tmpTB 
     1140        Make/O/B/N=(680,1656) tmpB 
     1141         
     1142        tmpLR = 1 
     1143        tmpTB = 1 
     1144        tmpB = 1 
    11361145         
    11371146//      Display/W=(745,45,945,425)/HOST=#  
    11381147        Display/W=(10,45+80,210,425+80)/HOST=#  
    1139         AppendImage/T/G=1 :Packages:NIST:VSANS:RAW:entry:instrument:detector_FL:data            //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
    1140  
    1141         ModifyImage data ctab= {*,*,ColdWarm,0} 
    1142         ModifyImage data ctabAutoscale=3 
     1148        //  root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FL:data 
     1149        AppendImage/T/G=1 tmpLR         //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
     1150 
     1151        ModifyImage tmpLR ctab= {*,*,ColdWarm,0} 
     1152        ModifyImage tmpLR ctabAutoscale=3 
    11431153        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
    11441154        ModifyGraph mirror=2 
     
    11551165//      Display/W=(1300,45,1500,425)/HOST=#  
    11561166        Display/W=(565,45+80,765,425+80)/HOST=#  
    1157         AppendImage/T/G=1 :Packages:NIST:VSANS:RAW:entry:instrument:detector_FR:data            //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
    1158         ModifyImage data ctab= {*,*,ColdWarm,0} 
    1159         ModifyImage data ctabAutoscale=3 
     1167        AppendImage/T/G=1 tmpLR         //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
     1168        ModifyImage tmpLR ctab= {*,*,ColdWarm,0} 
     1169        ModifyImage tmpLR ctabAutoscale=3 
    11601170        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
    11611171        ModifyGraph mirror=2 
     
    11721182//      Display/W=(945,45,1300,235)/HOST=#  
    11731183        Display/W=(210,45+80,565,235+80)/HOST=#  
    1174         AppendImage/T/G=1 :Packages:NIST:VSANS:RAW:entry:instrument:detector_FT:data            //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
    1175         ModifyImage data ctab= {*,*,ColdWarm,0} 
    1176         ModifyImage data ctabAutoscale=3 
     1184        AppendImage/T/G=1 tmpTB         //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
     1185        ModifyImage tmpTB ctab= {*,*,ColdWarm,0} 
     1186        ModifyImage tmpTB ctabAutoscale=3 
    11771187        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
    11781188        ModifyGraph mirror=2 
     
    11891199//      Display/W=(945,235,1300,425)/HOST=#  
    11901200        Display/W=(210,235+80,565,425+80)/HOST=#  
    1191         AppendImage/T/G=1 :Packages:NIST:VSANS:RAW:entry:instrument:detector_FB:data            //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
    1192         ModifyImage data ctab= {*,*,ColdWarm,0} 
    1193         ModifyImage data ctabAutoscale=3 
     1201        AppendImage/T/G=1 tmpTB         //  /G=1 flag prevents interpretation as RGB so 3, 4 slices display correctly 
     1202        ModifyImage tmpTB ctab= {*,*,ColdWarm,0} 
     1203        ModifyImage tmpTB ctabAutoscale=3 
    11941204        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
    11951205        ModifyGraph mirror=2 
     
    12161226        ControlInfo popup0 
    12171227        String carrStr = S_value 
     1228 
     1229        if(cmpstr("B",carrStr)==0) 
     1230                DoAlert 0, "Detector B plotting not supported yet" 
     1231                return(0) 
     1232        endif 
    12181233         
    12191234        ControlInfo popup1 
    12201235        String folder = S_Value 
    12211236 
     1237        Variable isVCALC=0 
     1238        if(cmpstr("VCALC",folder)==0) 
     1239                isVCALC=1 
     1240        endif 
    12221241 
    12231242        String tmpStr="" 
     
    12611280        // append the new image 
    12621281//      RemoveImage/Z/W=VSANS_Det_Panels#Panel_L data 
    1263         AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_L $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"L:data")                
    1264         SetActiveSubwindow VSANS_Det_Panels#Panel_L 
    1265         ModifyImage data ctab= {*,*,ColdWarm,0} 
    1266         ModifyImage data ctabAutoscale=3 
     1282        if(isVCALC) 
     1283                AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_L $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"L:det_"+carrStr+"L")            
     1284                SetActiveSubwindow VSANS_Det_Panels#Panel_L 
     1285                ModifyImage ''#0 ctab= {*,*,ColdWarm,0} 
     1286                ModifyImage ''#0 ctabAutoscale=3 
     1287        else 
     1288                AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_L $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"L:data")                
     1289                SetActiveSubwindow VSANS_Det_Panels#Panel_L 
     1290                ModifyImage data ctab= {*,*,ColdWarm,0} 
     1291                ModifyImage data ctabAutoscale=3         
     1292        endif 
    12671293        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
    12681294        ModifyGraph mirror=2 
     
    12781304 
    12791305//      RemoveImage/Z/W=VSANS_Det_Panels#Panel_T data 
    1280         AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_T $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"T:data")                
    1281         SetActiveSubwindow VSANS_Det_Panels#Panel_T 
    1282         ModifyImage data ctab= {*,*,ColdWarm,0} 
    1283         ModifyImage data ctabAutoscale=3 
     1306        if(isVCALC) 
     1307                AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_T $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"T:det_"+carrStr+"T")            
     1308                SetActiveSubwindow VSANS_Det_Panels#Panel_T 
     1309                ModifyImage ''#0 ctab= {*,*,ColdWarm,0} 
     1310                ModifyImage ''#0 ctabAutoscale=3 
     1311        else 
     1312                AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_T $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"T:data")                
     1313                SetActiveSubwindow VSANS_Det_Panels#Panel_T 
     1314                ModifyImage data ctab= {*,*,ColdWarm,0} 
     1315                ModifyImage data ctabAutoscale=3 
     1316        endif 
    12841317        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
    12851318        ModifyGraph mirror=2 
     
    12941327         
    12951328//      RemoveImage/Z/W=VSANS_Det_Panels#Panel_B data 
    1296         AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_B $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"B:data")                
    1297         SetActiveSubwindow VSANS_Det_Panels#Panel_B 
    1298         ModifyImage data ctab= {*,*,ColdWarm,0} 
    1299         ModifyImage data ctabAutoscale=3 
     1329        if(isVCALC) 
     1330                AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_B $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"B:det_"+carrStr+"B")            
     1331                SetActiveSubwindow VSANS_Det_Panels#Panel_B 
     1332                ModifyImage ''#0 ctab= {*,*,ColdWarm,0} 
     1333                ModifyImage ''#0 ctabAutoscale=3 
     1334        else 
     1335                AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_B $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"B:data")                
     1336                SetActiveSubwindow VSANS_Det_Panels#Panel_B 
     1337                ModifyImage data ctab= {*,*,ColdWarm,0} 
     1338                ModifyImage data ctabAutoscale=3 
     1339        endif 
    13001340        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
    13011341        ModifyGraph mirror=2 
     
    13101350 
    13111351//      RemoveImage/Z/W=VSANS_Det_Panels#Panel_R data 
    1312         AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_R $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"R:data")                
    1313         SetActiveSubwindow VSANS_Det_Panels#Panel_R 
    1314         ModifyImage data ctab= {*,*,ColdWarm,0} 
    1315         ModifyImage data ctabAutoscale=3 
     1352        if(isVCALC) 
     1353                AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_R $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"R:det_"+carrStr+"R")            
     1354                SetActiveSubwindow VSANS_Det_Panels#Panel_R 
     1355                ModifyImage ''#0 ctab= {*,*,ColdWarm,0} 
     1356                ModifyImage ''#0 ctabAutoscale=3 
     1357        else 
     1358                AppendImage/T/G=1/W=VSANS_Det_Panels#Panel_R $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+carrStr+"R:data")                
     1359                SetActiveSubwindow VSANS_Det_Panels#Panel_R 
     1360                ModifyImage data ctab= {*,*,ColdWarm,0} 
     1361                ModifyImage data ctabAutoscale=3 
     1362        endif 
    13161363        ModifyGraph margin(left)=14,margin(bottom)=14,margin(top)=14,margin(right)=14 
    13171364        ModifyGraph mirror=2 
     
    14271474                        endif 
    14281475                         
    1429                         wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":overlay_"+detStr) 
     1476                        wave/Z overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":overlay_"+detStr) 
    14301477                        CheckDisplayed/W=VSANS_Det_Panels#Panel_L overlay 
    14311478                        if(V_Flag == 1)         //overlay is present 
     
    17221769 
    17231770 
     1771        Variable isVCALC=0 
     1772        if(cmpstr("VCALC",folderStr)==0) 
     1773                isVCALC=1 
     1774        endif 
     1775         
    17241776        String maskPath = "root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data" 
    17251777        if(WaveExists($maskPath) == 1) 
     
    17301782                        wave maskW = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":data") 
    17311783                        // for the wave scaling 
    1732                         wave data = $("root:Packages:NIST:VSANS:"+folderStr+":entry:instrument:detector_"+detStr+":data")        
     1784                        if(isVCALC) 
     1785                                wave data = $("root:Packages:NIST:VSANS:"+folderStr+":entry:instrument:detector_"+detStr+":det_"+detStr)         
     1786                        else 
     1787                                wave data = $("root:Packages:NIST:VSANS:"+folderStr+":entry:instrument:detector_"+detStr+":data")        
     1788                        endif 
    17331789                        Duplicate/O data $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":overlay_"+detStr) 
    17341790                        wave overlay = $("root:Packages:NIST:VSANS:MSK:entry:instrument:detector_"+detStr+":overlay_"+detStr) 
     
    17381794                                case "ML": 
    17391795                                case "FL": 
    1740                                         Print ImageNameList("VSANS_Det_Panels#Panel_L", ";" ) 
     1796//                                      Print ImageNameList("VSANS_Det_Panels#Panel_L", ";" ) 
    17411797                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_L overlay 
    17421798                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
     
    18551911                                case "ML": 
    18561912                                case "FL": 
    1857                                         Print ImageNameList("VSANS_Det_Panels#Panel_L", ";" ) 
     1913//                                      Print ImageNameList("VSANS_Det_Panels#Panel_L", ";" ) 
    18581914                                        CheckDisplayed/W=VSANS_Det_Panels#Panel_L overlay 
    18591915                                        if(V_flag==0)           //so the overlay doesn't get appended more than once 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_RealTimeUpdate.ipf

    r1091 r1133  
    480480 
    481481 
    482 // TODO: 
    483 // -- is the 1D plot being updated? 
    484 ////                     
    485 //              //if the 1D plot is open, update this too 
    486 //              // make sure folders exist first 
    487 //              if(!DataFolderExists("root:myGlobals:Drawing")) 
    488 //                      Execute "InitializeAveragePanel()" 
    489 //              endif 
    490 //               
    491 //              // check for the mask, generate one? Two pixels all around 
    492 //                       
    493 //              // update the 1d plot 
    494 //              if(WinType("Plot_1d")==1)               //if the 1D graph exists 
    495 ////                    Panel_DoAverageButtonProc("")    
    496 //                      DoWindow/F V_SANS_Data   
    497 //              endif 
    498 //              /////// 
     482// DONE: 
     483// x- update the 1D plot 
     484// repeat what the IQ button does -- V_IvsQPanelButtonProc() 
     485                V_PlotData_Panel()              //-9999 requests a read from the popup on the panel 
     486                Variable binType = V_GetBinningPopMode() 
     487                ControlInfo/W=V_1D_Data popup0 
     488                V_BinningModePopup("",binType,S_Value)          // does binning of current popString and updates the graph 
    499489                 
    500490//              print "Bkg task time (s) =",(ticks-t1)/60.15 
Note: See TracChangeset for help on using the changeset viewer.