diff --git a/src/backscattering_analyzer/analyzer.py b/src/backscattering_analyzer/analyzer.py index c345bc7..0ef5340 100644 --- a/src/backscattering_analyzer/analyzer.py +++ b/src/backscattering_analyzer/analyzer.py @@ -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