@@ -171,24 +171,27 @@ def defaultvars(self, *args):
171
171
"""Set unset(=None) extraction variables to default values.
172
172
173
173
Certain variables may be partially set for convenience, and are transformed
174
- appropriately. See 'Default values' below.
174
+ appropriately. See 'Default values assigned ' below.
175
175
176
176
Parameters
177
- Any number of strings corresponding to extraction variables. These
178
- variables are reset to their default values even if another value
179
- already exists.
180
-
181
- Default values:
182
- cres -> 4 times the average spacing between elements in x
183
- effective_dy -> The data dy if all elements > 0, otherwise 5% of max(y)-min(y).
184
- If effective_dy is a positive scalar, then an array of that
185
- value of appropriate length.
186
- pf -> [GaussianOverR(maxwidth=x[-1]-x[0])]
187
- baseline -> Flat baseline located at y=0.
188
- error_method -> AIC (Aikake Information Criterion)
189
- initial_peaks -> No initial peaks
190
- rng -> [x[0], x[-1]]. Partially set ranges like [None, 100.] replace None with
191
- the appropriate limit in the data.
177
+ ----------
178
+ *args : str
179
+ The variable argument list where each string corresponds to an extraction
180
+ variable name.
181
+
182
+ Default values assigned:
183
+ - `cres` : 4 times the average spacing between elements in `x`.
184
+ - `effective_dy` : If all elements in `y` are positive, it's set to the data `dy`;
185
+ otherwise, it's 5% of the range (`max(y)` - `min(y)`). If `effective_dy`
186
+ is a positive scalar, an array of that value with a length matching `y` is used.
187
+ - `pf` : A list containing a single Gaussian overlap function with the maximum width
188
+ spanning the entire `x` range (`x[-1] - x[0]`).
189
+ - `baseline` : A flat baseline at `y=0`, indicating no background signal.
190
+ - `error_method` : Uses the AIC (Akaike Information Criterion) for evaluating model fits.
191
+ - `initial_peaks` : Assumes no initial peak guesses, implying peaks will be detected from scratch.
192
+ - `rng` : The default range is set to span the entire `x` dataset, i.e., `[x[0], x[-1]]`.
193
+ If a range is partially defined, e.g., `[None, 100.]`, the `None` value is replaced
194
+ with the respective boundary of the `x` data.
192
195
193
196
Note that the default values of very important parameters like the uncertainty
194
197
and clustering resolution are crude guesses at best.
@@ -264,7 +267,13 @@ def plot(self, **kwds):
264
267
265
268
Uses initial peaks instead if no peaks have been extracted.
266
269
267
- Takes same keywords as ModelCluster.plottable()"""
270
+ Takes same keywords as ModelCluster.plottable()
271
+
272
+ Parameters
273
+ ----------
274
+ **kwds :args
275
+ The keyword arguments to pass to matplotlib.
276
+ """
268
277
plt .clf ()
269
278
if self .extracted is not None :
270
279
plt .plot (* self .extracted .plottable (kwds ))
@@ -292,9 +301,14 @@ def plot(self, **kwds):
292
301
def read (self , filename ):
293
302
"""load PeakExtraction object from file
294
303
295
- filename -- file from which to read
304
+ Parameters
305
+ ----------
306
+ filename : str
307
+ The file from which to read
296
308
297
- returns self
309
+ Returns
310
+ -------
311
+ self
298
312
"""
299
313
try :
300
314
self .readstr (open (filename , "rb" ).read ())
@@ -312,7 +326,10 @@ def readstr(self, datastring):
312
326
"""Initialize members from string.
313
327
314
328
Parameters
315
- datastring: The raw data to read"""
329
+ ----------
330
+ datastring : array-like
331
+ The raw data to read
332
+ """
316
333
from diffpy .srmise .basefunction import BaseFunction
317
334
318
335
self .clear ()
@@ -525,15 +542,23 @@ def write(self, filename):
525
542
"""Write string representation of PeakExtraction instance to file.
526
543
527
544
Parameters
528
- filename: the name of the file to write"""
545
+ ----------
546
+ filename : str
547
+ The name of the file to write
548
+ """
529
549
bytes = self .writestr ()
530
550
f = open (filename , "w" )
531
551
f .write (bytes )
532
552
f .close ()
533
553
return
534
554
535
555
def writestr (self ):
536
- """Return string representation of PeakExtraction object."""
556
+ """Return string representation of PeakExtraction object.
557
+
558
+ Returns
559
+ -------
560
+ The str representation of PeakExtraction object
561
+ """
537
562
import time
538
563
from getpass import getuser
539
564
@@ -702,11 +727,16 @@ def estimate_peak(self, x, add=True):
702
727
Peaks already extracted, if any, are taken into account. If none exist,
703
728
use those specified by initial_peaks instead.
704
729
705
- Parameters:
706
- x: Coordinate of the point of interest
707
- add: (True) Automatically add peak to extracted peaks or initial_peaks.
708
-
709
- Return a Peak object, or None if estimation fails.
730
+ Parameters
731
+ ----------
732
+ x : array-like
733
+ The oordinate of the point of interest
734
+ add : bool
735
+ Automatically add peak to extracted peaks or initial_peaks. Default is True.
736
+
737
+ Returns
738
+ -------
739
+ The Peak object, or None if estimation fails.
710
740
"""
711
741
# Make sure all required extraction variables have some value
712
742
self .defaultvars ()
@@ -758,7 +788,10 @@ def add_peaks(self, peaks):
758
788
"""Add peaks to extracted peaks, or initial_peaks if no extracted peaks exist.
759
789
760
790
Parameters
761
- peaks: A Peaks instance"""
791
+ ----------
792
+ peaks: Peaks object
793
+ The peaks instance
794
+ """
762
795
if self .extracted is not None :
763
796
self .extracted .replacepeaks (peaks )
764
797
else :
0 commit comments