source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_DataPlotting.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: 14.8 KB
Line 
1#pragma TextEncoding = "MacRoman"               // For details execute DisplayHelpTopic "The TextEncoding Pragma"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
3#pragma version=1.0
4
5
6//
7// functions to plot the averaged data in various views.
8//
9
10
11
12//
13// simple entry procedure
14//
15// graph with the 1D representation of the VSANS detectors
16//
17// TODO:
18// -- add multiple options for how to present/rescale the data
19// -- automatically position the window next to the 2D data
20// -- color coding of the different panels (data tags/arrows/toggle on/off)?
21// -- VERIFY accuracy
22// -- decide what to add to the control bar
23//
24// -- see Middle_IQ_Graph() and similar for how VCALC does this plot
25//
26// -- when/if I want to add phi-averaging to this, go gack to AvgGraphics.ipf for the pink panel
27//    and to the function Draw_Plot1D() for the drawing of the plot
28//
29Function V_PlotData_Panel()
30
31
32        DoWindow V_1D_Data
33        if(V_flag==0)
34       
35                Display /W=(277,526,748,938)/N=V_1D_Data/K=1
36//              Display /W=(476,96,850,429)/N=V_1D_Data/K=1
37                ControlBar 70
38               
39                PopupMenu popup0,pos={16,5},size={71,20},title="Bin Type"
40                PopupMenu popup0,help={"This popup selects how the y-axis will be linearized based on the chosen data"}
41                PopupMenu popup0,value= "One;Two;Four;Slit Mode;"
42                PopupMenu popup0,mode=1,proc=V_BinningModePopup
43//              PopupMenu ymodel,pos={16,5},size={71,20},title="y-axis"
44//              PopupMenu ymodel,help={"This popup selects how the y-axis will be linearized based on the chosen data"}
45//              PopupMenu ymodel,value= #"\"I;log(I);ln(I);1/I;I^a;Iq^a;I^a q^b;1/sqrt(I);ln(Iq);ln(Iq^2)\""
46//              PopupMenu ymodel,mode=NumVarOrDefault("root:myGlobals:Plot_1d:gYMode", 1 ),proc=YMode_PopMenuProc
47//              PopupMenu xmodel,pos={150,5},size={74,20},title="x-axis"
48//              PopupMenu xmodel,help={"This popup selects how the x-axis will be linearized given the chosen data"}
49//              PopupMenu xmodel,value= #"\"q;log(q);q^2;q^c\""
50//              PopupMenu xmodel,mode=NumVarOrDefault("root:myGlobals:Plot_1d:gXMode", 1 ),proc=XMode_PopMenuProc
51//              Button Rescale,pos={281,4},size={70,20},proc=Rescale_Plot_1D_ButtonProc,title="Rescale"
52//              Button Rescale,help={"Rescale the x and y-axes of the data"},disable=1
53
54//              SetVariable expa,pos={28,28},size={80,15},title="pow \"a\""
55//              SetVariable expa,help={"This sets the exponent \"a\" for some y-axis formats. The value is ignored if the model does not use an adjustable exponent"}
56//              SetVariable expa,limits={-2,10,0},value= root:myGlobals:Plot_1d:gExpA
57//              SetVariable expb,pos={27,46},size={80,15},title="pow \"b\""
58//              SetVariable expb,help={"This sets the exponent \"b\" for some x-axis formats. The value is ignored if the model does not use an adjustable exponent"}
59//              SetVariable expb,limits={0,10,0},value= root:myGlobals:Plot_1d:gExpB
60//
61//              SetVariable expc,pos={167,28},size={80,15},title="pow \"c\""
62//              SetVariable expc,help={"This sets the exponent \"c\" for some x-axis formats. The value is ignored if the model does not use \"c\" as an adjustable exponent"}
63//              SetVariable expc,limits={-10,10,0},value= root:myGlobals:Plot_1d:gExpC
64               
65                Button AllQ,pos={281,28},size={70,20},proc=V_AllQ_Plot_1D_ButtonProc,title="All Q"
66                Button AllQ,help={"Show the full q-range of the dataset"}
67               
68        endif
69               
70       
71        SVAR type = root:Packages:NIST:VSANS:Globals:gCurDispType
72
73        V_QBinAllPanels(type)
74
75// TODO:
76// x- "B" detector is currently skipped - Q is not yet calculated
77        Execute ("V_Back_IQ_Graph(\""+type+"\")")
78        Execute ("V_Middle_IQ_Graph(\""+type+"\")")
79        Execute ("V_Front_IQ_Graph(\""+type+"\")")
80       
81       
82End
83
84//function to restore the graph axes to full scale, undoing any zooming
85Function V_AllQ_Plot_1D_ButtonProc(ctrlName) : ButtonControl
86        String ctrlName
87       
88//      DoWindow/F V_1D_Data
89        SetAxis/A
90End
91
92
93//
94// recalculate the I(q) binning. no need to adjust model function or views
95// just rebin
96//
97Function V_BinningModePopup(ctrlName,popNum,popStr) : PopupMenuControl
98        String ctrlName
99        Variable popNum // which item is currently selected (1-based)
100        String popStr           // contents of current popup item as string
101
102        SVAR type = root:Packages:NIST:VSANS:Globals:gCurDispType
103
104        V_QBinAllPanels(type)
105
106        Execute ("V_Back_IQ_Graph(\""+type+"\")")
107        Execute ("V_Middle_IQ_Graph(\""+type+"\")")
108        Execute ("V_Front_IQ_Graph(\""+type+"\")")
109       
110        return(0)       
111End
112
113Function V_GetBinningPopMode()
114
115        Variable binType
116        ControlInfo/W=V_1D_Data popup0
117        strswitch(S_Value)      // string switch
118                case "One":
119                        binType = 1
120                        break           // exit from switch
121                case "Two":
122                        binType = 2
123                        break           // exit from switch
124                case "Four":
125                        binType = 3
126                        break           // exit from switch
127                case "Slit Mode":
128                        binType = 4
129                        break           // exit from switch
130
131                default:                        // optional default expression executed
132                        binType = 0
133                        Abort "Binning mode not found in        V_QBinAllPanels() "// when no case matches
134        endswitch
135       
136        return(binType)
137end
138
139//
140// duplicated from Middle_IQ_Graph from VCALC
141// but plotted in a standalone graph window and not the VCALC subwindow
142//
143// V_1D_Data
144//
145// TODO
146// x- need to set binType
147// x- currently  hard-wired == 1
148//
149// input "type" is the data type and defines the folder
150//
151Proc V_Middle_IQ_Graph(type)
152        String type
153
154        Variable binType
155
156        binType = V_GetBinningPopMode()
157        SetDataFolder $("root:Packages:NIST:VSANS:"+type)
158
159// clear EVERYTHING
160//              ClearAllIQIfDisplayed("MLRTB")
161//              ClearAllIQIfDisplayed("MLR")
162//              ClearAllIQIfDisplayed("MTB")            //this returns to root:
163//              ClearAllIQIfDisplayed("MT")     
164//              ClearAllIQIfDisplayed("ML")     
165//              ClearAllIQIfDisplayed("MR")     
166//              ClearAllIQIfDisplayed("MB")     
167
168        if(binType==1)
169                ClearAllIQIfDisplayed("MLRTB")
170                ClearAllIQIfDisplayed("MLR")
171                ClearAllIQIfDisplayed("MTB")            //this returns to root:
172                ClearAllIQIfDisplayed("MT")     
173                ClearAllIQIfDisplayed("ML")     
174                ClearAllIQIfDisplayed("MR")     
175                ClearAllIQIfDisplayed("MB")                     
176                SetDataFolder $("root:Packages:NIST:VSANS:"+type)
177                CheckDisplayed/W=V_1D_Data iBin_qxqy_ML
178               
179                if(V_flag==0)
180                        AppendtoGraph/W=V_1D_Data iBin_qxqy_ML vs qBin_qxqy_ML
181                        AppendToGraph/W=V_1D_Data iBin_qxqy_MR vs qBin_qxqy_MR
182                        AppendToGraph/W=V_1D_Data iBin_qxqy_MT vs qBin_qxqy_MT
183                        AppendToGraph/W=V_1D_Data iBin_qxqy_MB vs qBin_qxqy_MB
184                        ModifyGraph/W=V_1D_Data mode=4
185                        ModifyGraph/W=V_1D_Data marker=19
186                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_ML)=(65535,0,0),rgb(iBin_qxqy_MB)=(1,16019,65535),rgb(iBin_qxqy_MR)=(65535,0,0),rgb(iBin_qxqy_MT)=(1,16019,65535)
187                        ModifyGraph/W=V_1D_Data msize=2
188                        ModifyGraph/W=V_1D_Data muloffset(iBin_qxqy_ML)={0,4},muloffset(iBin_qxqy_MB)={0,2},muloffset(iBin_qxqy_MR)={0,8}
189                        ModifyGraph/W=V_1D_Data grid=1
190                        ModifyGraph/W=V_1D_Data log=1
191                        ModifyGraph/W=V_1D_Data mirror=2
192                endif           
193        endif
194       
195        if(binType==2)
196                ClearAllIQIfDisplayed("MLRTB")
197                ClearAllIQIfDisplayed("MT")     
198                ClearAllIQIfDisplayed("ML")     
199                ClearAllIQIfDisplayed("MR")     
200                ClearAllIQIfDisplayed("MB")
201       
202
203                SetDataFolder $("root:Packages:NIST:VSANS:"+type)
204                CheckDisplayed/W=V_1D_Data iBin_qxqy_MLR
205               
206                if(V_flag==0)
207                        AppendtoGraph/W=V_1D_Data iBin_qxqy_MLR vs qBin_qxqy_MLR
208                        AppendToGraph/W=V_1D_Data iBin_qxqy_MTB vs qBin_qxqy_MTB
209                        ModifyGraph/W=V_1D_Data mode=4
210                        ModifyGraph/W=V_1D_Data marker=19
211                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_MLR)=(65535,0,0),rgb(iBin_qxqy_MTB)=(1,16019,65535)
212                        ModifyGraph/W=V_1D_Data msize=2
213                        ModifyGraph/W=V_1D_Data muloffset(iBin_qxqy_MLR)={0,2}
214                        ModifyGraph/W=V_1D_Data grid=1
215                        ModifyGraph/W=V_1D_Data log=1
216                        ModifyGraph/W=V_1D_Data mirror=2
217                        Label/W=V_1D_Data left "Intensity (1/cm)"
218                        Label/W=V_1D_Data bottom "Q (1/A)"
219                endif   
220                       
221        endif
222       
223        if(binType==3)
224                ClearAllIQIfDisplayed("MLR")
225                ClearAllIQIfDisplayed("MTB")   
226                ClearAllIQIfDisplayed("MT")     
227                ClearAllIQIfDisplayed("ML")     
228                ClearAllIQIfDisplayed("MR")     
229                ClearAllIQIfDisplayed("MB")     
230       
231                SetDataFolder $("root:Packages:NIST:VSANS:"+type)
232                CheckDisplayed/W=V_1D_Data iBin_qxqy_MLRTB
233               
234                if(V_flag==0)
235                        AppendtoGraph/W=V_1D_Data iBin_qxqy_MLRTB vs qBin_qxqy_MLRTB
236                        ModifyGraph/W=V_1D_Data mode=4
237                        ModifyGraph/W=V_1D_Data marker=19
238                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_MLRTB)=(65535,0,0)
239                        ModifyGraph/W=V_1D_Data msize=2
240                        ModifyGraph/W=V_1D_Data grid=1
241                        ModifyGraph/W=V_1D_Data log=1
242                        ModifyGraph/W=V_1D_Data mirror=2
243                        Label/W=V_1D_Data left "Intensity (1/cm)"
244                        Label/W=V_1D_Data bottom "Q (1/A)"
245                endif   
246                       
247        endif
248
249        if(binType==4)          // slit aperture binning - MT, ML, MR, MB are averaged
250                ClearAllIQIfDisplayed("MLRTB")
251                ClearAllIQIfDisplayed("MLR")
252                ClearAllIQIfDisplayed("MTB")
253               
254                SetDataFolder $("root:Packages:NIST:VSANS:"+type)
255                CheckDisplayed/W=V_1D_Data iBin_qxqy_ML
256               
257                if(V_flag==0)
258                        AppendToGraph/W=V_1D_Data iBin_qxqy_ML vs qBin_qxqy_ML
259                        AppendToGraph/W=V_1D_Data iBin_qxqy_MR vs qBin_qxqy_MR
260                        AppendToGraph/W=V_1D_Data iBin_qxqy_MT vs qBin_qxqy_MT
261                        AppendToGraph/W=V_1D_Data iBin_qxqy_MB vs qBin_qxqy_MB
262                        ModifyGraph/W=V_1D_Data mode=4
263                        ModifyGraph/W=V_1D_Data marker=19
264                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_ML)=(65535,0,0),rgb(iBin_qxqy_MB)=(1,16019,65535),rgb(iBin_qxqy_MR)=(65535,0,0),rgb(iBin_qxqy_MT)=(1,16019,65535)
265                        ModifyGraph/W=V_1D_Data msize=2
266                        ModifyGraph/W=V_1D_Data muloffset(iBin_qxqy_ML)={0,4},muloffset(iBin_qxqy_MB)={0,2},muloffset(iBin_qxqy_MR)={0,8}
267                        ModifyGraph/W=V_1D_Data grid=1
268                        ModifyGraph/W=V_1D_Data log=1
269                        ModifyGraph/W=V_1D_Data mirror=2
270                endif           
271                       
272        endif
273       
274        SetDataFolder root:
275End
276
277//
278// duplicated from Middle_IQ_Graph from VCALC
279// but plotted in a standalone graph window and not the VCALC subwindow
280//
281// V_1D_Data
282//
283// TODO
284// x- need to set binType
285// x- currently  hard-wired == 1
286//
287//
288Proc V_Front_IQ_Graph(type)
289        String type
290
291        Variable binType
292
293
294        binType = V_GetBinningPopMode()
295        SetDataFolder $("root:Packages:NIST:VSANS:"+type)
296
297// clear EVERYTHING
298//              ClearAllIQIfDisplayed("FLRTB")
299//             
300//              ClearAllIQIfDisplayed("FLR")
301//              ClearAllIQIfDisplayed("FTB")
302//
303//              ClearAllIQIfDisplayed("FT")     
304//              ClearAllIQIfDisplayed("FL")     
305//              ClearAllIQIfDisplayed("FR")     
306//              ClearAllIQIfDisplayed("FB")
307               
308        if(binType==1)
309                ClearAllIQIfDisplayed("FLRTB")
310               
311                ClearAllIQIfDisplayed("FLR")
312                ClearAllIQIfDisplayed("FTB")
313
314                ClearAllIQIfDisplayed("FT")     
315                ClearAllIQIfDisplayed("FL")     
316                ClearAllIQIfDisplayed("FR")     
317                ClearAllIQIfDisplayed("FB")
318                               
319                SetDataFolder $("root:Packages:NIST:VSANS:"+type)
320                CheckDisplayed/W=V_1D_Data iBin_qxqy_FL
321               
322                if(V_flag==0)
323                        AppendtoGraph/W=V_1D_Data iBin_qxqy_FL vs qBin_qxqy_FL
324                        AppendToGraph/W=V_1D_Data iBin_qxqy_FR vs qBin_qxqy_FR
325                        AppendToGraph/W=V_1D_Data iBin_qxqy_FT vs qBin_qxqy_FT
326                        AppendToGraph/W=V_1D_Data iBin_qxqy_FB vs qBin_qxqy_FB
327                        ModifyGraph/W=V_1D_Data mode=4
328                        ModifyGraph/W=V_1D_Data marker=19
329                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_FL)=(39321,26208,1),rgb(iBin_qxqy_FB)=(2,39321,1),rgb(iBin_qxqy_FR)=(39321,26208,1),rgb(iBin_qxqy_FT)=(2,39321,1)
330                        ModifyGraph/W=V_1D_Data msize=2
331                        ModifyGraph/W=V_1D_Data muloffset(iBin_qxqy_FL)={0,4},muloffset(iBin_qxqy_FB)={0,2},muloffset(iBin_qxqy_FR)={0,8}
332                        ModifyGraph/W=V_1D_Data grid=1
333                        ModifyGraph/W=V_1D_Data log=1
334                        ModifyGraph/W=V_1D_Data mirror=2
335                endif           
336        endif
337       
338        if(binType==2)
339                ClearAllIQIfDisplayed("FLRTB")
340                ClearAllIQIfDisplayed("FT")     
341                ClearAllIQIfDisplayed("FL")     
342                ClearAllIQIfDisplayed("FR")     
343                ClearAllIQIfDisplayed("FB")     
344
345                SetDataFolder $("root:Packages:NIST:VSANS:"+type)
346                CheckDisplayed/W=V_1D_Data iBin_qxqy_FLR
347               
348                if(V_flag==0)
349                        AppendtoGraph/W=V_1D_Data iBin_qxqy_FLR vs qBin_qxqy_FLR
350                        AppendToGraph/W=V_1D_Data iBin_qxqy_FTB vs qBin_qxqy_FTB
351                        ModifyGraph/W=V_1D_Data mode=4
352                        ModifyGraph/W=V_1D_Data marker=19
353                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_FLR)=(39321,26208,1),rgb(iBin_qxqy_FTB)=(2,39321,1)
354                        ModifyGraph/W=V_1D_Data msize=2
355                        ModifyGraph/W=V_1D_Data muloffset(iBin_qxqy_FLR)={0,2}
356                        ModifyGraph/W=V_1D_Data grid=1
357                        ModifyGraph/W=V_1D_Data log=1
358                        ModifyGraph/W=V_1D_Data mirror=2
359                        Label/W=V_1D_Data left "Intensity (1/cm)"
360                        Label/W=V_1D_Data bottom "Q (1/A)"
361                endif   
362                       
363        endif
364       
365        if(binType==3)
366                ClearAllIQIfDisplayed("FLR")
367                ClearAllIQIfDisplayed("FTB")   
368                ClearAllIQIfDisplayed("FT")     
369                ClearAllIQIfDisplayed("FL")     
370                ClearAllIQIfDisplayed("FR")     
371                ClearAllIQIfDisplayed("FB")     
372       
373                SetDataFolder $("root:Packages:NIST:VSANS:"+type)
374                CheckDisplayed/W=V_1D_Data iBin_qxqy_FLRTB
375               
376                if(V_flag==0)
377                        AppendtoGraph/W=V_1D_Data iBin_qxqy_FLRTB vs qBin_qxqy_FLRTB
378                        ModifyGraph/W=V_1D_Data mode=4
379                        ModifyGraph/W=V_1D_Data marker=19
380                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_FLRTB)=(39321,26208,1)
381                        ModifyGraph/W=V_1D_Data msize=2
382                        ModifyGraph/W=V_1D_Data grid=1
383                        ModifyGraph/W=V_1D_Data log=1
384                        ModifyGraph/W=V_1D_Data mirror=2
385                        Label/W=V_1D_Data left "Intensity (1/cm)"
386                        Label/W=V_1D_Data bottom "Q (1/A)"
387                endif   
388                       
389        endif
390
391        if(binType==4)          // slit aperture binning - MT, ML, MR, MB are averaged
392                ClearAllIQIfDisplayed("FLRTB")
393                ClearAllIQIfDisplayed("FLR")
394                ClearAllIQIfDisplayed("FTB")
395               
396                SetDataFolder $("root:Packages:NIST:VSANS:"+type)
397                CheckDisplayed/W=V_1D_Data iBin_qxqy_FL
398               
399                if(V_flag==0)
400                        AppendtoGraph/W=V_1D_Data iBin_qxqy_FL vs qBin_qxqy_FL
401                        AppendToGraph/W=V_1D_Data iBin_qxqy_FR vs qBin_qxqy_FR
402                        AppendToGraph/W=V_1D_Data iBin_qxqy_FT vs qBin_qxqy_FT
403                        AppendToGraph/W=V_1D_Data iBin_qxqy_FB vs qBin_qxqy_FB
404                        ModifyGraph/W=V_1D_Data mode=4
405                        ModifyGraph/W=V_1D_Data marker=19
406                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_FL)=(39321,26208,1),rgb(iBin_qxqy_FB)=(2,39321,1),rgb(iBin_qxqy_FR)=(39321,26208,1),rgb(iBin_qxqy_FT)=(2,39321,1)
407                        ModifyGraph/W=V_1D_Data msize=2
408                        ModifyGraph/W=V_1D_Data muloffset(iBin_qxqy_FL)={0,4},muloffset(iBin_qxqy_FB)={0,2},muloffset(iBin_qxqy_FR)={0,8}
409                        ModifyGraph/W=V_1D_Data grid=1
410                        ModifyGraph/W=V_1D_Data log=1
411                        ModifyGraph/W=V_1D_Data mirror=2
412                endif           
413                       
414        endif
415       
416        SetDataFolder root:
417End
418
419
420// TODO
421// x- need to set binType
422// x- currently  hard-wired == 1
423//
424////////////to plot the back panel I(q)
425Proc V_Back_IQ_Graph(type)
426        String type
427       
428//      SetDataFolder root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_B
429
430        Variable binType
431
432        binType = V_GetBinningPopMode()
433       
434        SetDataFolder $("root:Packages:NIST:VSANS:"+type)       
435
436        if(binType==1 || binType==2 || binType==3)
437       
438                ClearAllIQIfDisplayed("B")
439                SetDataFolder $("root:Packages:NIST:VSANS:"+type)       
440                CheckDisplayed/W=V_1D_Data iBin_qxqy_B
441               
442                if(V_flag==0)
443                        AppendtoGraph/W=V_1D_Data iBin_qxqy_B vs qBin_qxqy_B
444                        ModifyGraph/W=V_1D_Data mode=4
445                        ModifyGraph/W=V_1D_Data marker=19
446                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_B)=(1,52428,52428)
447                        ModifyGraph/W=V_1D_Data msize=2
448                        ModifyGraph/W=V_1D_Data grid=1
449                        ModifyGraph/W=V_1D_Data log=1
450                        ModifyGraph/W=V_1D_Data mirror=2
451                endif
452        endif
453
454        //nothing different here since there is ony a single detector to display, but for the future...
455        if(binType==4)
456       
457                ClearAllIQIfDisplayed("B")
458                SetDataFolder $("root:Packages:NIST:VSANS:"+type)       
459                CheckDisplayed/W=V_1D_Data iBin_qxqy_B
460               
461                if(V_flag==0)
462                        AppendtoGraph/W=V_1D_Data iBin_qxqy_B vs qBin_qxqy_B
463                        ModifyGraph/W=V_1D_Data mode=4
464                        ModifyGraph/W=V_1D_Data marker=19
465                        ModifyGraph/W=V_1D_Data rgb(iBin_qxqy_B)=(1,52428,52428)
466                        ModifyGraph/W=V_1D_Data msize=2
467                        ModifyGraph/W=V_1D_Data grid=1
468                        ModifyGraph/W=V_1D_Data log=1
469                        ModifyGraph/W=V_1D_Data mirror=2
470                endif
471        endif
472
473       
474        SetDataFolder root:
475End
476
Note: See TracBrowser for help on using the repository browser.