source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_DetectorBinning_Q.ipf @ 963

Last change on this file since 963 was 963, checked in by srkline, 7 years ago

Updated the display of the "beam center finder" to better display the panels with an appropriate aspect ratio for the pixels.

Made the number of pixels (x,y) on each of the panels as globals, plus access functions. Large panels were coded for 256, but will likely be 128 pixels in reality. Make global for easy changes. Made sure that exsting functions used the global and were not hard-wired.

File size: 37.0 KB
Line 
1#pragma rtGlobals=3             // Use modern global access method and strict wave access.
2
3
4//////////////////
5//
6// Procedures for:
7//
8//              Gathering information to calculate QxQyQz
9//              Filling the panels with Qtot, QxQyQz
10//              Filling the "data" with a model function
11//              Averaging the panels (independently) into I(Q)
12//              Plotting the 9 detector panels in 2D
13//              Plotting the 1D I(q) data depending on the panel combinations
14//
15//
16//  There are some things in the current circular averaging that don't make any sense
17//  and don't seem to really do anything at all, so i have decided to trim them out.
18//  1) subdividing pixels near the beam stop into 9 sub-pixels
19//  2) non-linear correction (only applies to Ordela)
20//
21//
22//  Do I separate out the circular, sector, rectangular, annular averaging into
23//   separate routines?
24//
25//
26//
27///////////////////
28
29
30Proc PlotFrontPanels()
31        fPlotFrontPanels()
32End
33
34//
35// Plot the front panels in 2D and 1D
36//              calcualate Q
37//              fill w/model data
38//              "shadow" the T/B detectors
39//              bin the data to I(q)
40//              draw I(q) graph
41//              draw 2D panel graph
42//
43// *** Call this function when front panels are adjusted, or wavelength, etc. changed
44//
45Function fPlotFrontPanels()
46
47        // space is allocated for all of the detectors and Q's on initialization
48        // calculate Qtot, qxqyqz arrays from geometry
49        V_CalculateQFrontPanels()
50       
51        // fill the panels with fake sphere scattering data
52        // TODO: am I in the right data folder??
53        SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
54
55        WAVE det_FL = det_FL
56        WAVE det_FR = det_FR
57        WAVE det_FT = det_FT
58        WAVE det_FB = det_FB
59       
60        WAVE qTot_FL = qTot_FL
61        WAVE qTot_FR = qTot_FR
62        WAVE qTot_FT = qTot_FT
63        WAVE qTot_FB = qTot_FB
64
65        FillPanel_wModelData(det_FL,qTot_FL,"FL")
66        FillPanel_wModelData(det_FR,qTot_FR,"FR")
67        FillPanel_wModelData(det_FT,qTot_FT,"FT")
68        FillPanel_wModelData(det_FB,qTot_FB,"FB")
69
70        SetDataFolder root:
71               
72        // set any "shadowed" area of the T/B detectors to NaN to get a realitic
73        // view of how much of the detectors are actually collecting data
74        // -- I can get the separation L/R from the panel - only this "open" width is visible.
75        //TODO - make this a proper shadow - TB extent of the LR panels matters too, not just the LR separation
76        V_SetShadow_TopBottom("Front","FT")             // TODO: -- be sure the data folder is properly set (within the function...)
77        V_SetShadow_TopBottom("Front","FB")
78       
79        // do the q-binning for each of the panels to get I(Q)
80        Execute "BinAllFrontPanels()"
81
82        // plot the results
83        Execute "Front_IQ_Graph()"
84        Execute "FrontPanels_AsQ()"
85       
86        return(0)
87End
88
89
90// works for Left, works for Right... works for T/B too.
91//
92// - TODO: be sure that the Q's are calculated correctly even when the beam is off of the
93//     detector, and on different sides of the detector (or T/B) - since it will be in a different
94//     relative postion to 0,0 on the detector. If the postions are symmetric, then the Q's should be identical.
95//     --- test this...
96// TODO -- be sure I'm in the right data folder. nothing is set correctly right now
97//
98// TODO: make all detector parameters global, not hard-wired
99//
100//
101// --- Panels are all allocated in the initialization. Here, only the q-values are calculated
102//     when anything changes
103//
104Function V_CalculateQFrontPanels()
105
106        Variable xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY,nPix_X,nPix_Y
107        Variable F_LR_sep,F_TB_sep,F_offset,F_sdd_offset
108
109// get the values from the panel + constants   
110        F_LR_sep = VCALC_getPanelSeparation("FLR")
111        F_TB_sep = VCALC_getPanelSeparation("FTB")
112        F_offset = VCALC_getLateralOffset("FL")
113       
114        SDD = VCALC_getSDD("FL")                //nominal SDD - need offset for TB
115        lam = VCALC_getWavelength()
116
117//separations are in mm -- need to watch the units, convert to cm
118        F_LR_sep /= 10
119        F_TB_sep /= 10
120// TODO - I'm treating the separation as the TOTAL width - so the difference
121//      from the "center" to the edge is 1/2 of the separation
122
123// TODO (make the N along the tube length a variable, since this can be reset @ acquisition)
124
125        F_sdd_offset = VCALC_getTopBottomSDDOffset("FT")        //T/B are 300 mm farther back  //TODO: make all detector parameters global, not hard-wired
126
127        SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
128        Wave det_FL,det_FR                      // these are (48,128)           (nominal, may change)
129        Wave det_FT,det_FB                      // these are (128,48)
130
131//FRONT/LEFT   
132        WAVE qTot_FL,qx_FL,qy_FL,qz_FL
133        qTot_FL = 0
134        qx_FL = 0
135        qy_FL = 0
136        qz_FL = 0       
137       
138// TODO - these are to be set from globals, not hard-wired. N and pixelSixze will be known (or pre-measured)
139// pixel sizes are in cm
140        pixSizeX = VCALC_getPixSizeX("FL")
141        pixSizeY = VCALC_getPixSizeY("FL")
142//      pixSizeX = 0.8                  // 0.8 cm/pixel along width
143//      pixSizeY = 0.4                  // approx 0.4 cm/pixel along length
144        nPix_X = VCALC_get_nPix_X("FL")
145        nPix_Y = VCALC_get_nPix_Y("FL")
146       
147        xCtr = nPix_X+(F_LR_sep/2/pixSizeX)             // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)??
148        yCtr = nPix_Y/2
149        V_Detector_2Q(det_FL,qTot_FL,qx_FL,qy_FL,qz_FL,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY)
150//      Print "xy for FL = ",xCtr,yCtr
151       
152        //set the wave scaling for the detector image so that it can be plotted in q-space
153        // TODO: this is only approximate - since the left "edge" is not the same from top to bottom, so I crudely
154        // take the middle value. At very small angles, OK, at 1m, this is a crummy approximation.
155        // since qTot is magnitude only, I need to put in the (-ve)
156        SetScale/I x WaveMin(qx_FL),WaveMax(qx_FL),"", det_FL           //this sets the left and right ends of the data scaling
157        SetScale/I y WaveMin(qy_FL),WaveMax(qy_FL),"", det_FL
158//////////////////
159
160//FRONT/RIGHT
161        SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
162        WAVE qTot_FR,qx_FR,qy_FR,qz_FR
163        qTot_FR = 0
164        qx_FR = 0
165        qy_FR = 0
166        qz_FR = 0
167
168// TODO - these are to be set from globals, not hard-wired
169// pixel sizes are in cm
170        pixSizeX = VCALC_getPixSizeX("FR")
171        pixSizeY = VCALC_getPixSizeY("FR")
172        nPix_X = VCALC_get_nPix_X("FR")
173        nPix_Y = VCALC_get_nPix_Y("FR")
174       
175        xCtr = -(F_LR_sep/2/pixSizeX)-1         
176        yCtr = nPix_Y/2
177        V_Detector_2Q(det_FR,qTot_FR,qx_FR,qy_FR,qz_FR,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY)
178//      Print "xy for FR = ",xCtr,yCtr
179        SetScale/I x WaveMin(qx_FR),WaveMax(qx_FR),"", det_FR           //this sets the left and right ends of the data scaling
180        SetScale/I y WaveMin(qy_FR),WaveMax(qy_FR),"", det_FR
181/////////////////
182
183//FRONT/TOP
184        SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
185        WAVE qTot_FT,qx_FT,qy_FT,qz_FT
186        qTot_FT = 0
187        qx_FT = 0
188        qy_FT = 0
189        qz_FT = 0
190
191// TODO - these are to be set from globals, not hard-wired
192// pixel sizes are in cm
193        pixSizeX = VCALC_getPixSizeX("FT")
194        pixSizeY = VCALC_getPixSizeY("FT")
195        nPix_X = VCALC_get_nPix_X("FT")
196        nPix_Y = VCALC_get_nPix_Y("FT")
197       
198        xCtr = nPix_X/2
199        yCtr = -(F_TB_sep/2/pixSizeY)-1   
200        // global sdd_offset is in (mm), convert to meters here for the Q-calculation
201        V_Detector_2Q(det_FT,qTot_FT,qx_FT,qy_FT,qz_FT,xCtr,yCtr,sdd+F_sdd_offset/1000,lam,pixSizeX,pixSizeY)
202//      Print "xy for FT = ",xCtr,yCtr
203        SetScale/I x WaveMin(qx_FT),WaveMax(qx_FT),"", det_FT           //this sets the left and right ends of the data scaling
204        SetScale/I y WaveMin(qy_FT),WaveMax(qy_FT),"", det_FT
205//////////////////
206
207//FRONT/BOTTOM
208        SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
209        WAVE qTot_FB,qx_FB,qy_FB,qz_FB
210        qTot_FB = 0
211        qx_FB = 0
212        qy_FB = 0
213        qz_FB = 0
214
215// TODO - these are to be set from globals, not hard-wired
216// pixel sizes are in cm
217        pixSizeX = VCALC_getPixSizeX("FB")
218        pixSizeY = VCALC_getPixSizeY("FB")
219        nPix_X = VCALC_get_nPix_X("FB")
220        nPix_Y = VCALC_get_nPix_Y("FB")
221               
222        xCtr = nPix_X/2
223        yCtr = nPix_Y+(F_TB_sep/2/pixSizeY)             // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)??
224        // global sdd_offset is in (mm), convert to meters here for the Q-calculation
225        V_Detector_2Q(det_FB,qTot_FB,qx_FB,qy_FB,qz_FB,xCtr,yCtr,sdd+F_sdd_offset/1000,lam,pixSizeX,pixSizeY)
226//      Print "xy for FB = ",xCtr,yCtr
227        SetScale/I x WaveMin(qx_FB),WaveMax(qx_FB),"", det_FB           //this sets the left and right ends of the data scaling
228        SetScale/I y WaveMin(qy_FB),WaveMax(qy_FB),"", det_FB
229/////////////////
230
231        SetDataFolder root:
232               
233        return(0)
234End
235
236
237// TODO - this doesn't quite mask things out as they should be (too much is masked L/R of center)
238// and the outer edges of the detector are masked even if the TB panels extend past the TB of the LR panels.
239// ? skip the masking? but then I bin the detector data directly to get I(q), skipping the masked NaN values...
240//
241Function V_SetShadow_TopBottom(folderStr,type)
242        String folderStr,type
243       
244        Variable LR_sep,nPix,xCtr,ii,jj,numCol,pixSizeX,pixSizeY,nPix_X,nPix_Y
245
246/// !! 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...
247        if(cmpstr(type[0],"F")==0)
248                //front
249                ControlInfo/W=VCALC VCALCCtrl_2a
250                LR_sep = V_Value       
251        else
252                //middle
253                ControlInfo/W=VCALC VCALCCtrl_3a
254                LR_sep = V_Value       
255        endif           
256//separations on panel are in mm -- need to watch the units, convert to cm
257        LR_sep /= 10
258
259//detector data
260        Wave det = $("root:Packages:NIST:VSANS:VCALC:"+folderStr+":det_"+type)
261
262// TODO - these are to be set from globals, not hard-wired
263// pixel sizes are in cm for T/B detector
264// TODO - the "FT" check is hard wired for FRONT -- get rid of this...
265
266        pixSizeX = VCALC_getPixSizeX(type)
267        pixSizeY = VCALC_getPixSizeY(type)
268
269        nPix_X = VCALC_get_nPix_X(type)
270        nPix_Y = VCALC_get_nPix_Y(type)
271       
272        //TODO -- get this from a global
273        xCtr = nPix_X/2
274        nPix = trunc(LR_sep/2/pixSizeX)         // approx # of pixels Left/right of center that are not obscured by L/R panels
275       
276        numCol = DimSize(det,0)         // x dim (columns)
277        for(ii=0;ii<(xCtr-nPix-2);ii+=1)
278                det[ii][] = NaN
279        endfor
280        for(ii=(xCtr+nPix+2);ii<numCol;ii+=1)
281                det[ii][] = NaN
282        endfor
283       
284        return(0)
285end
286
287
288// After the panels have been calculated and rescaled in terms of Q, and filled with simulated data
289// they can be appended to the subwindow. If they are already there, the axes and coloring
290// are rescaled as needed
291//
292Window FrontPanels_AsQ() : Graph
293
294        SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
295
296        CheckDisplayed /W=VCALC#Panels_Q det_FB
297        if(V_flag == 0)
298                AppendImage/W=VCALC#Panels_Q det_FB
299                ModifyImage/W=VCALC#Panels_Q det_FB ctab= {*,*,ColdWarm,0}
300                AppendImage/W=VCALC#Panels_Q det_FT
301                ModifyImage/W=VCALC#Panels_Q det_FT ctab= {*,*,ColdWarm,0}
302                AppendImage/W=VCALC#Panels_Q det_FL
303                ModifyImage/W=VCALC#Panels_Q det_FL ctab= {*,*,ColdWarm,0}
304                AppendImage/W=VCALC#Panels_Q det_FR
305                ModifyImage/W=VCALC#Panels_Q det_FR ctab= {*,*,ColdWarm,0}
306        endif
307
308        Variable dval
309        ControlInfo/W=VCALC setVar_b
310        dval = V_Value
311
312        SetAxis/W=VCALC#Panels_Q left -dval,dval
313        SetAxis/W=VCALC#Panels_Q bottom -dval,dval     
314
315        ControlInfo/W=VCALC check_0a
316// V_Value == 1 if checked
317        ModifyImage/W=VCALC#Panels_Q det_FB log=V_Value
318        ModifyImage/W=VCALC#Panels_Q det_FT log=V_Value
319        ModifyImage/W=VCALC#Panels_Q det_FL log=V_Value
320        ModifyImage/W=VCALC#Panels_Q det_FR log=V_Value
321
322
323        SetDataFolder root:
324       
325EndMacro
326
327
328
329
330
331
332//
333// these routines bin the 2D q data to 1D I(q). Currently the Qtot is magnitude only, no sign (since
334// it's being binned to I(Q), having a sign makes no sense. If you want the sign, work from qxqyqz
335//
336// first - the DeltaQ step is set as the smaller detector resolution (along tube)
337//       which is different for LR / TB geometry. This is not set in stone.
338//
339// second - each detector is binned separately
340//
341// -- like the routines in CircSectAve, start with 500 points, and trim after binning is done.
342//      you'l end up with < 200 points.
343//
344// the results are in iBin_qxqy, qBin_qxqy, and eBin_qxqy, in the folder passed
345//
346Proc BinAllFrontPanels()
347
348        SetDeltaQ("Front","FL")
349        SetDeltaQ("Front","FT")
350
351        Variable binType       
352        ControlInfo/W=VCALC popup_b
353        binType = V_Value               // V_value counts menu items from 1, so 1=1, 2=2, 3=4
354
355        if(binType == 1)
356                V_BinQxQy_to_1D("","FL")
357                V_BinQxQy_to_1D("","FR")
358                V_BinQxQy_to_1D("","FT")
359                V_BinQxQy_to_1D("","FB")
360        endif
361       
362        if(binType == 2)       
363                V_BinQxQy_to_1D("","FLR")
364                V_BinQxQy_to_1D("","FTB")
365        endif
366
367        if(binType == 3)
368                V_BinQxQy_to_1D("","FLRTB")
369        endif
370
371// TODO -- this is only a temporary fix for slit mode   
372        if(binType == 4)
373                /// this is for a tall, narrow slit mode       
374                V_fBinDetector_byRows("Front","FL")
375                V_fBinDetector_byRows("Front","FR")
376                V_fBinDetector_byRows("Front","FT")
377                V_fBinDetector_byRows("Front","FB")
378        endif
379               
380End
381
382
383
384
385
386
387
388Proc PlotMiddlePanels()
389        fPlotMiddlePanels()
390End
391
392// to plot I(q) for the 4 Middle panels
393//
394// *** Call this function when Middle panels are adjusted, or wavelength, etc. changed
395//
396Function fPlotMiddlePanels()
397
398        // space is allocated for all of the detectors and Q's on initialization
399        // calculate Qtot, qxqyqz arrays from geometry
400        V_CalculateQMiddlePanels()
401       
402        // fill the panels with fake sphere scattering data
403        // TODO: am I in the right data folder??
404        SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
405
406        WAVE det_ML = det_ML
407        WAVE det_MR = det_MR
408        WAVE det_MT = det_MT
409        WAVE det_MB = det_MB
410       
411        WAVE qTot_ML = qTot_ML
412        WAVE qTot_MR = qTot_MR
413        WAVE qTot_MT = qTot_MT
414        WAVE qTot_MB = qTot_MB
415
416        FillPanel_wModelData(det_ML,qTot_ML,"ML")
417        FillPanel_wModelData(det_MR,qTot_MR,"MR")
418        FillPanel_wModelData(det_MT,qTot_MT,"MT")
419        FillPanel_wModelData(det_MB,qTot_MB,"MB")                       
420
421        SetDataFolder root:
422               
423        // set any "shadowed" area of the T/B detectors to NaN to get a realitic
424        // view of how much of the detectors are actually collecting data
425        // -- I can get the separation L/R from the panel - only this "open" width is visible.
426        V_SetShadow_TopBottom("Middle","MT")            // TODO: -- be sure the data folder is properly set (within the function...)
427        V_SetShadow_TopBottom("Middle","MB")
428       
429        // do the q-binning for each of the panels to get I(Q)
430        Execute "BinAllMiddlePanels()"
431
432        // plot the results
433        Execute "Middle_IQ_Graph()"
434        Execute "MiddlePanels_AsQ()"
435       
436        return(0)
437End
438
439// works for Left, works for Right... works for T/B too.
440//
441// - TODO: be sure that the Q's are calculated correctly even when the beam is off of the
442//     detector, and on different sides of the detector (or T/B) - since it will be in a different
443//     relative postion to 0,0 on the detector. If the postions are symmetric, then the Q's should be identical.
444//     --- test this...
445// TODO -- be sure I'm in the right data folder. nothing is set correctly right now
446//
447// TODO: make all detector parameters global, not hard-wired
448//
449//
450// --- Panels are all allocated in the initialization. Here, only the q-values are calculated
451//     when anything changes
452//
453Function V_CalculateQMiddlePanels()
454
455        Variable xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY,nPix_X,nPix_Y
456        Variable M_LR_sep,M_TB_sep,M_offset, M_sdd_offset
457
458        M_LR_sep = VCALC_getPanelSeparation("MLR")
459        M_TB_sep = VCALC_getPanelSeparation("MTB")
460        M_offset = VCALC_getLateralOffset("ML")
461       
462        SDD = VCALC_getSDD("ML")                //nominal SDD - need offset for TB
463        lam = VCALC_getWavelength()
464
465//separations are in mm -- need to watch the units, convert to cm
466        M_LR_sep /= 10
467        M_TB_sep /= 10
468// TODO - I'm treating the separation as the TOTAL width - so the difference
469//      from the "center" to the edge is 1/2 of the separation
470
471// TODO (make the N along the tube length a variable, since this can be reset @ acquisition)
472        M_sdd_offset = VCALC_getTopBottomSDDOffset("MT")        //T/B are 30 cm farther back  //TODO: make all detector parameters global, not hard-wired
473
474        SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
475        Wave det_ML,det_MR                      // these are (48,128)           nominal, may change
476        Wave det_MT,det_MB                      // these are (128,48)
477
478//Middle/LEFT   
479        WAVE qTot_ML,qx_ML,qy_ML,qz_ML
480        qTot_ML = 0
481        qx_ML = 0
482        qy_ML = 0
483        qz_ML = 0       
484       
485// TODO - these are to be set from globals, not hard-wired. N and pixelSixze will be known (or pre-measured)
486// pixel sizes are in cm
487        pixSizeX = VCALC_getPixSizeX("ML")
488        pixSizeY = VCALC_getPixSizeY("ML")
489        nPix_X = VCALC_get_nPix_X("ML")
490        nPix_Y = VCALC_get_nPix_Y("ML")
491       
492        xCtr = nPix_X+(M_LR_sep/2/pixSizeX)             // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)??
493        yCtr = nPix_Y/2
494        V_Detector_2Q(det_ML,qTot_ML,qx_ML,qy_ML,qz_ML,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY)
495//      Print "xy for ML = ",xCtr,yCtr
496       
497        //set the wave scaling for the detector image so that it can be plotted in q-space
498        // TODO: this is only approximate - since the left "edge" is not the same from top to bottom, so I crudely
499        // take the middle value. At very small angles, OK, at 1m, this is a crummy approximation.
500        // since qTot is magnitude only, I need to put in the (-ve)
501        SetScale/I x WaveMin(qx_ML),WaveMax(qx_ML),"", det_ML           //this sets the left and right ends of the data scaling
502        SetScale/I y WaveMin(qy_ML),WaveMax(qy_ML),"", det_ML
503       
504//////////////////
505
506//Middle/RIGHT
507        SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
508        WAVE qTot_MR,qx_MR,qy_MR,qz_MR
509        qTot_MR = 0
510        qx_MR = 0
511        qy_MR = 0
512        qz_MR = 0
513
514// TODO - these are to be set from globals, not hard-wired
515// pixel sizes are in cm
516        pixSizeX = VCALC_getPixSizeX("MR")
517        pixSizeY = VCALC_getPixSizeY("MR")
518
519        nPix_X = VCALC_get_nPix_X("MR")
520        nPix_Y = VCALC_get_nPix_Y("MR")
521       
522        xCtr = -(M_LR_sep/2/pixSizeX)-1         
523        yCtr = nPix_Y/2
524        V_Detector_2Q(det_MR,qTot_MR,qx_MR,qy_MR,qz_MR,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY)
525//      Print "xy for MR = ",xCtr,yCtr
526        SetScale/I x WaveMin(qx_MR),WaveMax(qx_MR),"", det_MR           //this sets the left and right ends of the data scaling
527        SetScale/I y WaveMin(qy_MR),WaveMax(qy_MR),"", det_MR
528/////////////////
529
530//Middle/TOP
531        SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
532        WAVE qTot_MT,qx_MT,qy_MT,qz_MT
533        qTot_MT = 0
534        qx_MT = 0
535        qy_MT = 0
536        qz_MT = 0
537
538// TODO - these are to be set from globals, not hard-wired
539// pixel sizes are in cm
540        pixSizeX = VCALC_getPixSizeX("MT")
541        pixSizeY = VCALC_getPixSizeY("MT")
542        nPix_X = VCALC_get_nPix_X("MT")
543        nPix_Y = VCALC_get_nPix_Y("MT")
544       
545        xCtr = nPix_X/2
546        yCtr = -(M_TB_sep/2/pixSizeY)-1
547                // global sdd_offset is in (mm), convert to meters here for the Q-calculation 
548        V_Detector_2Q(det_MT,qTot_MT,qx_MT,qy_MT,qz_MT,xCtr,yCtr,sdd+M_sdd_offset/1000,lam,pixSizeX,pixSizeY)
549//      Print "xy for MT = ",xCtr,yCtr
550        SetScale/I x WaveMin(qx_MT),WaveMax(qx_MT),"", det_MT           //this sets the leMT and right ends of the data scaling
551        SetScale/I y WaveMin(qy_MT),WaveMax(qy_MT),"", det_MT
552//////////////////
553
554//Middle/BOTTOM
555        SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
556        WAVE qTot_MB,qx_MB,qy_MB,qz_MB
557        qTot_MB = 0
558        qx_MB = 0
559        qy_MB = 0
560        qz_MB = 0
561
562// TODO - these are to be set from globals, not hard-wired
563// pixel sizes are in cm
564        pixSizeX = VCALC_getPixSizeX("MB")
565        pixSizeY = VCALC_getPixSizeY("MB")
566        nPix_X = VCALC_get_nPix_X("MB")
567        nPix_Y = VCALC_get_nPix_Y("MB")
568               
569        xCtr = nPix_X/2
570        yCtr = nPix_Y+(M_TB_sep/2/pixSizeY)             // TODO  -- check -- starting from 47 rather than 48 (but I'm in pixel units for centers)??
571                // global sdd_offset is in (mm), convert to meters here for the Q-calculation
572        V_Detector_2Q(det_MB,qTot_MB,qx_MB,qy_MB,qz_MB,xCtr,yCtr,sdd+M_sdd_offset/1000,lam,pixSizeX,pixSizeY)
573//      Print "xy for MB = ",xCtr,yCtr
574        SetScale/I x WaveMin(qx_MB),WaveMax(qx_MB),"", det_MB           //this sets the left and right ends of the data scaling
575        SetScale/I y WaveMin(qy_MB),WaveMax(qy_MB),"", det_MB
576/////////////////
577
578        SetDataFolder root:
579               
580        return(0)
581End
582
583
584Window MiddlePanels_AsQ() : Graph
585//      DoWindow/F MiddlePanels_AsQ
586//      if(V_flag == 0)
587//      PauseUpdate; Silent 1           // building window...
588//      Display /W=(1477,44,1978,517)
589
590        SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
591
592        CheckDisplayed /W=VCALC#Panels_Q det_MB
593        if(V_flag == 0)
594                AppendImage/W=VCALC#Panels_Q det_MB
595                ModifyImage/W=VCALC#Panels_Q det_MB ctab= {*,*,ColdWarm,0}
596                AppendImage/W=VCALC#Panels_Q det_MT
597                ModifyImage/W=VCALC#Panels_Q det_MT ctab= {*,*,ColdWarm,0}
598                AppendImage/W=VCALC#Panels_Q det_ML
599                ModifyImage/W=VCALC#Panels_Q det_ML ctab= {*,*,ColdWarm,0}
600                AppendImage/W=VCALC#Panels_Q det_MR
601                ModifyImage/W=VCALC#Panels_Q det_MR ctab= {*,*,ColdWarm,0}
602        endif
603
604        Variable dval
605        ControlInfo/W=VCALC setVar_b
606        dval = V_Value
607
608        SetAxis/W=VCALC#Panels_Q left -dval,dval
609        SetAxis/W=VCALC#Panels_Q bottom -dval,dval     
610
611        ControlInfo/W=VCALC check_0a
612// V_Value == 1 if checked
613        ModifyImage/W=VCALC#Panels_Q det_MB log=V_Value
614        ModifyImage/W=VCALC#Panels_Q det_MT log=V_Value
615        ModifyImage/W=VCALC#Panels_Q det_ML log=V_Value
616        ModifyImage/W=VCALC#Panels_Q det_MR log=V_Value
617
618
619        SetDataFolder root:
620       
621//      ModifyGraph width={Aspect,1},height={Aspect,1},gbRGB=(56797,56797,56797)
622//      ModifyGraph grid=2
623//      ModifyGraph mirror=2
624//      SetAxis left -0.2,0.2
625//      SetAxis bottom -0.2,0.2
626//      endif
627EndMacro
628
629//
630// these routines bin the 2D q data to 1D I(q). Currently the Qtot is magnitude only, no sign (since
631// it's being binned to I(Q), having a sign makes no sense. If you want the sign, work from qxqyqz
632//
633// first - the DeltaQ step is set as the smaller detector resolution (along tube)
634//       which is different for LR / TB geometry. This is not set in stone.
635//
636// second - each detector is binned separately
637//
638// -- like the routines in CircSectAve, start with 500 points, and trim after binning is done.
639//      you'l end up with < 200 points.
640//
641// the results are in iBin_qxqy, qBin_qxqy, and eBin_qxqy, in the folder passed
642//
643Proc BinAllMiddlePanels()
644
645        SetDeltaQ("Middle","ML")
646        SetDeltaQ("Middle","MT")
647
648        Variable binType       
649        ControlInfo/W=VCALC popup_b
650        binType = V_Value               // V_value counts menu items from 1, so 1=1, 2=2, 3=4
651
652        if(binType == 1)
653                V_BinQxQy_to_1D("","ML")
654                V_BinQxQy_to_1D("","MR")
655                V_BinQxQy_to_1D("","MT")
656                V_BinQxQy_to_1D("","MB")
657        endif
658       
659        if(binType == 2)       
660                V_BinQxQy_to_1D("","MLR")
661                V_BinQxQy_to_1D("","MTB")
662        endif
663
664        if(binType == 3)
665                V_BinQxQy_to_1D("","MLRTB")
666        endif
667       
668        // TODO -- this is only a temporary fix for slit mode   
669        if(binType == 4)
670                /// this is for a tall, narrow slit mode       
671                V_fBinDetector_byRows("Middle","ML")
672                V_fBinDetector_byRows("Middle","MR")
673                V_fBinDetector_byRows("Middle","MT")
674                V_fBinDetector_byRows("Middle","MB")
675        endif
676End
677
678////////////to plot the (4) 2D panels and to plot the I(Q) data on the same plot
679Window Middle_IQ_Graph() : Graph
680
681        Variable binType
682       
683        ControlInfo/W=VCALC popup_b
684        binType = V_Value               // V_value counts menu items from 1, so 1=1, 2=2, 3=4
685
686        SetDataFolder root:Packages:NIST:VSANS:VCALC
687
688        if(binType==1)
689                ClearIQIfDisplayed("MLRTB")
690                ClearIQIfDisplayed("MLR")
691                ClearIQIfDisplayed("MTB")
692               
693                SetDataFolder root:Packages:NIST:VSANS:VCALC
694                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_ML
695               
696                if(V_flag==0)
697                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_ML vs qBin_qxqy_ML
698                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_MR vs qBin_qxqy_MR
699                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_MT vs qBin_qxqy_MT
700                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_MB vs qBin_qxqy_MB
701                        ModifyGraph/W=VCALC#Panels_IQ mode=4
702                        ModifyGraph/W=VCALC#Panels_IQ marker=19
703                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_ML)=(65535,0,0),rgb(iBin_qxqy_MB)=(1,16019,65535),rgb(iBin_qxqy_MR)=(65535,0,0),rgb(iBin_qxqy_MT)=(1,16019,65535)
704                        ModifyGraph/W=VCALC#Panels_IQ msize=2
705                        ModifyGraph/W=VCALC#Panels_IQ muloffset(iBin_qxqy_ML)={0,4},muloffset(iBin_qxqy_MB)={0,2},muloffset(iBin_qxqy_MR)={0,8}
706                        ModifyGraph/W=VCALC#Panels_IQ grid=1
707                        ModifyGraph/W=VCALC#Panels_IQ log=1
708                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
709                endif           
710        endif
711       
712        if(binType==2)
713                ClearIQIfDisplayed("MLRTB")
714                ClearIQIfDisplayed("MT")       
715                ClearIQIfDisplayed("ML")       
716                ClearIQIfDisplayed("MR")       
717                ClearIQIfDisplayed("MB")
718       
719
720                SetDataFolder root:Packages:NIST:VSANS:VCALC
721                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_MLR
722               
723                if(V_flag==0)
724                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_MLR vs qBin_qxqy_MLR
725                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_MTB vs qBin_qxqy_MTB
726                        ModifyGraph/W=VCALC#Panels_IQ mode=4
727                        ModifyGraph/W=VCALC#Panels_IQ marker=19
728                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_MLR)=(65535,0,0),rgb(iBin_qxqy_MTB)=(1,16019,65535)
729                        ModifyGraph/W=VCALC#Panels_IQ msize=2
730                        ModifyGraph/W=VCALC#Panels_IQ muloffset(iBin_qxqy_MLR)={0,2}
731                        ModifyGraph/W=VCALC#Panels_IQ grid=1
732                        ModifyGraph/W=VCALC#Panels_IQ log=1
733                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
734                        Label/W=VCALC#Panels_IQ left "Intensity (1/cm)"
735                        Label/W=VCALC#Panels_IQ bottom "Q (1/A)"
736                endif   
737                       
738        endif
739       
740        if(binType==3)
741                ClearIQIfDisplayed("MLR")
742                ClearIQIfDisplayed("MTB")       
743                ClearIQIfDisplayed("MT")       
744                ClearIQIfDisplayed("ML")       
745                ClearIQIfDisplayed("MR")       
746                ClearIQIfDisplayed("MB")       
747       
748                SetDataFolder root:Packages:NIST:VSANS:VCALC
749                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_MLRTB
750               
751                if(V_flag==0)
752                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_MLRTB vs qBin_qxqy_MLRTB
753                        ModifyGraph/W=VCALC#Panels_IQ mode=4
754                        ModifyGraph/W=VCALC#Panels_IQ marker=19
755                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_MLRTB)=(65535,0,0)
756                        ModifyGraph/W=VCALC#Panels_IQ msize=2
757                        ModifyGraph/W=VCALC#Panels_IQ grid=1
758                        ModifyGraph/W=VCALC#Panels_IQ log=1
759                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
760                        Label/W=VCALC#Panels_IQ left "Intensity (1/cm)"
761                        Label/W=VCALC#Panels_IQ bottom "Q (1/A)"
762                endif   
763                       
764        endif
765
766        if(binType==4)          // slit aperture binning - Mt, ML, MR, MB are averaged
767                ClearIQIfDisplayed("MLRTB")
768                ClearIQIfDisplayed("MLR")
769                ClearIQIfDisplayed("MTB")
770               
771                SetDataFolder root:Packages:NIST:VSANS:VCALC
772                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_ML
773               
774                if(V_flag==0)
775                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_ML vs qBin_qxqy_ML
776                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_MR vs qBin_qxqy_MR
777                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_MT vs qBin_qxqy_MT
778                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_MB vs qBin_qxqy_MB
779                        ModifyGraph/W=VCALC#Panels_IQ mode=4
780                        ModifyGraph/W=VCALC#Panels_IQ marker=19
781                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_ML)=(65535,0,0),rgb(iBin_qxqy_MB)=(1,16019,65535),rgb(iBin_qxqy_MR)=(65535,0,0),rgb(iBin_qxqy_MT)=(1,16019,65535)
782                        ModifyGraph/W=VCALC#Panels_IQ msize=2
783                        ModifyGraph/W=VCALC#Panels_IQ muloffset(iBin_qxqy_ML)={0,4},muloffset(iBin_qxqy_MB)={0,2},muloffset(iBin_qxqy_MR)={0,8}
784                        ModifyGraph/W=VCALC#Panels_IQ grid=1
785                        ModifyGraph/W=VCALC#Panels_IQ log=1
786                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
787                endif           
788                       
789        endif
790        SetDataFolder root:
791EndMacro
792
793
794////////// and for the BACK detector
795Proc PlotBackPanels()
796        fPlotBackPanels()
797End
798
799// to plot I(q) for the Back panel
800//
801// *** Call this function when Back panel is adjusted, or wavelength, etc. changed
802//
803Function fPlotBackPanels()
804
805        // space is allocated for all of the detectors and Q's on initialization
806        // calculate Qtot, qxqyqz arrays from geometry
807        V_CalculateQBackPanels()
808       
809        // fill the panels with fake sphere scattering data
810        // TODO: am I in the right data folder??
811        SetDataFolder root:Packages:NIST:VSANS:VCALC:Back
812
813        WAVE det_B = det_B
814        WAVE qTot_B = qTot_B
815
816        FillPanel_wModelData(det_B,qTot_B,"B")         
817
818        SetDataFolder root:
819               
820        // set any "shadowed" area of the T/B detectors to NaN to get a realitic
821        // view of how much of the detectors are actually collecting data
822        // -- I can get the separation L/R from the panel - only this "open" width is visible.
823//      V_SetShadow_TopBottom("","MT")          // TODO: -- be sure the data folder is properly set (within the function...)
824//      V_SetShadow_TopBottom("","MB")
825       
826        // do the q-binning for each of the panels to get I(Q)
827        Execute "BinAllBackPanels()"
828
829        // plot the results
830        Execute "Back_IQ_Graph()"
831        Execute "BackPanels_AsQ()"
832
833        return(0)
834
835End
836
837// works for Left, works for Right... works for T/B too.
838//
839// - TODO: be sure that the Q's are calculated correctly even when the beam is off of the
840//     detector, and on different sides of the detector (or T/B) - since it will be in a different
841//     relative postion to 0,0 on the detector. If the postions are symmetric, then the Q's should be identical.
842//     --- test this...
843// TODO -- be sure I'm in the right data folder. nothing is set correctly right now
844//
845// TODO: make all detector parameters global, not hard-wired
846//
847//
848// --- Panels are all allocated in the initialization. Here, only the q-values are calculated
849//     when anything changes
850//
851Function V_CalculateQBackPanels()
852
853        Variable xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY
854        Variable B_offset
855
856        B_offset = VCALC_getLateralOffset("B")
857       
858        SDD = VCALC_getSDD("B")         //nominal SDD - need offset for TB
859        lam = VCALC_getWavelength()
860
861// TODO (make the N along the tube length a variable, since this can be reset @ acquisition)
862        SetDataFolder root:Packages:NIST:VSANS:VCALC:Back
863        Wave det_B                      // this is (320,320)
864
865//Back detector
866        WAVE qTot_B,qx_B,qy_B,qz_B
867        qTot_B = 0
868        qx_B = 0
869        qy_B = 0
870        qz_B = 0       
871       
872// TODO - these are to be set from globals, not hard-wired. N and pixelSixze will be known (or pre-measured)
873// pixel sizes are in cm
874        pixSizeX = VCALC_getPixSizeX("B")
875        pixSizeY = VCALC_getPixSizeY("B")
876       
877        xCtr = trunc( DimSize(det_B,0)/2 )              //should be 160
878        yCtr = trunc( DimSize(det_B,1)/2 )              //should be 160
879        V_Detector_2Q(det_B,qTot_B,qx_B,qy_B,qz_B,xCtr,yCtr,sdd,lam,pixSizeX,pixSizeY)
880       
881        //set the wave scaling for the detector image so that it can be plotted in q-space
882        // TODO: this is only approximate - since the left "edge" is not the same from top to bottom, so I crudely
883        // take the middle value. At very small angles, OK, at 1m, this is a crummy approximation.
884        // since qTot is magnitude only, I need to put in the (-ve)
885        SetScale/I x WaveMin(qx_B),WaveMax(qx_B),"", det_B              //this sets the left and right ends of the data scaling
886        SetScale/I y WaveMin(qy_B),WaveMax(qy_B),"", det_B
887
888        SetDataFolder root:
889               
890        return(0)
891End
892
893
894Window BackPanels_AsQ() : Graph
895//      DoWindow/F BackPanels_AsQ
896//      if(V_flag == 0)
897//      PauseUpdate; Silent 1           // building window...
898//      Display /W=(1477,44,1978,517)
899
900        SetDataFolder root:Packages:NIST:VSANS:VCALC:Back
901
902        CheckDisplayed /W=VCALC#Panels_Q det_B
903        if(V_flag == 0)
904                AppendImage/W=VCALC#Panels_Q det_B
905                ModifyImage/W=VCALC#Panels_Q det_B ctab= {*,*,ColdWarm,0}
906        endif
907
908        Variable dval
909        ControlInfo/W=VCALC setVar_b
910        dval = V_Value
911
912        SetAxis/W=VCALC#Panels_Q left -dval,dval
913        SetAxis/W=VCALC#Panels_Q bottom -dval,dval     
914
915        ControlInfo/W=VCALC check_0a
916// V_Value == 1 if checked
917        ModifyImage/W=VCALC#Panels_Q det_B log=V_Value
918
919        SetDataFolder root:
920       
921//      ModifyGraph width={Aspect,1},height={Aspect,1},gbRGB=(56797,56797,56797)
922//      ModifyGraph grid=2
923//      ModifyGraph mirror=2
924//      SetAxis left -0.2,0.2
925//      SetAxis bottom -0.2,0.2
926//      endif
927EndMacro
928
929//
930// these routines bin the 2D q data to 1D I(q). Currently the Qtot is magnitude only, no sign (since
931// it's being binned to I(Q), having a sign makes no sense. If you want the sign, work from qxqyqz
932//
933// first - the DeltaQ step is set as the smaller detector resolution (along tube)
934//       which is different for LR / TB geometry. This is not set in stone.
935//
936// second - each detector is binned separately
937//
938// -- like the routines in CircSectAve, start with 500 points, and trim after binning is done.
939//      you'l end up with < 200 points.
940//
941// the results are in iBin_qxqy, qBin_qxqy, and eBin_qxqy, in the folder passed
942//
943Proc BinAllBackPanels()
944
945        SetDeltaQ("Back","B")
946
947        Variable binType       
948        ControlInfo/W=VCALC popup_b
949        binType = V_Value               // V_value counts menu items from 1, so 1=1, 2=2, 3=4
950       
951        V_BinQxQy_to_1D("","B")
952
953// TODO -- this is only a temporary fix for slit mode   
954        if(binType == 4)
955                /// this is for a tall, narrow slit mode       
956                V_fBinDetector_byRows("Back","B")
957        endif   
958       
959End
960
961////////////to plot the back panel I(q)
962Window Back_IQ_Graph() : Graph
963
964        SetDataFolder root:Packages:NIST:VSANS:VCALC
965
966        Variable binType
967       
968        ControlInfo/W=VCALC popup_b
969        binType = V_Value               // V_value counts menu items from 1, so 1=1, 2=2, 3=4
970       
971
972        if(binType==1 || binType==2 || binType==3)
973               
974                SetDataFolder root:Packages:NIST:VSANS:VCALC
975                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_B
976               
977                if(V_flag==0)
978                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_B vs qBin_qxqy_B
979                        ModifyGraph/W=VCALC#Panels_IQ mode=4
980                        ModifyGraph/W=VCALC#Panels_IQ marker=19
981                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_B)=(1,52428,52428)
982                        ModifyGraph/W=VCALC#Panels_IQ msize=2
983                        ModifyGraph/W=VCALC#Panels_IQ grid=1
984                        ModifyGraph/W=VCALC#Panels_IQ log=1
985                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
986                endif
987        endif
988
989        //nothing different here since there is ony a single detector to display, but for the future...
990        if(binType==4)
991               
992                SetDataFolder root:Packages:NIST:VSANS:VCALC
993                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_B
994               
995                if(V_flag==0)
996                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_B vs qBin_qxqy_B
997                        ModifyGraph/W=VCALC#Panels_IQ mode=4
998                        ModifyGraph/W=VCALC#Panels_IQ marker=19
999                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_B)=(1,52428,52428)
1000                        ModifyGraph/W=VCALC#Panels_IQ msize=2
1001                        ModifyGraph/W=VCALC#Panels_IQ grid=1
1002                        ModifyGraph/W=VCALC#Panels_IQ log=1
1003                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
1004                endif
1005        endif
1006
1007       
1008        SetDataFolder root:
1009EndMacro
1010
1011
1012////////////to plot the (4) 2D panels and to plot the I(Q) data on the same plot
1013//
1014// ** but now I need to check and see if these waves exist before trying to append them
1015// since the panels may bave been combined when binned - rather than all separate.
1016//
1017// TODO
1018// -- so maybe I want to clear the traces from the graph?
1019// -- set a flag on the panel to know how the binning is applied?
1020//
1021Window Front_IQ_Graph() : Graph
1022
1023        Variable binType
1024       
1025        ControlInfo/W=VCALC popup_b
1026        binType = V_Value               // V_value counts menu items from 1, so 1=1, 2=2, 3=4
1027
1028        SetDataFolder root:Packages:NIST:VSANS:VCALC
1029
1030        if(binType==1)
1031                ClearIQIfDisplayed("FLRTB")
1032                ClearIQIfDisplayed("FLR")
1033                ClearIQIfDisplayed("FTB")
1034               
1035                SetDataFolder root:Packages:NIST:VSANS:VCALC
1036                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_FL
1037               
1038                if(V_flag==0)
1039                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_FL vs qBin_qxqy_FL
1040                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_FR vs qBin_qxqy_FR
1041                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_FT vs qBin_qxqy_FT
1042                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_FB vs qBin_qxqy_FB
1043                        ModifyGraph/W=VCALC#Panels_IQ mode=4
1044                        ModifyGraph/W=VCALC#Panels_IQ marker=19
1045                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_FL)=(39321,26208,1),rgb(iBin_qxqy_FB)=(2,39321,1),rgb(iBin_qxqy_FR)=(39321,26208,1),rgb(iBin_qxqy_FT)=(2,39321,1)
1046                        ModifyGraph/W=VCALC#Panels_IQ msize=2
1047                        ModifyGraph/W=VCALC#Panels_IQ muloffset(iBin_qxqy_FL)={0,4},muloffset(iBin_qxqy_FB)={0,2},muloffset(iBin_qxqy_FR)={0,8}
1048                        ModifyGraph/W=VCALC#Panels_IQ grid=1
1049                        ModifyGraph/W=VCALC#Panels_IQ log=1
1050                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
1051                        Label/W=VCALC#Panels_IQ left "Intensity (1/cm)"
1052                        Label/W=VCALC#Panels_IQ bottom "Q (1/A)"
1053                endif   
1054                               
1055        endif
1056
1057        if(binType==2)
1058                ClearIQIfDisplayed("FLRTB")
1059                ClearIQIfDisplayed("FT")       
1060                ClearIQIfDisplayed("FL")       
1061                ClearIQIfDisplayed("FR")       
1062                ClearIQIfDisplayed("FB")
1063       
1064
1065                SetDataFolder root:Packages:NIST:VSANS:VCALC
1066                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_FLR
1067               
1068                if(V_flag==0)
1069                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_FLR vs qBin_qxqy_FLR
1070                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_FTB vs qBin_qxqy_FTB
1071                        ModifyGraph/W=VCALC#Panels_IQ mode=4
1072                        ModifyGraph/W=VCALC#Panels_IQ marker=19
1073                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_FLR)=(39321,26208,1),rgb(iBin_qxqy_FTB)=(2,39321,1)
1074                        ModifyGraph/W=VCALC#Panels_IQ msize=2
1075                        ModifyGraph/W=VCALC#Panels_IQ muloffset(iBin_qxqy_FLR)={0,2}
1076                        ModifyGraph/W=VCALC#Panels_IQ grid=1
1077                        ModifyGraph/W=VCALC#Panels_IQ log=1
1078                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
1079                        Label/W=VCALC#Panels_IQ left "Intensity (1/cm)"
1080                        Label/W=VCALC#Panels_IQ bottom "Q (1/A)"
1081                endif   
1082                       
1083        endif
1084       
1085        if(binType==3)
1086                ClearIQIfDisplayed("FLR")
1087                ClearIQIfDisplayed("FTB")       
1088                ClearIQIfDisplayed("FT")       
1089                ClearIQIfDisplayed("FL")       
1090                ClearIQIfDisplayed("FR")       
1091                ClearIQIfDisplayed("FB")       
1092       
1093                SetDataFolder root:Packages:NIST:VSANS:VCALC
1094                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_FLRTB
1095               
1096                if(V_flag==0)
1097                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_FLRTB vs qBin_qxqy_FLRTB
1098                        ModifyGraph/W=VCALC#Panels_IQ mode=4
1099                        ModifyGraph/W=VCALC#Panels_IQ marker=19
1100                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_FLRTB)=(39321,26208,1)
1101                        ModifyGraph/W=VCALC#Panels_IQ msize=2
1102                        ModifyGraph/W=VCALC#Panels_IQ grid=1
1103                        ModifyGraph/W=VCALC#Panels_IQ log=1
1104                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
1105                        Label/W=VCALC#Panels_IQ left "Intensity (1/cm)"
1106                        Label/W=VCALC#Panels_IQ bottom "Q (1/A)"
1107                endif   
1108                       
1109        endif
1110
1111
1112        if(binType==4)          //slit mode
1113                ClearIQIfDisplayed("FLRTB")
1114                ClearIQIfDisplayed("FLR")
1115                ClearIQIfDisplayed("FTB")
1116               
1117                SetDataFolder root:Packages:NIST:VSANS:VCALC
1118                CheckDisplayed/W=VCALC#Panels_IQ iBin_qxqy_FL
1119               
1120                if(V_flag==0)
1121                        AppendtoGraph/W=VCALC#Panels_IQ iBin_qxqy_FL vs qBin_qxqy_FL
1122                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_FR vs qBin_qxqy_FR
1123                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_FT vs qBin_qxqy_FT
1124                        AppendToGraph/W=VCALC#Panels_IQ iBin_qxqy_FB vs qBin_qxqy_FB
1125                        ModifyGraph/W=VCALC#Panels_IQ mode=4
1126                        ModifyGraph/W=VCALC#Panels_IQ marker=19
1127                        ModifyGraph/W=VCALC#Panels_IQ rgb(iBin_qxqy_FL)=(39321,26208,1),rgb(iBin_qxqy_FB)=(2,39321,1),rgb(iBin_qxqy_FR)=(39321,26208,1),rgb(iBin_qxqy_FT)=(2,39321,1)
1128                        ModifyGraph/W=VCALC#Panels_IQ msize=2
1129                        ModifyGraph/W=VCALC#Panels_IQ muloffset(iBin_qxqy_FL)={0,4},muloffset(iBin_qxqy_FB)={0,2},muloffset(iBin_qxqy_FR)={0,8}
1130                        ModifyGraph/W=VCALC#Panels_IQ grid=1
1131                        ModifyGraph/W=VCALC#Panels_IQ log=1
1132                        ModifyGraph/W=VCALC#Panels_IQ mirror=2
1133                        Label/W=VCALC#Panels_IQ left "Intensity (1/cm)"
1134                        Label/W=VCALC#Panels_IQ bottom "Q (1/A)"
1135                endif   
1136                               
1137        endif
1138
1139       
1140        SetDataFolder root:
1141       
1142EndMacro
1143
1144Function        ClearIQIfDisplayed(type)
1145        String type
1146       
1147        SetDataFolder root:Packages:NIST:VSANS:VCALC
1148        CheckDisplayed/W=VCALC#Panels_IQ $("iBin_qxqy_"+type)
1149        if(V_flag==1)
1150                RemoveFromGraph/W=VCALC#Panels_IQ $("iBin_qxqy_"+type)
1151        endif
1152        SetDataFolder root:
1153       
1154        return(0)
1155end
1156
1157Window Table_of_QBins() : Table
1158        PauseUpdate; Silent 1           // building window...
1159        String fldrSav0= GetDataFolder(1)
1160        SetDataFolder root:Packages:NIST:VSANS:VCALC:
1161        Edit/W=(5,44,771,898) qBin_qxqy_FL,qBin_qxqy_FR,qBin_qxqy_FT,qBin_qxqy_FB,qBin_qxqy_FLR
1162        AppendToTable qBin_qxqy_FTB,qBin_qxqy_FLRTB
1163        ModifyTable format(Point)=1,width(qBin_qxqy_FLR)=136,width(qBin_qxqy_FLRTB)=120
1164        SetDataFolder fldrSav0
1165EndMacro
1166
1167
1168
1169
Note: See TracBrowser for help on using the repository browser.