1
- Purpose
2
- ----------
1
+ ## Purpose
3
2
4
3
These example scripts are intended to help a developer get acquainted with the
5
4
SrFit programming interface. Although one can write scripts like these to drive
6
5
optimization, these scripts do not represent the SrFit user interface. That
7
6
interface will be made available in a future release.
8
7
9
- A secondary purpose of these tutorials is to generate interest in SrFit. By
8
+ A secondary purpose of these tutorials is to generate interest in SrFit. By
10
9
reading through the examples we hope that you are inspired to think of exciting
11
10
new ways to get the most out of your scientific data. If you think SrFit can
12
11
help you with that, please feel free to contact us through the DiffPy website.
13
12
14
13
http://www.diffpy.org
15
14
16
-
17
- Overview
18
- ----------
15
+ ## Overview
19
16
20
17
Three things are required for optimization: a function that generates a
21
18
quantity to be minimized, variables that can be used to manipulate that
22
19
function and an algorithm that can drive the function output to a smaller value
23
- by steering the variables. For scientific purposes, the quantity to be
20
+ by steering the variables. For scientific purposes, the quantity to be
24
21
minimized is the disagreement between a measured profile and a theoretical
25
22
profile. The scientific understanding of the system under consideration partly
26
23
determines the suitability of the theoretical profile generator and the
@@ -30,38 +27,36 @@ The purpose of SrFit is to give users the means to combine known information
30
27
about a system of interest in order to extract scientifically relevant
31
28
quantities, and thus understanding from it. Various experimental procedures and
32
29
theoretical calculations may be needed to gain the desired understanding of the
33
- system. SrFit helps users combine these views of the system in a coherent and
30
+ system. SrFit helps users combine these views of the system in a coherent and
34
31
consistent manner.
35
32
36
33
To achieve this purpose, SrFit provides:
37
34
38
- 1) a function to be optimized (the residual) given one or more measured
35
+ 1. a function to be optimized (the residual) given one or more measured
39
36
profiles, one or more profile generators and variables to be steered by an
40
37
optimizer.
41
- 2) constraints and restraints that encapsulate known information about the
38
+ 2. constraints and restraints that encapsulate known information about the
42
39
system.
43
- 3) a clearly defined programming interface that developers can use to add their
40
+ 3. a clearly defined programming interface that developers can use to add their
44
41
own profile generators, thereby enabling the combination of more views of a
45
42
system.
46
- 4) an equation building interface that allows users to tweak profile generators
43
+ 4. an equation building interface that allows users to tweak profile generators
47
44
when scientific understanding of a system is more advanced than the existing
48
45
software.
49
46
50
47
The examples described below will go into detail about each of these points.
51
48
49
+ ## Examples
52
50
53
- Examples
54
- ----------
55
-
56
- The following examples are contained in the *doc/examples/* directory of the
57
- SrFit source distribution. They can be downloaded from
51
+ The following examples are contained in the _doc/examples/_ directory of the
52
+ SrFit source distribution. They can be downloaded from
58
53
http://dev.danse.us/packages/srfit_examples-alpha9.zip
59
54
60
55
For each example, start by running the example by typing in the command line ::
61
56
62
57
python example.py
63
58
64
- where *example.py* represents the example file. The output will show on screen
59
+ where _example.py_ represents the example file. The output will show on screen
65
60
and a plot window will display. Once you've studied the output and plot, close
66
61
the plot window and open the example file. In the file there will be a
67
62
description of what the script is doing and the purpose of the example. By
@@ -73,97 +68,94 @@ them in the order listed below.
73
68
74
69
Basic:
75
70
76
- * gaussianrecipe.py_
77
- Introductory recipe building and configuration. This introduces the
78
- fundamental classes in SrFit.
71
+ - gaussianrecipe.py\_
72
+ Introductory recipe building and configuration. This introduces the
73
+ fundamental classes in SrFit.
79
74
80
- * debyemodel.py_
81
- Introductory recipe building and configuration. This shows how to use a
82
- function created by someone else in a refinement. This example also
83
- introduces restraints.
75
+ - debyemodel.py\_
76
+ Introductory recipe building and configuration. This shows how to use a
77
+ function created by someone else in a refinement. This example also
78
+ introduces restraints.
84
79
85
- * debyemodelII.py_
86
- Refine two different values of a variable from two different regions of a
87
- profile. This example introduces constraints and working with multiple
88
- contributions to a fit.
80
+ - debyemodelII.py\_
81
+ Refine two different values of a variable from two different regions of a
82
+ profile. This example introduces constraints and working with multiple
83
+ contributions to a fit.
89
84
90
85
Advanced:
91
86
92
- * gaussiangenerator.py_
93
- Create a custom ProfileGenerator and use it in a refinement. This is an
94
- instructive extension to gaussianrecipe.py_.
95
-
96
- * npintensity.py_
97
- Use diffpy.structure to build a nanoparticle intensity generator, and use
98
- it to refine a structure to simulated data.
87
+ - gaussiangenerator.py*
88
+ Create a custom ProfileGenerator and use it in a refinement. This is an
89
+ instructive extension to gaussianrecipe.py*.
99
90
100
- * npintensityII.py_
101
- Use the calculator built in npintensity.py to simultaneously refine a
102
- structure to two data sets .
91
+ - npintensity.py\_
92
+ Use diffpy.structure to build a nanoparticle intensity generator, and use
93
+ it to refine a structure to simulated data.
103
94
95
+ - npintensityII.py\_
96
+ Use the calculator built in npintensity.py to simultaneously refine a
97
+ structure to two data sets.
104
98
105
- Use Cases
106
- -----------
99
+ ## Use Cases
107
100
108
101
There are several examples that demonstrate various SrFit use cases. These do
109
102
not adopt the tutorial format of the previous examples. Regardless, developers
110
103
should read through these use cases to gain an understanding of PDF and SAS
111
104
refinement with SrFit.
112
105
113
- * crystalpdf.py_
114
- Refine a diffpy.structure crystal to PDF data using automatic explicit
115
- space group constraints.
106
+ - crystalpdf.py\_
107
+ Refine a diffpy.structure crystal to PDF data using automatic explicit
108
+ space group constraints.
116
109
117
- * simplepdf.py_
118
- As crystalpdf.py_ , but with a simplified interface.
110
+ - simplepdf.py*
111
+ As crystalpdf.py* , but with a simplified interface.
119
112
120
- * crystalpdfobjcryst.py_
121
- Refine a pyobjcryst crystal to PDF data using automatic implicit space
122
- group constraints.
113
+ - crystalpdfobjcryst.py\_
114
+ Refine a pyobjcryst crystal to PDF data using automatic implicit space
115
+ group constraints.
123
116
124
- * crystalpdftwophase.py_
125
- Refine a two-phase structure to PDF data using two profile generators.
117
+ - crystalpdftwophase.py\_
118
+ Refine a two-phase structure to PDF data using two profile generators.
126
119
127
- * simplepdftwophase.py_
128
- crystalpdftwophase.py_ using the simplified PDFContribution interface.
120
+ - simplepdftwophase.py*
121
+ crystalpdftwophase.py* using the simplified PDFContribution interface.
129
122
130
- * crystalpdftwodata.py_
131
- Refine a single structure to x-ray and neutron data simultaneously.
123
+ - crystalpdftwodata.py\_
124
+ Refine a single structure to x-ray and neutron data simultaneously.
132
125
133
- * crystalpdfall.py_
134
- Refine a two-phase structure using four data sets.
126
+ - crystalpdfall.py\_
127
+ Refine a two-phase structure using four data sets.
135
128
136
- * nppdfobjcryst.py_
137
- Refine the C60 structure to real data.
129
+ - nppdfobjcryst.py\_
130
+ Refine the C60 structure to real data.
138
131
139
- * nppdfcrystal.py_
140
- Fit a nanoparticle PDF as a crystal PDF attenuated by a nanoparticle form
141
- factor.
132
+ - nppdfcrystal.py\_
133
+ Fit a nanoparticle PDF as a crystal PDF attenuated by a nanoparticle form
134
+ factor.
142
135
143
- * coreshellnp.py_
144
- As above, but fit the PDF from core-shell nanoparticles.
136
+ - coreshellnp.py\_
137
+ As above, but fit the PDF from core-shell nanoparticles.
145
138
146
- * ellipsoidsas.py_
147
- Refine an ellipsoid SAS model to ideal data.
139
+ - ellipsoidsas.py\_
140
+ Refine an ellipsoid SAS model to ideal data.
148
141
149
- * nppdfsas.py_
150
- Refine PDF from nanoparticle of assumed shape using a crystal model and SAS
151
- data from the same system.
142
+ - nppdfsas.py\_
143
+ Refine PDF from nanoparticle of assumed shape using a crystal model and SAS
144
+ data from the same system.
152
145
153
- Miscellaneous
154
- --------------
146
+ ## Miscellaneous
155
147
156
148
These demonstrate other SrFit features. These are in flux and may not be in
157
149
future versions.
158
150
159
- * simplerecipe.py_
160
- This introduces the SimpleRecipe class that is a FitRecipe with an embedded
161
- Profile and FitContribution. SimpleRecipe exposes methods from the Profile
162
- and FitContribution, and adds other methods so it is easy to set up a
163
- simple fit.
164
-
165
- * interface.py_
166
- This example introduces some interface enhancements that allow the SrFit
167
- recipes to be written with less code. This is not the same as a
168
- full-featured scripting interface, but rather somewhere in between a
169
- scripting interface and the API.
151
+ - simplerecipe.py\_
152
+ This introduces the SimpleRecipe class that is a FitRecipe with an embedded
153
+ Profile and FitContribution. SimpleRecipe exposes methods from the Profile
154
+ and FitContribution, and adds other methods so it is easy to set up a
155
+ simple fit.
156
+
157
+ - interface.py\_
158
+ This example introduces some interface enhancements that allow the SrFit
159
+ recipes to be written with less code. This is not the same as a
160
+ full-featured scripting interface, but rather somewhere in between a
161
+ scripting interface and the API.
0 commit comments