@@ -32,48 +32,67 @@ class PDFComponent(object):
32
32
"""Common base class."""
33
33
34
34
def __init__ (self , name ):
35
- """initialize
35
+ """initialize the object
36
36
37
- name -- object name
37
+ Parameter
38
+ ---------
39
+ name : str
40
+ object name
38
41
"""
39
42
self .name = name
40
43
41
44
def close (self , force = False ):
42
45
"""close myself
43
46
44
- force -- if forcibly (no wait)
47
+ Parameter
48
+ ---------
49
+ force : bool
50
+ Force to close if True, default is False.
45
51
"""
46
52
pass
47
53
48
54
49
55
class PDFDataSet (PDFComponent ):
50
56
"""PDFDataSet is a class for experimental PDF data.
51
57
52
- Data members:
53
- robs -- list of observed r points
54
- Gobs -- list of observed G values
55
- drobs -- list of standard deviations of robs
56
- dGobs -- list of standard deviations of Gobs
57
- stype -- scattering type, 'X' or 'N'
58
- qmax -- maximum value of Q in inverse Angstroms. Termination
59
- ripples are neglected for qmax=0.
60
- qdamp -- specifies width of Gaussian damping factor in pdf_obs due
61
- to imperfect Q resolution
62
- qbroad -- quadratic peak broadening factor related to dataset
63
- spdiameter -- particle diameter for shape damping function
64
- Note: This attribute was moved to PDFStructure.
65
- It is kept for backward compatibility when reading
66
- PDFgui project files.
67
- dscale -- scale factor of this dataset
68
- rmin -- same as robs[0]
69
- rmax -- same as robs[-1]
70
- filename -- set to absolute path after reading from file
71
- metadata -- dictionary for other experimental conditions, such as
72
- temperature or doping
73
-
74
- Global member:
75
- persistentItems -- list of attributes saved in project file
76
- refinableVars -- set (dict) of refinable variable names.
58
+ Attributes
59
+ ----------
60
+ robs : list
61
+ The list of observed r points.
62
+ Gobs : list
63
+ The list of observed G values.
64
+ drobs : list
65
+ The list of standard deviations of `robs`.
66
+ dGobs : list
67
+ The list of standard deviations of `Gobs`.
68
+ stype : str
69
+ The scattering type, either 'X' or 'N'.
70
+ qmax : float
71
+ The maximum value of Q in inverse Angstroms. Termination ripples are neglected for qmax=0.
72
+ qdamp : float
73
+ Specifies width of Gaussian damping factor in pdf_obs due to imperfect Q resolution.
74
+ qbroad : float
75
+ The quadratic peak broadening factor related to the dataset.
76
+ spdiameter : float
77
+ The particle diameter for shape damping function. Note: This attribute was moved to PDFStructure.
78
+ It is retained here for backward compatibility when reading PDFgui project files.
79
+ dscale : float
80
+ The scale factor of this dataset.
81
+ rmin : float
82
+ The same as `robs[0]`.
83
+ rmax : float
84
+ The same as `robs[-1]`.
85
+ filename : str
86
+ Set to the absolute path after reading from a file.
87
+ metadata : dict
88
+ The dictionary for other experimental conditions, such as temperature or doping.
89
+
90
+ Class Members
91
+ -------------
92
+ persistentItems : list
93
+ The list of attributes saved in the project file.
94
+ refinableVars : set
95
+ The set (or dict-like) of refinable variable names.
77
96
"""
78
97
79
98
persistentItems = [
@@ -95,14 +114,17 @@ class PDFDataSet(PDFComponent):
95
114
def __init__ (self , name ):
96
115
"""Initialize.
97
116
98
- name -- name of the data set. It must be a unique identifier.
117
+ name : str
118
+ The name of the data set. It must be a unique identifier.
99
119
"""
100
120
PDFComponent .__init__ (self , name )
101
121
self .clear ()
102
122
return
103
123
104
124
def clear (self ):
105
- """reset all data members to initial empty values"""
125
+ """reset all data members to initial empty values
126
+
127
+ The purpose of this method is to set the PDF dataset to initial empty values."""
106
128
self .robs = []
107
129
self .Gobs = []
108
130
self .drobs = []
@@ -121,12 +143,21 @@ def clear(self):
121
143
return
122
144
123
145
def setvar (self , var , value ):
124
- """Assign data member using PdfFit-style variable.
125
- Used by applyParameters().
146
+ """Assign a data member using PdfFit-style variable notation.
147
+ This method is typically utilized by the `applyParameters()` function.
148
+
149
+ Parameters
150
+ ----------
151
+ var : str
152
+ String representation of the dataset PdfFit variable.
153
+ Possible values include: 'qdamp', 'qbroad', 'dscale'.
154
+
155
+ value : float
156
+ The new value to which the variable `var` will be set.
126
157
127
- var -- string representation of dataset PdfFit variable.
128
- Possible values: qdamp, qbroad, dscale
129
- value -- new value of the variable
158
+ Returns
159
+ -------
160
+ None
130
161
"""
131
162
barevar = var .strip ()
132
163
fvalue = float (value )
@@ -141,10 +172,16 @@ def getvar(self, var):
141
172
"""Obtain value corresponding to PdfFit dataset variable.
142
173
Used by findParameters().
143
174
144
- var -- string representation of dataset PdfFit variable.
145
- Possible values: qdamp, qbroad, dscale
175
+ Parameters
176
+ ----------
177
+ var : str
178
+ string representation of dataset PdfFit variable.
179
+ Possible values: qdamp, qbroad, dscale
146
180
147
- returns value of var
181
+ Returns
182
+ -------
183
+ float
184
+ value of var
148
185
"""
149
186
barevar = var .strip ()
150
187
if barevar in PDFDataSet .refinableVars :
@@ -157,9 +194,12 @@ def getvar(self, var):
157
194
def read (self , filename ):
158
195
"""load data from PDFGetX2 or PDFGetN gr file
159
196
160
- filename -- file to read from
197
+ filename : str
198
+ file to read from
161
199
162
- returns self
200
+ Returns
201
+ -------
202
+ self
163
203
"""
164
204
try :
165
205
self .readStr (open (filename , "rb" ).read ())
@@ -176,9 +216,13 @@ def read(self, filename):
176
216
def readStr (self , datastring ):
177
217
"""read experimental PDF data from a string
178
218
179
- datastring -- string of raw data
219
+ Parameter
220
+ ---------
221
+ datastring : str
222
+ string of raw data
180
223
181
- returns self
224
+ Returns
225
+ self
182
226
"""
183
227
self .clear ()
184
228
# useful regex patterns:
@@ -299,9 +343,14 @@ def readStr(self, datastring):
299
343
def write (self , filename ):
300
344
"""Write experimental PDF data to a file.
301
345
302
- filename -- name of file to write to
346
+ Parameters
347
+ ----------
348
+ filename : str
349
+ name of file to write to
303
350
304
- No return value.
351
+ Returns
352
+ -------
353
+ None
305
354
"""
306
355
bytes = self .writeStr ()
307
356
f = open (filename , "w" )
@@ -312,7 +361,11 @@ def write(self, filename):
312
361
def writeStr (self ):
313
362
"""String representation of experimental PDF data.
314
363
315
- Return data string.
364
+
365
+ Returns
366
+ -------
367
+ str
368
+ The PDF data string.
316
369
"""
317
370
lines = []
318
371
# write metadata
@@ -357,8 +410,15 @@ def writeStr(self):
357
410
def copy (self , other = None ):
358
411
"""copy self to other. if other is None, create new instance
359
412
360
- other -- ref to other object
361
- returns reference to copied object
413
+ Parameters
414
+ ----------
415
+ other : PDFDataSet instance
416
+ ref to other object
417
+
418
+ Returns
419
+ -------
420
+ PDFDataSet instance
421
+ reference to copied object
362
422
"""
363
423
if other is None :
364
424
other = PDFDataSet (self .name )
0 commit comments