Peaks Module¶
pyspc.peaks
¶
Provides helper function related to peaks.
Currently, the main function here is around_max_peak_fit
which helps to estimate peak position and height based on fitting
a function aroud maximum value.
Other functions related to peak fitting can be found in scipy.signal.*
Functions¶
gaussian(x, a, x0, sigma)
¶
Gaussian function calculated as:
.. math:: y = a\exp\left(-\frac{(x-x_0)^2}{2\sigma^2}\right)
Notes
Do not confuse with probability density function of the normal distribution.
Source code in pyspc/peaks.py
lorentzian(x, a, x0, gamma)
¶
Lorentzian function calculated as:
.. math:: y = a\frac{\gamma^2}{(x-x_0)^2 + gamma^2}
parabola_peak_fit(x, y)
¶
Fit a peak with a 2nd order polynom
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
1D numeric (vector) of |
required |
y |
ndarray
|
1D numeric (vector) of |
required |
Returns:
Type | Description |
---|---|
dict
|
A dictionary with the following keys and values:
|
Source code in pyspc/peaks.py
gaussian_peak_fit(x, y)
¶
Fit a peak with the Gaussian.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
1D numeric (vector) of |
required |
y |
ndarray
|
1D numeric (vector) of |
required |
Returns:
Type | Description |
---|---|
dict
|
A dictionary with the peak max and the fitting information:
|
Source code in pyspc/peaks.py
lorentzian_peak_fit(x, y)
¶
Fit a peak with the Lorentzian function
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
1D numeric (vector) of |
required |
y |
ndarray
|
1D numeric (vector) of |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
a dictionary with the peak max and the fitting infomation:
|
Source code in pyspc/peaks.py
around_max_peak_fit(x, y, fit_func='max', window=None)
¶
Fit a peak using window
points around the global maximum value
First, x
and y
vectors are filtered so that only window
points are
taken where the middle point corresponds to the global maximum of y
. Then,
the fitting function is applied to the filtered values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
1D numeric (vector) of |
required |
y |
ndarray
|
Either 1D numeric (vector) or a 2D matrix of |
required |
fit_func |
str | Callable
|
Fitting function. Must be one of:
|
'max'
|
window |
int
|
window size. Must be and odd number (3,5,7,...) |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
A dataframe with the same number of rows as |
Raises:
Type | Description |
---|---|
ValueError
|
Unknown peak fitting method |
Source code in pyspc/peaks.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|