From e924dfa9303e83aa5ba0175461613ff6117c989f Mon Sep 17 00:00:00 2001 From: Sparks29032 Date: Fri, 3 Oct 2025 10:48:43 -0700 Subject: [PATCH 1/2] Fix examples --- docs/source/funcxy.rst | 14 +++++++------- docs/source/morphpy.rst | 10 +++++----- docs/source/quickstart.rst | 16 ++++++++-------- docs/source/tutorials.rst | 11 ++++++----- news/example_fix.rst | 23 +++++++++++++++++++++++ 5 files changed, 49 insertions(+), 25 deletions(-) create mode 100644 news/example_fix.rst diff --git a/docs/source/funcxy.rst b/docs/source/funcxy.rst index 689ad3d..4f15768 100644 --- a/docs/source/funcxy.rst +++ b/docs/source/funcxy.rst @@ -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 @@ -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): @@ -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" diff --git a/docs/source/morphpy.rst b/docs/source/morphpy.rst index 54a17ce..09e0f92 100644 --- a/docs/source/morphpy.rst +++ b/docs/source/morphpy.rst @@ -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`. @@ -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). @@ -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 @@ -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. diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst index d448746..89a95ce 100644 --- a/docs/source/quickstart.rst +++ b/docs/source/quickstart.rst @@ -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 @@ -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. @@ -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 @@ -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 diff --git a/docs/source/tutorials.rst b/docs/source/tutorials.rst index 01fac3d..6e8b6bf 100644 --- a/docs/source/tutorials.rst +++ b/docs/source/tutorials.rst @@ -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 @@ -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. @@ -259,7 +260,7 @@ 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``. @@ -267,5 +268,5 @@ Currently, the supported nanoparticle shapes include: spheres and spheroids. 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. diff --git a/news/example_fix.rst b/news/example_fix.rst new file mode 100644 index 0000000..36eb11b --- /dev/null +++ b/news/example_fix.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Tutorial examples for funcxy and pyfai now run properly. + +**Security:** + +* From 1960078de501be06fbc1bb6dbd056e071a3b3b57 Mon Sep 17 00:00:00 2001 From: Sparks29032 Date: Fri, 3 Oct 2025 10:53:16 -0700 Subject: [PATCH 2/2] bump --- docs/source/index.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 8224e5f..eb98122 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -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 `__. For those looking to see more advanced features, you can read our