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

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

converted and renamed VSANS files. "VC_" prefix for VCALC related files (that's all of them right now), and moved and renamed parts of files so that the ipf names are more logical now with the contents. Deleted the "V_" prefix files. Added a lengthy routine to be able to write out a VSANS file in HDF format. This is NOT the final and approved data format, only a working version so that I can test things out...

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