1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | //////////////////////////////////////////////////// |
---|
3 | // J. Barker, 2-10-99 |
---|
4 | ////////////////// |
---|
5 | Proc PlotPeak_Gauss(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_Gauss, ywave_Peak_Gauss |
---|
12 | xwave_Peak_Gauss = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
13 | Make/O/D coef_Peak_Gauss = {100.0, 0.05,0.005, 1.0} |
---|
14 | make/o/t parameters_Peak_Gauss = {"Scale Factor, I0 ", "Peak position (^-1)", "Std Dev (^-1)","Incoherent Bgd (cm-1)"} |
---|
15 | Edit parameters_Peak_Gauss, coef_Peak_Gauss |
---|
16 | ywave_Peak_Gauss := Peak_Gauss_Model(coef_Peak_Gauss, xwave_Peak_Gauss) |
---|
17 | Display ywave_Peak_Gauss vs xwave_Peak_Gauss |
---|
18 | ModifyGraph marker=29, msize=2, mode=4 |
---|
19 | ModifyGraph log(left)=1 |
---|
20 | Label bottom "q (\\S-1\\M) " |
---|
21 | Label left "Peak - Gauss (cm\\S-1\\M)" |
---|
22 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
23 | // |
---|
24 | End |
---|
25 | //////////////////////////////////////////////////// |
---|
26 | Proc PlotSmearedPeak_Gauss() //Peak_Gauss |
---|
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_Gauss = {100.0, 0.05,0.005, 1.0} |
---|
37 | make/o/t smear_parameters_Peak_Gauss = {"Scale Factor, I0 ", "Peak position (^-1)", "Std Dev (^-1)","Incoherent Bgd (cm-1)"} |
---|
38 | Edit smear_parameters_Peak_Gauss,smear_coef_Peak_Gauss //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_Gauss,smeared_qvals // |
---|
43 | SetScale d,0,0,"1/cm",smeared_Peak_Gauss // |
---|
44 | |
---|
45 | smeared_Peak_Gauss := SmearedPeak_Gauss_Model(smear_coef_Peak_Gauss,$gQvals) // SMEARED function name |
---|
46 | Display smeared_Peak_Gauss vs smeared_qvals // |
---|
47 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
48 | Label bottom "q (\\S-1\\M)" |
---|
49 | Label left "Peak_Gauss Model (cm\\S-1\\M)" |
---|
50 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
51 | End // end macro PlotSmearedPeak_Gauss |
---|
52 | |
---|
53 | Function Peak_Gauss_model(w,x) : FitFunc |
---|
54 | Wave w |
---|
55 | Variable x |
---|
56 | // Input (fitting) variables are: |
---|
57 | //[0] scale factor |
---|
58 | //[1] peak position |
---|
59 | //[2] Std Dev |
---|
60 | //[3] incoherent background |
---|
61 | // give them nice names |
---|
62 | Variable I0, qpk, dq,bgd |
---|
63 | I0 = w[0] |
---|
64 | qpk = w[1] |
---|
65 | dq = w[2] |
---|
66 | bgd = w[3] |
---|
67 | |
---|
68 | // local variables |
---|
69 | Variable inten, qval |
---|
70 | // x is the q-value for the calculation |
---|
71 | qval = x |
---|
72 | // do the calculation and return the function value |
---|
73 | |
---|
74 | inten = I0*exp(-0.5*((qval-qpk)/dq)^2)+ bgd |
---|
75 | Return (inten) |
---|
76 | End |
---|
77 | ///////////////////////////////////////////////////////////////////////////////// |
---|
78 | |
---|
79 | // this is all there is to the smeared calculation! |
---|
80 | Function SmearedPeak_Gauss_Model(w,x) :FitFunc |
---|
81 | Wave w |
---|
82 | Variable x |
---|
83 | |
---|
84 | Variable ans |
---|
85 | SVAR sq = gSig_Q |
---|
86 | SVAR qb = gQ_bar |
---|
87 | SVAR sh = gShadow |
---|
88 | SVAR gQ = gQVals |
---|
89 | |
---|
90 | //the name of your unsmeared model is the first argument |
---|
91 | ans = Smear_Model_20(Peak_Gauss_model,$sq,$qb,$sh,$gQ,w,x) |
---|
92 | |
---|
93 | return(ans) |
---|
94 | End |
---|