Skip to content

Commit bd16cd7

Browse files
committed
File add
1 parent 67eaa3b commit bd16cd7

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/diffpy/morph/pdfmorphpy.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python
2+
3+
##############################################################################
4+
#
5+
# diffpy.pdfmorph by DANSE Diffraction group
6+
# Simon J. L. Billinge
7+
# (c) 2010 Trustees of the Columbia University
8+
# in the City of New York. All rights reserved.
9+
#
10+
# File coded by: Andrew Yang
11+
#
12+
# See AUTHORS.txt for a list of people who contributed.
13+
# See LICENSE.txt for license information.
14+
#
15+
##############################################################################
16+
17+
from diffpy.pdfmorph.pdfmorphapp import create_option_parser, single_morph
18+
19+
20+
def pdfmorph(file1, file2, stdout_flag=False, **kwargs):
21+
"""Run PDFmorph at Python level.
22+
23+
Parameters
24+
----------
25+
file1: str
26+
Path-like object to the file to be morphed.
27+
file2: str
28+
Path-like object to the target file.
29+
kwargs: dict
30+
See the PDFmorph manual for options. Multiple morphs not supported.
31+
32+
Returns
33+
-------
34+
dict:
35+
Summary of morphs.
36+
x: array-like
37+
The r grid after the morph is applied.
38+
y: array-like
39+
The g(r) values after the morph is applied.
40+
"""
41+
42+
parser = create_option_parser()
43+
44+
inputs = []
45+
for key, value in kwargs.items():
46+
inputs.append(f"--{key}")
47+
inputs.append(f"{value}")
48+
(opts, pargs) = parser.parse_args(inputs)
49+
pargs = [file1, file2]
50+
51+
return single_morph(parser, opts, pargs, stdout_flag=stdout_flag, return_morph=True)

0 commit comments

Comments
 (0)