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