Add visualization

This commit is contained in:
linarphy 2024-05-24 16:46:00 +02:00
parent 59a01b77ed
commit 002c7ecd9d
No known key found for this signature in database
GPG key ID: E61920135EFF2295

View file

@ -7,7 +7,7 @@ from backscattering_analyzer import (
opt_compute_light,
interpolate,
)
from numpy import loadtxt, pi
from numpy import loadtxt, logspace, pi
from scipy.io.matlab import loadmat
from scipy.optimize import Bounds, minimize
@ -180,7 +180,7 @@ class Analyzer:
)
)
bounds = Bounds(0, 1)
bounds = Bounds(1e-30, 1e-3)
min_result = minimize(
fit_compute_light,
guess,
@ -194,7 +194,7 @@ class Analyzer:
data,
reference,
),
method = 'TNC',
method="Powell",
bounds=bounds,
)
@ -232,4 +232,25 @@ class Analyzer:
_ = plt.legend()
_ = plt.show()
"""
as the minimization does not work (why ?), visual help
"""
x = logspace(-50, 0, 1000)
y = [
fit_compute_light(
x[i],
factor_n,
coupling_n,
factor_d,
coupling_d,
self.settings.power_in,
self.settings.power_out,
data,
reference,
)
for i in range(len(x))
]
_ = plt.loglog(x, y)
_ = plt.show()
return min_result.x