1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma IgorVersion=6.0 |
---|
3 | |
---|
4 | // "simple" version of 2D function |
---|
5 | // |
---|
6 | // The plotting macro sets up TWO dependencies |
---|
7 | // - one for the triplet calculation |
---|
8 | // - one for a matrix to display, a copy of the triplet |
---|
9 | // |
---|
10 | // For display, there are two copies of the matrix. One matrix is linear, and is a copy of the |
---|
11 | // triplet (which is ALWAYS linear). The other matrix is toggled log/lin for display |
---|
12 | // in the same way the 2D SANS data matrix is handled. |
---|
13 | // |
---|
14 | // Nothing is threaded at this point, although I think it needs to be since upon |
---|
15 | // reading of the WM documentation, it looks like only "basic" fit functions (meaning |
---|
16 | // NOT AAO or Struct functions) are automatically threaded during curve fitting. |
---|
17 | // |
---|
18 | // |
---|
19 | |
---|
20 | //Cylinder_2D_Dist() |
---|
21 | |
---|
22 | // this is what Cylinder_2D_Dist() from our XOP is expecting |
---|
23 | //double dist_cylinder_2D(double pars[], double q, double phi) { |
---|
24 | // SmearCylinderParameters danse_pars; |
---|
25 | // danse_pars.scale = pars[0]; |
---|
26 | // danse_pars.radius = pars[1]; |
---|
27 | // danse_pars.length = pars[2]; |
---|
28 | // danse_pars.contrast = pars[3]; |
---|
29 | // danse_pars.background = pars[4]; |
---|
30 | // danse_pars.cyl_theta = pars[5]; |
---|
31 | // danse_pars.cyl_phi = pars[6]; |
---|
32 | // danse_pars.sigma_theta = pars[7]; |
---|
33 | // danse_pars.sigma_phi = pars[8]; |
---|
34 | // danse_pars.sigma_radius = pars[9]; |
---|
35 | // |
---|
36 | // return smeared_cylinder_analytical_2D(&danse_pars, q, phi); |
---|
37 | // |
---|
38 | //}; |
---|
39 | |
---|
40 | // |
---|
41 | // the calculation is done as for the QxQy data set: |
---|
42 | // three waves XYZ, then converted to a matrix |
---|
43 | // |
---|
44 | Proc PlotCylinder2D(str) |
---|
45 | String str |
---|
46 | Prompt str,"Pick the data folder containing the 2D data",popup,getAList(4) |
---|
47 | |
---|
48 | // if any of the resolution waves are missing => abort |
---|
49 | // if(ResolutionWavesMissingDF(str)) //updated to NOT use global strings (in GaussUtils) |
---|
50 | // Abort |
---|
51 | // endif |
---|
52 | |
---|
53 | SetDataFolder $("root:"+str) |
---|
54 | |
---|
55 | // Setup parameter table for model function |
---|
56 | make/O/T/N=10 parameters_Cyl2D |
---|
57 | Make/O/D/N=10 coef_Cyl2D |
---|
58 | coef_Cyl2D[0] = 1.0 |
---|
59 | coef_Cyl2D[1] = 20.0 |
---|
60 | coef_Cyl2D[2] = 60.0 |
---|
61 | coef_Cyl2D[3] = 6.0e-6 |
---|
62 | coef_Cyl2D[4] = 0.0 |
---|
63 | coef_Cyl2D[5] = 1.57 |
---|
64 | coef_Cyl2D[6] = 0.0 |
---|
65 | coef_Cyl2D[7] = 0.0 |
---|
66 | coef_Cyl2D[8] = 0.0 |
---|
67 | coef_Cyl2D[9] = 0.0 |
---|
68 | //NOT THE SAME ORDER AS MATHIEU'S CODE |
---|
69 | parameters_Cyl2D[0] = "Scale" |
---|
70 | parameters_Cyl2D[1] = "Radius" |
---|
71 | parameters_Cyl2D[2] = "Length" |
---|
72 | parameters_Cyl2D[3] = "Contrast" |
---|
73 | parameters_Cyl2D[4] = "Background" |
---|
74 | parameters_Cyl2D[5] = "Axis Theta" |
---|
75 | parameters_Cyl2D[6] = "Axis Phi" |
---|
76 | parameters_Cyl2D[7] = "Sigma of polydisp in Theta [rad]" |
---|
77 | parameters_Cyl2D[8] = "Sigma of polydisp in Phi [rad]" |
---|
78 | parameters_Cyl2D[9] = "Sigma of polydisp in Radius [Angstroem]" |
---|
79 | |
---|
80 | Edit parameters_Cyl2D,coef_Cyl2D |
---|
81 | |
---|
82 | // generate the triplet representation |
---|
83 | Duplicate/O $(str+"_qx") xwave_Cyl2D |
---|
84 | Duplicate/O $(str+"_qy") ywave_Cyl2D,zwave_Cyl2D |
---|
85 | |
---|
86 | Variable/G gs_Cyl2D=0 |
---|
87 | gs_Cyl2D := Cylinder2D(coef_Cyl2D,zwave_Cyl2D,ywave_Cyl2D,xwave_Cyl2D) //AAO 2D calculation |
---|
88 | |
---|
89 | Display ywave_Cyl2D vs xwave_Cyl2D |
---|
90 | modifygraph log=0 |
---|
91 | ModifyGraph mode=3,marker=16,zColor(ywave_Cyl2D)={zwave_Cyl2D,*,*,YellowHot,0} |
---|
92 | ModifyGraph standoff=0 |
---|
93 | ModifyGraph width={Aspect,1} |
---|
94 | ModifyGraph lowTrip=0.001 |
---|
95 | Label bottom "q (\\S-1\\M)" |
---|
96 | Label left "q (\\S-1\\M)" |
---|
97 | AutoPositionWindow/M=1/R=$(WinName(0,1)) $WinName(0,2) |
---|
98 | |
---|
99 | // generate the matrix representation |
---|
100 | ConvertQxQy2Mat(xwave_Cyl2D,ywave_Cyl2D,zwave_Cyl2D,"Cyl2D_mat") |
---|
101 | Duplicate/O $"Cyl2D_mat",$"Cyl2D_lin" //keep a linear-scaled version of the data |
---|
102 | // _mat is for display, _lin is the real calculation |
---|
103 | |
---|
104 | Variable/G gs_Cyl2Dmat=0 |
---|
105 | gs_Cyl2Dmat := UpdateQxQy2Mat(xwave_Cyl2D,ywave_Cyl2D,zwave_Cyl2D,Cyl2D_lin,Cyl2D_mat) |
---|
106 | |
---|
107 | |
---|
108 | SetDataFolder root: |
---|
109 | AddModelToStrings("Cylinder2D","coef_Cyl2D","Cyl2D") |
---|
110 | End |
---|
111 | |
---|
112 | |
---|
113 | //AAO version, uses XOP if available |
---|
114 | // simply calls the original single point calculation with |
---|
115 | // a wave assignment (this will behave nicely if given point ranges) |
---|
116 | Function Cylinder2D(cw,zw,yw,xw) : FitFunc |
---|
117 | Wave cw,zw,yw,xw |
---|
118 | |
---|
119 | #if exists("Cylinder_2D_Dist") |
---|
120 | zw = Cylinder_2D_Dist(cw,yw,xw) |
---|
121 | #else |
---|
122 | Abort "You do not have the SANS Analysis XOP installed" |
---|
123 | #endif |
---|
124 | return(0) |
---|
125 | End |
---|