forked from diffpy/diffpy.srreal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbondcalculator.py
More file actions
80 lines (61 loc) · 2.19 KB
/
bondcalculator.py
File metadata and controls
80 lines (61 loc) · 2.19 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
##############################################################################
#
# diffpy.srreal by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2011 The Trustees of Columbia University
# in the City of New York. All rights reserved.
#
# File coded by: Pavol Juhas
#
# See AUTHORS.txt for a list of people who contributed.
# See LICENSE_DANSE.txt for license information.
#
##############################################################################
"""Class BondCalculator -- distances between atoms in the structure."""
# exported items, these also makes them show in pydoc.
__all__ = ["BondCalculator"]
from diffpy.srreal.srreal_ext import BondCalculator
from diffpy.srreal.wraputils import (
propertyFromExtDoubleAttr,
setattrFromKeywordArguments,
)
# property wrappers to C++ double attributes
BondCalculator.rmin = propertyFromExtDoubleAttr(
"rmin",
"""Lower bound for the bond distances.
[0 A]""",
)
BondCalculator.rmax = propertyFromExtDoubleAttr(
"rmax",
"""Upper bound for the bond distances.
[5 A]""",
)
# method overrides that support keyword arguments
def _init_kwargs(self, **kwargs):
"""Create a new instance of BondCalculator. Keyword arguments can be
used to configure calculator properties, for example:
bdc = BondCalculator(rmin=1.5, rmax=2.5)
Raise ValueError for invalid keyword argument.
"""
BondCalculator.__boostpython__init(self)
setattrFromKeywordArguments(self, **kwargs)
return
def _call_kwargs(self, structure=None, **kwargs):
"""Return sorted bond distances in the specified structure.
Attributes
----------
structure
structure to be evaluated, an instance of diffpy Structure
or pyobjcryst Crystal. Reuse the last structure when None.
kwargs
optional parameter settings for this calculator
Return a sorted numpy array.
"""
setattrFromKeywordArguments(self, **kwargs)
self.eval(structure)
return self.distances
BondCalculator.__boostpython__init = BondCalculator.__init__
BondCalculator.__init__ = _init_kwargs
BondCalculator.__call__ = _call_kwargs
# End of file