1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma IgorVersion = 6.0 |
---|
3 | |
---|
4 | ///////////////////////////////////////////////////// |
---|
5 | // |
---|
6 | // Plot's Greg Beaucage's Rg-power Law "model" of scattering |
---|
7 | // somewhat useful for identifying length scales, but short on |
---|
8 | // physical inerpretation of the real structure of the sample. |
---|
9 | // |
---|
10 | // up to 4 "levels" can be calculated |
---|
11 | // best to start with single level, and fit a small range of |
---|
12 | // the data, and add more levels as needed |
---|
13 | // |
---|
14 | // see the help file for the original references |
---|
15 | // |
---|
16 | Proc PlotBeau_One(num,qmin,qmax) |
---|
17 | Variable num=256,qmin=0.001,qmax=0.7 |
---|
18 | Prompt num "Enter number of data points for model: " |
---|
19 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
20 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
21 | |
---|
22 | make/o/d/n=(num) xwave_b1,ywave_b1 |
---|
23 | xwave_b1 = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
24 | make/o/d coef_b1 = {1,3,21,6e-4,2,0} |
---|
25 | make/o/t parameters_b1 = {"scale","G1 (cm-1 sr-1)","Rg1 (A)","B1 (cm-1 sr-1)","Pow1","bkg (cm-1 sr-1)"} |
---|
26 | Edit parameters_b1,coef_b1 |
---|
27 | |
---|
28 | Variable/G root:g_b1 |
---|
29 | g_b1 := OneLevel(coef_b1,ywave_b1,xwave_b1) |
---|
30 | Display ywave_b1 vs xwave_b1 |
---|
31 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
32 | Label bottom "q (\\S-1\\M)" |
---|
33 | Label left "Intensity (cm\\S-1\\M)" |
---|
34 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
35 | End |
---|
36 | |
---|
37 | Proc PlotBeau_Two(num,qmin,qmax) |
---|
38 | Variable num=256,qmin=0.001,qmax=0.7 |
---|
39 | Prompt num "Enter number of data points for model: " |
---|
40 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
41 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
42 | |
---|
43 | make/o/d/n=(num) xwave_b2,ywave_b2 |
---|
44 | xwave_b2 = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
45 | make/o/d coef_b2 = {1,400,200,5e-6,4,3,21,6e-4,2,0} |
---|
46 | make/o/t parameters_b2 = {"scale","G1 (cm-1 sr-1)","Rg1 (A)","B1 (cm-1 sr-1)","Pow1","G2 (cm-1 sr-1)","Rg2 (A)","B2 (cm-1 sr-1)","Pow2","bkg (cm-1 sr-1)"} |
---|
47 | Edit parameters_b2,coef_b2 |
---|
48 | |
---|
49 | Variable/G root:g_b2 |
---|
50 | g_b2 := TwoLevel(coef_b2,ywave_b2,xwave_b2) |
---|
51 | Display ywave_b2 vs xwave_b2 |
---|
52 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
53 | Label bottom "q (\\S-1\\M)" |
---|
54 | Label left "Intensity (cm\\S-1\\M)" |
---|
55 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
56 | End |
---|
57 | |
---|
58 | Proc PlotBeau_Three(num,qmin,qmax) |
---|
59 | Variable num=256,qmin=0.001,qmax=0.7 |
---|
60 | Prompt num "Enter number of data points for model: " |
---|
61 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
62 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
63 | |
---|
64 | make/o/d/n=(num) xwave_b3,ywave_b3 |
---|
65 | xwave_b3 = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
66 | make/o/d coef_b3 = {1,4000,600,2e-7,4,400,200,5e-6,4,3,21,6e-4,2,0} |
---|
67 | make/o/t parameters_b3 = {"scale","G1 (cm-1 sr-1)","Rg1 (A)","B1 (cm-1 sr-1)","Pow1","G2 (cm-1 sr-1)","Rg2 (A)","B2 (cm-1 sr-1)","Pow2","G3 (cm-1 sr-1)","Rg3 (A)","B3 (cm-1 sr-1)","Pow3","bkg (cm-1)"} |
---|
68 | Edit parameters_b3,coef_b3 |
---|
69 | |
---|
70 | Variable/G root:g_b3 |
---|
71 | g_b3 := ThreeLevel(coef_b3,ywave_b3,xwave_b3) |
---|
72 | Display ywave_b3 vs xwave_b3 |
---|
73 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
74 | Label bottom "q (\\S-1\\M)" |
---|
75 | Label left "Intensity (cm\\S-1\\M)" |
---|
76 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
77 | End |
---|
78 | |
---|
79 | Proc PlotBeau_Four(num,qmin,qmax) |
---|
80 | Variable num=256,qmin=0.001,qmax=0.7 |
---|
81 | Prompt num "Enter number of data points for model: " |
---|
82 | Prompt qmin "Enter minimum q-value (^-1) for model: " |
---|
83 | Prompt qmax "Enter maximum q-value (^-1) for model: " |
---|
84 | |
---|
85 | make/o/d/n=(num) xwave_b4,ywave_b4 |
---|
86 | xwave_b4 = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
87 | make/o/d coef_b4 = {1,40000,2000,1e-8,4,4000,600,2e-7,4,400,200,5e-6,4,3,21,6e-4,2,0} |
---|
88 | make/o/t parameters_b4 = {"scale","G1 (cm-1 sr-1)","Rg1 (A)","B1 (cm-1 sr-1)","Pow1","G2 (cm-1 sr-1)","Rg2 (A)","B2 (cm-1 sr-1)","Pow2","G3 (cm-1 sr-1)","Rg3 (A)","B3 (cm-1 sr-1)","Pow3","G4 (cm-1 sr-1)","Rg4 (A)","B4 (cm-1 sr-1)","Pow4","bkg (cm-1)"} |
---|
89 | Edit parameters_b4,coef_b4 |
---|
90 | |
---|
91 | Variable/G root:g_b4 |
---|
92 | g_b4 := FourLevel(coef_b4,ywave_b4,xwave_b4) |
---|
93 | Display ywave_b4 vs xwave_b4 |
---|
94 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
95 | Label bottom "q (\\S-1\\M)" |
---|
96 | Label left "Intensity (cm\\S-1\\M)" |
---|
97 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
98 | End |
---|
99 | |
---|
100 | /////////// macros for smeared model calculations |
---|
101 | |
---|
102 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
103 | Proc PlotSmearedBeau_OneLevel(str) |
---|
104 | String str |
---|
105 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
106 | |
---|
107 | // if any of the resolution waves are missing => abort |
---|
108 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
109 | Abort |
---|
110 | endif |
---|
111 | |
---|
112 | SetDataFolder $("root:"+str) |
---|
113 | |
---|
114 | // Setup parameter table for model function |
---|
115 | Make/O/D smear_coef_b1 ={1,3,21,6e-4,2,0} |
---|
116 | make/o/t smear_parameters_b1 = {"scale","G1 (cm-1 sr-1)","Rg1 (A)","B1 (cm-1 sr-1)","Pow1","bkg (cm-1 sr-1)"} |
---|
117 | Edit smear_parameters_b1,smear_coef_b1 |
---|
118 | |
---|
119 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
120 | // make extra copy of experimental q-values for easy plotting |
---|
121 | Duplicate/O $(str+"_q") smeared_b1,smeared_qvals |
---|
122 | SetScale d,0,0,"1/cm",smeared_b1 |
---|
123 | |
---|
124 | Variable/G gs_b1=0 |
---|
125 | gs_b1 := fSmearedOneLevel(smear_coef_b1,smeared_b1,smeared_qvals) //this wrapper fills the STRUCT |
---|
126 | |
---|
127 | Display smeared_b1 vs smeared_qvals |
---|
128 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
129 | Label bottom "q (\\S-1\\M)" |
---|
130 | Label left "Intensity (cm\\S-1\\M)" |
---|
131 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
132 | |
---|
133 | SetDataFolder root: |
---|
134 | End |
---|
135 | |
---|
136 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
137 | Proc PlotSmearedBeau_TwoLevel(str) |
---|
138 | String str |
---|
139 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
140 | |
---|
141 | // if any of the resolution waves are missing => abort |
---|
142 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
143 | Abort |
---|
144 | endif |
---|
145 | |
---|
146 | SetDataFolder $("root:"+str) |
---|
147 | |
---|
148 | // Setup parameter table for model function |
---|
149 | Make/O/D smear_coef_b2 = {1,400,200,5e-6,4,3,21,6e-4,2,0} |
---|
150 | make/o/t smear_parameters_b2 = {"scale","G1 (cm-1 sr-1)","Rg1 (A)","B1 (cm-1 sr-1)","Pow1","G2 (cm-1 sr-1)","Rg2 (A)","B2 (cm-1 sr-1)","Pow2","bkg (cm-1 sr-1)"} |
---|
151 | Edit smear_parameters_b2,smear_coef_b2 |
---|
152 | |
---|
153 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
154 | // make extra copy of experimental q-values for easy plotting |
---|
155 | Duplicate/O $(str+"_q") smeared_b2,smeared_qvals |
---|
156 | SetScale d,0,0,"1/cm",smeared_b2 |
---|
157 | |
---|
158 | Variable/G gs_b2=0 |
---|
159 | gs_b2 := fSmearedTwoLevel(smear_coef_b2,smeared_b2,smeared_qvals) //this wrapper fills the STRUCT |
---|
160 | |
---|
161 | Display smeared_b2 vs smeared_qvals |
---|
162 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
163 | Label bottom "q (\\S-1\\M)" |
---|
164 | Label left "Intensity (cm\\S-1\\M)" |
---|
165 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
166 | |
---|
167 | SetDataFolder root: |
---|
168 | End |
---|
169 | |
---|
170 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
171 | Proc PlotSmearedBeau_ThreeLevel(str) |
---|
172 | String str |
---|
173 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
174 | |
---|
175 | // if any of the resolution waves are missing => abort |
---|
176 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
177 | Abort |
---|
178 | endif |
---|
179 | |
---|
180 | SetDataFolder $("root:"+str) |
---|
181 | |
---|
182 | // Setup parameter table for model function |
---|
183 | Make/O/D smear_coef_b3 = {1,4000,600,2e-7,4,400,200,5e-6,4,3,21,6e-4,2,0} |
---|
184 | make/o/t smear_parameters_b3 = {"scale","G1 (cm-1 sr-1)","Rg1 (A)","B1 (cm-1 sr-1)","Pow1","G2 (cm-1 sr-1)","Rg2 (A)","B2 (cm-1 sr-1)","Pow2","G3 (cm-1 sr-1)","Rg3 (A)","B3 (cm-1 sr-1)","Pow3","bkg (cm-1)"} |
---|
185 | Edit smear_parameters_b3,smear_coef_b3 |
---|
186 | |
---|
187 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
188 | // make extra copy of experimental q-values for easy plotting |
---|
189 | Duplicate/O $(str+"_q") smeared_b3,smeared_qvals |
---|
190 | SetScale d,0,0,"1/cm",smeared_b3 |
---|
191 | |
---|
192 | Variable/G gs_b3=0 |
---|
193 | gs_b3 := fSmearedThreeLevel(smear_coef_b3,smeared_b3,smeared_qvals) //this wrapper fills the STRUCT |
---|
194 | |
---|
195 | Display smeared_b3 vs smeared_qvals |
---|
196 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
197 | Label bottom "q (\\S-1\\M)" |
---|
198 | Label left "Intensity (cm\\S-1\\M)" |
---|
199 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
200 | |
---|
201 | SetDataFolder root: |
---|
202 | End |
---|
203 | |
---|
204 | // - sets up a dependency to a wrapper, not the actual SmearedModelFunction |
---|
205 | Proc PlotSmearedBeau_FourLevel(str) |
---|
206 | String str |
---|
207 | Prompt str,"Pick the data folder containing the resolution you want",popup,getAList(4) |
---|
208 | |
---|
209 | // if any of the resolution waves are missing => abort |
---|
210 | if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
211 | Abort |
---|
212 | endif |
---|
213 | |
---|
214 | SetDataFolder $("root:"+str) |
---|
215 | |
---|
216 | // Setup parameter table for model function |
---|
217 | Make/O/D smear_coef_b4 = {1,40000,2000,1e-8,4,4000,600,2e-7,4,400,200,5e-6,4,3,21,6e-4,2,0} |
---|
218 | Make/o/t smear_parameters_b4 = {"scale","G1 (cm-1 sr-1)","Rg1 (A)","B1 (cm-1 sr-1)","Pow1","G2 (cm-1 sr-1)","Rg2 (A)","B2 (cm-1 sr-1)","Pow2","G3 (cm-1 sr-1)","Rg3 (A)","B3 (cm-1 sr-1)","Pow3","G4 (cm-1 sr-1)","Rg4 (A)","B4 (cm-1 sr-1)","Pow4","bkg (cm-1)"} |
---|
219 | Edit smear_parameters_b4,smear_coef_b4 |
---|
220 | |
---|
221 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
222 | // make extra copy of experimental q-values for easy plotting |
---|
223 | Duplicate/O $(str+"_q") smeared_b4,smeared_qvals |
---|
224 | SetScale d,0,0,"1/cm",smeared_b4 |
---|
225 | |
---|
226 | Variable/G gs_b4=0 |
---|
227 | gs_b4 := fSmearedFourLevel(smear_coef_b4,smeared_b4,smeared_qvals) //this wrapper fills the STRUCT |
---|
228 | |
---|
229 | Display smeared_b4 vs smeared_qvals |
---|
230 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
231 | Label bottom "q (\\S-1\\M)" |
---|
232 | Label left "Intensity (cm\\S-1\\M)" |
---|
233 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
234 | |
---|
235 | SetDataFolder root: |
---|
236 | End |
---|
237 | |
---|
238 | |
---|
239 | |
---|
240 | |
---|
241 | //AAO version, uses XOP if available |
---|
242 | // simply calls the original single point calculation with |
---|
243 | // a wave assignment (this will behave nicely if given point ranges) |
---|
244 | Function OneLevel(cw,yw,xw) : FitFunc |
---|
245 | Wave cw,yw,xw |
---|
246 | |
---|
247 | #if exists("OneLevelX") |
---|
248 | yw = OneLevelX(cw,xw) |
---|
249 | #else |
---|
250 | yw = fOneLevel(cw,xw) |
---|
251 | #endif |
---|
252 | return(0) |
---|
253 | End |
---|
254 | |
---|
255 | //////////Function definitions |
---|
256 | |
---|
257 | Function fOneLevel(w,x) :FitFunc |
---|
258 | Wave w |
---|
259 | Variable x |
---|
260 | |
---|
261 | Variable ans,erf1,prec=1e-15 |
---|
262 | Variable G1,Rg1,B1,Pow1,bkg,scale |
---|
263 | |
---|
264 | scale = w[0] |
---|
265 | G1 = w[1] |
---|
266 | Rg1 = w[2] |
---|
267 | B1 = w[3] |
---|
268 | Pow1 = w[4] |
---|
269 | bkg = w[5] |
---|
270 | |
---|
271 | erf1 = erf( (x*Rg1/sqrt(6)) ,prec) |
---|
272 | |
---|
273 | ans = G1*exp(-x*x*Rg1*Rg1/3) |
---|
274 | ans += B1*(erf1^3/x)^Pow1 |
---|
275 | ans *= scale |
---|
276 | ans += bkg |
---|
277 | |
---|
278 | Return (ans) |
---|
279 | End |
---|
280 | |
---|
281 | //AAO version, uses XOP if available |
---|
282 | // simply calls the original single point calculation with |
---|
283 | // a wave assignment (this will behave nicely if given point ranges) |
---|
284 | Function TwoLevel(cw,yw,xw) : FitFunc |
---|
285 | Wave cw,yw,xw |
---|
286 | |
---|
287 | #if exists("TwoLevelX") |
---|
288 | yw = TwoLevelX(cw,xw) |
---|
289 | #else |
---|
290 | yw = fTwoLevel(cw,xw) |
---|
291 | #endif |
---|
292 | return(0) |
---|
293 | End |
---|
294 | |
---|
295 | Function fTwoLevel(w,x) :FitFunc |
---|
296 | Wave w |
---|
297 | Variable x |
---|
298 | |
---|
299 | Variable ans,G1,Rg1,B1,G2,Rg2,B2,Pow1,Pow2,bkg |
---|
300 | Variable erf1,erf2,prec=1e-15,scale |
---|
301 | |
---|
302 | //Rsub = Rs |
---|
303 | scale = w[0] |
---|
304 | G1 = w[1] //equivalent to I(0) |
---|
305 | Rg1 = w[2] |
---|
306 | B1 = w[3] |
---|
307 | Pow1 = w[4] |
---|
308 | G2 = w[5] |
---|
309 | Rg2 = w[6] |
---|
310 | B2 = w[7] |
---|
311 | Pow2 = w[8] |
---|
312 | bkg = w[9] |
---|
313 | |
---|
314 | erf1 = erf( (x*Rg1/sqrt(6)) ,prec) |
---|
315 | erf2 = erf( (x*Rg2/sqrt(6)) ,prec) |
---|
316 | //Print erf1 |
---|
317 | |
---|
318 | ans = G1*exp(-x*x*Rg1*Rg1/3) |
---|
319 | ans += B1*exp(-x*x*Rg2*Rg2/3)*(erf1^3/x)^Pow1 |
---|
320 | ans += G2*exp(-x*x*Rg2*Rg2/3) |
---|
321 | ans += B2*(erf2^3/x)^Pow2 |
---|
322 | ans *= scale |
---|
323 | ans += bkg |
---|
324 | |
---|
325 | Return(ans) |
---|
326 | End |
---|
327 | |
---|
328 | //AAO version, uses XOP if available |
---|
329 | // simply calls the original single point calculation with |
---|
330 | // a wave assignment (this will behave nicely if given point ranges) |
---|
331 | Function ThreeLevel(cw,yw,xw) : FitFunc |
---|
332 | Wave cw,yw,xw |
---|
333 | |
---|
334 | #if exists("ThreeLevelX") |
---|
335 | yw = ThreeLevelX(cw,xw) |
---|
336 | #else |
---|
337 | yw = fThreeLevel(cw,xw) |
---|
338 | #endif |
---|
339 | return(0) |
---|
340 | End |
---|
341 | |
---|
342 | Function fThreeLevel(w,x) :FitFunc |
---|
343 | Wave w |
---|
344 | Variable x |
---|
345 | |
---|
346 | Variable ans,G1,Rg1,B1,G2,Rg2,B2,Pow1,Pow2,bkg |
---|
347 | Variable G3,Rg3,B3,Pow3,erf3 |
---|
348 | Variable erf1,erf2,prec=1e-15,scale |
---|
349 | |
---|
350 | //Rsub = Rs |
---|
351 | scale = w[0] |
---|
352 | G1 = w[1] //equivalent to I(0) |
---|
353 | Rg1 = w[2] |
---|
354 | B1 = w[3] |
---|
355 | Pow1 = w[4] |
---|
356 | G2 = w[5] |
---|
357 | Rg2 = w[6] |
---|
358 | B2 = w[7] |
---|
359 | Pow2 = w[8] |
---|
360 | G3 = w[9] |
---|
361 | Rg3 = w[10] |
---|
362 | B3 = w[11] |
---|
363 | Pow3 = w[12] |
---|
364 | bkg = w[13] |
---|
365 | |
---|
366 | erf1 = erf( (x*Rg1/sqrt(6)) ,prec) |
---|
367 | erf2 = erf( (x*Rg2/sqrt(6)) ,prec) |
---|
368 | erf3 = erf( (x*Rg3/sqrt(6)) ,prec) |
---|
369 | //Print erf1 |
---|
370 | |
---|
371 | ans = G1*exp(-x*x*Rg1*Rg1/3) + B1*exp(-x*x*Rg2*Rg2/3)*(erf1^3/x)^Pow1 |
---|
372 | ans += G2*exp(-x*x*Rg2*Rg2/3) + B2*exp(-x*x*Rg3*Rg3/3)*(erf2^3/x)^Pow2 |
---|
373 | ans += G3*exp(-x*x*Rg3*Rg3/3) + B3*(erf3^3/x)^Pow3 |
---|
374 | ans *= scale |
---|
375 | ans += bkg |
---|
376 | |
---|
377 | Return(ans) |
---|
378 | End |
---|
379 | |
---|
380 | //AAO version, uses XOP if available |
---|
381 | // simply calls the original single point calculation with |
---|
382 | // a wave assignment (this will behave nicely if given point ranges) |
---|
383 | Function FourLevel(cw,yw,xw) : FitFunc |
---|
384 | Wave cw,yw,xw |
---|
385 | |
---|
386 | #if exists("FourLevelX") |
---|
387 | yw = FourLevelX(cw,xw) |
---|
388 | #else |
---|
389 | yw = fFourLevel(cw,xw) |
---|
390 | #endif |
---|
391 | return(0) |
---|
392 | End |
---|
393 | |
---|
394 | Function fFourLevel(w,x) :FitFunc |
---|
395 | Wave w |
---|
396 | Variable x |
---|
397 | |
---|
398 | Variable ans,G1,Rg1,B1,G2,Rg2,B2,Pow1,Pow2,bkg |
---|
399 | Variable G3,Rg3,B3,Pow3,erf3 |
---|
400 | Variable G4,Rg4,B4,Pow4,erf4 |
---|
401 | Variable erf1,erf2,prec=1e-15,scale |
---|
402 | |
---|
403 | //Rsub = Rs |
---|
404 | scale = w[0] |
---|
405 | G1 = w[1] //equivalent to I(0) |
---|
406 | Rg1 = w[2] |
---|
407 | B1 = w[3] |
---|
408 | Pow1 = w[4] |
---|
409 | G2 = w[5] |
---|
410 | Rg2 = w[6] |
---|
411 | B2 = w[7] |
---|
412 | Pow2 = w[8] |
---|
413 | G3 = w[9] |
---|
414 | Rg3 = w[10] |
---|
415 | B3 = w[11] |
---|
416 | Pow3 = w[12] |
---|
417 | G4 = w[13] |
---|
418 | Rg4 = w[14] |
---|
419 | B4 = w[15] |
---|
420 | Pow4 = w[16] |
---|
421 | bkg = w[17] |
---|
422 | |
---|
423 | erf1 = erf( (x*Rg1/sqrt(6)) ,prec) |
---|
424 | erf2 = erf( (x*Rg2/sqrt(6)) ,prec) |
---|
425 | erf3 = erf( (x*Rg3/sqrt(6)) ,prec) |
---|
426 | erf4 = erf( (x*Rg4/sqrt(6)) ,prec) |
---|
427 | |
---|
428 | ans = G1*exp(-x*x*Rg1*Rg1/3) + B1*exp(-x*x*Rg2*Rg2/3)*(erf1^3/x)^Pow1 |
---|
429 | ans += G2*exp(-x*x*Rg2*Rg2/3) + B2*exp(-x*x*Rg3*Rg3/3)*(erf2^3/x)^Pow2 |
---|
430 | ans += G3*exp(-x*x*Rg3*Rg3/3) + B3*exp(-x*x*Rg4*Rg4/3)*(erf3^3/x)^Pow3 |
---|
431 | ans += G4*exp(-x*x*Rg4*Rg4/3) + B4*(erf4^3/x)^Pow4 |
---|
432 | ans *= scale |
---|
433 | ans += bkg |
---|
434 | |
---|
435 | Return(ans) |
---|
436 | End |
---|
437 | |
---|
438 | Function SmearedOneLevel(s) :FitFunc |
---|
439 | Struct ResSmearAAOStruct &s |
---|
440 | |
---|
441 | // the name of your unsmeared model (AAO) is the first argument |
---|
442 | s.yW = Smear_Model_20(OneLevel,s.coefW,s.xW,s.resW) |
---|
443 | |
---|
444 | return(0) |
---|
445 | End |
---|
446 | |
---|
447 | |
---|
448 | Function SmearedTwoLevel(s) :FitFunc |
---|
449 | Struct ResSmearAAOStruct &s |
---|
450 | |
---|
451 | // the name of your unsmeared model (AAO) is the first argument |
---|
452 | s.yW = Smear_Model_20(TwoLevel,s.coefW,s.xW,s.resW) |
---|
453 | |
---|
454 | return(0) |
---|
455 | End |
---|
456 | |
---|
457 | |
---|
458 | Function SmearedThreeLevel(s) :FitFunc |
---|
459 | Struct ResSmearAAOStruct &s |
---|
460 | |
---|
461 | // the name of your unsmeared model (AAO) is the first argument |
---|
462 | s.yW = Smear_Model_20(ThreeLevel,s.coefW,s.xW,s.resW) |
---|
463 | |
---|
464 | return(0) |
---|
465 | End |
---|
466 | |
---|
467 | Function SmearedFourLevel(s) :FitFunc |
---|
468 | Struct ResSmearAAOStruct &s |
---|
469 | |
---|
470 | // the name of your unsmeared model (AAO) is the first argument |
---|
471 | s.yW = Smear_Model_20(FourLevel,s.coefW,s.xW,s.resW) |
---|
472 | |
---|
473 | return(0) |
---|
474 | End |
---|
475 | |
---|
476 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
477 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
478 | // |
---|
479 | // used only for the dependency, not for fitting |
---|
480 | // |
---|
481 | Function fSmearedOneLevel(coefW,yW,xW) |
---|
482 | Wave coefW,yW,xW |
---|
483 | |
---|
484 | String str = getWavesDataFolder(yW,0) |
---|
485 | String DF="root:"+str+":" |
---|
486 | |
---|
487 | WAVE resW = $(DF+str+"_res") |
---|
488 | |
---|
489 | STRUCT ResSmearAAOStruct fs |
---|
490 | WAVE fs.coefW = coefW |
---|
491 | WAVE fs.yW = yW |
---|
492 | WAVE fs.xW = xW |
---|
493 | WAVE fs.resW = resW |
---|
494 | |
---|
495 | Variable err |
---|
496 | err = SmearedOneLevel(fs) |
---|
497 | |
---|
498 | return (0) |
---|
499 | End |
---|
500 | |
---|
501 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
502 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
503 | // |
---|
504 | // used only for the dependency, not for fitting |
---|
505 | // |
---|
506 | Function fSmearedTwoLevel(coefW,yW,xW) |
---|
507 | Wave coefW,yW,xW |
---|
508 | |
---|
509 | String str = getWavesDataFolder(yW,0) |
---|
510 | String DF="root:"+str+":" |
---|
511 | |
---|
512 | WAVE resW = $(DF+str+"_res") |
---|
513 | |
---|
514 | STRUCT ResSmearAAOStruct fs |
---|
515 | WAVE fs.coefW = coefW |
---|
516 | WAVE fs.yW = yW |
---|
517 | WAVE fs.xW = xW |
---|
518 | WAVE fs.resW = resW |
---|
519 | |
---|
520 | Variable err |
---|
521 | err = SmearedTwoLevel(fs) |
---|
522 | |
---|
523 | return (0) |
---|
524 | End |
---|
525 | |
---|
526 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
527 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
528 | // |
---|
529 | // used only for the dependency, not for fitting |
---|
530 | // |
---|
531 | Function fSmearedThreeLevel(coefW,yW,xW) |
---|
532 | Wave coefW,yW,xW |
---|
533 | |
---|
534 | String str = getWavesDataFolder(yW,0) |
---|
535 | String DF="root:"+str+":" |
---|
536 | |
---|
537 | WAVE resW = $(DF+str+"_res") |
---|
538 | |
---|
539 | STRUCT ResSmearAAOStruct fs |
---|
540 | WAVE fs.coefW = coefW |
---|
541 | WAVE fs.yW = yW |
---|
542 | WAVE fs.xW = xW |
---|
543 | WAVE fs.resW = resW |
---|
544 | |
---|
545 | Variable err |
---|
546 | err = SmearedThreeLevel(fs) |
---|
547 | |
---|
548 | return (0) |
---|
549 | End |
---|
550 | |
---|
551 | //wrapper to calculate the smeared model as an AAO-Struct |
---|
552 | // fills the struct and calls the ususal function with the STRUCT parameter |
---|
553 | // |
---|
554 | // used only for the dependency, not for fitting |
---|
555 | // |
---|
556 | Function fSmearedFourLevel(coefW,yW,xW) |
---|
557 | Wave coefW,yW,xW |
---|
558 | |
---|
559 | String str = getWavesDataFolder(yW,0) |
---|
560 | String DF="root:"+str+":" |
---|
561 | |
---|
562 | WAVE resW = $(DF+str+"_res") |
---|
563 | |
---|
564 | STRUCT ResSmearAAOStruct fs |
---|
565 | WAVE fs.coefW = coefW |
---|
566 | WAVE fs.yW = yW |
---|
567 | WAVE fs.xW = xW |
---|
568 | WAVE fs.resW = resW |
---|
569 | |
---|
570 | Variable err |
---|
571 | err = SmearedFourLevel(fs) |
---|
572 | |
---|
573 | return (0) |
---|
574 | End |
---|