#pragma rtGlobals=3 // Use modern global access method and strict wave access. ////////////////// // // Procedures for: // // Gathering information to calculate QxQyQz // Filling the panels with Qtot, QxQyQz // Filling the "data" with a model function // Averaging the panels (independently) into I(Q) // Plotting the 9 detector panels in 2D // Plotting the 1D I(q) data depending on the panel combinations // // // There are some things in the current circular averaging that don't make any sense // and don't seem to really do anything at all, so i have decided to trim them out. // 1) subdividing pixels near the beam stop into 9 sub-pixels // 2) non-linear correction (only applies to Ordela) // // // Do I separate out the circular, sector, rectangular, annular averaging into // separate routines? // // // /////////////////// Proc PlotFrontPanels() fPlotFrontPanels() End // // Plot the front panels in 2D and 1D // calcualate Q // fill w/model data // "shadow" the T/B detectors // bin the data to I(q) // draw I(q) graph // draw 2D panel graph // // *** Call this function when front panels are adjusted, or wavelength, etc. changed // Function fPlotFrontPanels() // space is allocated for all of the detectors and Q's on initialization // calculate Qtot, qxqyqz arrays from geometry V_CalculateQFrontPanels() // fill the panels with fake sphere scattering data // TODO: am I in the right data folder?? SetDataFolder root:Packages:NIST:VSANS:VCALC:Front WAVE det_FL = det_FL WAVE det_FR = det_FR WAVE det_FT = det_FT WAVE det_FB = det_FB WAVE qTot_FL = qTot_FL WAVE qTot_FR = qTot_FR WAVE qTot_FT = qTot_FT WAVE qTot_FB = qTot_FB FillPanel_wModelData(det_FL,qTot_FL,"FL") FillPanel_wModelData(det_FR,qTot_FR,"FR") FillPanel_wModelData(det_FT,qTot_FT,"FT") FillPanel_wModelData(det_FB,qTot_FB,"FB") SetDataFolder root: // set any "shadowed" area of the T/B detectors to NaN to get a realitic // view of how much of the detectors are actually collecting data // -- I can get the separation L/R from the panel - only this "open" width is visible. //TODO - make this a proper shadow - TB extent of the LR panels matters too, not just the LR separation V_SetShadow_TopBottom("Front","FT") // TODO: -- be sure the data folder is properly set (within the function...) V_SetShadow_TopBottom("Front","FB") // do the q-binning for each of the panels to get I(Q) Execute "BinAllFrontPanels()" // plot the results Execute "Front_IQ_Graph()" Execute "FrontPanels_AsQ()" return(0) End // works for Left, works for Right... works for T/B too. // // - TODO: be sure that the Q's are calculated correctly even when the beam is off of the // detector, and on different sides of the detector (or T/B) - since it will be in a different // relative postion to 0,0 on the detector. If the postions are symmetric, then the Q's should be identical. // --- test this... // TODO -- be sure I'm in the right data folder. nothing is set correctly right now // // TODO: make all detector parameters global, not hard-wired // // // --- Panels are all allocated in the initialization. Here, only the q-values are calculated // when anything changes // Function V_CalculateQFrontPanels() Variable xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY Variable F_LR_sep,F_TB_sep,F_offset,F_sdd_offset // get the values from the panel + constants F_LR_sep = VCALC_getPanelSeparation("FLR") F_TB_sep = VCALC_getPanelSeparation("FTB") F_offset = VCALC_getLateralOffset("FL") SDD = VCALC_getSDD("FL") //nominal SDD - need offset for TB lam = VCALC_getWavelength() //separations are in mm -- need to watch the units, convert to cm F_LR_sep /= 10 F_TB_sep /= 10 // TODO - I'm treating the separation as the TOTAL width - so the difference // from the "center" to the edge is 1/2 of the separation // TODO (make the N along the tube length a variable, since this can be reset @ acquisition) F_sdd_offset = VCALC_getTopBottomSDDOffset("FT") //T/B are 300 mm farther back //TODO: make all detector parameters global, not hard-wired SetDataFolder root:Packages:NIST:VSANS:VCALC:Front Wave det_FL,det_FR // these are (48,256) Wave det_FT,det_FB // these are (128,48) //FRONT/LEFT WAVE qTot_FL,qx_FL,qy_FL,qz_FL qTot_FL = 0 qx_FL = 0 qy_FL = 0 qz_FL = 0 // TODO - these are to be set from globals, not hard-wired. N and pixelSixze will be known (or pre-measured) // pixel sizes are in cm pixSizeX = VCALC_getPixSizeX("FL") pixSizeY = VCALC_getPixSizeY("FL") // pixSizeX = 0.8 // 0.8 cm/pixel along width // pixSizeY = 0.4 // approx 0.4 cm/pixel along length xCtr = 48+(F_LR_sep/2/pixSizeX) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? yCtr = 127 V_Detector_2Q(det_FL,qTot_FL,qx_FL,qy_FL,qz_FL,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) // Print "xy for FL = ",xCtr,yCtr //set the wave scaling for the detector image so that it can be plotted in q-space // TODO: this is only approximate - since the left "edge" is not the same from top to bottom, so I crudely // take the middle value. At very small angles, OK, at 1m, this is a crummy approximation. // since qTot is magnitude only, I need to put in the (-ve) SetScale/I x WaveMin(qx_FL),WaveMax(qx_FL),"", det_FL //this sets the left and right ends of the data scaling SetScale/I y WaveMin(qy_FL),WaveMax(qy_FL),"", det_FL ////////////////// //FRONT/RIGHT SetDataFolder root:Packages:NIST:VSANS:VCALC:Front WAVE qTot_FR,qx_FR,qy_FR,qz_FR qTot_FR = 0 qx_FR = 0 qy_FR = 0 qz_FR = 0 // TODO - these are to be set from globals, not hard-wired // pixel sizes are in cm pixSizeX = VCALC_getPixSizeX("FR") pixSizeY = VCALC_getPixSizeY("FR") xCtr = -(F_LR_sep/2/pixSizeX)-1 yCtr = 127 V_Detector_2Q(det_FR,qTot_FR,qx_FR,qy_FR,qz_FR,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY) // Print "xy for FR = ",xCtr,yCtr SetScale/I x WaveMin(qx_FR),WaveMax(qx_FR),"", det_FR //this sets the left and right ends of the data scaling SetScale/I y WaveMin(qy_FR),WaveMax(qy_FR),"", det_FR ///////////////// //FRONT/TOP SetDataFolder root:Packages:NIST:VSANS:VCALC:Front WAVE qTot_FT,qx_FT,qy_FT,qz_FT qTot_FT = 0 qx_FT = 0 qy_FT = 0 qz_FT = 0 // TODO - these are to be set from globals, not hard-wired // pixel sizes are in cm pixSizeX = VCALC_getPixSizeX("FT") pixSizeY = VCALC_getPixSizeY("FT") xCtr = 64 yCtr = -(F_TB_sep/2/pixSizeY)-1 // global sdd_offset is in (mm), convert to meters here for the Q-calculation V_Detector_2Q(det_FT,qTot_FT,qx_FT,qy_FT,qz_FT,xCtr,yCtr,sdd+F_sdd_offset/1000,lam,pixSizeX,pixSizeY) // Print "xy for FT = ",xCtr,yCtr SetScale/I x WaveMin(qx_FT),WaveMax(qx_FT),"", det_FT //this sets the left and right ends of the data scaling SetScale/I y WaveMin(qy_FT),WaveMax(qy_FT),"", det_FT ////////////////// //FRONT/BOTTOM SetDataFolder root:Packages:NIST:VSANS:VCALC:Front WAVE qTot_FB,qx_FB,qy_FB,qz_FB qTot_FB = 0 qx_FB = 0 qy_FB = 0 qz_FB = 0 // TODO - these are to be set from globals, not hard-wired // pixel sizes are in cm pixSizeX = VCALC_getPixSizeX("FB") pixSizeY = VCALC_getPixSizeY("FB") xCtr = 64 yCtr = 48+(F_TB_sep/2/pixSizeY) // TODO -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)?? // global sdd_offset is in (mm), convert to meters here for the Q-calculation V_Detector_2Q(det_FB,qTot_FB,qx_FB,qy_FB,qz_FB,xCtr,yCtr,sdd+F_sdd_offset/1000,lam,pixSizeX,pixSizeY) // Print "xy for FB = ",xCtr,yCtr SetScale/I x WaveMin(qx_FB),WaveMax(qx_FB),"", det_FB //this sets the left and right ends of the data scaling SetScale/I y WaveMin(qy_FB),WaveMax(qy_FB),"", det_FB ///////////////// SetDataFolder root: return(0) End // TODO - this doesn't quite mask things out as they should be (too much is masked L/R of center) // and the outer edges of the detector are masked even if the TB panels extend past the TB of the LR panels. // ? skip the masking? but then I bin the detector data directly to get I(q), skipping the masked NaN values... // Function V_SetShadow_TopBottom(folderStr,type) String folderStr,type Variable LR_sep,nPix,xCtr,ii,jj,numCol,pixSizeX,pixSizeY /// !! 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... if(cmpstr(type[0],"F")==0) //front ControlInfo/W=VCALC VCALCCtrl_2a LR_sep = V_Value else //middle ControlInfo/W=VCALC VCALCCtrl_3a LR_sep = V_Value endif //separations on panel are in mm -- need to watch the units, convert to cm LR_sep /= 10 //detector data Wave det = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":det_"+type) // TODO - these are to be set from globals, not hard-wired // pixel sizes are in cm for T/B detector // TODO - the "FT" check is hard wired for FRONT -- get rid of this... pixSizeX = VCALC_getPixSizeX(type) pixSizeY = VCALC_getPixSizeY(type) //TODO -- get this from a global xCtr = 64 nPix = trunc(LR_sep/2/pixSizeX) // approx # of pixels Left/right of center that are not obscured by L/R panels numCol = DimSize(det,0) // x dim (columns) for(ii=0;ii<(xCtr-nPix-2);ii+=1) det[ii][] = NaN endfor for(ii=(xCtr+nPix+2);ii