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

Last change on this file since 955 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: 11.7 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3
4
5
6/////////////
7// different views of the detector positions - based on John's drawings and the geometry
8//
9//
10// These are the side and top views with the "rays" traced out to show
11// where the detector views overlap
12//
13// TODO:
14// -x  make sure that all of the values are from global constants, not hard-wired values
15//
16//
17//
18
19
20// generate the waves needed for drawing the views
21// draw a blank graph
22Function SetupSideView()
23
24        SetDataFolder root:Packages:NIST:VSANS:VCALC
25
26        Make/O/D/N=2 FT_profileX,FT_profileY,FB_profileX,FB_profileY
27        Make/O/D/N=2 MT_profileX,MT_profileY,MB_profileX,MB_profileY
28       
29        Make/O/D/N=4 FT_rayX,FT_rayY,FB_rayX,FB_rayY
30        Make/O/D/N=4 MT_rayX,MT_rayY,MB_rayX,MB_rayY
31
32        Make/O/D/N=2 B_S_profileX,B_S_profileY
33        Make/O/D/N=4 B_S_rayX,B_S_rayY
34       
35        DoWindow SideView
36        if(V_Flag==0)
37                Execute "SideView()"
38        endif
39       
40//      UpdateSideView()  // don't bother running this here - the Execute is a separate command and is out of sync.
41       
42        SetDataFolder root:
43        return(0)
44End
45
46// TODO:
47// -x account for the 30cm SDD offset for the T/B detectors. These are only seen in the side view.
48//
49Function UpdateSideView()
50
51        SetDataFolder root:Packages:NIST:VSANS:VCALC
52       
53// wave declarations
54        Wave FT_profileX,FT_profileY,FB_profileX,FB_profileY
55        Wave MT_profileX,MT_profileY,MB_profileX,MB_profileY
56       
57        Wave FT_rayX,FT_rayY,FB_rayX,FB_rayY
58        Wave MT_rayX,MT_rayY,MB_rayX,MB_rayY
59
60        Wave B_S_profileX,B_S_profileY
61        Wave B_S_rayX,B_S_rayY
62
63// Dimensions of detectors
64        NVAR F_LR_w = gFront_LR_w
65        NVAR F_LR_h = gFront_LR_h
66        NVAR F_TB_w = gFront_TB_w
67        NVAR F_TB_h = gFront_TB_h
68       
69        NVAR M_LR_w = gMiddle_LR_w
70        NVAR M_LR_h = gMiddle_LR_h
71        NVAR M_TB_w = gMiddle_TB_w
72        NVAR M_TB_h = gMiddle_TB_h
73
74        NVAR B_h = gBack_h
75        NVAR B_w = gBack_w
76
77
78// get the values from the panel
79        Variable F_LR_sep,F_TB_sep, F_SDD, F_offset
80        Variable M_LR_sep,M_TB_sep, M_SDD, M_offset
81        Variable B_SDD, B_offset
82
83        NVAR TB_SDD_offset = gFront_SDDOffset           //in mm !!  distance T/B are behind L/R - not to be confused with lateral offset
84       
85        //front
86//      ControlInfo VCALCCtrl_2a
87//      F_LR_sep = V_Value
88        ControlInfo VCALCCtrl_2b
89        F_TB_sep = V_Value
90        ControlInfo VCALCCtrl_2c
91        F_offset = V_Value
92        ControlInfo VCALCCtrl_2d
93        F_SDD = V_Value
94                               
95        //middle
96//      ControlInfo VCALCCtrl_3a
97//      M_LR_sep = V_Value
98        ControlInfo VCALCCtrl_3b
99        M_TB_sep = V_Value
100        ControlInfo VCALCCtrl_3c
101        M_offset = V_Value
102        ControlInfo VCALCCtrl_3d
103        M_SDD = V_Value
104       
105        //back                 
106        ControlInfo VCALCCtrl_4a
107        B_offset = V_Value     
108        ControlInfo VCALCCtrl_4b
109        B_SDD = V_Value         
110
111//      Print "Front ", F_LR_sep,F_TB_sep, F_SDD, F_offset
112//      Print "Middle ",  M_LR_sep,M_TB_sep, M_SDD, M_offset
113//      Print "Back ",  B_SDD, B_offset                 
114                       
115
116// FRONT
117        FT_profileX = F_SDD+TB_SDD_offset/1000          //SDD in meters, set back from L/R      ---- convert to meters for the plot
118        FB_profileX = FT_profileX
119       
120        FT_profileY[0] = F_TB_sep               // separation in mm
121        FT_profileY[1] = FT_profileY[0] + F_TB_h        // add in height of T/B panel in mm
122       
123        FB_profileY = -FT_profileY
124
125        //angles (not calculating anything, just connect the dots)
126        FT_rayX[0] = 0
127        FT_rayX[1] = F_SDD+TB_SDD_offset/1000
128        FT_rayX[2] = F_SDD+TB_SDD_offset/1000
129        FT_rayX[3] = 0
130       
131        FT_rayY[0] = 0
132        FT_rayy[1] = FT_profileY[0]
133        FT_rayY[2] = FT_profileY[1]
134        FT_rayY[3] = 0
135       
136       
137        FB_rayX[0] = 0
138        FB_rayX[1] = F_SDD+TB_SDD_offset/1000
139        FB_rayX[2] = F_SDD+TB_SDD_offset/1000
140        FB_rayX[3] = 0
141       
142        FB_rayY[0] = 0
143        FB_rayy[1] = FB_profileY[0]
144        FB_rayY[2] = FB_profileY[1]
145        FB_rayY[3] = 0 
146
147
148// MIDDLE       
149        MT_profileX = M_SDD+TB_SDD_offset/1000          //SDD in meters
150        MB_profileX = MT_profileX
151       
152        MT_profileY[0] = M_TB_sep               // separation in mm
153        MT_profileY[1] = MT_profileY[0] + M_TB_h        // add in height of T/B panel in mm
154       
155        MB_profileY = -MT_profileY
156
157        //angles (not calculating anything, just connect the dots)
158        MT_rayX[0] = 0
159        MT_rayX[1] = M_SDD+TB_SDD_offset/1000
160        MT_rayX[2] = M_SDD+TB_SDD_offset/1000
161        MT_rayX[3] = 0
162       
163        MT_rayY[0] = 0
164        MT_rayy[1] = MT_profileY[0]
165        MT_rayY[2] = MT_profileY[1]
166        MT_rayY[3] = 0
167       
168       
169        MB_rayX[0] = 0
170        MB_rayX[1] = M_SDD+TB_SDD_offset/1000
171        MB_rayX[2] = M_SDD+TB_SDD_offset/1000
172        MB_rayX[3] = 0
173       
174        MB_rayY[0] = 0
175        MB_rayy[1] = MB_profileY[0]
176        MB_rayY[2] = MB_profileY[1]
177        MB_rayY[3] = 0 
178
179// BACK
180        B_S_profileX = B_SDD            //SDDb in meters
181       
182        B_S_profileY[0] = B_h/2         // half-height
183        B_S_profileY[1] = -B_h/2                // half-height
184
185        B_S_rayX[0] = 0
186        B_S_rayX[1] = B_SDD
187        B_S_rayX[2] = B_SDD
188        B_S_rayX[3] = 0
189       
190        B_S_rayY[0] = 0
191        B_S_rayy[1] = B_S_profileY[0]
192        B_S_rayY[2] = B_S_profileY[1]
193        B_S_rayY[3] = 0
194       
195        SetDataFolder root:
196       
197        Execute "SideView()"
198       
199        return(0)
200       
201End
202
203
204Window SideView() : Graph
205
206        PauseUpdate; Silent 1           // building window...
207        String fldrSav0= GetDataFolder(1)
208        SetDataFolder root:Packages:NIST:VSANS:VCALC
209       
210        CheckDisplayed/W=VCALC#SideView FB_rayY
211        if(V_flag == 0)
212//              Display /W=(41,720,592,1119) FB_rayY vs FB_rayX as "SideView"
213                AppendToGraph/W=VCALC#SideView FB_rayY vs FB_rayX
214                AppendToGraph/W=VCALC#SideView FT_rayY vs FT_rayX
215                AppendToGraph/W=VCALC#SideView MB_rayY vs MB_rayX
216                AppendToGraph/W=VCALC#SideView MT_rayY vs MT_rayX
217                AppendToGraph/W=VCALC#SideView B_S_rayY vs B_S_rayX
218                AppendToGraph/W=VCALC#SideView B_S_profileY vs B_S_profileX
219                AppendToGraph/W=VCALC#SideView FB_profileY vs FB_profileX
220                AppendToGraph/W=VCALC#SideView FT_profileY vs FT_profileX
221                AppendToGraph/W=VCALC#SideView MB_profileY vs MB_profileX
222                AppendToGraph/W=VCALC#SideView MT_profileY vs MT_profileX
223       
224                ModifyGraph/W=VCALC#SideView lSize(B_S_profileY)=5,lSize(FB_profileY)=5,lSize(FT_profileY)=5,lSize(MB_profileY)=5
225                ModifyGraph/W=VCALC#SideView lSize(MT_profileY)=5
226                ModifyGraph/W=VCALC#SideView rgb(FB_rayY)=(0,0,0),rgb(FT_rayY)=(0,0,0),rgb(MB_rayY)=(0,0,0),rgb(MT_rayY)=(0,0,0)
227                ModifyGraph/W=VCALC#SideView rgb(B_S_rayY)=(0,0,0),rgb(B_S_profileY)=(1,52428,52428),rgb(FB_profileY)=(3,52428,1)
228                ModifyGraph/W=VCALC#SideView rgb(FT_profileY)=(3,52428,1),rgb(MB_profileY)=(1,12815,52428),rgb(MT_profileY)=(1,12815,52428)
229                ModifyGraph/W=VCALC#SideView grid=1
230                ModifyGraph/W=VCALC#SideView mirror=2
231                ModifyGraph/W=VCALC#SideView nticks(left)=8
232                Label/W=VCALC#SideView left "\\Z10Vertical position (mm)"
233                Label/W=VCALC#SideView bottom "\\Z10SDD (meters)"
234                SetAxis/W=VCALC#SideView left -800,800
235                SetAxis/W=VCALC#SideView bottom 0,25
236//              TextBox/W=VCALC#SideView/C/N=text0/A=MC/X=22.54/Y=42.04 "\\JCSIDE VIEW\rOnly the Top/Bottom panels are shown"
237                TextBox/W=VCALC#SideView/C/N=text0/A=MC/X=40.15/Y=43.62 "\\JCSIDE VIEW\r= Top/Bottom panels"
238        endif
239        SetDataFolder fldrSav0
240       
241EndMacro
242
243
244
245//////////////////
246// generate the waves needed for drawing the views
247// draw a blank graph
248//
249// TOP VIEW uses the L and R banks
250//
251Function SetupTopView()
252
253        SetDataFolder root:Packages:NIST:VSANS:VCALC
254
255        Make/O/D/N=2 FL_profileX,FL_profileY,FR_profileX,FR_profileY
256        Make/O/D/N=2 ML_profileX,ML_profileY,MR_profileX,MR_profileY
257       
258        Make/O/D/N=4 FL_rayX,FL_rayY,FR_rayX,FR_rayY
259        Make/O/D/N=4 ML_rayX,ML_rayY,MR_rayX,MR_rayY
260
261        Make/O/D/N=2 B_T_profileX,B_T_profileY
262        Make/O/D/N=4 B_T_rayX,B_T_rayY
263
264        DoWindow TopView
265        if(V_Flag==0)
266                Execute "TopView()"
267        endif
268       
269       
270        SetDataFolder root:
271        return(0)
272End
273
274Function UpdateTopView()
275
276        SetDataFolder root:Packages:NIST:VSANS:VCALC
277       
278// wave declarations
279        Wave FL_profileX,FL_profileY,FR_profileX,FR_profileY
280        Wave ML_profileX,ML_profileY,MR_profileX,MR_profileY
281       
282        Wave FL_rayX,FL_rayY,FR_rayX,FR_rayY
283        Wave ML_rayX,ML_rayY,MR_rayX,MR_rayY
284
285        Wave B_T_profileX,B_T_profileY
286        Wave B_T_rayX,B_T_rayY
287
288// Dimensions of detectors
289        NVAR F_LR_w = gFront_LR_w
290        NVAR F_LR_h = gFront_LR_h
291        NVAR F_TB_w = gFront_TB_w
292        NVAR F_TB_h = gFront_TB_h
293       
294        NVAR M_LR_w = gMiddle_LR_w
295        NVAR M_LR_h = gMiddle_LR_h
296        NVAR M_TB_w = gMiddle_TB_w
297        NVAR M_TB_h = gMiddle_TB_h
298
299        NVAR B_h = gBack_h
300        NVAR B_w = gBack_w
301
302
303// get the values from the panel
304        Variable F_LR_sep,F_TB_sep, F_SDD, F_offset
305        Variable M_LR_sep,M_TB_sep, M_SDD, M_offset
306        Variable B_SDD, B_offset
307        //front
308        ControlInfo VCALCCtrl_2a
309        F_LR_sep = V_Value
310//      ControlInfo VCALCCtrl_2b
311//      F_TB_sep = V_Value
312        ControlInfo VCALCCtrl_2c
313        F_offset = V_Value
314        ControlInfo VCALCCtrl_2d
315        F_SDD = V_Value
316                               
317        //middle
318        ControlInfo VCALCCtrl_3a
319        M_LR_sep = V_Value
320//      ControlInfo VCALCCtrl_3b
321//      M_TB_sep = V_Value
322        ControlInfo VCALCCtrl_3c
323        M_offset = V_Value
324        ControlInfo VCALCCtrl_3d
325        M_SDD = V_Value
326       
327        //back                 
328        ControlInfo VCALCCtrl_4a
329        B_offset = V_Value     
330        ControlInfo VCALCCtrl_4b
331        B_SDD = V_Value         
332
333//      Print "Front ", F_LR_sep,F_TB_sep, F_SDD, F_offset
334//      Print "Middle ",  M_LR_sep,M_TB_sep, M_SDD, M_offset
335//      Print "Back ",  B_SDD, B_offset                 
336                       
337
338// FRONT
339        FL_profileX = F_SDD             //SDD in meters
340        FR_profileX = FL_profileX
341       
342        FL_profileY[0] = F_LR_sep               // separation in mm
343        FL_profileY[1] = FL_profileY[0] + F_LR_w        // add in width of L/R panel in mm
344       
345        FR_profileY = -FL_profileY
346
347        //angles (not calculating anything, just connect the dots)
348        FL_rayX[0] = 0
349        FL_rayX[1] = F_SDD
350        FL_rayX[2] = F_SDD
351        FL_rayX[3] = 0
352       
353        FL_rayY[0] = 0
354        FL_rayy[1] = FL_profileY[0]
355        FL_rayY[2] = FL_profileY[1]
356        FL_rayY[3] = 0
357       
358       
359        FR_rayX[0] = 0
360        FR_rayX[1] = F_SDD
361        FR_rayX[2] = F_SDD
362        FR_rayX[3] = 0
363       
364        FR_rayY[0] = 0
365        FR_rayy[1] = FR_profileY[0]
366        FR_rayY[2] = FR_profileY[1]
367        FR_rayY[3] = 0 
368
369
370// MIDDLE       
371        ML_profileX = M_SDD             //SDD in meters
372        MR_profileX = ML_profileX
373       
374        ML_profileY[0] = M_LR_sep               // separation in mm
375        ML_profileY[1] = ML_profileY[0] + M_LR_w        // add in width of L/R panel in mm
376       
377        MR_profileY = -ML_profileY
378
379        //angles (not calculating anything, just connect the dots)
380        ML_rayX[0] = 0
381        ML_rayX[1] = M_SDD
382        ML_rayX[2] = M_SDD
383        ML_rayX[3] = 0
384       
385        ML_rayY[0] = 0
386        ML_rayy[1] = ML_profileY[0]
387        ML_rayY[2] = ML_profileY[1]
388        ML_rayY[3] = 0
389       
390       
391        MR_rayX[0] = 0
392        MR_rayX[1] = M_SDD
393        MR_rayX[2] = M_SDD
394        MR_rayX[3] = 0
395       
396        MR_rayY[0] = 0
397        MR_rayy[1] = MR_profileY[0]
398        MR_rayY[2] = MR_profileY[1]
399        MR_rayY[3] = 0 
400
401// BACK
402        B_T_profileX = B_SDD            //SDDb in meters
403       
404        B_T_profileY[0] = B_h/2         // half-height
405        B_T_profileY[1] = -B_h/2                // half-height
406
407        B_T_rayX[0] = 0
408        B_T_rayX[1] = B_SDD
409        B_T_rayX[2] = B_SDD
410        B_T_rayX[3] = 0
411       
412        B_T_rayY[0] = 0
413        B_T_rayY[1] = B_T_profileY[0]
414        B_T_rayY[2] = B_T_profileY[1]
415        B_T_rayY[3] = 0
416       
417        SetDataFolder root:
418       
419        Execute "TopView()"
420       
421        return(0)
422       
423End
424
425
426Window TopView() : Graph
427        PauseUpdate; Silent 1           // building window...
428        String fldrSav0= GetDataFolder(1)
429        SetDataFolder root:Packages:NIST:VSANS:VCALC
430       
431        CheckDisplayed/W=VCALC#TopView FR_rayY
432        if(V_flag == 0)
433               
434//              Display /W=(594,721,1144,1119) FR_rayY vs FR_rayX as "TopView"
435                AppendToGraph/W=VCALC#TopView FR_rayY vs FR_rayX
436                AppendToGraph/W=VCALC#TopView FL_rayY vs FL_rayX
437                AppendToGraph/W=VCALC#TopView MR_rayY vs MR_rayX
438                AppendToGraph/W=VCALC#TopView ML_rayY vs ML_rayX
439                AppendToGraph/W=VCALC#TopView B_T_rayY vs B_T_rayX
440                AppendToGraph/W=VCALC#TopView B_T_profileY vs B_T_profileX
441                AppendToGraph/W=VCALC#TopView FR_profileY vs FR_profileX
442                AppendToGraph/W=VCALC#TopView FL_profileY vs FL_profileX
443                AppendToGraph/W=VCALC#TopView MR_profileY vs MR_profileX
444                AppendToGraph/W=VCALC#TopView ML_profileY vs ML_profileX
445       
446                ModifyGraph/W=VCALC#TopView lSize(B_T_profileY)=5,lSize(FR_profileY)=5,lSize(FL_profileY)=5,lSize(MR_profileY)=5
447                ModifyGraph/W=VCALC#TopView lSize(ML_profileY)=5
448                ModifyGraph/W=VCALC#TopView rgb(FR_rayY)=(0,0,0),rgb(FL_rayY)=(0,0,0),rgb(MR_rayY)=(0,0,0),rgb(ML_rayY)=(0,0,0)
449                ModifyGraph/W=VCALC#TopView rgb(B_T_rayY)=(0,0,0),rgb(B_T_profileY)=(1,52428,52428),rgb(FR_profileY)=(39321,26208,1)
450                ModifyGraph/W=VCALC#TopView rgb(FL_profileY)=(39321,26208,1)
451                ModifyGraph/W=VCALC#TopView grid=1
452                ModifyGraph/W=VCALC#TopView mirror=2
453                ModifyGraph/W=VCALC#TopView nticks(left)=8
454                Label/W=VCALC#TopView left "\\Z10Horizontal position (mm)"
455                Label/W=VCALC#TopView bottom "\\Z10SDD (meters)"
456                SetAxis/W=VCALC#TopView left -800,800
457                SetAxis/W=VCALC#TopView bottom 0,25
458                TextBox/W=VCALC#TopView/C/N=text0/A=MC/X=41.61/Y=43.62 "\\JCTOP VIEW\r= Left/Right panels"
459        endif
460        SetDataFolder fldrSav0
461
462EndMacro
463
464
465
Note: See TracBrowser for help on using the repository browser.