From b927ce0084f2cb469857a23e8be5521e17b6839b Mon Sep 17 00:00:00 2001 From: Sparks29032 Date: Tue, 23 Sep 2025 16:16:21 -0700 Subject: [PATCH 1/3] Refactor away from pdf language --- README.rst | 29 ++++---- TUTORIAL.rst | 8 +-- src/diffpy/morph/morph_api.py | 30 ++++----- src/diffpy/morph/morphapp.py | 34 +++++----- src/diffpy/morph/morphs/morphrgrid.py | 66 +++++++++---------- src/diffpy/morph/plot.py | 4 +- tests/test_morphapp.py | 10 +-- tests/test_morphchain.py | 12 ++-- tests/test_morphio.py | 12 ++-- tests/test_morphrgrid.py | 66 +++++++++---------- tests/test_refine.py | 12 ++-- tests/testdata/funcy_target.cgr | 6 +- tests/testdata/squeeze_target.cgr | 6 +- tests/testdata/testsequence/a_210K.gr | 6 +- tests/testdata/testsequence/b_204K.gr | 6 +- tests/testdata/testsequence/c_198K.gr | 6 +- tests/testdata/testsequence/d_192K.gr | 6 +- tests/testdata/testsequence/e_186K.gr | 6 +- tests/testdata/testsequence/f_180K.gr | 6 +- tests/testdata/testsequence/g_174K.gr | 6 +- .../verbose/Morph_Reference_Table.txt | 36 +++++----- .../testsaving/verbose/Morphs/mwt_a.cgr | 6 +- .../testsaving/verbose/Morphs/mwt_b.cgr | 6 +- .../testsaving/verbose/Morphs/mwt_c.cgr | 6 +- .../testsaving/verbose/Morphs/mwt_d.cgr | 6 +- .../testsaving/verbose/Morphs/mwt_e.cgr | 6 +- .../testsaving/verbose/Morphs/mwt_f.cgr | 6 +- .../verbose/single_verbose_morph.cgr | 6 +- tests/testdata/testsequence_serialfile.json | 42 ++++++------ 29 files changed, 230 insertions(+), 227 deletions(-) diff --git a/README.rst b/README.rst index 87c60770..9f69ba7f 100644 --- a/README.rst +++ b/README.rst @@ -35,34 +35,35 @@ .. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue :target: https://github.com/diffpy/diffpy.morph/issues -Python package for manipulating and comparing PDF profiles +Python package for manipulating and comparing diffraction data ``diffpy.morph`` is a Python software package designed to increase the insight -researchers can obtain from measured atomic pair distribution functions +researchers can obtain from measured diffraction data +and atomic pair distribution functions (PDFs) in a model-independent way. The program was designed to help a researcher answer the question: "Has my material undergone a phase transition between these two measurements?" -One approach is to compare the two PDFs in a plot and view the difference -curve underneath. However, significant signal can be seen in the -difference curve from benign effects such as thermal expansion (peak -shifts) and increased thermal motion (peak broadening) or a change in +One approach is to compare the two diffraction patterns in a plot +and view the difference curve underneath. However, significant signal can +be seen in the difference curve from benign effects such as thermal expansion +(peak shifts) and increased thermal motion (peak broadening) or a change in scale due to differences in incident flux, for example. ``diffpy.morph`` will do its best to correct for these benign effects before computing and -plotting the difference curve. One measured PDF (typically that collected -at higher temperature) is identified as the target PDF and the second -PDF is then morphed by "stretching" (changing the r-axis to simulate a +plotting the difference curve. One measured function (typically that collected +at higher temperature) is identified as the target function and the second +function is then morphed by "stretching" (changing the r-axis to simulate a uniform lattice expansion), "smearing" (broadening peaks through a uniform convolution to simulate increased thermal motion), and "scaling" (self-explanatory). ``diffpy.morph`` will vary the amplitude of the morphing transformations to obtain the best fit between the morphed and the target -PDFs, then plot them on top of each other with the difference plotted +functions, then plot them on top of each other with the difference plotted below. There are also a few other morphing transformations in the program. -Finally, we note that ``diffpy.morph`` should work on other spectra that are not -PDFs, though it has not been extensively tested beyond the PDF. +Finally, we note that ``diffpy.morph`` should work on other spectra, +though it has not been extensively tested beyond spectral data and the PDF. For more information about the diffpy.morph library, please consult our `online documentation `_. @@ -153,9 +154,9 @@ If installed correctly, this last command should return the version of ``diffpy.morph`` that you have installed on your system. To begin using ``diffpy.morph``, run a command like :: - diffpy.morph + diffpy.morph -where both PDFs file are text files which contain PDF data, such as ``.gr`` +where both files are text files which contain two-column data, such as ``.gr`` or ``.cgr`` files that are produced by ``PDFgetX2``, ``PDFgetX3``, or ``PDFgui``. File extensions other than ``.gr`` or ``.cgr``, but with the same content structure, also work with ``diffpy.morph``. diff --git a/TUTORIAL.rst b/TUTORIAL.rst index 433c301a..86b8a06d 100644 --- a/TUTORIAL.rst +++ b/TUTORIAL.rst @@ -132,10 +132,10 @@ 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=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``. @@ -151,7 +151,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.5 --rmin=1.5 --rmax=30 -a darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr + diffpy.morph --scale=0.8 --smear=-0.08 --stretch=0.5 --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 @@ -160,7 +160,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=-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/src/diffpy/morph/morph_api.py b/src/diffpy/morph/morph_api.py index e13f4d0f..25374cce 100644 --- a/src/diffpy/morph/morph_api.py +++ b/src/diffpy/morph/morph_api.py @@ -86,9 +86,9 @@ def morph( y_morph, x_target, y_target, - rmin=None, - rmax=None, - rstep=None, + xmin=None, + xmax=None, + xstep=None, pearson=False, add_pearson=False, fixed_operations=None, @@ -112,12 +112,12 @@ def morph( y_morph: numpy.array An array of target y values, i.e., those will be kept constant by morphing. - rmin: float, optional - A value to specify lower r-limit of morph operations. - rmax: float, optional - A value to specify upper r-limit of morph operations. - rstep: float, optional - A value to specify rstep of morph operations. + xmin: float, optional + A value to specify lower x-limit of morph operations. + xmax: float, optional + A value to specify upper x-limit of morph operations. + xstep: float, optional + A value to specify xstep of morph operations. pearson: Bool, optional Option to include Pearson coefficient as a minimizing target during morphing. Default to False. @@ -191,9 +191,9 @@ def morph( for k, v in rv_cfg.items() if (v is not None) and k in _morph_step_dict ] - rv_cfg["rmin"] = rmin - rv_cfg["rmax"] = rmax - rv_cfg["rstep"] = rstep + rv_cfg["xmin"] = xmin + rv_cfg["xmax"] = xmax + rv_cfg["xstep"] = xstep # configure smear, guess baselineslope when it is not provided if rv_cfg.get("smear") is not None and rv_cfg.get("baselineslope") is None: rv_cfg["baselineslope"] = -0.5 @@ -295,9 +295,9 @@ def plot_morph(chain, ax=None, **kwargs): rdat, grdat = chain.xy_target_out l_list = ax.plot(rfit, grfit, label="morph", **kwargs) l_list += ax.plot(rdat, grdat, label="target", **kwargs) - ax.set_xlim([chain.config["rmin"], chain.config["rmax"]]) + ax.set_xlim([chain.config["xmin"], chain.config["xmax"]]) ax.legend() - ax.set_xlabel(r"r ($\mathrm{\AA}$)") - ax.set_ylabel(r"G ($\mathrm{\AA}^{-2}$)") + # ax.set_xlabel(r"r ($\mathrm{\AA}$)") + # ax.set_ylabel(r"G ($\mathrm{\AA}^{-2}$)") return l_list diff --git a/src/diffpy/morph/morphapp.py b/src/diffpy/morph/morphapp.py index 43976984..327ed2da 100755 --- a/src/diffpy/morph/morphapp.py +++ b/src/diffpy/morph/morphapp.py @@ -110,14 +110,16 @@ def custom_error(self, msg): help="Print additional header details to saved files.", ) parser.add_option( - "--rmin", + "--xmin", type="float", - help="Minimum r-value (abscissa) to use for function comparisons.", + metavar="XMIN", + help="Minimum x-value (abscissa) to use for function comparisons.", ) parser.add_option( - "--rmax", + "--xmax", type="float", - help="Maximum r-value (abscissa) to use for function comparisons.", + metavar="XMAX", + help="Maximum x-value (abscissa) to use for function comparisons.", ) parser.add_option( "--tolerance", @@ -343,12 +345,12 @@ def custom_error(self, msg): group.add_option( "--pmin", type="float", - help="Minimum r-value to plot. Defaults to RMIN.", + help="Minimum x-value to plot. Defaults to XMIN.", ) group.add_option( "--pmax", type="float", - help="Maximum r-value to plot. Defaults to RMAX.", + help="Maximum x-value to plot. Defaults to XMAX.", ) group.add_option( "--maglim", @@ -505,13 +507,13 @@ def single_morph( smear_in = "None" hshift_in = "None" vshift_in = "None" - config = {"rmin": opts.rmin, "rmax": opts.rmax, "rstep": None} + config = {"xmin": opts.xmin, "xmax": opts.xmax, "xstep": None} if ( - opts.rmin is not None - and opts.rmax is not None - and opts.rmax <= opts.rmin + opts.xmin is not None + and opts.xmax is not None + and opts.xmax <= opts.xmin ): - e = "rmin must be less than rmax" + e = "xmin must be less than xmax" parser.custom_error(e) # Set up the morphs @@ -765,7 +767,7 @@ def single_morph( xy_save = [chain.x_morph_out, chain.y_morph_out] if opts.get_diff is not None: diff_chain = morphs.MorphChain( - {"rmin": None, "rmax": None, "rstep": None} + {"xmin": None, "xmax": None, "xstep": None} ) diff_chain.append(morphs.MorphRGrid()) diff_chain( @@ -804,16 +806,16 @@ def single_morph( labels[0] = opts.tlabel # Plot extent defaults to calculation extent - pmin = opts.pmin if opts.pmin is not None else opts.rmin - pmax = opts.pmax if opts.pmax is not None else opts.rmax + pmin = opts.pmin if opts.pmin is not None else opts.xmin + pmax = opts.pmax if opts.pmax is not None else opts.xmax maglim = opts.maglim mag = opts.mag l_width = opts.lwidth plot.compare_funcs( pairlist, labels, - rmin=pmin, - rmax=pmax, + xmin=pmin, + xmax=pmax, maglim=maglim, mag=mag, rw=rw, diff --git a/src/diffpy/morph/morphs/morphrgrid.py b/src/diffpy/morph/morphs/morphrgrid.py index d0c6ce1b..9b20cf67 100644 --- a/src/diffpy/morph/morphs/morphrgrid.py +++ b/src/diffpy/morph/morphs/morphrgrid.py @@ -28,12 +28,12 @@ class MorphRGrid(Morph): Configuration Variables ----------------------- - rmin - The lower-bound on the r-range. - rmax - The upper-bound on the r-range (exclusive within tolerance of 1e-8). - rstep - The r-spacing. + xmin + The lower-bound on the x-range. + xmax + The upper-bound on the x-range (exclusive within tolerance of 1e-8). + xstep + The x-spacing. Notes ----- @@ -49,47 +49,47 @@ class MorphRGrid(Morph): yinlabel = LABEL_GR xoutlabel = LABEL_RA youtlabel = LABEL_GR - parnames = ["rmin", "rmax", "rstep"] + parnames = ["xmin", "xmax", "xstep"] - # Define rmin rmax holders for adaptive x-grid refinement + # Define xmin xmax holders for adaptive x-grid refinement # Without these, the program r-grid can only decrease in interval size - rmin_origin = None - rmax_origin = None - rstep_origin = None + xmin_origin = None + xmax_origin = None + xstep_origin = None def morph(self, x_morph, y_morph, x_target, y_target): """Resample arrays onto specified grid.""" - if self.rmin is not None: - self.rmin_origin = self.rmin - if self.rmax is not None: - self.rmax_origin = self.rmax - if self.rstep is not None: - self.rstep_origin = self.rstep + if self.xmin is not None: + self.xmin_origin = self.xmin + if self.xmax is not None: + self.xmax_origin = self.xmax + if self.xstep is not None: + self.xstep_origin = self.xstep Morph.morph(self, x_morph, y_morph, x_target, y_target) - rmininc = max(min(self.x_target_in), min(self.x_morph_in)) - r_step_target = (max(self.x_target_in) - min(self.x_target_in)) / ( + xmininc = max(min(self.x_target_in), min(self.x_morph_in)) + x_step_target = (max(self.x_target_in) - min(self.x_target_in)) / ( len(self.x_target_in) - 1 ) - r_step_morph = (max(self.x_morph_in) - min(self.x_morph_in)) / ( + x_step_morph = (max(self.x_morph_in) - min(self.x_morph_in)) / ( len(self.x_morph_in) - 1 ) - rstepinc = max(r_step_target, r_step_morph) - rmaxinc = min( - max(self.x_target_in) + r_step_target, - max(self.x_morph_in) + r_step_morph, + xstepinc = max(x_step_target, x_step_morph) + xmaxinc = min( + max(self.x_target_in) + x_step_target, + max(self.x_morph_in) + x_step_morph, ) - if self.rmin_origin is None or self.rmin_origin < rmininc: - self.rmin = rmininc - if self.rmax_origin is None or self.rmax_origin > rmaxinc: - self.rmax = rmaxinc - if self.rstep_origin is None or self.rstep_origin < rstepinc: - self.rstep = rstepinc + if self.xmin_origin is None or self.xmin_origin < xmininc: + self.xmin = xmininc + if self.xmax_origin is None or self.xmax_origin > xmaxinc: + self.xmax = xmaxinc + if self.xstep_origin is None or self.xstep_origin < xstepinc: + self.xstep = xstepinc # roundoff tolerance for selecting bounds on arrays. - epsilon = self.rstep / 2 - # Make sure that rmax is exclusive + epsilon = self.xstep / 2 + # Make sure that xmax is exclusive self.x_morph_out = numpy.arange( - self.rmin, self.rmax - epsilon, self.rstep + self.xmin, self.xmax - epsilon, self.xstep ) self.y_morph_out = numpy.interp( self.x_morph_out, self.x_morph_in, self.y_morph_in diff --git a/src/diffpy/morph/plot.py b/src/diffpy/morph/plot.py index d0ca14b0..22eb46b4 100644 --- a/src/diffpy/morph/plot.py +++ b/src/diffpy/morph/plot.py @@ -212,8 +212,8 @@ def compare_funcs( plt.ylim(ymin, ymax) # Make labels and legends - plt.xlabel(r"r ($\mathrm{\AA})$") - plt.ylabel(r"G $(\mathrm{\AA}^{-1})$") + # plt.xlabel(r"r ($\mathrm{\AA})$") + # plt.ylabel(r"G $(\mathrm{\AA}^{-1})$") if legend: plt.legend( bbox_to_anchor=(0.005, 1.02, 0.99, 0.10), diff --git a/tests/test_morphapp.py b/tests/test_morphapp.py index 379d9f22..97682aec 100644 --- a/tests/test_morphapp.py +++ b/tests/test_morphapp.py @@ -52,8 +52,8 @@ def test_parser_numerical(self, setup_parser): # Check values parsed correctly n_names = [ - "--rmin", - "--rmax", + "--xmin", + "--xmax", "--scale", "--smear", "--stretch", @@ -134,14 +134,14 @@ def test_parser_systemexits(self, capsys, setup_parser): in err ) - # Make sure rmax greater than rmin + # Make sure xmax greater than xmin (opts, pargs) = self.parser.parse_args( - [f"{nickel_PDF}", f"{nickel_PDF}", "--rmin", "10", "--rmax", "1"] + [f"{nickel_PDF}", f"{nickel_PDF}", "--xmin", "10", "--xmax", "1"] ) with pytest.raises(SystemExit): single_morph(self.parser, opts, pargs, stdout_flag=False) _, err = capsys.readouterr() - assert "rmin must be less than rmax" in err + assert "xmin must be less than xmax" in err # ###Tests exclusive to multiple morphs### # Make sure we save to a directory that exists diff --git a/tests/test_morphchain.py b/tests/test_morphchain.py index 721beae0..004b5f2b 100644 --- a/tests/test_morphchain.py +++ b/tests/test_morphchain.py @@ -30,9 +30,9 @@ def test_morph(self, setup): """Check MorphChain.morph()""" # Define the morphs config = { - "rmin": 1, - "rmax": 6, - "rstep": 0.1, + "xmin": 1, + "xmax": 6, + "xstep": 0.1, "scale": 3.0, } @@ -48,8 +48,8 @@ def test_morph(self, setup): pytest.approx(x_morph[0], 1.0) pytest.approx(x_morph[-1], 4.9) pytest.approx(x_morph[1] - x_morph[0], 0.1) - pytest.approx(x_morph[0], mgrid.rmin) - pytest.approx(x_morph[-1], mgrid.rmax - mgrid.rstep) - pytest.approx(x_morph[1] - x_morph[0], mgrid.rstep) + pytest.approx(x_morph[0], mgrid.xmin) + pytest.approx(x_morph[-1], mgrid.xmax - mgrid.xstep) + pytest.approx(x_morph[1] - x_morph[0], mgrid.xstep) assert numpy.allclose(y_morph, y_target) return diff --git a/tests/test_morphio.py b/tests/test_morphio.py index c86b66c6..2eed0135 100644 --- a/tests/test_morphio.py +++ b/tests/test_morphio.py @@ -72,14 +72,14 @@ def are_diffs_right(file1, file2, diff_file): f2_data = loadData(file2) diff_data = loadData(diff_file) - rmin = max(min(f1_data[:, 0]), min(f1_data[:, 1])) - rmax = min(max(f2_data[:, 0]), max(f2_data[:, 1])) - rnumsteps = max( - len(f1_data[:, 0][(rmin <= f1_data[:, 0]) & (f1_data[:, 0] <= rmax)]), - len(f2_data[:, 0][(rmin <= f2_data[:, 0]) & (f2_data[:, 0] <= rmax)]), + xmin = max(min(f1_data[:, 0]), min(f1_data[:, 1])) + xmax = min(max(f2_data[:, 0]), max(f2_data[:, 1])) + xnumsteps = max( + len(f1_data[:, 0][(xmin <= f1_data[:, 0]) & (f1_data[:, 0] <= xmax)]), + len(f2_data[:, 0][(xmin <= f2_data[:, 0]) & (f2_data[:, 0] <= xmax)]), ) - share_grid = np.linspace(rmin, rmax, rnumsteps) + share_grid = np.linspace(xmin, xmax, xnumsteps) f1_interp = np.interp(share_grid, f1_data[:, 0], f1_data[:, 1]) f2_interp = np.interp(share_grid, f2_data[:, 0], f2_data[:, 1]) diff_interp = np.interp(share_grid, diff_data[:, 0], diff_data[:, 1]) diff --git a/tests/test_morphrgrid.py b/tests/test_morphrgrid.py index 866c6332..8d85a2c2 100644 --- a/tests/test_morphrgrid.py +++ b/tests/test_morphrgrid.py @@ -27,9 +27,9 @@ def setup(self): def _runTests(self, xyallout, morph): x_morph, y_morph, x_target, y_target = xyallout assert (x_morph == x_target).all() - pytest.approx(x_morph[0], morph.rmin) - pytest.approx(x_morph[-1], morph.rmax - morph.rstep) - pytest.approx(x_morph[1] - x_morph[0], morph.rstep) + pytest.approx(x_morph[0], morph.xmin) + pytest.approx(x_morph[-1], morph.xmax - morph.xstep) + pytest.approx(x_morph[1] - x_morph[0], morph.xstep) pytest.approx(len(y_morph), len(y_target)) return @@ -37,70 +37,70 @@ def testRangeInBounds(self, setup): """Selected range is within input bounds.""" config = { - "rmin": 1.0, - "rmax": 2.0, - "rstep": 0.1, + "xmin": 1.0, + "xmax": 2.0, + "xstep": 0.1, } morph = MorphRGrid(config) xyallout = morph( self.x_morph, self.y_morph, self.x_target, self.y_target ) - pytest.approx(config["rmin"], morph.rmin) - pytest.approx(config["rmax"], morph.rmax) - pytest.approx(config["rstep"], morph.rstep) + pytest.approx(config["xmin"], morph.xmin) + pytest.approx(config["xmax"], morph.xmax) + pytest.approx(config["xstep"], morph.xstep) self._runTests(xyallout, morph) return - def testRmaxOut(self, setup): - """Selected rmax is outside of input bounds.""" + def testxmaxOut(self, setup): + """Selected xmax is outside of input bounds.""" config = { - "rmin": 1.0, - "rmax": 15.0, - "rstep": 0.1, + "xmin": 1.0, + "xmax": 15.0, + "xstep": 0.1, } morph = MorphRGrid(config) xyallout = morph( self.x_morph, self.y_morph, self.x_target, self.y_target ) - pytest.approx(config["rmin"], morph.rmin) - pytest.approx(5, morph.rmax) - pytest.approx(config["rstep"], morph.rstep) + pytest.approx(config["xmin"], morph.xmin) + pytest.approx(5, morph.xmax) + pytest.approx(config["xstep"], morph.xstep) self._runTests(xyallout, morph) return - def testRminOut(self, setup): - """Selected rmin is outside of input bounds.""" + def testxminOut(self, setup): + """Selected xmin is outside of input bounds.""" config = { - "rmin": 0.0, - "rmax": 2.0, - "rstep": 0.01, + "xmin": 0.0, + "xmax": 2.0, + "xstep": 0.01, } morph = MorphRGrid(config) xyallout = morph( self.x_morph, self.y_morph, self.x_target, self.y_target ) - pytest.approx(1.0, morph.rmin) - pytest.approx(config["rmax"], morph.rmax) - pytest.approx(config["rstep"], morph.rstep) + pytest.approx(1.0, morph.xmin) + pytest.approx(config["xmax"], morph.xmax) + pytest.approx(config["xstep"], morph.xstep) self._runTests(xyallout, morph) return - def testRstepOut(self, setup): - """Selected rstep is outside of input bounds.""" + def testxstepOut(self, setup): + """Selected xstep is outside of input bounds.""" config = { - "rmin": 1.0, - "rmax": 2.0, - "rstep": 0.001, + "xmin": 1.0, + "xmax": 2.0, + "xstep": 0.001, } morph = MorphRGrid(config) xyallout = morph( self.x_morph, self.y_morph, self.x_target, self.y_target ) - pytest.approx(config["rmin"], morph.rmin) - pytest.approx(config["rmax"], morph.rmax) - pytest.approx(0.01, morph.rstep) + pytest.approx(config["xmin"], morph.xmin) + pytest.approx(config["xmax"], morph.xmax) + pytest.approx(0.01, morph.xstep) self._runTests(xyallout, morph) return diff --git a/tests/test_refine.py b/tests/test_refine.py index 2c10c196..b64bccd1 100644 --- a/tests/test_refine.py +++ b/tests/test_refine.py @@ -137,9 +137,9 @@ def shift(x, y, hshift): config = { "funcx_function": shift, "funcx": {"hshift": 0}, - "rmin": 0, - "rmax": 7, - "rstep": 0.01, + "xmin": 0, + "xmax": 7, + "xstep": 0.01, } mfuncx = MorphFuncx(config) @@ -168,9 +168,9 @@ def stretch(x, y, stretch): config = { "funcx_function": stretch, "funcx": {"stretch": 0.7}, - "rmin": 0, - "rmax": 4, - "rstep": 0.01, + "xmin": 0, + "xmax": 4, + "xstep": 0.01, } mfuncx = MorphFuncx(config) diff --git a/tests/testdata/funcy_target.cgr b/tests/testdata/funcy_target.cgr index 5744e86a..fa36dc6b 100644 --- a/tests/testdata/funcy_target.cgr +++ b/tests/testdata/funcy_target.cgr @@ -20,9 +20,9 @@ def quadratic(x, y, a0, a1, a2): """ # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 10.100000 -# rstep = 0.100000 +# xmin = 0.000000 +# xmax = 10.100000 +# xstep = 0.100000 # squeeze a0 = 0.000000 # squeeze a1 = 0.000000 # squeeze a2 = 0.000000 diff --git a/tests/testdata/squeeze_target.cgr b/tests/testdata/squeeze_target.cgr index 5a7c4017..1474409a 100644 --- a/tests/testdata/squeeze_target.cgr +++ b/tests/testdata/squeeze_target.cgr @@ -13,9 +13,9 @@ # squeeze a3 = 0.0001 # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 10.100000 -# rstep = 0.100000 +# xmin = 0.000000 +# xmax = 10.100000 +# xstep = 0.100000 # scale = 0.500000 # squeeze a0 = 0.000000 # squeeze a1 = 0.010000 diff --git a/tests/testdata/testsequence/a_210K.gr b/tests/testdata/testsequence/a_210K.gr index a9932c9b..8b73d5bc 100644 --- a/tests/testdata/testsequence/a_210K.gr +++ b/tests/testdata/testsequence/a_210K.gr @@ -12,9 +12,9 @@ outputtype = gr qmaxinst = 25.0 qmin = 0.4 qmax = 25.0 -rmax = 100.0 -rmin = 0.0 -rstep = 0.01 +xmax = 100.0 +xmin = 0.0 +xstep = 0.01 rpoly = 0.7 [Misc] diff --git a/tests/testdata/testsequence/b_204K.gr b/tests/testdata/testsequence/b_204K.gr index bfce0df5..75584763 100644 --- a/tests/testdata/testsequence/b_204K.gr +++ b/tests/testdata/testsequence/b_204K.gr @@ -12,9 +12,9 @@ outputtype = gr qmaxinst = 25.0 qmin = 0.4 qmax = 25.0 -rmax = 100.0 -rmin = 0.0 -rstep = 0.01 +xmax = 100.0 +xmin = 0.0 +xstep = 0.01 rpoly = 0.7 [Misc] diff --git a/tests/testdata/testsequence/c_198K.gr b/tests/testdata/testsequence/c_198K.gr index 9f884651..a8fda3b3 100644 --- a/tests/testdata/testsequence/c_198K.gr +++ b/tests/testdata/testsequence/c_198K.gr @@ -12,9 +12,9 @@ outputtype = gr qmaxinst = 25.0 qmin = 0.4 qmax = 25.0 -rmax = 100.0 -rmin = 0.0 -rstep = 0.01 +xmax = 100.0 +xmin = 0.0 +xstep = 0.01 rpoly = 0.7 [Misc] diff --git a/tests/testdata/testsequence/d_192K.gr b/tests/testdata/testsequence/d_192K.gr index bcbe7330..38083694 100644 --- a/tests/testdata/testsequence/d_192K.gr +++ b/tests/testdata/testsequence/d_192K.gr @@ -12,9 +12,9 @@ outputtype = gr qmaxinst = 25.0 qmin = 0.4 qmax = 25.0 -rmax = 100.0 -rmin = 0.0 -rstep = 0.01 +xmax = 100.0 +xmin = 0.0 +xstep = 0.01 rpoly = 0.7 [Misc] diff --git a/tests/testdata/testsequence/e_186K.gr b/tests/testdata/testsequence/e_186K.gr index 0bcb4646..bde9e2a9 100644 --- a/tests/testdata/testsequence/e_186K.gr +++ b/tests/testdata/testsequence/e_186K.gr @@ -12,9 +12,9 @@ outputtype = gr qmaxinst = 25.0 qmin = 0.4 qmax = 25.0 -rmax = 100.0 -rmin = 0.0 -rstep = 0.01 +xmax = 100.0 +xmin = 0.0 +xstep = 0.01 rpoly = 0.7 [Misc] diff --git a/tests/testdata/testsequence/f_180K.gr b/tests/testdata/testsequence/f_180K.gr index e0800537..af5b64f8 100644 --- a/tests/testdata/testsequence/f_180K.gr +++ b/tests/testdata/testsequence/f_180K.gr @@ -12,9 +12,9 @@ outputtype = gr qmaxinst = 25.0 qmin = 0.4 qmax = 25.0 -rmax = 100.0 -rmin = 0.0 -rstep = 0.01 +xmax = 100.0 +xmin = 0.0 +xstep = 0.01 rpoly = 0.7 [Misc] diff --git a/tests/testdata/testsequence/g_174K.gr b/tests/testdata/testsequence/g_174K.gr index 88a2ad0b..9deb50ca 100644 --- a/tests/testdata/testsequence/g_174K.gr +++ b/tests/testdata/testsequence/g_174K.gr @@ -12,9 +12,9 @@ outputtype = gr qmaxinst = 25.0 qmin = 0.4 qmax = 25.0 -rmax = 100.0 -rmin = 0.0 -rstep = 0.01 +xmax = 100.0 +xmin = 0.0 +xstep = 0.01 rpoly = 0.7 [Misc] diff --git a/tests/testdata/testsequence/testsaving/verbose/Morph_Reference_Table.txt b/tests/testdata/testsequence/testsaving/verbose/Morph_Reference_Table.txt index c849e35f..83445d1e 100644 --- a/tests/testdata/testsequence/testsaving/verbose/Morph_Reference_Table.txt +++ b/tests/testdata/testsequence/testsaving/verbose/Morph_Reference_Table.txt @@ -11,49 +11,49 @@ # Target: f_180K.gr # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.020141 # Pearson = 0.999810 # Target: e_186K.gr # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.034859 # Pearson = 0.999424 # Target: d_192K.gr # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.062392 # Pearson = 0.998077 # Target: c_198K.gr # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.105918 # Pearson = 0.994409 # Target: b_204K.gr # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.117595 # Pearson = 0.993160 # Target: a_210K.gr # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.127100 # Pearson = 0.992111 diff --git a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_a.cgr b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_a.cgr index d4ab20ff..95cba1f9 100644 --- a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_a.cgr +++ b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_a.cgr @@ -9,9 +9,9 @@ # vshift = None # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.127100 # Pearson = 0.992111 diff --git a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_b.cgr b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_b.cgr index fd039d17..ef8cf023 100644 --- a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_b.cgr +++ b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_b.cgr @@ -9,9 +9,9 @@ # vshift = None # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.117595 # Pearson = 0.993160 diff --git a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_c.cgr b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_c.cgr index 0321f80e..27ebcd00 100644 --- a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_c.cgr +++ b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_c.cgr @@ -9,9 +9,9 @@ # vshift = None # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.105918 # Pearson = 0.994409 diff --git a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_d.cgr b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_d.cgr index fa694073..8a30b321 100644 --- a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_d.cgr +++ b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_d.cgr @@ -9,9 +9,9 @@ # vshift = None # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.062392 # Pearson = 0.998077 diff --git a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_e.cgr b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_e.cgr index 5ea8d806..1ad1a45f 100644 --- a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_e.cgr +++ b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_e.cgr @@ -9,9 +9,9 @@ # vshift = None # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.034859 # Pearson = 0.999424 diff --git a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_f.cgr b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_f.cgr index 1cf81646..32ce202b 100644 --- a/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_f.cgr +++ b/tests/testdata/testsequence/testsaving/verbose/Morphs/mwt_f.cgr @@ -9,9 +9,9 @@ # vshift = None # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.020141 # Pearson = 0.999810 diff --git a/tests/testdata/testsequence/testsaving/verbose/single_verbose_morph.cgr b/tests/testdata/testsequence/testsaving/verbose/single_verbose_morph.cgr index d4ab20ff..95cba1f9 100644 --- a/tests/testdata/testsequence/testsaving/verbose/single_verbose_morph.cgr +++ b/tests/testdata/testsequence/testsaving/verbose/single_verbose_morph.cgr @@ -9,9 +9,9 @@ # vshift = None # Optimized morphing parameters: -# rmin = 0.000000 -# rmax = 100.010000 -# rstep = 0.010000 +# xmin = 0.000000 +# xmax = 100.010000 +# xstep = 0.010000 # Rw = 0.127100 # Pearson = 0.992111 diff --git a/tests/testdata/testsequence_serialfile.json b/tests/testdata/testsequence_serialfile.json index bc49ce93..834f3c1e 100644 --- a/tests/testdata/testsequence_serialfile.json +++ b/tests/testdata/testsequence_serialfile.json @@ -13,9 +13,9 @@ "qmaxinst": 25.0, "qmin": 0.4, "qmax": 25.0, - "rmax": 100.0, - "rmin": 0.0, - "rstep": 0.01, + "xmax": 100.0, + "xmin": 0.0, + "xstep": 0.01, "rpoly": 0.7 }, "b_204K.gr": { @@ -32,9 +32,9 @@ "qmaxinst": 25.0, "qmin": 0.4, "qmax": 25.0, - "rmax": 100.0, - "rmin": 0.0, - "rstep": 0.01, + "xmax": 100.0, + "xmin": 0.0, + "xstep": 0.01, "rpoly": 0.7 }, "c_198K.gr": { @@ -51,9 +51,9 @@ "qmaxinst": 25.0, "qmin": 0.4, "qmax": 25.0, - "rmax": 100.0, - "rmin": 0.0, - "rstep": 0.01, + "xmax": 100.0, + "xmin": 0.0, + "xstep": 0.01, "rpoly": 0.7 }, "d_192K.gr": { @@ -70,9 +70,9 @@ "qmaxinst": 25.0, "qmin": 0.4, "qmax": 25.0, - "rmax": 100.0, - "rmin": 0.0, - "rstep": 0.01, + "xmax": 100.0, + "xmin": 0.0, + "xstep": 0.01, "rpoly": 0.7 }, "e_186K.gr": { @@ -89,9 +89,9 @@ "qmaxinst": 25.0, "qmin": 0.4, "qmax": 25.0, - "rmax": 100.0, - "rmin": 0.0, - "rstep": 0.01, + "xmax": 100.0, + "xmin": 0.0, + "xstep": 0.01, "rpoly": 0.7 }, "f_180K.gr": { @@ -108,9 +108,9 @@ "qmaxinst": 25.0, "qmin": 0.4, "qmax": 25.0, - "rmax": 100.0, - "rmin": 0.0, - "rstep": 0.01, + "xmax": 100.0, + "xmin": 0.0, + "xstep": 0.01, "rpoly": 0.7 }, "g_174K.gr": { @@ -127,9 +127,9 @@ "qmaxinst": 25.0, "qmin": 0.4, "qmax": 25.0, - "rmax": 100.0, - "rmin": 0.0, - "rstep": 0.01, + "xmax": 100.0, + "xmin": 0.0, + "xstep": 0.01, "rpoly": 0.7 } } From 1a89bd5e51495eedee05abf64aa5a5d4dad5273c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Sep 2025 23:17:01 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit hooks --- CITATION.cff | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 9e2c37aa..65f37b8b 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -10,24 +10,24 @@ authors: family-names: Yang email: ayang2@caltech.edu affiliation: Caltech - orcid: 'https://orcid.org/0000-0003-0553-715X' + orcid: "https://orcid.org/0000-0003-0553-715X" - given-names: Christopher family-names: Farrow - orcid: 'https://orcid.org/0000-0001-5768-6654' + orcid: "https://orcid.org/0000-0001-5768-6654" - given-names: Chia-Hao family-names: Liu affiliation: Columbia University - orcid: 'https://orcid.org/0000-0002-3216-0354' + orcid: "https://orcid.org/0000-0002-3216-0354" - given-names: Luis family-names: Kitsu - orcid: 'https://orcid.org/0000-0002-9292-4416' + orcid: "https://orcid.org/0000-0002-9292-4416" affiliation: University of Colorado Boulder email: Luis.Kitsu@echemes.ethz.ch - given-names: Simon family-names: Billinge email: sb2896@columbia.edu affiliation: Columbia University - orcid: 'https://orcid.org/0000-0002-9734-4998' + orcid: "https://orcid.org/0000-0002-9734-4998" abstract: >- diffpy.morph is an open-source and free-to-use Python package that increases the insight researchers can obtain @@ -47,7 +47,7 @@ abstract: >- comparison. Other morphs are also possible such as corrections for nanoparticle shape effects on the PDF. diffpy.morph is model-independent and also could be used - on other non-diffraction spectra, though + on other non-diffraction spectra, though it has not been extensively tested beyond powder diffraction patterns and the PDF. keywords: From e1793ffbf8b5778361c543a0817428eb75eccd52 Mon Sep 17 00:00:00 2001 From: Sparks29032 Date: Tue, 23 Sep 2025 16:17:59 -0700 Subject: [PATCH 3/3] Add news --- news/refactor_pdf.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 news/refactor_pdf.rst diff --git a/news/refactor_pdf.rst b/news/refactor_pdf.rst new file mode 100644 index 00000000..4d24450b --- /dev/null +++ b/news/refactor_pdf.rst @@ -0,0 +1,25 @@ +**Added:** + +* + +**Changed:** + +* Changed tutorial language away from PDF-specific names +* Names of rmin, rmax, rstep renamed to xmin, xmax, xstep +* Removed PDF-specific labels from plotting functions + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +*