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

Last change on this file since 955 was 955, checked in by srkline, 8 years ago

some reorganization of the r/w routines to generate HDF test files for SANS and VSANS (all are housed together for testing). also some reorganization of the detector binning routines to get functions grouped in more logical locations.

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