-
Notifications
You must be signed in to change notification settings - Fork 207
/
error_function.py
70 lines (58 loc) · 1.97 KB
/
error_function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# -*- coding: utf-8 -*-
# Copyright 2007-2023 The HyperSpy developers
#
# This file is part of HyperSpy.
#
# HyperSpy is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# HyperSpy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>.
from hyperspy._components.expression import Expression
class Erf(Expression):
r"""Error function component.
.. math::
f(x) = \frac{A}{2}~\mathrm{erf}\left[\frac{(x - x_0)}{\sqrt{2}
\sigma}\right]
============== =============
Variable Parameter
============== =============
:math:`A` A
:math:`\sigma` sigma
:math:`x_0` origin
============== =============
Parameters
----------
A : float
The min/max values of the distribution are -A/2 and A/2.
sigma : float
Width of the distribution.
origin : float
Position of the zero crossing.
**kwargs
Extra keyword arguments are passed to the
:py:class:`~._components.expression.Expression` component.
"""
def __init__(self, A=1., sigma=1., origin=0., module=["numpy", "scipy"],
**kwargs):
super().__init__(
expression="A * erf((x - origin) / sqrt(2) / sigma) / 2",
name="Erf",
A=A,
sigma=sigma,
origin=origin,
module=module,
autodoc=False,
**kwargs,
)
# Boundaries
self.A.bmin = 0.
self.isbackground = False
self.convolved = True