Skip to content

Instantly share code, notes, and snippets.

@DarioSucic
Created August 10, 2020 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarioSucic/45fab23f94b8c0286fc722a61bc0c9e4 to your computer and use it in GitHub Desktop.
Save DarioSucic/45fab23f94b8c0286fc722a61bc0c9e4 to your computer and use it in GitHub Desktop.
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