Skip to content

Commit

Permalink
change peakextraction function to numpydoc
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenhua0320 committed Aug 19, 2024
1 parent ee41be5 commit 7a6dafb
Showing 1 changed file with 52 additions and 27 deletions.
79 changes: 52 additions & 27 deletions src/diffpy/srmise/peakextraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,44 @@
class PeakExtraction(object):
"""Class for peak extraction.
Data members
x: x coordinates of the data
y: y coordinates of the data
dx: uncertainties in the x coordinates (not used)
dy: uncertainties in the y coordinates
effective_dy: uncertainties in the y coordinates actually used during extraction
rng: [xmin, xmax] Range of x coordinates over which to extract peaks
pf: Sequence of peak functions that can be extracted
initial_peaks: Peaks present at start of extraction
baseline: Baseline for data
cres: Resolution of clustering
error_method: ErrorEvaluator class used to compare models
Parameters
----------
x : array-like
The x coordinates of the data
y : array-like
The y coordinates of the data
dx : array-like
The uncertainties in the x coordinates (not used)
dy : array-like
The uncertainties in the y coordinates
effective_dy : array-like
The uncertainties in the y coordinates actually used during extraction
rng : list
The [xmin, xmax] Range of x coordinates over which to extract peaks
pf : array-like
The sequence of peak functions that can be extracted
initial_peaks: Peaks object
The peaks present at start of extraction
baseline : Baseline object
The baseline for data
cres : float
The resolution of clustering
error_method : ErrorEvaluator class
The Evaluation class used to compare models
Calculated members
extracted: ModelCluster after extraction
extraction_type: Type of extraction
------------------
extracted : ModelCluster object
The ModelCluster object after extraction
extraction_type : Type of extraction
"""

def __init__(self, newvars=[]):
"""Initialize PeakExtraction object.
Parameters
newvars: Sequence of strings that represent additional extraction parameters."""
newvars : array-like
Sequence of strings that represent additional extraction parameters."""
self.clear()
self.extractvars = dict.fromkeys(
(
Expand All @@ -77,7 +92,9 @@ def __init__(self, newvars=[]):
return

def clear(self):
"""Clear all members."""
"""Clear all members.
The purpose of the method is to ensure the object is in initialized state."""
self.x = None
self.y = None
self.dx = None
Expand Down Expand Up @@ -119,17 +136,24 @@ def setdata(self, x, y, dx=None, dy=None):
def setvars(self, quiet=False, **kwds):
"""Set one or more extraction variables.
Variables
quiet: [False] Log changes quietly.
Keywords
cres: The clustering resolution, must be > 0.
effective_dy: The uncertainties actually used during extraction
pf: Sequence of PeakFunctionBase subclass instances.
baseline: Baseline instance or BaselineFunction instance (use built-in estimation)
error_method: ErrorEvaluator subclass instance used to compare models (default AIC)
initial_peaks: Peaks instance. These peaks are present at the start of extraction.
rng: Sequence specifying the least and greatest x-values over which to extract peaks.
Parameters
----------
quiet : bool
The log changes quietly. Default is False.
cres : float
The clustering resolution, must be > 0.
effective_dy : array-like
The uncertainties actually used during extraction
pf : list
The sequence of PeakFunctionBase subclass instances.
baseline : Baseline instance or BaselineFunction instance
The Baseline instance or BaselineFunction instance that use built-in estimation
error_method : ErrorEvaluator subclass instance
The ErrorEvaluator subclass instance used to compare models. Default is AIC.
initial_peaks : Peaks instance
These peaks are present at the start of extraction.
rng : array-like
The sequence specifying the least and greatest x-values over which to extract peaks.
"""
for k, v in kwds.items():
if k in self.extractvars:
Expand Down Expand Up @@ -1309,6 +1333,7 @@ def fit_single(self):

from diffpy.srmise.modelevaluators.aicc import AICc
from diffpy.srmise.peaks.gaussianoverr import GaussianOverR
from diffpy.srmise.dataclusters import DataClusters

srmiselog.setlevel("info")
srmiselog.liveplotting(False)
Expand Down

0 comments on commit 7a6dafb

Please sign in to comment.