Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/source/funcxy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ scaling factor ``bgscale``.
We will showcase an example of how one would refine over the
``PDFGetter`` parameters using ``funcxy`` to obtain a PDF.

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

.. code-block:: python

Expand All @@ -44,8 +44,8 @@ glass background ``background.chi``.

pg = PDFGetter()

backgroundfile = loadData("background.chi")
composition = "PbS"
backgroundfile = "background.chi"
composition = "SiO2"


def wrap(x, y, **kwargs):
Expand Down Expand Up @@ -150,7 +150,7 @@ our wavelength was ``1.11`` angstroms.
centerY=cent_y+cent_offset_y
)

return ai.integrate1D_ng(
return ai.integrate1d_ng(
pattern_2d,
npt=1000, unit="q_A^-1",
method="mean"
Expand Down
5 changes: 3 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ plotted below.

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

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

To get started, please visit the `quickstart tutorial <quickstart.html>`__.
For those looking to see more advanced features, you can read our
Expand Down
10 changes: 5 additions & 5 deletions docs/source/morphpy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Python Morphing Functions
morph on the files `darkSub_rh20_C_01.gr` and `darkSub_rh20_C_44.gr` using the command-line
command ::

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
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

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

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

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)
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)

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

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)
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)

9. Notice that the two-column format of the input to ``morph_arrays`` is the same as the
output of ``morph`` and ``morph_arrays``. It is VERY IMPORTANT that the data is in two-column format
Expand All @@ -86,9 +86,9 @@ get_diff: bool
verbose: bool
Print additional header details to saved files. These include details about the morph
inputs and outputs.
rmin: float
xmin: float
Minimum r-value (abscissa) to use for function comparisons.
rmax: float
xmax: float
Maximum r-value (abscissa) to use for function comparisons.
tolerance: float
Specify least squares refiner tolerance when optimizing for morph parameters. Default: 10e-8.
Expand Down
16 changes: 8 additions & 8 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Basic diffpy.morph Workflow
7. Now, we will examine the Gaussian smearing factor. We provide an
initial guess by typing ::

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

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

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

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

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

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

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

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
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

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

If you cannot, type ::

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
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

to observe decreased difference and then remove ``-a`` to see
the optimized ``--stretch=0.001762``. We have now reached
Expand Down
11 changes: 6 additions & 5 deletions docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ files can be found in ``additionalData/morphsqueeze/``.
.. warning::

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

diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a --rmax=30
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a --xmax=30

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

diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 --rmax=30
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 --xmax=30

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

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

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

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

There is also support for morphing from a nanoparticle to a bulk. When
applying the inverse morphs, it is recommended to set ``--rmax=psize``
applying the inverse morphs, it is recommended to set ``--xmax=psize``
where ``psize`` is the longest diameter of the nanoparticle.
23 changes: 23 additions & 0 deletions news/example_fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Tutorial examples for funcxy and pyfai now run properly.

**Security:**

* <news item>
Loading