1+ """class MorphFuncy -- apply a user-supplied python function to the y-axis."""
2+
13from diffpy .morph .morphs .morph import LABEL_GR , LABEL_RA , Morph
24
35
46class MorphFuncy (Morph ):
5- """Apply the user-supplied Python function to the y-coordinates of the
6- morph data"""
7+ """General morph function that applies a user-supplied function to the
8+ y-coordinates of morph data to make it align with a target.
9+
10+ Configuration Variables
11+ -----------------------
12+ function: callable
13+ The user-supplied function that applies a transformation to the
14+ y-coordinates of the data.
15+
16+ parameters: dict
17+ A dictionary of parameters to pass to the function.
18+ These parameters are unpacked using **kwargs.
19+
20+ Returns
21+ -------
22+ A tuple (x_morph_out, y_morph_out, x_target_out, y_target_out)
23+ where the target values remain the same and the morph data is
24+ transformed according to the user-specified function and parameters
25+ The morphed data is returned on the same grid as the unmorphed data
26+
27+ Example
28+ -------
29+ Import the funcy morph function:
30+
31+ >>> from diffpy.morph.morphs.morphfuncy import MorphFuncy
32+
33+ Define or import the user-supplied transformation function:
34+
35+ >>> def sine_function(x, y, amplitude, frequency):
36+ >>> return amplitude * np.sin(frequency * x) * y
37+
38+ Provide initial guess for parameters:
39+
40+ >>> parameters = {'amplitude': 2, 'frequency': 2}
41+
42+ Run the funcy morph given input morph array (x_morph, y_morph)and target
43+ array (x_target, y_target):
44+
45+ >>> morph = MorphFuncy()
46+ >>> morph.function = sine_function
47+ >>> morph.funcy = parameters
48+ >>> x_morph_out, y_morph_out, x_target_out, y_target_out =
49+ ... morph.morph(x_morph, y_morph, x_target, y_target)
50+
51+ To access parameters from the morph instance:
52+
53+ >>> x_morph_in = morph.x_morph_in
54+ >>> y_morph_in = morph.y_morph_in
55+ >>> x_target_in = morph.x_target_in
56+ >>> y_target_in = morph.y_target_in
57+ >>> parameters_out = morph.funcy
58+ """
759
860 # Define input output types
961 summary = "Apply a Python function to the y-axis data"
@@ -14,53 +66,8 @@ class MorphFuncy(Morph):
1466 parnames = ["funcy" ]
1567
1668 def morph (self , x_morph , y_morph , x_target , y_target ):
17- """General morph function that applies a user-supplied function to the
18- y-coordinates of morph data to make it align with a target.
19-
20- Configuration Variables
21- -----------------------
22- function: callable
23- The user-supplied function that applies a transformation to the
24- y-coordinates of the data.
25-
26- parameters: dict
27- A dictionary of parameters to pass to the function.
28- These parameters are unpacked using **kwargs.
29-
30- Returns
31- -------
32- A tuple (x_morph_out, y_morph_out, x_target_out, y_target_out)
33- where the target values remain the same and the morph data is
34- transformed according to the user-specified function and parameters
35- The morphed data is returned on the same grid as the unmorphed data
36-
37- Example
38- -------
39- Import the funcy morph function:
40- >>> from diffpy.morph.morphs.morphfuncy import MorphFuncy
41-
42- Define or import the user-supplied transformation function:
43- >>> def sine_function(x, y, amplitude, frequency):
44- >>> return amplitude * np.sin(frequency * x) * y
45-
46- Provide initial guess for parameters:
47- >>> parameters = {'amplitude': 2, 'frequency': 2}
48-
49- Run the funcy morph given input morph array (x_morph, y_morph)
50- and target array (x_target, y_target):
51- >>> morph = MorphFuncy()
52- >>> morph.function = sine_function
53- >>> morph.funcy = parameters
54- >>> x_morph_out, y_morph_out, x_target_out, y_target_out = morph.morph(
55- ... x_morph, y_morph, x_target, y_target)
56-
57- To access parameters from the morph instance:
58- >>> x_morph_in = morph.x_morph_in
59- >>> y_morph_in = morph.y_morph_in
60- >>> x_target_in = morph.x_target_in
61- >>> y_target_in = morph.y_target_in
62- >>> parameters_out = morph.funcy
63- """
69+ """Apply the user-supplied Python function to the y-coordinates of the
70+ morph data"""
6471 Morph .morph (self , x_morph , y_morph , x_target , y_target )
6572
6673 self .y_morph_out = self .function (
0 commit comments