forked from diffpy/diffpy.morph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransformrdftopdf.py
More file actions
64 lines (51 loc) · 2.16 KB
/
transformrdftopdf.py
File metadata and controls
64 lines (51 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
##############################################################################
#
# diffpy.morph by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2010 Trustees of the Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Chris Farrow
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSE.txt for license information.
#
##############################################################################
"""Class TransformXtalRDFtoPDF -- Transform crystal RDFs to PDFs."""
import numpy
from diffpy.morph.morphs.morph import LABEL_GR, LABEL_RA, LABEL_RR, Morph
class TransformXtalRDFtoPDF(Morph):
"""Transform crystal RDFs to PDFs.
Converts both morph data and target data RDFs to PDFs.
Configuration variables:
baselineslope -- The slope of the PDF baseline. With the perfect scale,
the baseline slope is equal to -4*pi*rho0, where rho0
is the density of the crystalline sample.
With s = baselineslope,
G(r) = R(r) / r + r * s
"""
# Define input output types
summary = "Turn the PDF into the RDF for both the morph and target"
xinlabel = LABEL_RA
yinlabel = LABEL_RR
xoutlabel = LABEL_RA
youtlabel = LABEL_GR
parnames = ["baselineslope"]
def morph(self, x_morph, y_morph, x_target, y_target):
"""Return corresponding PDF given RDF."""
Morph.morph(self, x_morph, y_morph, x_target, y_target)
morph_baseline = self.baselineslope * self.x_morph_in
target_baseline = self.baselineslope * self.x_target_in
with numpy.errstate(divide="ignore", invalid="ignore"):
self.y_target_out = (
self.y_target_in / self.x_target_in + target_baseline
)
self.y_target_out[self.x_target_in == 0] = 0
with numpy.errstate(divide="ignore", invalid="ignore"):
self.y_morph_out = (
self.y_morph_in / self.x_morph_in + morph_baseline
)
self.y_morph_out[self.x_target_in == 0] = 0
return self.xyallout
# End of class MorphScale