1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | //////////////////////////////////////////////////// |
---|
3 | // J. Barker, 2-10-99 |
---|
4 | ////////////////////////////////// |
---|
5 | Proc PlotPower_Law(num,qmin,qmax) |
---|
6 | Variable num=512, qmin=.001, qmax=.2 |
---|
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_Power_Law, ywave_Power_Law |
---|
12 | xwave_Power_Law = alog(log(qmin) + x*((log(qmax)-log(qmin))/num)) |
---|
13 | Make/O/D coef_Power_Law = {1e-6, 4.0, 1.0} |
---|
14 | make/o/t parameters_Power_Law = {"Coefficient, A ", "(-)Power","Incoherent Bgd (cm-1)"} |
---|
15 | Edit parameters_Power_Law, coef_Power_Law |
---|
16 | ywave_Power_Law := Power_Law_Model(coef_Power_Law, xwave_Power_Law) |
---|
17 | Display ywave_Power_Law vs xwave_Power_Law |
---|
18 | ModifyGraph marker=29, msize=2, mode=4 |
---|
19 | ModifyGraph log(left)=1 |
---|
20 | ModifyGraph log(bottom)=1 |
---|
21 | Label bottom "q (\\S-1\\M) " |
---|
22 | Label left "Power-Law (cm\\S-1\\M)" |
---|
23 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
24 | // |
---|
25 | End |
---|
26 | //////////////////////////////////////////////////// |
---|
27 | Proc PlotSmearedPower_Law() // Power-Law |
---|
28 | //no input parameters necessary, it MUST use the experimental q-values |
---|
29 | // from the experimental data read in from an AVE/QSIG data file |
---|
30 | |
---|
31 | // if no gQvals wave, data must not have been loaded => abort |
---|
32 | if(ResolutionWavesMissing()) |
---|
33 | Abort |
---|
34 | endif |
---|
35 | |
---|
36 | // Setup parameter table for model function |
---|
37 | Make/O/D smear_coef_Power_Law = {1e-6, 4.0, 1.0} |
---|
38 | make/o/t smear_parameters_Power_Law = {"Coefficient, A ", "(-)Power","Incoherent Bgd (cm-1)"} |
---|
39 | Edit smear_parameters_Power_Law,smear_coef_Power_Law //display parameters in a table |
---|
40 | |
---|
41 | // output smeared intensity wave, dimensions are identical to experimental QSIG values |
---|
42 | // make extra copy of experimental q-values for easy plotting |
---|
43 | Duplicate/O $gQvals smeared_Power_Law,smeared_qvals // |
---|
44 | SetScale d,0,0,"1/cm",smeared_Power_Law // |
---|
45 | |
---|
46 | smeared_Power_Law := SmearedPower_Law_Model(smear_coef_Power_Law,$gQvals) // SMEARED function name |
---|
47 | Display smeared_Power_Law vs smeared_qvals // |
---|
48 | ModifyGraph log=1,marker=29,msize=2,mode=4 |
---|
49 | Label bottom "q (\\S-1\\M)" |
---|
50 | Label left "Power_Law (cm\\S-1\\M)" |
---|
51 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
52 | End // end macro PlotSmearedPower_Law |
---|
53 | |
---|
54 | Function Power_Law_model(w,x) : FitFunc |
---|
55 | Wave w |
---|
56 | Variable x |
---|
57 | // Input (fitting) variables are: |
---|
58 | //[0] Coefficient |
---|
59 | //[1] (-) Power |
---|
60 | //[2] incoherent background |
---|
61 | // give them nice names |
---|
62 | Variable A, m,bgd |
---|
63 | A = w[0] |
---|
64 | m = w[1] |
---|
65 | bgd = w[2] |
---|
66 | |
---|
67 | // local variables |
---|
68 | Variable inten, qval |
---|
69 | // x is the q-value for the calculation |
---|
70 | qval = x |
---|
71 | // do the calculation and return the function value |
---|
72 | |
---|
73 | inten = A*qval^-m + bgd |
---|
74 | Return (inten) |
---|
75 | End |
---|
76 | ///////////////////////////////////////////////////////////////////////////////// |
---|
77 | |
---|
78 | |
---|
79 | // this is all there is to the smeared calculation! |
---|
80 | Function SmearedPower_Law_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(Power_Law_model,$sq,$qb,$sh,$gQ,w,x) |
---|
92 | |
---|
93 | return(ans) |
---|
94 | End |
---|