diffpy.srreal 1.4.0__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diffpy/__init__.py +22 -0
- diffpy/srreal/__init__.py +23 -0
- diffpy/srreal/_cleanup.py +82 -0
- diffpy/srreal/_docstrings.py +171 -0
- diffpy/srreal/_final_imports.py +51 -0
- diffpy/srreal/atomradiitable.py +81 -0
- diffpy/srreal/attributes.py +70 -0
- diffpy/srreal/bondcalculator.py +80 -0
- diffpy/srreal/bvparameterstable.py +24 -0
- diffpy/srreal/bvscalculator.py +98 -0
- diffpy/srreal/devutils/tunePeakPrecision.py +216 -0
- diffpy/srreal/eventticker.py +24 -0
- diffpy/srreal/overlapcalculator.py +88 -0
- diffpy/srreal/pairquantity.py +24 -0
- diffpy/srreal/parallel.py +238 -0
- diffpy/srreal/pdfbaseline.py +106 -0
- diffpy/srreal/pdfcalculator.py +335 -0
- diffpy/srreal/pdfenvelope.py +136 -0
- diffpy/srreal/peakprofile.py +54 -0
- diffpy/srreal/peakwidthmodel.py +78 -0
- diffpy/srreal/scatteringfactortable.py +47 -0
- diffpy/srreal/sfaverage.py +170 -0
- diffpy/srreal/srreal_ext.cp313-win_amd64.pyd +0 -0
- diffpy/srreal/structureadapter.py +133 -0
- diffpy/srreal/structureconverters.py +174 -0
- diffpy/srreal/version.py +31 -0
- diffpy/srreal/wraputils.py +177 -0
- diffpy_srreal-1.4.0.dist-info/METADATA +189 -0
- diffpy_srreal-1.4.0.dist-info/RECORD +34 -0
- diffpy_srreal-1.4.0.dist-info/WHEEL +5 -0
- diffpy_srreal-1.4.0.dist-info/licenses/AUTHORS.rst +12 -0
- diffpy_srreal-1.4.0.dist-info/licenses/LICENSE.rst +142 -0
- diffpy_srreal-1.4.0.dist-info/licenses/LICENSE_DANSE.rst +42 -0
- diffpy_srreal-1.4.0.dist-info/top_level.txt +1 -0
diffpy/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# (c) 2025 The Trustees of Columbia University in the City of New York.
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
#
|
|
7
|
+
# File coded by: Billinge Group members and community contributors.
|
|
8
|
+
#
|
|
9
|
+
# See GitHub contributions for a more detailed list of contributors.
|
|
10
|
+
# https://github.com/diffpy/diffpy.srreal/graphs/contributors
|
|
11
|
+
#
|
|
12
|
+
# See LICENSE.rst for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Blank namespace package for module diffpy."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
from pkgutil import extend_path
|
|
19
|
+
|
|
20
|
+
__path__ = extend_path(__path__, __name__)
|
|
21
|
+
|
|
22
|
+
# End of file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# (c) 2025 The Trustees of Columbia University in the City of New York.
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
#
|
|
7
|
+
# File coded by: Billinge Group members and community contributors.
|
|
8
|
+
#
|
|
9
|
+
# See GitHub contributions for a more detailed list of contributors.
|
|
10
|
+
# https://github.com/diffpy/diffpy.srreal/graphs/contributors
|
|
11
|
+
#
|
|
12
|
+
# See LICENSE.rst for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Tools for real space structure analysis."""
|
|
16
|
+
|
|
17
|
+
# package version
|
|
18
|
+
from diffpy.srreal.version import __version__
|
|
19
|
+
|
|
20
|
+
# silence the pyflakes syntax checker
|
|
21
|
+
assert __version__ or True
|
|
22
|
+
|
|
23
|
+
# End of file
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal Complex Modeling Initiative
|
|
5
|
+
# (c) 2016 Brookhaven Science Associates,
|
|
6
|
+
# Brookhaven National Laboratory.
|
|
7
|
+
# All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Cancel registration of Python-extended C++ classes when Python exits.
|
|
16
|
+
|
|
17
|
+
Note
|
|
18
|
+
----
|
|
19
|
+
Python finishes before the shared library libdiffpy, but the registry of
|
|
20
|
+
class prototypes is implemented in libdiffpy. Any Python-extended classes
|
|
21
|
+
thus need to be removed from the registry prior to Python exit.
|
|
22
|
+
|
|
23
|
+
This module is not intended for direct use. It is used implicitly within
|
|
24
|
+
a call of _registerThisType.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
import atexit
|
|
29
|
+
import weakref
|
|
30
|
+
|
|
31
|
+
# Routine to be used from srreal_ext module ----------------------------------
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def registerForCleanUp(obj):
|
|
35
|
+
"""Remember to clean up the specified prototype at Python exit.
|
|
36
|
+
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
obj : wrapped class that has class registry
|
|
40
|
+
This is an object being added to the C++ registry of prototypes.
|
|
41
|
+
If active at Python exit, the associated string type will be
|
|
42
|
+
removed from the class registry.
|
|
43
|
+
|
|
44
|
+
No return value.
|
|
45
|
+
"""
|
|
46
|
+
_cleanup_handler.add(obj)
|
|
47
|
+
return
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# ----------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class _DerivedClassesCleanUpHandler(object):
|
|
54
|
+
|
|
55
|
+
def __init__(self):
|
|
56
|
+
self._references = set()
|
|
57
|
+
return
|
|
58
|
+
|
|
59
|
+
def add(self, obj):
|
|
60
|
+
wr = weakref.ref(obj)
|
|
61
|
+
self._references.add(wr)
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
def clean(self):
|
|
65
|
+
while self._references:
|
|
66
|
+
wr = self._references.pop()
|
|
67
|
+
obj = wr()
|
|
68
|
+
if obj is not None:
|
|
69
|
+
obj._deregisterType(obj.type())
|
|
70
|
+
return
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# end of class _DerivedClassesCleanUpHandler
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# create singleton instance of the cleanup handler
|
|
77
|
+
_cleanup_handler = _DerivedClassesCleanUpHandler()
|
|
78
|
+
atexit.register(_cleanup_handler.clean)
|
|
79
|
+
|
|
80
|
+
del _DerivedClassesCleanUpHandler
|
|
81
|
+
|
|
82
|
+
# End of file.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal Complex Modeling Initiative
|
|
5
|
+
# (c) 2016 Brookhaven Science Associates,
|
|
6
|
+
# Brookhaven National Laboratory.
|
|
7
|
+
# All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Docstrings for classes and functions in srreal_ext module."""
|
|
16
|
+
|
|
17
|
+
# Shared docstrings for classes derived from HasClassRegistry ----------------
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_registry_docstrings(cls):
|
|
21
|
+
"""Build a dictionary of docstrings per each HasClassRegistry
|
|
22
|
+
method.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
cls : class type that is wrapped
|
|
27
|
+
This parameter is used to extract the class name and substitute
|
|
28
|
+
it in the docstrings template.
|
|
29
|
+
|
|
30
|
+
Returns a dictionary mapping Python method names to their docstrins.
|
|
31
|
+
"""
|
|
32
|
+
n = cls.__name__
|
|
33
|
+
rv = {
|
|
34
|
+
k: v.replace("@NAME@", n)
|
|
35
|
+
for k, v in (
|
|
36
|
+
("create", doc_HasClassRegistry_create),
|
|
37
|
+
("clone", doc_HasClassRegistry_clone),
|
|
38
|
+
("type", doc_HasClassRegistry_type),
|
|
39
|
+
("_registerThisType", doc_HasClassRegistry__registerThisType),
|
|
40
|
+
("_aliasType", doc_HasClassRegistry__aliasType),
|
|
41
|
+
("_deregisterType", doc_HasClassRegistry__deregisterType),
|
|
42
|
+
("createByType", doc_HasClassRegistry_createByType),
|
|
43
|
+
("isRegisteredType", doc_HasClassRegistry_isRegisteredType),
|
|
44
|
+
("getAliasedTypes", doc_HasClassRegistry_getAliasedTypes),
|
|
45
|
+
("getRegisteredTypes", doc_HasClassRegistry_getRegisteredTypes),
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
return rv
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
doc_HasClassRegistry_create = """\
|
|
52
|
+
Return a new instance of the same type as self.
|
|
53
|
+
|
|
54
|
+
This method must be overloaded in a derived class.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
doc_HasClassRegistry_clone = """\
|
|
59
|
+
Return a new instance that is a copy of self.
|
|
60
|
+
|
|
61
|
+
This method must be overloaded in a derived class.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
doc_HasClassRegistry_type = """\
|
|
66
|
+
Return a unique string type that identifies a @NAME@-derived class.
|
|
67
|
+
The string type is used for class registration and in the `createByType`
|
|
68
|
+
function.
|
|
69
|
+
|
|
70
|
+
This method must be overloaded in a derived class.
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
doc_HasClassRegistry__registerThisType = """\
|
|
75
|
+
Add this class to the global registry of @NAME@ types.
|
|
76
|
+
|
|
77
|
+
This method must be called once after definition of the derived
|
|
78
|
+
class to support pickling and the `createByType` factory.
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
doc_HasClassRegistry__aliasType = """\
|
|
83
|
+
Register the specified class type under another string alias.
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
tp : str
|
|
88
|
+
string type identifying a registered @NAME@ class.
|
|
89
|
+
alias : str
|
|
90
|
+
string alias to be used for the `tp` type.
|
|
91
|
+
|
|
92
|
+
Raises
|
|
93
|
+
------
|
|
94
|
+
RuntimeError
|
|
95
|
+
When they `tp` type is unknown or if the `alias` type is already
|
|
96
|
+
registered.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
doc_HasClassRegistry__deregisterType = """\
|
|
101
|
+
Cancel registration of the specified string type and any of its aliases.
|
|
102
|
+
|
|
103
|
+
Parameters
|
|
104
|
+
----------
|
|
105
|
+
tp : str
|
|
106
|
+
string type or an alias of a registered @NAME@ class.
|
|
107
|
+
|
|
108
|
+
Returns
|
|
109
|
+
-------
|
|
110
|
+
count : int
|
|
111
|
+
Number of unregistered names or aliases.
|
|
112
|
+
Return 0 if `tp` is not a registered type.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
doc_HasClassRegistry_createByType = """\
|
|
117
|
+
Return a new @NAME@ instance of the specified string type.
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
tp : str
|
|
122
|
+
string type identifying a registered @NAME@ class.
|
|
123
|
+
|
|
124
|
+
Returns
|
|
125
|
+
-------
|
|
126
|
+
@NAME@
|
|
127
|
+
A new instance of the @NAME@-derived class named `tp`.
|
|
128
|
+
|
|
129
|
+
See Also
|
|
130
|
+
--------
|
|
131
|
+
getRegisteredTypes : Return set of the recognized type strings.
|
|
132
|
+
getAliasedTypes : Return dictionary of string aliases.
|
|
133
|
+
"""
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
doc_HasClassRegistry_isRegisteredType = """\
|
|
137
|
+
Check if the given string is registered as a named @NAME@ type.
|
|
138
|
+
|
|
139
|
+
Parameters
|
|
140
|
+
----------
|
|
141
|
+
tp : str
|
|
142
|
+
string name or an alias to be checked.
|
|
143
|
+
|
|
144
|
+
Returns
|
|
145
|
+
-------
|
|
146
|
+
bool
|
|
147
|
+
``True`` if `tp` is known to the registry either as a standard
|
|
148
|
+
type or its alias.
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
doc_HasClassRegistry_getAliasedTypes = """\
|
|
153
|
+
Get all aliases registered for the @NAME@ string types.
|
|
154
|
+
|
|
155
|
+
Returns
|
|
156
|
+
-------
|
|
157
|
+
dict
|
|
158
|
+
a map of registered aliases to their corresponding standard names.
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
doc_HasClassRegistry_getRegisteredTypes = """\
|
|
163
|
+
Get string types of all registered @NAME@ classes.
|
|
164
|
+
|
|
165
|
+
These are the allowed arguments for the `createByType` factory.
|
|
166
|
+
|
|
167
|
+
Returns
|
|
168
|
+
-------
|
|
169
|
+
set
|
|
170
|
+
the registered string types.
|
|
171
|
+
"""
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal Complex Modeling Initiative
|
|
5
|
+
# (c) 2016 Brookhaven Science Associates,
|
|
6
|
+
# Brookhaven National Laboratory.
|
|
7
|
+
# All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Finalize tweak of classes from the extension module srreal_ext.
|
|
16
|
+
|
|
17
|
+
This private module handles loading of Python-level tweaks of the
|
|
18
|
+
extension-defined classes. Any client that imports this module
|
|
19
|
+
must call the `import_now` function. If this module is not loaded
|
|
20
|
+
by the time of srreal_ext initialization, `import_now` is executed
|
|
21
|
+
from srreal_ext.
|
|
22
|
+
|
|
23
|
+
This avoids unresolvable import dependencies for any order of imports.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def import_now():
|
|
28
|
+
"""Import all Python modules that tweak extension-defined
|
|
29
|
+
classes."""
|
|
30
|
+
global _import_now_called
|
|
31
|
+
if _import_now_called:
|
|
32
|
+
return
|
|
33
|
+
_import_now_called = True
|
|
34
|
+
from importlib import import_module
|
|
35
|
+
|
|
36
|
+
import_module("diffpy.srreal.attributes")
|
|
37
|
+
import_module("diffpy.srreal.atomradiitable")
|
|
38
|
+
import_module("diffpy.srreal.bondcalculator")
|
|
39
|
+
import_module("diffpy.srreal.bvscalculator")
|
|
40
|
+
import_module("diffpy.srreal.overlapcalculator")
|
|
41
|
+
import_module("diffpy.srreal.pdfbaseline")
|
|
42
|
+
import_module("diffpy.srreal.pdfenvelope")
|
|
43
|
+
import_module("diffpy.srreal.peakprofile")
|
|
44
|
+
import_module("diffpy.srreal.peakwidthmodel")
|
|
45
|
+
import_module("diffpy.srreal.scatteringfactortable")
|
|
46
|
+
import_module("diffpy.srreal.pdfcalculator")
|
|
47
|
+
import_module("diffpy.srreal.structureconverters")
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
_import_now_called = False
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal by DANSE Diffraction group
|
|
5
|
+
# Simon J. L. Billinge
|
|
6
|
+
# (c) 2011 The Trustees of Columbia University
|
|
7
|
+
# in the City of New York. All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE_DANSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Class AtomRadiiTable -- storage of empirical atom radii."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# exported items, these also makes them show in pydoc.
|
|
19
|
+
__all__ = ["AtomRadiiTable", "ConstantRadiiTable", "CovalentRadiiTable"]
|
|
20
|
+
|
|
21
|
+
from diffpy.srreal.srreal_ext import AtomRadiiTable, ConstantRadiiTable
|
|
22
|
+
|
|
23
|
+
# class CovalentRadiiTable ---------------------------------------------------
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class CovalentRadiiTable(AtomRadiiTable):
|
|
27
|
+
"""Covalent radii from Cordero et al., 2008, doi:10.1039/b801115j.
|
|
28
|
+
|
|
29
|
+
Instantiation of this class requires the periodictable module.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
# class variable that holds the periodictable.elements object
|
|
33
|
+
_elements = None
|
|
34
|
+
|
|
35
|
+
def _standardLookup(self, smbl):
|
|
36
|
+
"""Return covalent atom radius in Angstroms.
|
|
37
|
+
|
|
38
|
+
Attributes
|
|
39
|
+
----------
|
|
40
|
+
smbl
|
|
41
|
+
string symbol of an element
|
|
42
|
+
|
|
43
|
+
Return float. Raise ValueError for unknown element symbol.
|
|
44
|
+
"""
|
|
45
|
+
if CovalentRadiiTable._elements is None:
|
|
46
|
+
from periodictable import elements
|
|
47
|
+
|
|
48
|
+
CovalentRadiiTable._elements = elements
|
|
49
|
+
e = self._elements.isotope(smbl)
|
|
50
|
+
rv = e.covalent_radius
|
|
51
|
+
if rv is None:
|
|
52
|
+
emsg = "Undefined covalent radius for %r." % smbl
|
|
53
|
+
raise ValueError(emsg)
|
|
54
|
+
return rv
|
|
55
|
+
|
|
56
|
+
# HasClassRegistry overloads:
|
|
57
|
+
|
|
58
|
+
def create(self):
|
|
59
|
+
"""Create new instance of the CovalentRadiiTable."""
|
|
60
|
+
return CovalentRadiiTable()
|
|
61
|
+
|
|
62
|
+
def clone(self):
|
|
63
|
+
"""Return a new duplicate instance of self."""
|
|
64
|
+
import copy
|
|
65
|
+
|
|
66
|
+
return copy.copy(self)
|
|
67
|
+
|
|
68
|
+
def type(self):
|
|
69
|
+
"""Unique string identifier of the CovalentRadiiTable type. This
|
|
70
|
+
is used for class registration and as an argument for the
|
|
71
|
+
createByType function.
|
|
72
|
+
|
|
73
|
+
Return string.
|
|
74
|
+
"""
|
|
75
|
+
return "covalent"
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# End of class CovalentRadiiTable
|
|
79
|
+
CovalentRadiiTable()._registerThisType()
|
|
80
|
+
|
|
81
|
+
# End of file
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal by DANSE Diffraction group
|
|
5
|
+
# Simon J. L. Billinge
|
|
6
|
+
# (c) 2010 The Trustees of Columbia University
|
|
7
|
+
# in the City of New York. All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE_DANSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""class Attributes -- wrapper to C++ class diffpy::Attributes
|
|
16
|
+
A base to PairQuantity and quite a few other classes.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
__all__ = ["Attributes"]
|
|
20
|
+
|
|
21
|
+
from diffpy.srreal.srreal_ext import Attributes
|
|
22
|
+
|
|
23
|
+
# Inject the __getattr__ and __setattr__ methods to the Attributes class
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _getattr(self, name):
|
|
27
|
+
"""Lookup a C++ double attribute if standard Python lookup fails.
|
|
28
|
+
|
|
29
|
+
Raise AttributeError if C++ double attribute does not exist.
|
|
30
|
+
"""
|
|
31
|
+
rv = self._getDoubleAttr(name)
|
|
32
|
+
return rv
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
Attributes.__getattr__ = _getattr
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _setattr(self, name, value):
|
|
39
|
+
"""Assign to C++ double attribute if Python attribute does not
|
|
40
|
+
exist."""
|
|
41
|
+
try:
|
|
42
|
+
object.__getattribute__(self, name)
|
|
43
|
+
except AttributeError:
|
|
44
|
+
if self._hasDoubleAttr(name):
|
|
45
|
+
self._setDoubleAttr(name, value)
|
|
46
|
+
return
|
|
47
|
+
object.__setattr__(self, name, value)
|
|
48
|
+
return
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
Attributes.__setattr__ = _setattr
|
|
52
|
+
|
|
53
|
+
# Helper accessor functions used by the _registerDoubleAttribute method
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _pyattrgetter(name):
|
|
57
|
+
def f(obj):
|
|
58
|
+
return object.__getattribute__(obj, name)
|
|
59
|
+
|
|
60
|
+
return f
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _pyattrsetter(name):
|
|
64
|
+
def f(obj, value):
|
|
65
|
+
object.__setattr__(obj, name, value)
|
|
66
|
+
|
|
67
|
+
return f
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# End of file
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal by DANSE Diffraction group
|
|
5
|
+
# Simon J. L. Billinge
|
|
6
|
+
# (c) 2011 The Trustees of Columbia University
|
|
7
|
+
# in the City of New York. All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE_DANSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Class BondCalculator -- distances between atoms in the structure."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# exported items, these also makes them show in pydoc.
|
|
19
|
+
__all__ = ["BondCalculator"]
|
|
20
|
+
|
|
21
|
+
from diffpy.srreal.srreal_ext import BondCalculator
|
|
22
|
+
from diffpy.srreal.wraputils import (
|
|
23
|
+
propertyFromExtDoubleAttr,
|
|
24
|
+
setattrFromKeywordArguments,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# property wrappers to C++ double attributes
|
|
28
|
+
|
|
29
|
+
BondCalculator.rmin = propertyFromExtDoubleAttr(
|
|
30
|
+
"rmin",
|
|
31
|
+
"""Lower bound for the bond distances.
|
|
32
|
+
[0 A]""",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
BondCalculator.rmax = propertyFromExtDoubleAttr(
|
|
36
|
+
"rmax",
|
|
37
|
+
"""Upper bound for the bond distances.
|
|
38
|
+
[5 A]""",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# method overrides that support keyword arguments
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _init_kwargs(self, **kwargs):
|
|
46
|
+
"""Create a new instance of BondCalculator. Keyword arguments can be
|
|
47
|
+
used to configure calculator properties, for example:
|
|
48
|
+
|
|
49
|
+
bdc = BondCalculator(rmin=1.5, rmax=2.5)
|
|
50
|
+
|
|
51
|
+
Raise ValueError for invalid keyword argument.
|
|
52
|
+
"""
|
|
53
|
+
BondCalculator.__boostpython__init(self)
|
|
54
|
+
setattrFromKeywordArguments(self, **kwargs)
|
|
55
|
+
return
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _call_kwargs(self, structure=None, **kwargs):
|
|
59
|
+
"""Return sorted bond distances in the specified structure.
|
|
60
|
+
|
|
61
|
+
Attributes
|
|
62
|
+
----------
|
|
63
|
+
structure
|
|
64
|
+
structure to be evaluated, an instance of diffpy Structure
|
|
65
|
+
or pyobjcryst Crystal. Reuse the last structure when None.
|
|
66
|
+
kwargs
|
|
67
|
+
optional parameter settings for this calculator
|
|
68
|
+
|
|
69
|
+
Return a sorted numpy array.
|
|
70
|
+
"""
|
|
71
|
+
setattrFromKeywordArguments(self, **kwargs)
|
|
72
|
+
self.eval(structure)
|
|
73
|
+
return self.distances
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
BondCalculator.__boostpython__init = BondCalculator.__init__
|
|
77
|
+
BondCalculator.__init__ = _init_kwargs
|
|
78
|
+
BondCalculator.__call__ = _call_kwargs
|
|
79
|
+
|
|
80
|
+
# End of file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
##############################################################################
|
|
3
|
+
#
|
|
4
|
+
# diffpy.srreal by DANSE Diffraction group
|
|
5
|
+
# Simon J. L. Billinge
|
|
6
|
+
# (c) 2011 The Trustees of Columbia University
|
|
7
|
+
# in the City of New York. All rights reserved.
|
|
8
|
+
#
|
|
9
|
+
# File coded by: Pavol Juhas
|
|
10
|
+
#
|
|
11
|
+
# See AUTHORS.txt for a list of people who contributed.
|
|
12
|
+
# See LICENSE_DANSE.txt for license information.
|
|
13
|
+
#
|
|
14
|
+
##############################################################################
|
|
15
|
+
"""Class BVParametersTable -- storage of bond valence parameters class BVParam
|
|
16
|
+
-- bond valence data associated with specific cation-anion pair."""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# exported items, these also makes them show in pydoc.
|
|
20
|
+
__all__ = ["BVParam", "BVParametersTable"]
|
|
21
|
+
|
|
22
|
+
from diffpy.srreal.srreal_ext import BVParam, BVParametersTable
|
|
23
|
+
|
|
24
|
+
# End of file
|