1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | //////////////////////////////////////////////////// |
---|
3 | // J. Barker, 2-10-99 |
---|
4 | //////////////////////////////////// |
---|
5 | Proc PlotPeak_Lorentz(num,qmin,qmax) |
---|
6 | Variable num=512, qmin=.001, qmax=.7 |
---|
7 | Prompt num "Enter number of data points for model: " |
---|
8 | Prompt qmin "Enter minimum q-value (^1) for model: " |
---|
9 | Prompt qmax "Enter maximum q-value (^1) for model: " |
---|
10 | // |
---|
11 | Make/O/D/n=(num) xwave_Peak_Lorentz, ywave_Peak_Lorentz |
---|
12 | xwave_Peak_Lorentz = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
13 | Make/O/D coef_Peak_Lorentz = {100.0, 0.05,0.005, 1.0} |
---|
14 | make/o/t parameters_Peak_Lorentz = {"Scale Factor, I0 ", "Peak position (^-1)", "Peak hwhm (^-1)","Incoherent Bgd (cm-1)"} |
---|
15 | Edit parameters_Peak_Lorentz, coef_Peak_Lorentz |
---|
16 | ywave_Peak_Lorentz := Peak_Lorentz_Model(coef_Peak_Lorentz, xwave_Peak_Lorentz) |
---|
17 | Display ywave_Peak_Lorentz vs xwave_Peak_Lorentz |
---|
18 | ModifyGraph marker=29, msize=2, mode=4 |
---|
19 | ModifyGraph log(left)=1 |
---|
20 | Label bottom "q (\\S-1\\M) " |
---|
21 | Label left "Peak - Lorentzian (cm\\S-1\\M)" |
---|
22 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
23 | // |
---|
24 | End |
---|
25 | //////////////////////////////////////////////////// |
---|
26 | Proc PlotSmearedPeak_Lorentz() //Peak_Lorentz |
---|
27 | //no input parameters necessary, it MUST use the experimental q-values |
---|
28 | // from the experimental data read in from an AVE/QSIG data file |
---|
29 | |
---|
30 | // if no gQvals wave, data must not have been loaded => abort |
---|
31 | if(ResolutionWavesMissing()) |
---|
32 | Abort |
---|
33 | endif |
---|
34 | |
---|
35 | // Setup parameter table for model function |
---|
36 | Make/O/D smear_coef_Peak_Lorentz = {100.0, 0.05,0.005, 1.0} |
---|
37 | make/o/t smear_parameters_Peak_Lorentz = {"Scale Factor, I0 ", "Peak position (^-1)", "Peak hwhm (^-1)","Incoherent Bgd (cm-1)"} |
---|
38 | Edit smear_parameters_Peak_Lorentz,smear_coef_Peak_Lorentz //display parameters in a table |
---|
39 | |
---|
40 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
41 | // make extra copy of experimental q-values for easy plotting |
---|
42 | Duplicate/O $gQvals smeared_Peak_Lorentz,smeared_qvals // |
---|
43 | SetScale d,0,0,"1/cm",smeared_Peak_Lorentz // |
---|
44 | |
---|
45 | smeared_Peak_Lorentz := SmearedPeak_Lorentz_Model(smear_coef_Peak_Lorentz,$gQvals) // SMEARED function name |
---|
46 | Display smeared_Peak_Lorentz vs smeared_qvals // |
---|
47 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
48 | Label bottom "q (\\S-1\\M)" |
---|
49 | Label left "Peak_Lorentz Model (cm\\S-1\\M)" |
---|
50 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
51 | |
---|
52 | End // end macro PlotSmearedPeak_Lorentz |
---|
53 | |
---|
54 | Function Peak_Lorentz_model(w,x) : FitFunc |
---|
55 | Wave w |
---|
56 | Variable x |
---|
57 | // Input (fitting) variables are: |
---|
58 | //[0] scale factor |
---|
59 | //[1] peak position |
---|
60 | //[2] peak hwhm |
---|
61 | //[3] incoherent background |
---|
62 | // give them nice names |
---|
63 | Variable I0, qpk, dq,bgd |
---|
64 | I0 = w[0] |
---|
65 | qpk = w[1] |
---|
66 | dq = w[2] |
---|
67 | bgd = w[3] |
---|
68 | |
---|
69 | // local variables |
---|
70 | Variable inten, qval |
---|
71 | // x is the q-value for the calculation |
---|
72 | qval = x |
---|
73 | // do the calculation and return the function value |
---|
74 | |
---|
75 | inten = I0/(1 + ((qval-qpk)/dq)^2) + bgd |
---|
76 | Return (inten) |
---|
77 | End |
---|
78 | ///////////////////////////////////////////////////////////////////////////////// |
---|
79 | |
---|
80 | // this is all there is to the smeared calculation! |
---|
81 | Function SmearedPeak_Lorentz_Model(w,x) :FitFunc |
---|
82 | Wave w |
---|
83 | Variable x |
---|
84 | |
---|
85 | Variable ans |
---|
86 | SVAR sq = gSig_Q |
---|
87 | SVAR qb = gQ_bar |
---|
88 | SVAR sh = gShadow |
---|
89 | SVAR gQ = gQVals |
---|
90 | |
---|
91 | //the name of your unsmeared model is the first argument |
---|
92 | ans = Smear_Model_20(Peak_Lorentz_model,$sq,$qb,$sh,$gQ,w,x) |
---|
93 | |
---|
94 | return(ans) |
---|
95 | End |
---|