source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_VCALCPanel_MockUp.ipf @ 1097

Last change on this file since 1097 was 1097, checked in by srkline, 5 years ago

added procedures to compare files to see if they are from the same configuration, same wavelength, etc. so they can be properly chosen for transmission files, scattering files, and properly identified for the different resolution conditions.

Re-worked the logic of dispatching averaging, plotting, and saving in Execute_Protocol. Hopefully this will alow for easier dispatching for future conditions, including getting the correct resolution calculation.

File size: 33.7 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2
3//
4//
5// mockup of the panel for VCALC
6//
7// -- all is housed in the folder:
8//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC
9//
10// -- Put all of the constants to define the instrument plus all of the VCALC stuff
11//
12// anticipating that at the same level as VCALC will be all of the reduction folders
13// in a similar way as for SANS reduction
14//
15//
16
17
18Proc VCALC_Panel()
19        DoWindow/F VCALC
20        if(V_flag==0)
21       
22                //initialize space = folders, parameters, instrument constants, etc.
23                VC_Initialize_Space()
24               
25                //open the panel
26                DrawVCALC_Panel()
27               
28                // two graphs with the ray-tracing side/top views
29                SetupSideView()
30                SetupTopView()
31               
32                // a front view of the panels
33                FrontView_1x()
34               
35                // TODO: fake a "click" on the front SDD to force (almost)everything to update
36                // including the I(q) graph
37                FakeFrontMiddleSDDClick()
38
39        endif
40End
41
42Function FakeFrontMiddleSDDClick()
43       
44        STRUCT WMSetVariableAction sva
45        sva.eventCode = 3
46//      sva.dval = 0.3
47
48        VC_BDet_SDD_SetVarProc(sva)             
49        VC_MDet_SDD_SetVarProc(sva)
50        VC_FDet_SDD_SetVarProc(sva)
51
52        return(0)
53end
54
55
56Proc DrawVCALC_Panel()
57        PauseUpdate; Silent 1           // building window...
58        NewPanel /W=(34,44,1274,699)/N=VCALC/K=1
59        ModifyPanel cbRGB=(49151,60031,65535)
60//      ShowTools/A
61        SetDrawLayer UserBack
62       
63// always visible stuff, not on any tab
64       
65        GroupBox group0,pos={10,10},size={444,180},title="Setup"
66        TabControl Vtab,labelBack=(45000,61000,58000),pos={14,215},size={430,426},tabLabel(0)="Collim"
67        TabControl Vtab,tabLabel(1)="Sample",tabLabel(2)="Front Det",tabLabel(3)="Mid Det"
68        TabControl Vtab,tabLabel(4)="Back Det",tabLabel(5)="Simul",value= 0,proc=VCALCTabProc
69        GroupBox group1,pos={460,10},size={762,635},title="Detector Panel Positions + Data"
70
71        PopupMenu popup_a,pos={50,40},size={142,20},title="Presets"
72        PopupMenu popup_a,mode=1,popvalue="Low Q",value= root:Packages:NIST:VSANS:VCALC:gPresetPopStr
73
74        PopupMenu popup_b,pos={690,310},size={142,20},title="Binning type",proc=VC_RebinIQ_PopProc
75        PopupMenu popup_b,mode=1,value= root:Packages:NIST:VSANS:VCALC:gBinTypeStr
76       
77        SetVariable setVar_a,pos={476,26},size={120,15},title="axis degrees",proc=FrontView_Range_SetVarProc
78        SetVariable setVar_a,limits={0.3,30,0.2},value=_NUM:20
79
80        // for panels (in degrees)     
81        Display/W=(476,45,757,303)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
82        RenameWindow #,FrontView
83        ModifyGraph mode=2              // mode = 2 = dots
84        ModifyGraph marker=19
85        ModifyGraph rgb=(0,0,0)
86        ModifyGraph tick=2,mirror=1
87        Label left "degrees"
88        Label bottom "degrees" 
89        SetActiveSubwindow ##
90
91
92        // for side view
93        Display/W=(842,25,1200,170)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
94        RenameWindow #,SideView
95        ModifyGraph mode=2              // mode = 2 = dots
96        ModifyGraph marker=19
97        ModifyGraph rgb=(0,0,0)
98        ModifyGraph tick=2,mirror=1
99        Label left "Vertical position (mm)"
100        Label bottom "SDD (m)" 
101        SetActiveSubwindow ##   
102       
103        // for top view
104        Display/W=(842,180,1200,325)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
105        RenameWindow #,TopView
106        ModifyGraph mode=2              // mode = 2 = dots
107        ModifyGraph marker=19
108        ModifyGraph rgb=(0,0,0)
109        ModifyGraph tick=2,mirror=1
110        Label left "Horizontal position (mm)"
111        Label bottom "SDD (m)" 
112        SetActiveSubwindow ##   
113
114        // for panels (as 2D Q)
115        Display/W=(475,332,814,631)/HOST=# root:Packages:NIST:VSANS:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
116        RenameWindow #,Panels_Q
117        ModifyGraph mode=2              // mode = 2 = dots
118        ModifyGraph tick=2,mirror=1,grid=2,standoff=0
119        ModifyGraph width={Aspect,1},height={Aspect,1},gbRGB=(56797,56797,56797)
120        SetAxis left -0.2,0.2
121        SetAxis bottom -0.2,0.2
122        Label left "Qy"
123        Label bottom "Qx"       
124        SetActiveSubwindow ##
125
126        SetVariable setVar_b,pos={476,314},size={120,15},title="axis Q",proc=Front2DQ_Range_SetVarProc
127        SetVariable setVar_b,limits={0.02,1,0.02},value=_NUM:0.3
128        CheckBox check_0a title="Log?",size={60,20},pos={619,313},proc=Front2DQ_Log_CheckProc
129
130        // for averaged I(Q)
131        Display/W=(842,334,1204,629)/HOST=# //root:Packages:NIST:VCALC:fv_degY vs root:Packages:NIST:VSANS:VCALC:fv_degX
132        RenameWindow #,Panels_IQ
133//      ModifyGraph mode=2              // mode = 2 = dots
134        ModifyGraph tick=2,mirror=1,grid=2
135//      Label left "Intensity"
136//      Label bottom "Q"       
137        SetActiveSubwindow ##
138
139
140       
141// all controls are named VCALCCtrl_NA where N is the tab number and A is the letter indexing items on tab
142
143       
144// tab(0), collimation - initially visible
145        Slider VCALCCtrl_0a,pos={223,324},size={200,45},limits={0,10,1},value= 1,vert= 0
146        SetVariable VCALCCtrl_0b,pos={25,294},size={120,15},title="wavelength"
147        SetVariable VCALCCtrl_0b,limits={4,20,1},value=_NUM:8,proc=VC_Lambda_SetVarProc
148        PopupMenu VCALCCtrl_0c,pos={26,257},size={150,20},title="monochromator"
149        PopupMenu VCALCCtrl_0c,mode=1,popvalue="Velocity Selector",value= root:Packages:NIST:VSANS:VCALC:gMonochromatorType
150        PopupMenu VCALCCtrl_0d,pos={26,321},size={115,20},title="delta lambda"
151        PopupMenu VCALCCtrl_0d,mode=1,popvalue="0.10",value= root:Packages:NIST:VSANS:VCALC:gDeltaLambda
152        PopupMenu VCALCCtrl_0e,pos={291,262},size={132,20},title="source shape"
153        PopupMenu VCALCCtrl_0e,mode=1,popvalue="circular",value= root:Packages:NIST:VSANS:VCALC:gSourceShape
154        PopupMenu VCALCCtrl_0f,pos={283,293},size={141,20},title="source aperture"
155        PopupMenu VCALCCtrl_0f,mode=1,popvalue="1.0 cm",value= root:Packages:NIST:VSANS:VCALC:gSourceDiam
156       
157
158// tab(1) - Sample conditions, initially not visible
159        PopupMenu VCALCCtrl_1a,pos={38,270},size={142,20},title="table location",disable=1
160        PopupMenu VCALCCtrl_1a,mode=1,popvalue="Changer",value= root:Packages:NIST:VSANS:VCALC:gTableLocation
161        PopupMenu VCALCCtrl_1b,pos={270,270},size={115,20},title="Aperture Shape",disable=1
162        PopupMenu VCALCCtrl_1b,mode=1,popvalue="circular",value= root:Packages:NIST:VSANS:VCALC:gSampleApertureShape
163        PopupMenu VCALCCtrl_1c,pos={270,330},size={132,20},title="Aperture Size (cm)",disable=1
164        PopupMenu VCALCCtrl_1c,mode=1,popvalue="0.5",value= root:Packages:NIST:VSANS:VCALC:gSampleApertureDiam
165       
166
167// tab(2) - Front detector panels, initially not visible
168        SetVariable VCALCCtrl_2a,pos={30,260},size={150,15},title="LEFT Offset (cm)",proc=VC_FDet_LR_SetVarProc
169        SetVariable VCALCCtrl_2a,limits={-20,19,0.1},disable=1,value=_NUM:-10
170        SetVariable VCALCCtrl_2aa,pos={30,290},size={150,15},title="RIGHT Offset (cm)",proc=VC_FDet_LR_SetVarProc
171        SetVariable VCALCCtrl_2aa,limits={-19,20,0.1},disable=1,value=_NUM:10
172       
173        SetVariable VCALCCtrl_2b,pos={30,330},size={150,15},title="TOP Offset (cm)",proc=VC_FDet_LR_SetVarProc
174        SetVariable VCALCCtrl_2b,limits={0,18,0.1},disable=1,value=_NUM:10
175        SetVariable VCALCCtrl_2bb,pos={30,360},size={150,15},title="BOTTOM Offset (cm)",proc=VC_FDet_LR_SetVarProc
176        SetVariable VCALCCtrl_2bb,limits={-18,0,0.1},disable=1,value=_NUM:-10
177       
178        SetVariable VCALCCtrl_2d,pos={205,260},size={230,15},title="Sample to Detector Distance (cm)",proc=VC_FDet_SDD_SetVarProc
179        SetVariable VCALCCtrl_2d,limits={100,800,1},disable=1   ,value=_NUM:150
180       
181
182// tab(3) - Middle detector panels, initially not visible
183        SetVariable VCALCCtrl_3a,pos={30,260},size={150,15},title="LEFT Offset (cm)",proc=VC_MDet_LR_SetVarProc
184        SetVariable VCALCCtrl_3a,limits={-20,19,0.1},disable=1,value=_NUM:-7
185        SetVariable VCALCCtrl_3aa,pos={30,290},size={150,15},title="RIGHT Offset (cm)",proc=VC_MDet_LR_SetVarProc
186        SetVariable VCALCCtrl_3aa,limits={-19,20,0.1},disable=1,value=_NUM:7
187               
188        SetVariable VCALCCtrl_3b,pos={30,330},size={150,15},title="TOP Offset (cm)",proc=VC_MDet_LR_SetVarProc
189        SetVariable VCALCCtrl_3b,limits={0,18,0.1},disable=1,value=_NUM:14
190        SetVariable VCALCCtrl_3bb,pos={30,360},size={150,15},title="BOTTOM Offset (cm)",proc=VC_MDet_LR_SetVarProc
191        SetVariable VCALCCtrl_3bb,limits={-18,0,0.1},disable=1,value=_NUM:-14
192
193        SetVariable VCALCCtrl_3d,pos={205,260},size={230,15},title="Sample to Detector Distance (cm)",proc=VC_MDet_SDD_SetVarProc
194        SetVariable VCALCCtrl_3d,limits={800,2000,1},disable=1,value=_NUM:1000
195
196       
197// tab(4) - Back detector panel
198        SetVariable VCALCCtrl_4a,pos={188,290},size={150,15},title="Lateral Offset (cm)"
199        SetVariable VCALCCtrl_4a,limits={0,20,0.1},disable=1,value=_NUM:0
200        SetVariable VCALCCtrl_4b,pos={188,260},size={230,15},title="Sample to Detector Distance (cm)",proc=VC_BDet_SDD_SetVarProc
201        SetVariable VCALCCtrl_4b,limits={2000,2500,1},disable=1,value=_NUM:2200
202//      PopupMenu VCALCCtrl_4c,pos={40,260},size={180,20},title="Detector type",disable=1
203//      PopupMenu VCALCCtrl_4c,mode=1,popvalue="2D",value= root:Packages:NIST:VSANS:VCALC:gBackDetType
204
205// tab(5) - Simulation setup
206        SetVariable VCALCCtrl_5a,pos={40,290},size={200,15},title="Neutrons on Sample (imon)"
207        SetVariable VCALCCtrl_5a,limits={1e7,1e15,1e7},disable=1,value=_NUM:1e11,proc=VC_SimImon_SetVarProc
208        PopupMenu VCALCCtrl_5b,pos={40,260},size={180,20},title="Model Function",disable=1
209        PopupMenu VCALCCtrl_5b,mode=1,popvalue="Debye",value= root:Packages:NIST:VSANS:VCALC:gModelFunctionType,proc=VC_SimModelFunc_PopProc
210       
211End
212
213//
214// just recalculates the detector panels, doesn't adjust the views
215//
216Function Recalculate_AllDetectors()
217
218        fPlotBackPanels()
219        fPlotMiddlePanels()
220        fPlotFrontPanels()
221
222        return(0)
223End
224
225// function to control the drawing of controls in the TabControl on the main panel
226// Naming scheme for the controls MUST be strictly adhered to... else controls will
227// appear in odd places...
228// all controls are named VCALCCtrl_NA where N is the tab number and A is the letter denoting
229// the controls position on that particular tab.
230// in this way, they will always be drawn correctly..
231//
232//
233// -- this will need to be modified to allow for the graph to be drawn of the detector bank positions
234//     if that is individual to each tab - or if it's  always visible - that's still to be decided.
235//
236//
237Function VCALCTabProc(name,tab)
238        String name
239        Variable tab
240       
241//      Print "name,number",name,tab
242        String ctrlList = ControlNameList("",";"),item="",nameStr=""
243        Variable num = ItemsinList(ctrlList,";"),ii,onTab
244        for(ii=0;ii<num;ii+=1)
245                //items all start w/"VCALCCtrl_", 10 characters
246                item=StringFromList(ii, ctrlList ,";")
247                nameStr=item[0,9]
248                if(cmpstr(nameStr,"VCALCCtrl_")==0)
249                        onTab = str2num(item[10])                       //[10] is a number
250                        ControlInfo $item
251                        switch(abs(V_flag))     
252                                case 1:
253                                        Button $item,disable=(tab!=onTab)
254                                        break
255                                case 2:
256                                        CheckBox $item,disable=(tab!=onTab)
257                                        break
258                                case 3:
259                                        PopupMenu $item,disable=(tab!=onTab)
260                                        break
261                                case 4:
262                                        ValDisplay $item,disable=(tab!=onTab)
263                                        break
264                                case 5:
265                                        SetVariable $item,disable=(tab!=onTab)
266                                        break
267                                case 7:
268                                        Slider $item,disable=(tab!=onTab)
269                                        break
270                                case 9:
271                                        GroupBox $item,disable=(tab!=onTab)
272                                        break
273                                case 10:       
274                                        TitleBox $item,disable=(tab!=onTab)
275                                        break
276                                // add more items to the switch if different control types are used
277                        endswitch
278                endif
279        endfor
280       
281
282       
283        return(0)
284End
285
286Function Front2DQ_Log_CheckProc(cba) : CheckBoxControl
287        STRUCT WMCheckboxAction &cba
288
289        switch( cba.eventCode )
290                case 2: // mouse up
291                        Variable checked = cba.checked
292                       
293                        Execute "FrontPanels_AsQ()"
294                        Execute "MiddlePanels_AsQ()"
295                        Execute "BackPanels_AsQ()"
296                       
297                        break
298                case -1: // control being killed
299                        break
300        endswitch
301
302        return 0
303End
304
305//
306// recalculate the detectors with a preset model function
307//
308Function VC_SimModelFunc_PopProc(ctrlName,popNum,popStr) : PopupMenuControl
309        String ctrlName
310        Variable popNum // which item is currently selected (1-based)
311        String popStr           // contents of current popup item as string
312
313        Recalculate_AllDetectors()
314       
315        return(0)       
316End
317
318
319//
320// recalculate the I(q) binning. no need to adjust model function or views
321// just rebin
322//
323// this is for the VCALC 1-D plot subwindow only. so it is set up to
324// operate on that window - but uses the same binning and plotting routines
325// as the regualr VSANS data display
326//
327Function VC_RebinIQ_PopProc(ctrlName,popNum,popStr) : PopupMenuControl
328        String ctrlName
329        Variable popNum // which item is currently selected (1-based)
330        String popStr           // contents of current popup item as string
331
332
333        String type = "VCALC"
334        String str,winStr="VCALC#Panels_IQ",workTypeStr
335        workTypeStr = "root:Packages:NIST:VSANS:"+type
336       
337        String collimationStr = "pinhole"               //TODO: fill this in from the VCALC panel
338       
339// dispatch based on the string, not on the number of selection in the pop string
340        V_QBinAllPanels_Circular(type,V_BinTypeStr2Num(popStr),collimationStr)
341       
342        sprintf str,"(\"%s\",%d,\"%s\")",workTypeStr,V_BinTypeStr2Num(popStr),winStr
343
344        Execute ("V_Back_IQ_Graph"+str)
345        Execute ("V_Middle_IQ_Graph"+str)
346        Execute ("V_Front_IQ_Graph"+str)
347
348// OLD - do not use
349//      // do the q-binning for front panels to get I(Q)
350//      Execute "BinAllFrontPanels()"
351//      Execute "Front_IQ_Graph()"
352//
353//      // do the q-binning for middle panels to get I(Q)
354//      Execute "BinAllMiddlePanels()"
355//      Execute "Middle_IQ_Graph()"
356//     
357//      // do the q-binning for the back panel to get I(Q)
358//      Execute "BinAllBackPanels()"
359//      Execute "Back_IQ_Graph()"
360//     
361        return(0)       
362End
363
364
365
366       
367       
368//
369// setVar for the wavelength
370//
371Function VC_Lambda_SetVarProc(sva) : SetVariableControl
372        STRUCT WMSetVariableAction &sva
373
374        switch( sva.eventCode )
375                case 1: // mouse up
376                case 2: // Enter key
377                case 3: // Live update
378                        Variable dval = sva.dval
379                        String sval = sva.sval
380                       
381//                      // don't need to recalculate the views, but need to recalculate the detectors
382//                      fPlotBackPanels()
383//                      fPlotMiddlePanels()
384//                      fPlotFrontPanels()
385
386                        Recalculate_AllDetectors()             
387                               
388                        break
389                case -1: // control being killed
390                        break
391        endswitch
392
393        return 0
394End
395
396//
397// setVar for the simulation monitor count
398//
399Function VC_SimImon_SetVarProc(sva) : SetVariableControl
400        STRUCT WMSetVariableAction &sva
401
402        switch( sva.eventCode )
403                case 1: // mouse up
404                case 2: // Enter key
405                case 3: // Live update
406                        Variable dval = sva.dval
407                        String sval = sva.sval
408
409                        Recalculate_AllDetectors()             
410                               
411                        break
412                case -1: // control being killed
413                        break
414        endswitch
415
416        return 0
417End
418
419
420// setVar for the range (in degrees) for the FrontView plot of the detectors
421//
422Function FrontView_Range_SetVarProc(sva) : SetVariableControl
423        STRUCT WMSetVariableAction &sva
424
425        switch( sva.eventCode )
426                case 1: // mouse up
427                case 2: // Enter key
428                case 3: // Live update
429                        Variable dval = sva.dval
430                        String sval = sva.sval
431                       
432                        FrontView_1x()
433                       
434                        break
435                case -1: // control being killed
436                        break
437        endswitch
438
439        return 0
440End
441
442// setVar for the range (in Q) for the FrontView plot of the detectors
443//
444// TODO: this assumes that everything (the data) is already updated - this only updates the plot range
445Function Front2DQ_Range_SetVarProc(sva) : SetVariableControl
446        STRUCT WMSetVariableAction &sva
447
448        switch( sva.eventCode )
449                case 1: // mouse up
450                case 2: // Enter key
451                case 3: // Live update
452                        Variable dval = sva.dval
453                        String sval = sva.sval
454                       
455                        SetAxis/W=VCALC#Panels_Q left -dval,dval
456                        SetAxis/W=VCALC#Panels_Q bottom -dval,dval
457                       
458//                      FrontPanels_AsQ()
459                       
460                        break
461                case -1: // control being killed
462                        break
463        endswitch
464
465        return 0
466End
467
468// SDD for the Front detector. triggers a recalculation
469// of the intensity and a redraw of the banks
470//
471Function VC_FDet_SDD_SetVarProc(sva) : SetVariableControl
472        STRUCT WMSetVariableAction &sva
473
474        switch( sva.eventCode )
475                case 1: // mouse up
476                case 2: // Enter key
477                case 3: // Live update
478                        Variable dval = sva.dval
479                        String sval = sva.sval
480                       
481//                      Variable LR_sep,TB_sep
482//                      // don't know if LR or TB called, so get the explicit values
483//                      //
484//                      ControlInfo VCALCCtrl_2a
485//                      LR_sep = V_Value
486//                      ControlInfo VCALCCtrl_2b
487//                      TB_sep = V_Value
488//                     
489//                      UpdateFrontDetector(LR_sep,TB_sep)
490                       
491                        UpdateSideView()
492                        UpdateTopView()
493                        FrontView_1x()
494                       
495                        fPlotFrontPanels()
496                       
497                        break
498                case -1: // control being killed
499                        break
500        endswitch
501
502        return 0
503End
504
505// SDD for the Middle detector. triggers a recalculation
506// of the intensity and a redraw of the banks
507//
508Function VC_MDet_SDD_SetVarProc(sva) : SetVariableControl
509        STRUCT WMSetVariableAction &sva
510
511        switch( sva.eventCode )
512                case 1: // mouse up
513                case 2: // Enter key
514                case 3: // Live update
515                        Variable dval = sva.dval
516                        String sval = sva.sval
517                       
518//                      Variable LR_sep,TB_sep
519//                      // don't know if LR or TB called, so get the explicit values
520//                      //
521//                      ControlInfo VCALCCtrl_2a
522//                      LR_sep = V_Value
523//                      ControlInfo VCALCCtrl_2b
524//                      TB_sep = V_Value
525//                     
526//                      UpdateFrontDetector(LR_sep,TB_sep)
527                       
528                        UpdateSideView()
529                        UpdateTopView()
530                        FrontView_1x()
531                       
532                        fPlotMiddlePanels()
533                       
534                        break
535                case -1: // control being killed
536                        break
537        endswitch
538
539        return 0
540End
541
542// SDD for the Back detector. triggers a recalculation
543// of the intensity and a redraw of the banks
544//
545Function VC_BDet_SDD_SetVarProc(sva) : SetVariableControl
546        STRUCT WMSetVariableAction &sva
547
548        switch( sva.eventCode )
549                case 1: // mouse up
550                case 2: // Enter key
551                case 3: // Live update
552                        Variable dval = sva.dval
553                        String sval = sva.sval
554                       
555//                      Variable LR_sep,TB_sep
556//                      // don't know if LR or TB called, so get the explicit values
557//                      //
558//                      ControlInfo VCALCCtrl_2a
559//                      LR_sep = V_Value
560//                      ControlInfo VCALCCtrl_2b
561//                      TB_sep = V_Value
562//                     
563//                      UpdateFrontDetector(LR_sep,TB_sep)
564                       
565                        UpdateSideView()
566                        UpdateTopView()
567                        FrontView_1x()
568                       
569                        fPlotBackPanels()
570                       
571                        break
572                case -1: // control being killed
573                        break
574        endswitch
575
576        return 0
577End
578
579// separation, either LR or TB of the front detector. triggers a recalculation
580// of the intensity and a redraw of the banks
581//
582Function VC_FDet_LR_SetVarProc(sva) : SetVariableControl
583        STRUCT WMSetVariableAction &sva
584
585        switch( sva.eventCode )
586                case 1: // mouse up
587                case 2: // Enter key
588                case 3: // Live update
589                        Variable dval = sva.dval
590                        String sval = sva.sval
591                       
592//                      Variable LR_sep,TB_sep
593//                      // don't know if LR or TB called, so get the explicit values
594//                      //
595//                      ControlInfo VCALCCtrl_2a
596//                      LR_sep = V_Value
597//                      ControlInfo VCALCCtrl_2b
598//                      TB_sep = V_Value
599//                     
600//                      UpdateFrontDetector(LR_sep,TB_sep)
601                       
602                        UpdateSideView()
603                        UpdateTopView()
604                        FrontView_1x()
605                       
606                        fPlotFrontPanels()
607                       
608                        break
609                case -1: // control being killed
610                        break
611        endswitch
612
613        return 0
614End
615
616
617// separation, either LR or TB of the middle detector. triggers a recalculation
618// of the intensity and a redraw of the banks
619//
620Function VC_MDet_LR_SetVarProc(sva) : SetVariableControl
621        STRUCT WMSetVariableAction &sva
622
623        switch( sva.eventCode )
624                case 1: // mouse up
625                case 2: // Enter key
626                case 3: // Live update
627                        Variable dval = sva.dval
628                        String sval = sva.sval
629                       
630//                      Variable LR_sep,TB_sep
631//                      // don't know if LR or TB called, so get the explicit values
632//                      //
633//                      ControlInfo VCALCCtrl_3a
634//                      LR_sep = V_Value
635//                      ControlInfo VCALCCtrl_3b
636//                      TB_sep = V_Value
637                       
638//                      UpdateMiddleDetector(LR_sep,TB_sep)
639                       
640                        UpdateSideView()
641                        UpdateTopView()
642                        FrontView_1x()
643                       
644                        fPlotMiddlePanels()
645                       
646                        break
647                case -1: // control being killed
648                        break
649        endswitch
650
651        return 0
652End
653
654
655
656
657// this all needs to be fixed and updated - it is all pertinent to SANS (SASCALC)
658// and not yet specific to VSANS
659//
660// -- all of the simulation stuff will need to be re-thought
661// -- all of the integersRead, data, etc. will need to be re-thought...
662// -- but the space needs to be allocated.
663// -- parameters and constants need to be defined in their own space
664//
665// FEB 2016 -- changed the data folder space to mimic the HDF folder structure
666// so that the averaging routines could be re-used (along with everything else)
667// -- painful, but better in the long run
668//
669// -- I have not re-named the detector arrays to all be "data" since that is very difficult to
670//   deal with on images. Added a global "gVCALC_Active" as a crude workaround as needed. Turn it
671//   on when needed and then immediately off
672//
673Proc VC_Initialize_Space()
674//
675        NewDataFolder/O root:Packages
676        NewDataFolder/O root:Packages:NIST
677        NewDataFolder/O root:Packages:NIST:VSANS
678        NewDataFolder/O root:Packages:NIST:VSANS:VCALC
679        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry
680        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument
681        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B
682        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB
683        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT
684        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML
685        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR
686        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB
687        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT
688        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL
689        NewDataFolder/O root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR
690
691//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Front
692//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Middle
693//      NewDataFolder/O root:Packages:NIST:VSANS:VCALC:Back
694
695        NewDataFolder/O root:Packages:NIST:VSANS:RawVSANS
696       
697        Variable/G root:Packages:NIST:VSANS:VCALC:gVCALC_Active = 1
698        Variable/G root:Packages:NIST:VSANS:VCALC:gUseNonLinearDet = 0          //if == 1, use RAW non-linear corrections
699       
700        SetDataFolder root:Packages:NIST:VSANS:VCALC
701       
702
703///// FRONT DETECTOR BANKS
704// dimensions for the detector banks (then get them in the drawing functions)
705// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing
706// so keep them as variables
707        Variable/G gFront_LR_w = 38.4           //front bank, nominal LR panel width [cm]
708        Variable/G gFront_LR_h = 100.0
709        Variable/G gFront_TB_w = 50.0
710        Variable/G gFront_TB_h = 38.4
711
712// SDD setback of T/B (decide on units??)
713// for the Nexus file, the detector distance should already be corrected for the "setback"
714// of the T/B panels. keep as VCALC variable
715        Variable/G gFront_SDDsetback = 41.0                     // [cm]
716       
717       
718// detector resolution (xy for each bank!)
719        Make/O/D/N=1 :entry:instrument:detector_FL:x_pixel_size = 0.84          // (cm)         these tubes are vertical 8.4 mm x-spacing (JGB 2/2106)
720        Make/O/D/N=1 :entry:instrument:detector_FL:y_pixel_size = 0.8           // (cm)         //!! now 8 mm, since nPix=128, rather than 256
721        Make/O/D/N=1 :entry:instrument:detector_FR:x_pixel_size = 0.84
722        Make/O/D/N=1 :entry:instrument:detector_FR:y_pixel_size = 0.8
723        //T/B
724        Make/O/D/N=1 :entry:instrument:detector_FT:x_pixel_size = 0.4           //these tubes are horizontal
725        Make/O/D/N=1 :entry:instrument:detector_FT:y_pixel_size = 0.84
726        Make/O/D/N=1 :entry:instrument:detector_FB:x_pixel_size = 0.4
727        Make/O/D/N=1 :entry:instrument:detector_FB:y_pixel_size = 0.84
728       
729
730// number of pixels in each bank (this can be modified at acquisition time, so it must be adjustable here)
731        Make/O/D/N=1 :entry:instrument:detector_FL:pixel_num_x = 48     // == number of tubes
732        Make/O/D/N=1 :entry:instrument:detector_FL:pixel_num_y = 128    // == pixels in vertical direction (was 256, John says likely will run @ 128 9/2015)
733        Make/O/D/N=1 :entry:instrument:detector_FR:pixel_num_x = 48     // == number of tubes
734        Make/O/D/N=1 :entry:instrument:detector_FR:pixel_num_y = 128    // == pixels in vertical direction
735        Make/O/D/N=1 :entry:instrument:detector_FT:pixel_num_x = 128    // == pixels in horizontal direction
736        Make/O/D/N=1 :entry:instrument:detector_FT:pixel_num_y = 48     // == number of tubes
737        Make/O/D/N=1 :entry:instrument:detector_FB:pixel_num_x = 128    // == pixels in horizontal direction
738        Make/O/D/N=1 :entry:instrument:detector_FB:pixel_num_y = 48     // == number of tubes
739
740
741
742// pixel beam center - HDF style
743        Make/O/D/N=1 :entry:instrument:detector_FL:beam_center_x = 55           // == x beam center, in pixels
744        Make/O/D/N=1 :entry:instrument:detector_FL:beam_center_y = 64           // == y beam center, in pixels
745        Make/O/D/N=1 :entry:instrument:detector_FR:beam_center_x = -8   
746        Make/O/D/N=1 :entry:instrument:detector_FR:beam_center_y = 64   
747        Make/O/D/N=1 :entry:instrument:detector_FT:beam_center_x = 64   
748        Make/O/D/N=1 :entry:instrument:detector_FT:beam_center_y = -8   
749        Make/O/D/N=1 :entry:instrument:detector_FB:beam_center_x = 64   
750        Make/O/D/N=1 :entry:instrument:detector_FB:beam_center_y = 55   
751
752
753
754///// MIDDLE DETECTOR BANKS
755// Width and height are not part of the Nexus file definition, but are needed for VCALC drawing
756// so keep them as variables
757        Variable/G gMiddle_LR_w = 38.4          //middle bank, nominal LR panel width (cm)
758        Variable/G gMiddle_LR_h = 100.0
759        Variable/G gMiddle_TB_w = 50.0
760        Variable/G gMiddle_TB_h = 38.4
761// SDD offset of T/B (decide on units??)
762// for the Nexus file, the detector distance should already be corrected for the "setback"
763// of the T/B panels. keep as VCALC variable
764        Variable/G gMiddle_SDDsetback = 41.0                    // [cm]
765       
766// detector resolution (xy for each bank!)
767        Make/O/D/N=1 :entry:instrument:detector_ML:x_pixel_size = 0.84          // (cm)         these tubes are vertical 8.4 mm x-spacing (JGB 2/2106)
768        Make/O/D/N=1 :entry:instrument:detector_ML:y_pixel_size = 0.8           // (cm)         //!! now 8 mm, since nPix=128, rather than 256
769        Make/O/D/N=1 :entry:instrument:detector_MR:x_pixel_size = 0.84
770        Make/O/D/N=1 :entry:instrument:detector_MR:y_pixel_size = 0.8
771        //T/B
772        Make/O/D/N=1 :entry:instrument:detector_MT:x_pixel_size = 0.4           //these tubes are horizontal
773        Make/O/D/N=1 :entry:instrument:detector_MT:y_pixel_size = 0.84
774        Make/O/D/N=1 :entry:instrument:detector_MB:x_pixel_size = 0.4
775        Make/O/D/N=1 :entry:instrument:detector_MB:y_pixel_size = 0.84
776
777
778
779// number of pixels in each bank (this can be modified at acquisition time, so it must be adjustable here)
780        Make/O/D/N=1 :entry:instrument:detector_ML:pixel_num_x = 48     // == number of tubes
781        Make/O/D/N=1 :entry:instrument:detector_ML:pixel_num_y = 128    // == pixels in vertical direction (was 256, John says likely will run @ 128 9/2015)
782        Make/O/D/N=1 :entry:instrument:detector_MR:pixel_num_x = 48     // == number of tubes
783        Make/O/D/N=1 :entry:instrument:detector_MR:pixel_num_y = 128    // == pixels in vertical direction
784        Make/O/D/N=1 :entry:instrument:detector_MT:pixel_num_x = 128    // == pixels in horizontal direction
785        Make/O/D/N=1 :entry:instrument:detector_MT:pixel_num_y = 48     // == number of tubes
786        Make/O/D/N=1 :entry:instrument:detector_MB:pixel_num_x = 128    // == pixels in horizontal direction
787        Make/O/D/N=1 :entry:instrument:detector_MB:pixel_num_y = 48     // == number of tubes
788       
789
790
791// pixel beam center - HDF style
792        Make/O/D/N=1 :entry:instrument:detector_ML:beam_center_x = 55           // == x beam center, in pixels
793        Make/O/D/N=1 :entry:instrument:detector_ML:beam_center_y = 64           // == y beam center, in pixels
794        Make/O/D/N=1 :entry:instrument:detector_MR:beam_center_x = -8   
795        Make/O/D/N=1 :entry:instrument:detector_MR:beam_center_y = 64   
796        Make/O/D/N=1 :entry:instrument:detector_MT:beam_center_x = 64   
797        Make/O/D/N=1 :entry:instrument:detector_MT:beam_center_y = -8   
798        Make/O/D/N=1 :entry:instrument:detector_MB:beam_center_x = 64   
799        Make/O/D/N=1 :entry:instrument:detector_MB:beam_center_y = 55   
800
801
802
803
804//// BACK DETECTOR
805        Variable/G gBack_w = 22.2                               //w and h for the back detector [cm]
806        Variable/G gBack_h = 50.4
807       
808        Make/O/D/N=1 :entry:instrument:detector_B:x_pixel_size = 0.034          // 340 micron resolution (units of cm here)
809        Make/O/D/N=1 :entry:instrument:detector_B:y_pixel_size = 0.034         
810
811
812        Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_x = 680             // detector pixels in x-direction
813        Make/O/D/N=1 :entry:instrument:detector_B:pixel_num_y = 1656
814       
815
816// pixel beam center - HDF style
817        Make/O/D/N=1 :entry:instrument:detector_B:beam_center_x = 340           // == x beam center, in pixels
818        Make/O/D/N=1 :entry:instrument:detector_B:beam_center_y = 828           // == y beam center, in pixels
819
820
821// Generate all of the waves used for the detector and the q values
822//
823// TODO: the detector dimensions need to be properly defined here...
824// FRONT
825//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Front
826
827        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FL
828        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FL
829        Duplicate/O det_FL qTot_FL,qx_FL,qy_FL,qz_FL
830
831        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FR
832        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FR
833        Duplicate/O det_FR qTot_FR,qx_FR,qy_FR,qz_FR
834
835        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FT
836        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FT
837        Duplicate/O det_FT qTot_FT,qx_FT,qy_FT,qz_FT
838       
839        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_FB
840        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_FB
841        Duplicate/O det_FB qTot_FB,qx_FB,qy_FB,qz_FB
842
843
844//MIDDLE
845// TODO: the detector dimensions need to be properly defined here...
846//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Middle
847
848        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_ML
849        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_ML
850        Duplicate/O det_ML qTot_ML,qx_ML,qy_ML,qz_ML
851       
852        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MR
853        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MR
854        Duplicate/O det_MR qTot_MR,qx_MR,qy_MR,qz_MR
855
856        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MT
857        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MT
858        Duplicate/O det_MT qTot_MT,qx_MT,qy_MT,qz_MT
859       
860        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_MB
861        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_MB
862        Duplicate/O det_MB qTot_MB,qx_MB,qy_MB,qz_MB
863
864// BACK
865// TODO: the detector dimensions need to be properly defined here...
866//      SetDataFolder root:Packages:NIST:VSANS:VCALC:Back
867
868        SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B
869        Make/O/D/N=(pixel_num_x[0],pixel_num_y[0]) det_B
870        Duplicate/O det_B qTot_B,qx_B,qy_B,qz_B
871
872
873////////////    FOR THE PANEL
874
875        SetDataFolder root:Packages:NIST:VSANS:VCALC
876
877        Make/O/D/N=2 fpx1,fpy1,mpx1,mpy1                // for display of the detector panels
878        Make/O/D/N=2 fv_degX,fv_degY
879
880
881// to fill in:
882// values for always-visible items
883        String/G gPresetPopStr = "Low Q;High Q;Converging Pinholes;Narrow Slit Aperture;White Beam;Polarizer;"
884        String/G gBinTypeStr = ksBinTypeStr
885
886
887
888
889// popup strings for each tab (then use the string in the panel)
890// tab 0 - collimation
891        String/G gMonochromatorType = "Velocity Selector;Graphite;White Beam;"
892        String/G gSourceShape = "circular;rectangular;converging pinholes;"
893        String/G gSourceDiam = "1.0 cm;2.0 cm;5.0 cm;"
894        String/G gSourceDiam_0g = "0.75 cm;1.5 cm;3.0 cm;"              // values from John Mar 2018
895        String/G gDeltaLambda = "0.10;0.20;0.30;"
896       
897// tab 1 - sample conditions
898        String/G gTableLocation = "Changer;Stage;"
899        String/G gSampleApertureShape = "circular;rectangular;converging pinholes;"
900        String/G gSampleApertureDiam = "0.5;1.0;1.5;2.0;"
901       
902// tab 2
903
904// tab 3
905
906// tab 4 - back detector
907        String/G gBackDetType = "1D;2D;"
908
909// tab 5
910        String/G gModelFunctionType = "Debye;Sphere;Big Debye;Big Sphere;AgBeh;Vycor;Empty Cell;Blocked Beam;"
911        gModelFunctionType += "Debye +;AgBeh +;Empty Cell +;"
912
913////////////////////
914
915
916
917// limits for detector travel? or are these limits part of the panel, hard-wired there
918
919
920//      // for the panel
921
922        Variable/G gNg=0
923//      Variable/G gOffset=0
924        Variable/G gSamAp=1.27          //samAp diameter in cm
925        String/G gSourceApString = "1.43 cm;2.54 cm;3.81 cm;"
926        String/G gApPopStr = "1/16\";1/8\";3/16\";1/4\";5/16\";3/8\";7/16\";1/2\";9/16\";5/8\";11/16\";3/4\";other;"
927        Variable/G gSamApOther = 10             //non-standard aperture diameter, in mm
928        Variable/G gUsingLenses = 0             //0=no lenses, 1=lenses(or prisms)
929//      Variable/G gModelOffsetFactor = 1
930//     
931//      // for the MC simulation
932//      Variable/G doSimulation =0              // == 1 if 1D simulated data, 0 if other from the checkbox
933//      Variable/G gRanDateTime=datetime
934//      Variable/G gImon = 10000
935//      Variable/G gThick = 0.1
936//      Variable/G gSig_incoh = 0.1
937//      String/G gFuncStr = ""
938//      Variable/G gR2 = 2.54/2
939//      Variable/G gSamTrans=0.8                        //for 1D, default value
940//      Variable/G gCntTime = 300
941//      Variable/G gDoMonteCarlo = 0
942//      Variable/G gUse_MC_XOP = 1                              //set to zero to use Igor code
943//      Variable/G gBeamStopIn = 1                      //set to zero for beamstop out (transmission)
944//      Variable/G gRawCounts = 0
945//      Variable/G gSaveIndex = 100
946//      String/G gSavePrefix = "SIMUL"
947//      Variable/G gAutoSaveIndex = 100                 //a way to set the index for automated saves
948//      String/G gAutoSaveLabel = ""                            //a way to set the "sample" label for automated saves
949//      Make/O/D/N=10 results = 0
950//      Make/O/T/N=10 results_desc = {"total X-section (1/cm)","SAS X-section (1/cm)","number that scatter","number that reach detector","avg # times scattered","fraction single coherent","fraction multiple coherent","fraction multiple scattered","fraction transmitted","detector counts w/beamstop"}
951//
952//      Variable/G g_1DTotCts = 0                       //summed counts (simulated)
953//      Variable/G g_1DEstDetCR = 0             // estimated detector count rate
954//      Variable/G g_1DFracScatt = 0            // fraction of beam captured on detector
955//      Variable/G g_1DEstTrans = 0             // estimated transmission of sample
956//      Variable/G g_1D_DoABS = 1
957//      Variable/G g_1D_AddNoise = 1
958//      Variable/G g_MultScattFraction=0
959//      Variable/G g_detectorEff=0.75                   //average value for most wavelengths
960//      Variable/G g_actSimTime = 0                             //for the save
961//      Variable/G g_SimTimeWarn = 10                   //manually set to a very large value for scripted operation
962//     
963
964//     
965//      //for the fake dependency
966//      Variable/G gTouched=0
967//      Variable/G gCalculate=0
968//      //for plotting
969//      Variable/G gFreezeCount=1               //start the count at 1 to keep Jeff happy
970//      Variable/G gDoTraceOffset=0             // (1==Yes, offset 2^n), 0==turn off the offset
971
972
973
974//
975// instrument - specific dimensions
976//
977
978//     
979        Variable/G gInstrument = 6              // files (may) be tagged SA6 as the 6th SANS instrument
980        Variable/G gS12 = 54.8
981//      Variable/G d_det = 0.5
982//      Variable/G a_pixel = 0.5
983//      Variable/G del_r = 0.5
984//      Variable/G det_width = 64.0
985        Variable/G gLambda_t = 5.50
986        Variable/G gL2r_lower = 132.3
987        Variable/G gL2r_upper =  1317
988        Variable/G gLambda_lower = 2.5
989        Variable/G gLambda_upper = 20.0
990        Variable/G gD_upper = 25.0
991        Variable/G gBs_factor = 1.05
992        Variable/G gT1 = 0.63
993        Variable/G gT2 = 1.0
994        Variable/G gT3 = 0.75
995        Variable/G gL_gap = 100.0
996        Variable/G gGuide_width = 6.0
997        Variable/G gIdmax = 100.0
998
999//
1000//      //new values, from 11/2009 --- BeamFluxReport_2009.ifn
1001        Variable/G gPhi_0 = 2.42e13
1002        Variable/G gB = 0.0
1003        Variable/G gC = -0.0243
1004        Variable/G gGuide_loss = 0.924
1005//     
1006//      //fwhm values (new variables) (+3, 0, -3, calibrated 2009)
1007        Variable/G gFwhm_narrow = 0.109
1008        Variable/G gFwhm_mid = 0.125
1009        Variable/G gFwhm_wide = 0.236
1010//     
1011//      //source apertures (cm)
1012        Variable/G gA1_0_0 = 1.43
1013        Variable/G gA1_0_1 = 2.54
1014        Variable/G gA1_0_2 = 3.81
1015        Variable/G gA1_7_0 = 2.5                        // after the polarizer         
1016        Variable/G gA1_7_1 = 5.0
1017        Variable/G gA1_7_1 = 0.95               //
1018        Variable/G gA1_def = 5.00
1019//     
1020        SetDataFolder root:
1021end
Note: See TracBrowser for help on using the repository browser.