source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WhiteBeamDistribution.ipf @ 1222

Last change on this file since 1222 was 1222, checked in by srkline, 3 years ago

Updated help file for VSANS. Graphics were not PNG.

Removed HFIR SANS package since if requires XML XOP - no longer supported.

Improved quality of graphics export for Analysis reports.

Added more support for super_white_beam mode on VSANS

Corrected printf bug (Igor 8) when printing out % sign

Added utilities for patching wavelength and monochromator type on VSANS since the type is still not written out correctly by NICE, and super_white_beam is not yet defined in NICE

Adjusted panel dimensions for the temperature sensor display on VSANS (needed onWindows)

File size: 4.4 KB
Line 
1#pragma TextEncoding = "MacRoman"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
3
4
5//
6// this is an empirical representation of the White Beam wavelength
7// distribution.
8//
9// using Integrate function -- find the normalization value
10//
11// integral = 20926 (cts*A) for "top"
12// integral = 19933 (cts*A) for "middle"
13// integration of interpolated data (100 pts) = 20051 (3 A to 9 A)
14//
15//
16//
17// of the three choices, using the fit to the "top" of the distribution gives the best-looking
18// result when compared to the AgBeh data
19//
20
21
22// 9/2019
23// added an empirical functional form for the "Super" white beam mode where the deflector is out
24// and the wavelength is not cut off at the higher wavelength, but extends to 20 
25//
26// Integral = 30955 (cts*A) for middle fit
27//
28//
29
30//  White Beam:
31//  mean wavelength = 5.29687
32//  3rd moment/2nd moment = 5.741
33//
34//  Super White Beam:
35//  mean wavelength = 6.2033
36//  3rd moment/2nd moment = 7.93267
37//
38Constant kWhiteBeam_Mean = 5.3
39//Constant kWhiteBeam_Mean = 5.7                // mean of lam^2
40Constant kWhiteBeam_Normalization = 19933
41
42Constant kSuperWhiteBeam_Mean = 6.2
43//Constant kSuperWhiteBeam_Mean = 7.9           //mean of lam^2
44Constant kSuperWhiteBeam_Normalization = 30955
45
46
47
48
49Function V_WhiteBeamDist_top(lam)
50        Variable lam
51       
52        if(lam < 3.37)
53                return(0)
54        endif
55       
56        if(lam < 3.69)
57                return(-31013 + 9198*lam)
58        endif
59       
60        if(lam < 3.84)
61                return(23715 - 5649*lam)
62        endif
63       
64//// the "middle" of the spikes
65//      if(lam < 4.12)
66//              return(-84962 + 22634*lam)
67//      endif
68//      if(lam < 8.37)
69//              return(-2336 + 11422*exp(-( (lam-3.043)/4.234 )^2))
70//      endif
71
72//// the "top" of the spikes
73        if(lam < 4.16)
74                return(-84962 + 22634*lam)
75        endif
76        if(lam < 8.25)
77                return(-2336 + 12422*exp(-( (lam-3.043)/4.034 )^2))
78        endif
79
80//       anything larger than 8.37, return 0   
81        return(0)
82       
83End
84
85
86Function V_WhiteBeamDist_mid(lam)
87        Variable lam
88       
89        if(lam < 3.37)
90                return(0)
91        endif
92       
93        if(lam < 3.69)
94                return(-31013 + 9198*lam)
95        endif
96       
97        if(lam < 3.84)
98                return(23715 - 5649*lam)
99        endif
100       
101//// the "middle" of the spikes
102        if(lam < 4.12)
103                return(-84962 + 22634*lam)
104        endif
105        if(lam < 8.37)
106                return(-2336 + 11422*exp(-( (lam-3.043)/4.234 )^2))
107        endif
108
109////// the "top" of the spikes
110//      if(lam < 4.16)
111//              return(-84962 + 22634*lam)
112//      endif
113//      if(lam < 8.25)
114//              return(-2336 + 12422*exp(-( (lam-3.043)/4.034 )^2))
115//      endif
116
117//       anything larger than 8.37, return 0   
118        return(0)
119       
120End
121
122// this is not used - there is no improvement in the results when using the "full" shape of the
123// WB distribution.
124Function V_WhiteBeamInterp(lam)
125        Variable lam
126       
127        WAVE interp_lam = root:interp_lam
128        WAVE interp_cts = root:interp_cts
129       
130        return(interp(lam,interp_lam,interp_cts))
131End
132
133// change the x-scaling of cts_for_mean to 3,9 (beg,end)
134// 3309 is the average value of cts_for_mean
135// cts_for_mean = interp_cts*x/3309
136//
137// gives an average wavelength of 5.302 A
138// median ~ 5.97 A
139//
140Function V_WB_Mean()
141
142        WAVE cts_for_mean
143        Variable tot=sum(cts_for_mean)
144        Variable ans
145       
146        cts_for_mean = cts_for_mean*x
147        ans = sum(cts_for_mean)/tot
148       
149        return(ans)
150End
151
152
153// assumes that the counts and wavelength data for white and superWhite both are loaded and named:
154//
155// white_wavelength, counts_white
156// super_white_wavelength, counts_super_white
157//
158//
159Proc V_WB_Stats()
160
161        duplicate/O counts_white cts_W, intg_W,intg_W3
162        duplicate/O counts_super_white cts_SW intg_SW,intg_SW3
163
164        Print "White Beam:"
165        intg_W = cts_W*white_wavelength
166        printf "mean wavelength = %g\r",sum(intg_W)/sum(cts_W)
167        intg_W = cts_W*white_wavelength^2
168//      printf "sqrt(wavelength^2)/N = %g\r",sqrt( sum(intg_W)/sum(cts_W) )
169        intg_W3 = cts_W*white_wavelength^3
170        printf "3rd moment/2nd moment = %g\r",sum(intg_W3)/sum(intg_W)
171
172        Print
173        Print "Super White Beam:"
174        intg_SW = cts_SW*super_white_wavelength
175        printf "mean wavelength = %g\r",sum(intg_SW)/sum(cts_SW)
176        intg_SW = cts_SW*super_white_wavelength^2
177//      printf "sqrt(wavelength^2)/N = %g\r",sqrt( sum(intg_SW)/sum(cts_SW) )
178        intg_SW3 = cts_SW*super_white_wavelength^3
179        printf "3rd moment/2nd moment = %g\r",sum(intg_SW3)/sum(intg_SW)
180               
181End
182
183//
184//
185//
186Function V_SuperWhiteBeamDist_mid(lam)
187        Variable lam
188       
189        if(lam < 3.37)
190                return(0)
191        endif
192       
193        if(lam < 3.72)
194                return(-33536 + 9919*lam)
195        endif
196       
197        if(lam < 3.88)
198                return(28941 - 6848*lam)
199        endif
200       
201//// the "middle" of the spikes
202        if(lam < 4.16)
203                return(-1.0111e5 + 26689*lam)
204        endif
205       
206        if(lam < 20)
207                return(5 - 10081*exp(-( (lam-4.161)/0.9788 )) + 19776*exp(-( (lam-4.161)/1.921 )) )
208        endif
209
210//       anything larger than 20, return 0     
211        return(0)
212       
213End
214
215
Note: See TracBrowser for help on using the repository browser.