Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85635868
fit_utils.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Sep 30, 13:30
Size
1 KB
Mime Type
text/x-python
Expires
Wed, Oct 2, 13:30 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21225545
Attached To
R6746 RationalROMPy
fit_utils.py
View Options
# Copyright (C) 2018 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
from
numpy
import
pi
,
polynomial
as
po
from
rrompy.utilities.base.types
import
DictAny
from
rrompy.utilities.warning_manager
import
warn
__all__
=
[
'setupFitCallables'
]
def
setupFitCallables
(
kind
:
str
)
->
DictAny
:
"""Setup main callables and name for data fitting."""
kind
=
kind
.
upper
()
if
kind
==
"CHEBYSHEV"
:
val
=
po
.
chebyshev
.
chebval
vander
=
po
.
chebyshev
.
chebvander
fitname
=
"chebfit"
roots
=
po
.
chebyshev
.
chebroots
domcoeff
=
lambda
n
:
2.
**
(
n
-
1
)
if
n
>
0
else
1.
elif
kind
==
"LEGENDRE"
:
val
=
po
.
legendre
.
legval
vander
=
po
.
legendre
.
legvander
fitname
=
"legfit"
roots
=
po
.
legendre
.
legroots
from
scipy.special
import
binom
domcoeff
=
lambda
n
:
(
2.
**
n
*
(
pi
*
n
)
**
-.
5
if
n
>
10
else
.
5
**
n
*
binom
(
2
*
n
,
n
))
else
:
if
kind
!=
"MONOMIAL"
:
warn
(
"Fitting basis not recognized. Overriding to 'MONOMIAL'."
)
val
=
po
.
polynomial
.
polyval
vander
=
po
.
polynomial
.
polyvander
fitname
=
"polyfit"
roots
=
po
.
polynomial
.
polyroots
domcoeff
=
lambda
n
:
1.
return
{
"val"
:
val
,
"vander"
:
vander
,
"fitname"
:
fitname
,
"roots"
:
roots
,
"domcoeff"
:
domcoeff
}
Event Timeline
Log In to Comment