-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
304 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
This is an example model for an experiment from the second undergraduate lab course. (232) | ||
Here we demonstrate how to plot two separate fits in the same graph | ||
""" | ||
|
||
import numpy as np | ||
from fitting_toolkit import curve_fit, plot_fit | ||
|
||
def lin(x, a, b): | ||
return a*x + b | ||
|
||
# R = infty | ||
x_inf = 1-np.array([20, 30, 40, 50, 60, 70, 80])/100 | ||
U_inf = np.array([3.2, 2.8, 2.4, 2.0, 1.6, 1.2, 0.8]) | ||
dU = 0.1 | ||
|
||
params_inf, cov_inf, lower_inf, upper_inf = curve_fit(lin, x_inf, U_inf, dU, confidence_resolution = 50, nsigma = 2, absolute_sigma = True) | ||
|
||
# R = 50 Ohm | ||
x_20 = x_inf | ||
U_20 = np.array([2.7, 2.4, 2.0, 1.7, 1.5, 1.1, 0.7]) | ||
params_20, cov_20, lower_20, upper_20 = curve_fit(lin, x_20, U_20, dU, confidence_resolution = 50, nsigma = 2, absolute_sigma = True) | ||
#params_21, cov_21, lower_21, upper_21 = curve_fit(lin, x_20, U_20, dU, confidence_resolution = 50, nsigma = 2, absolute_sigma = True) | ||
#params_22, cov_22, lower_22, upper_22 = curve_fit(lin, x_20, U_20, dU, confidence_resolution = 50, nsigma = 3, absolute_sigma = True) | ||
|
||
|
||
#show both fits | ||
fig, ax = plt.subplots() | ||
ax.grid("both") | ||
fig, ax = plot_fit(1-np.array([20, 30, 40, 50, 60, 70, 80, 90])/100, U_inf, lin, params_inf, lower_inf, upper_inf, yerror=dU, confidence_resolution = 50, fit_label="$R = \\infty$", confidence_label="2-$\\sigma$", fig = fig) | ||
fig, ax = plot_fit(x_20, U_20, lin, params_20, lower_20, upper_20, yerror=dU, confidence_resolution = 50, fit_color = "crimson", fit_label="$R = 50\\Omega$", confidence_label="2-$\\sigma$", fig = fig, ax = ax) | ||
#fig, ax = plot_fit(x_20, U_20, lin, params_21, lower_21, upper_21, yerror=dU, confidence_resolution = 50, fit_color = "crimson", fit_label="$R = 50\\Omega$", confidence_label=None, fig = fig, ax = ax) | ||
#fig, ax = plot_fit(x_20, U_20, lin, params_22, lower_22, upper_22, yerror=dU, confidence_resolution = 50, fit_color = "crimson", fit_label="$R = 50\\Omega$", confidence_label=None, fig = fig, ax = ax) | ||
ax.legend() | ||
ax.set_xlabel("x / l") | ||
ax.set_ylabel("U / V") | ||
plt.show() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from setuptools import setup | ||
#run with python3 setup.py sdist bdist_wheel | ||
|
||
with open("./README.md") as f: | ||
description = f.read() | ||
|
||
with open("./requirements.txt", encoding="utf-16") as f: | ||
requirements = f.readlines() | ||
|
||
setup( | ||
name = "fitting_toolkit", | ||
version = "1.0.1", | ||
package_dir={"": "src"}, | ||
packages=[""], | ||
long_description=description, | ||
long_description_content_type="text/markdown", | ||
install_requires = requirements, | ||
project_urls = { | ||
"Documentation": "https://github.com/davidkowalk/fitting_toolkit/blob/development/docs/manual.md", | ||
"Source": "https://github.com/davidkowalk/fitting_toolkit/", | ||
"Tracker": "https://github.com/davidkowalk/fitting_toolkit/issues" | ||
}, | ||
license="MIT", | ||
description="Easy and Flexible Curve Fitting", | ||
url="https://github.com/davidkowalk/fitting_toolkit/" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from .fitting_toolkit import * | ||
#generate_thresholds, get_sigma_probability, confidence_interval, curve_fit, plot_fit | ||
|
||
__package_name__ = "fitting_toolkit" | ||
__author__ = "David J. Kowalk" | ||
__version__ = "1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.