@@ -78,12 +78,19 @@ def estimate_parameters(self, r, y):
78
78
"""Estimate parameters for single peak from data provided.
79
79
80
80
Parameters
81
- r: (Numpy array) Data along r from which to estimate
82
- y: (Numpy array) Data along y from which to estimate
83
-
84
- Returns Numpy array of parameters in the default internal format.
85
- Raises SrMiseEstimationError if parameters cannot be estimated for any
86
- reason."""
81
+ ----------
82
+ r : array-like
83
+ Data along r from which to estimate
84
+ y : array-like
85
+ Data along y from which to estimate
86
+
87
+ Returns
88
+ -------
89
+ array-like
90
+ Numpy array of parameters in the default internal format.
91
+ Raises SrMiseEstimationError if parameters cannot be estimated for any
92
+ reason.
93
+ """
87
94
if len (r ) != len (y ):
88
95
emsg = "Arrays r, y must have equal length."
89
96
raise SrMiseEstimationError (emsg )
@@ -154,9 +161,19 @@ def scale_at(self, pars, x, scale):
154
161
SrMiseScalingError if the parameters cannot be scaled.
155
162
156
163
Parameters
157
- pars: (Array) Parameters corresponding to a single peak
158
- x: (float) Position of the border
159
- scale: (float > 0) Size of scaling at x."""
164
+ ----------
165
+ pars : array-like
166
+ Parameters corresponding to a single peak
167
+ x : float
168
+ Position of the border
169
+ scale : float
170
+ Size of scaling at x. Must be positive.
171
+
172
+ Returns
173
+ -------
174
+ array-like
175
+ The sequence of scaled parameters.
176
+ """
160
177
if scale <= 0 :
161
178
emsg = "" .join (["Cannot scale by " , str (scale ), "." ])
162
179
raise SrMiseScalingError (emsg )
@@ -204,19 +221,37 @@ def scale_at(self, pars, x, scale):
204
221
return tpars
205
222
206
223
def _jacobianraw (self , pars , r , free ):
207
- """Return Jacobian of width-limited Gaussian/r.
208
-
209
- pars: Sequence of parameters for a single width-limited Gaussian
210
- pars[0]=peak position
211
- pars[1]=effective width, up to fwhm=maxwidth as par[1] -> inf.
212
- =tan(pi/2*fwhm/maxwidth)
213
- pars[2]=multiplicative constant a, equivalent to peak area
214
- r: sequence or scalar over which pars is evaluated
215
- free: sequence of booleans which determines which derivatives are
216
- needed. True for evaluation, False for no evaluation.
224
+ """
225
+ Compute the Jacobian of a width-limited Gaussian/r function.
226
+
227
+ This method calculates the partial derivatives of a Gaussian/r function
228
+ with respect to its parameters, considering a limiting width. The Gaussian/r's
229
+ width approaches its maximum FWHM (maxwidth) as the effective width parameter
230
+ (`pars[1]`) tends to infinity.
231
+
232
+ Parameters
233
+ ----------
234
+ pars : array-like
235
+ Sequence of parameters defining a single width-limited Gaussian:
236
+ - pars[0]: Peak position.
237
+ - pars[1]: Effective width, which scales up to the full width at half maximum (fwhm=maxwidth) as
238
+ `pars[1]` approaches infinity. It is mathematically represented as `tan(pi/2 * fwhm / maxwidth)`.
239
+ - pars[2]: Multiplicative constant 'a', equivalent to the peak area.
240
+ r : array-like or scalar
241
+ The sequence or scalar over which the Gaussian parameters `pars` are evaluated.
242
+ free : array-like of bools
243
+ Determines which derivatives need to be computed. A `True` value indicates that the derivative
244
+ with respect to the corresponding parameter in `pars` should be calculated;
245
+ `False` indicates no evaluation is needed.
246
+ Returns
247
+ -------
248
+ jacobian : ndarray
249
+ The Jacobian matrix, where each column corresponds to the derivative of the Gaussian/r function
250
+ with respect to one of the input parameters `pars`, evaluated at points `r`.
251
+ Only columns corresponding to `True` values in `free` are computed.
217
252
"""
218
253
jacobian = [None , None , None ]
219
- if ( free is False ) .sum () == self .npars :
254
+ if np .sum (np . logical_not ( free ) ) == self .npars :
220
255
return jacobian
221
256
222
257
# Optimization
@@ -304,18 +339,28 @@ def _transform_derivativesraw(self, pars, in_format, out_format):
304
339
def _transform_parametersraw (self , pars , in_format , out_format ):
305
340
"""Convert parameter values from in_format to out_format.
306
341
307
- Also restores parameters to a preferred range if it permits multiple
308
- values that correspond to the same physical result.
342
+ This method convert parameter values from one format to another and optionally restore
343
+ them to a preferred range if the target format supports multiple values
344
+ representing the same physical result.
309
345
310
346
Parameters
311
- pars: Sequence of parameters
312
- in_format: A format defined for this class
313
- out_format: A format defined for this class
314
-
315
- Defined Formats
316
- internal: [position, parameterized width-squared, area]
317
- pwa: [position, full width at half maximum, area]
318
- mu_sigma_area: [mu, sigma, area]
347
+ ----------
348
+ pars : array_like
349
+ Sequence of parameters in the `in_format`.
350
+ in_format : str, optional
351
+ The input format of the parameters. Supported formats are:
352
+ - 'internal': [position, parameterized width-squared, area]
353
+ - 'pwa': [position, full width at half maximum, area]
354
+ - 'mu_sigma_area': [mu, sigma, area]
355
+ Default is 'internal'.
356
+ out_format : str, optional
357
+ The desired output format of the parameters. Same options as `in_format`.
358
+ Default is 'pwa'.
359
+
360
+ Returns
361
+ -------
362
+ array_like
363
+ The transformed parameters in the `out_format`.
319
364
"""
320
365
temp = np .array (pars )
321
366
@@ -367,14 +412,27 @@ def _transform_parametersraw(self, pars, in_format, out_format):
367
412
return temp
368
413
369
414
def _valueraw (self , pars , r ):
370
- """Return value of width-limited Gaussian/r for the given parameters and r values.
371
-
372
- pars: Sequence of parameters for a single width-limited Gaussian
373
- pars[0]=peak position
374
- pars[1]=effective width, up to fwhm=maxwidth as par[1] -> inf.
375
- =tan(pi/2*fwhm/maxwidth)
376
- pars[2]=multiplicative constant a, equivalent to peak area
377
- r: sequence or scalar over which pars is evaluated
415
+ """Compute the value of a width-limited Gaussian/r for the specified parameters at given radial distances.
416
+
417
+ This function calculates the value of a Gaussian/r distribution,
418
+ where its effective width is constrained and related to the maxwidth. As `pars[1]` approaches infinity,
419
+ the effective width reaches `FWHM` (maxwidth). The returned values represent the Gaussian's intensity
420
+ across the provided radial coordinates `r`.
421
+
422
+ Parameters
423
+ ----------
424
+ pars : array_like
425
+ A sequence of parameters defining the Gaussian shape:
426
+ - pars[0]: Peak position of the Gaussian.
427
+ - pars[1]: Effective width factor, approaching infinity implies the FWHM equals `maxwidth`.
428
+ It is related to the FWHM by `tan(pi/2*FWHM/maxwidth)`.
429
+ - pars[2]: Multiplicative constant 'a', equivalent to the peak area of the Gaussian when integrated.
430
+ r : array_like or float
431
+ Radial distances or a single value at which the Gaussian is to be evaluated.
432
+ Returns
433
+ -------
434
+ float
435
+ The value of a width-limited Gaussian for the specified parameters at given radial distances.
378
436
"""
379
437
return (
380
438
np .abs (pars [2 ])
@@ -388,7 +446,17 @@ def getmodule(self):
388
446
# Other methods ####
389
447
390
448
def max (self , pars ):
391
- """Return position and height of the peak maximum."""
449
+ """Return position and height of the peak maximum.
450
+
451
+ Parameters
452
+ ----------
453
+ pars : array_like
454
+ The sequence of parameters defining the Gaussian shape.
455
+
456
+ Returns
457
+ -------
458
+ array-like
459
+ The sequence of position and height of the peak maximum."""
392
460
# TODO: Reconsider this behavior
393
461
if len (pars ) == 0 :
394
462
return None
0 commit comments