Skip to content

Commit f49f787

Browse files
committed
Add funcxy, funcx
# Conflicts: # src/diffpy/morph/morphs/morphfuncx.py
1 parent cb3a404 commit f49f787

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

src/diffpy/morph/morphs/morphfuncx.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@ class MorphFuncx(Morph):
1111
General morph function that applies a user-supplied function to the
1212
x-coordinates of morph data to make it align with a target.
1313
14-
Notice: the function provided must preserve the monotonic
15-
increase of the grid.
16-
I.e. the function f applied on the grid x must ensure for all
17-
indices i<j, f(x[i]) < f(x[j]).
14+
Notice: the morph should maintain the monotonicity of the grid.
1815
1916
Configuration Variables
2017
-----------------------
2118
function: callable
2219
The user-supplied function that applies a transformation to the
23-
x-coordinates of the data.
20+
y-coordinates of the data.
2421
2522
parameters: dict
2623
A dictionary of parameters to pass to the function.
@@ -32,31 +29,27 @@ class MorphFuncx(Morph):
3229
transformed according to the user-specified function and parameters
3330
The morphed data is returned on the same grid as the unmorphed data
3431
35-
Example
36-
-------
37-
Import the funcx morph function:
32+
Example (FIX)
33+
-------------
34+
Import the funcy morph function:
3835
39-
>>> from diffpy.morph.morphs.morphfuncx import MorphFuncx
36+
>>> from diffpy.morph.morphs.morphfuncy import MorphFuncy
4037
4138
Define or import the user-supplied transformation function:
4239
43-
>>> import numpy as np
44-
>>> def exp_function(x, y, scale, rate):
45-
>>> return abs(scale) * np.exp(rate * x)
46-
47-
Note that this transformation is monotonic increasing, so will preserve
48-
the monotonic increasing nature of the provided grid.
40+
>>> def sine_function(x, y, amplitude, frequency):
41+
>>> return amplitude * np.sin(frequency * x) * y
4942
5043
Provide initial guess for parameters:
5144
52-
>>> parameters = {'scale': 1, 'rate': 1}
45+
>>> parameters = {'amplitude': 2, 'frequency': 2}
5346
5447
Run the funcy morph given input morph array (x_morph, y_morph)and target
5548
array (x_target, y_target):
5649
57-
>>> morph = MorphFuncx()
58-
>>> morph.funcx_function = exp_function
59-
>>> morph.funcx = parameters
50+
>>> morph = MorphFuncy()
51+
>>> morph.function = sine_function
52+
>>> morph.funcy = parameters
6053
>>> x_morph_out, y_morph_out, x_target_out, y_target_out =
6154
... morph.morph(x_morph, y_morph, x_target, y_target)
6255
@@ -70,7 +63,7 @@ class MorphFuncx(Morph):
7063
"""
7164

7265
# Define input output types
73-
summary = "Apply a Python function to the x-axis data"
66+
summary = "Apply a Python function to the y-axis data"
7467
xinlabel = LABEL_RA
7568
yinlabel = LABEL_GR
7669
xoutlabel = LABEL_RA

0 commit comments

Comments
 (0)