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

Last change on this file since 1022 was 1022, checked in by srkline, 6 years ago

ADDED:

included common NCNR procedures for the PlotManager?, to allow plotting of 1D data sets using a familiar interface

greatly expanded Patch functionality to include input in the multiple sections of the Nexus file, including separate panels to handle patching of waves to the file - needed for non-linear coefficients, dead time, and XY beam centers. All patch operations are expandable as more fields become necessary to patch.

removed bug of group_id being defined in /reduction and in /sample (removed R/W that referenced /reduction)

added panel to "isolate" a single detector panel, allowing the corrections to be applied/removed/recalculated as needed to directly see their effects.

linked new procedures to their appropriate action buttons

Added more data fields (label, intent, etc.) to the VCALC to Nexus data writer to get more realistic values into the fake data files for testing

Added VCALC simulation functions with EMP and BGD in anticipation of testing the CORRECT step

more little bug and documentation fixes which I can't remember, but they are all important...

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