Created
August 10, 2020 13:28
-
-
Save DarioSucic/45fab23f94b8c0286fc722a61bc0c9e4 to your computer and use it in GitHub Desktop.
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
import numpy as np | |
from scipy.optimize import curve_fit | |
x, y = np.loadtxt("2a.txt", delimiter=";").T | |
def test_func(x, n): | |
alpha = (2 * np.pi / 360) * x | |
n_sq = n ** 2 | |
cosine = np.cos(alpha) | |
sine = np.sin(alpha) | |
root_delta = np.sqrt(n_sq - sine ** 2) | |
n_sq_cosine = n_sq * cosine | |
return (n_sq_cosine - root_delta) / (n_sq_cosine + root_delta) | |
params, params_covariance = curve_fit(test_func, x, y) | |
print(params) | |
print(params_covariance) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment