-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathpdffitstructure.py
More file actions
127 lines (106 loc) · 3.73 KB
/
pdffitstructure.py
File metadata and controls
127 lines (106 loc) · 3.73 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env python
##############################################################################
#
# diffpy.structure by DANSE Diffraction group
# Simon J. L. Billinge
# (c) 2006 trustees of the Michigan State University.
# 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.
#
##############################################################################
"""Definition of PDFFitStructure class derived from Structure."""
from diffpy.structure.structure import Structure
from diffpy.utils._deprecator import build_deprecation_message, deprecated
base = "diffpy.structure.PDFFitStructure"
removal_version = "4.0.0"
readStr_deprecation_msg = build_deprecation_message(
base,
"readStr",
"read_structure",
removal_version,
)
# ----------------------------------------------------------------------------
class PDFFitStructure(Structure):
"""PDFFitStructure --> Structure with extra pdffit member.
Parameters
----------
*args, **kwargs :
See `Structure` class constructor.
Attributes
----------
pdffit : dict
Dictionary for storing following extra parameters from
PDFFit structure files:
`'scale', 'delta1', 'delta2', 'sratio',
'rcut', 'spcgr', 'dcell', 'ncell'`
"""
def __init__(self, *args, **kwargs):
self.pdffit = {
"scale": 1.0,
"delta1": 0.0,
"delta2": 0.0,
"sratio": 1.0,
"rcut": 0.0,
"spcgr": "P1",
"spdiameter": 0.0,
"stepcut": 0.0,
"dcell": 6 * [0.0],
"ncell": [1, 1, 1, 0],
}
Structure.__init__(self, *args, **kwargs)
return
def read(self, filename, format="auto"):
"""Same as `Structure.read`, but update `spcgr` value in
`self.pdffit` when parser can get spacegroup.
See `Structure.read()` for more info.
Parameters
----------
filename : str
File to be loaded.
format : str, Optional
All structure formats are defined in parsers submodule,
when ``format == 'auto'`` all parsers are tried one by one.
Return
------
StructureParser
Instance of StructureParser used to load the data.
"""
p = Structure.read(self, filename, format)
sg = getattr(p, "spacegroup", None)
if sg:
self.pdffit["spcgr"] = sg.short_name
return p
@deprecated(readStr_deprecation_msg)
def readStr(self, s, format="auto"):
"""'diffpy.structure.PDFFitStructure.readStr' is deprecated and
will be removed in version 4.0.0.
Please use 'diffpy.structure.PDFFitStructure.read_structure'
instead.
"""
return self.read_structure(s, format)
def read_structure(self, s, format="auto"):
"""Same as `Structure.readStr`, but update `spcgr` value in
`self.pdffit` when parser can get spacegroup.
See `Structure.readStr()` for more info.
Parameters
----------
s : str
String with structure definition.
format : str, Optional
All structure formats are defined in parsers submodule. When ``format == 'auto'``,
all parsers are tried one by one.
Return
------
StructureParser
Instance of `StructureParser` used to load the data.
"""
p = Structure.read_structure(self, s, format)
sg = getattr(p, "spacegroup", None)
if sg:
self.pdffit["spcgr"] = sg.short_name
return p
# End of class PDFFitStructure