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).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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) 
Note: See TracChangeset for help on using the changeset viewer.