Skip to content

Commit f5fc9ac

Browse files
authored
Fix examples (#265)
* Fix examples * bump
1 parent c0588b4 commit f5fc9ac

File tree

6 files changed

+52
-27
lines changed

6 files changed

+52
-27
lines changed

docs/source/funcxy.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ scaling factor ``bgscale``.
2929
We will showcase an example of how one would refine over the
3030
``PDFGetter`` parameters using ``funcxy`` to obtain a PDF.
3131

32-
Let's say you have a measured I(Q) with Q in angstroms of a lead
33-
nanoparticle (composition PbS) named ``sample.chi`` taken on a
34-
glass background. We want to match a target calculated PDF G(r)
32+
Let's say you have a measured I(Q) with Q in angstroms of
33+
glass (composition SiO2) named ``sample.chi`` taken on a
34+
kapton background. We want to match a target calculated PDF G(r)
3535
stored in a file named ``target.cgr``.
3636
Let's also say we have a measured I(Q) of the
37-
glass background ``background.chi``.
37+
kapton background ``background.chi``.
3838

3939
.. code-block:: python
4040
@@ -44,8 +44,8 @@ glass background ``background.chi``.
4444
4545
pg = PDFGetter()
4646
47-
backgroundfile = loadData("background.chi")
48-
composition = "PbS"
47+
backgroundfile = "background.chi"
48+
composition = "SiO2"
4949
5050
5151
def wrap(x, y, **kwargs):
@@ -150,7 +150,7 @@ our wavelength was ``1.11`` angstroms.
150150
centerY=cent_y+cent_offset_y
151151
)
152152
153-
return ai.integrate1D_ng(
153+
return ai.integrate1d_ng(
154154
pattern_2d,
155155
npt=1000, unit="q_A^-1",
156156
method="mean"

docs/source/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ plotted below.
3434

3535
There are also a few other morphing transformations in the program.
3636
If no morphing transformation is specified, ``diffpy.morph`` will return just
37-
the plotted PDFs.
37+
the plotted functions.
3838

3939
Finally, we note that though ``diffpy.morph`` should work on other spectra
40-
that are not PDFs, it has not been extensively tested beyond the PDF.
40+
that are not from diffraction, it has not been extensively tested beyond 1D
41+
diffraction patterns and PDFs.
4142

4243
To get started, please visit the `quickstart tutorial <quickstart.html>`__.
4344
For those looking to see more advanced features, you can read our

docs/source/morphpy.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Python Morphing Functions
2222
morph on the files `darkSub_rh20_C_01.gr` and `darkSub_rh20_C_44.gr` using the command-line
2323
command ::
2424

25-
diffpy.morph --scale=0.8 --smear=-0.08 --stretch=0.005 --rmin=1.5 --rmax=30 darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
25+
diffpy.morph --scale=0.8 --smear=-0.08 --stretch=0.005 --xmin=1.5 --xmax=30 darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
2626

2727
2. To do the same on Python, we must first create a new Python script in the same directory as the
2828
data files `darkSub_rh20_C_01.gr` and `darkSub_rh20_C_44.gr`.
@@ -32,7 +32,7 @@ Python Morphing Functions
3232

3333
3. Finally, we run the ``morph`` function ::
3434

35-
morph_info, morph_table = morph("darkSub_rh20_C_01.gr", "darkSub_rh20_C_44.gr", scale=0.8, smear=-0.08, stretch=0.005, rmin=1.5, rmax=30)
35+
morph_info, morph_table = morph("darkSub_rh20_C_01.gr", "darkSub_rh20_C_44.gr", scale=0.8, smear_pdf=-0.08, stretch=0.005, xmin=1.5, xmax=30)
3636

3737
* The ``morph`` function takes in two file names (or paths). You can also provide various parameters
3838
for morphing (see the Full Parameter List below).
@@ -62,7 +62,7 @@ Python Morphing Functions
6262
`darkSub_rh20_C_44.gr` into ``ds_rh20_c_44_array``, we can apply the same morph as step 3
6363
by running ::
6464

65-
morph_info, morph_table = morph_arrays(ds_rh20_c_01_array, ds_rh20_c_44_array, scale=0.8, smear=-0.08, stretch=0.5, rmin=1.5, rmax=30)
65+
morph_info, morph_table = morph_arrays(ds_rh20_c_01_array, ds_rh20_c_44_array, scale=0.8, smear_pdf=-0.08, stretch=0.5, xmin=1.5, xmax=30)
6666

6767
9. Notice that the two-column format of the input to ``morph_arrays`` is the same as the
6868
output of ``morph`` and ``morph_arrays``. It is VERY IMPORTANT that the data is in two-column format
@@ -86,9 +86,9 @@ get_diff: bool
8686
verbose: bool
8787
Print additional header details to saved files. These include details about the morph
8888
inputs and outputs.
89-
rmin: float
89+
xmin: float
9090
Minimum r-value (abscissa) to use for function comparisons.
91-
rmax: float
91+
xmax: float
9292
Maximum r-value (abscissa) to use for function comparisons.
9393
tolerance: float
9494
Specify least squares refiner tolerance when optimizing for morph parameters. Default: 10e-8.

docs/source/quickstart.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Basic diffpy.morph Workflow
148148
7. Now, we will examine the Gaussian smearing factor. We provide an
149149
initial guess by typing ::
150150

151-
diffpy.morph --scale=0.8 --smear=0.5 -a darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
151+
diffpy.morph --scale=0.8 --smear-pdf=0.5 -a darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
152152

153153
And viewing the results. We've tailored our scale factor to be
154154
close to the value given by ``diffpy.morph``, but see that the difference
@@ -162,17 +162,17 @@ Basic diffpy.morph Workflow
162162
superficial and in most cases can be ignored.
163163

164164
We see that this has had hardly any effect on our PDF. To see
165-
an effect, we restrict the ``rmin`` and ``rmax`` values to
165+
an effect, we restrict the ``xmin`` and ``xmax`` values to
166166
reflect relevant data range by typing ::
167167

168-
diffpy.morph --scale=0.8 --smear=0.5 --rmin=1.5 --rmax=30 darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
168+
diffpy.morph --scale=0.8 --smear-pdf=0.5 --xmin=1.5 --xmax=30 darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
169169

170170
Now, we see that the difference Rw = 0.204 and that the optimized
171171
``smear=-0.084138``.
172172

173-
* We restricted the r values because some of the Gaussian
174-
smear effects are only visible in a fixed r range. We
175-
chose this r range by noting where most of our relevant
173+
* We restricted the ``x``-axis (``r``) values because some of the Gaussian
174+
smear effects are only visible in a fixed ``x`` range. We
175+
chose this ``x`` range by noting where most of our relevant
176176
data was that was not exponentially decayed by
177177
instrumental shortcomings.
178178

@@ -181,7 +181,7 @@ Basic diffpy.morph Workflow
181181
8. Finally, we will examine the stretch factor. Provide an initial
182182
guess by typing ::
183183

184-
diffpy.morph --scale=0.8 --smear=-0.08 --stretch=0.005 --rmin=1.5 --rmax=30 -a darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
184+
diffpy.morph --scale=0.8 --smear-pdf=-0.08 --stretch=0.005 --xmin=1.5 --xmax=30 -a darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
185185

186186
And noting that the difference has increased. Before continuing,
187187
see if you can see which direction (higher or lower) our initial
@@ -190,7 +190,7 @@ Basic diffpy.morph Workflow
190190

191191
If you cannot, type ::
192192

193-
diffpy.morph --scale=0.8 --smear=-0.08 --stretch=0.005 --rmin=1.5 --rmax=30 -a darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
193+
diffpy.morph --scale=0.8 --smear-pdf=-0.08 --stretch=0.005 --xmin=1.5 --xmax=30 -a darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
194194

195195
to observe decreased difference and then remove ``-a`` to see
196196
the optimized ``--stretch=0.001762``. We have now reached

docs/source/tutorials.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ files can be found in ``additionalData/morphsqueeze/``.
179179
.. warning::
180180

181181
**Extrapolation risk:**
182-
A polynomial squeeze can shift morph data outside the target’s ``r``-range,
182+
A polynomial squeeze can shift morph data outside the target’s grid
183+
(``x``-axis) range,
183184
so parts of the output may be extrapolated.
184185
This is generally fine if the polynomial coefficients are small and
185186
the distortion is therefore small. If your coefficients are large, check the
@@ -236,12 +237,12 @@ Currently, the supported nanoparticle shapes include: spheres and spheroids.
236237
3. Now, we are ready to perform a morph applying spherical
237238
effects. To do so, we use the ``--radius`` parameter ::
238239

239-
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a --rmax=30
240+
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a --xmax=30
240241

241242
4. We can see that the :math:`Rw` value has significantly decreased
242243
from before. Run without the ``-a`` tag to refine ::
243244

244-
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 --rmax=30
245+
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 --xmax=30
245246

246247
5. After refining, we see the actual radius of the
247248
nanoparticle was closer to 12.
@@ -259,13 +260,13 @@ Currently, the supported nanoparticle shapes include: spheres and spheroids.
259260
enough information to define our spheroid. To apply
260261
spheroid shape effects onto our bulk, run ::
261262

262-
diffpy.morph Ni_bulk.gr Ni_nano_spheroid.cgr --radius=12 --pradius=6 -a --rmax=30
263+
diffpy.morph Ni_bulk.gr Ni_nano_spheroid.cgr --radius=12 --pradius=6 -a --xmax=30
263264

264265
Note that the equatorial radius corresponds to the
265266
``--radius`` parameter and polar radius to ``--pradius``.
266267

267268
3. Remove the ``-a`` tag to refine.
268269

269270
There is also support for morphing from a nanoparticle to a bulk. When
270-
applying the inverse morphs, it is recommended to set ``--rmax=psize``
271+
applying the inverse morphs, it is recommended to set ``--xmax=psize``
271272
where ``psize`` is the longest diameter of the nanoparticle.

news/example_fix.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* Tutorial examples for funcxy and pyfai now run properly.
20+
21+
**Security:**
22+
23+
* <news item>

0 commit comments

Comments
 (0)