debugging of fitter, many issues still persist
This commit is contained in:
		
							
								
								
									
										12
									
								
								fitter.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								fitter.py
									
									
									
									
									
								
							| @@ -6,7 +6,8 @@ import re | ||||
|  | ||||
|  | ||||
| from scipy.optimize import least_squares | ||||
| from model import Model | ||||
| from scipy.linalg import svd | ||||
| from Model import Model | ||||
| from Data import Data | ||||
|  | ||||
|  | ||||
| @@ -81,7 +82,7 @@ class Fitter: | ||||
|             plt.show() | ||||
|             # exit() | ||||
|  | ||||
|         return res  # , measured_fluo - calculated_fluo) | ||||
|         return res, err  # , measured_fluo - calculated_fluo) | ||||
|  | ||||
|     def optimize(self, init_parameters=None): | ||||
|         t0 = time.time() | ||||
| @@ -102,7 +103,7 @@ class Fitter: | ||||
|             (10, 100, 100, 1, 100, 10, 10), | ||||
|         ) | ||||
|  | ||||
|             res = least_squares(self.cost_func, init_parameters, bounds=bounds, xtol=1e-10) | ||||
|         res, err = least_squares(self.cost_func, init_parameters, bounds=bounds, xtol=1e-10) | ||||
|         print() | ||||
|         print("   Parameters: [gGaL, ECal, K_pc_half, tau_xfer, tau_RC, offset]") | ||||
|         print("      Initial:", init_parameters.tolist()) | ||||
| @@ -149,6 +150,7 @@ class Fitter: | ||||
|         ax2.set_xlabel("time, ms") | ||||
|         ax2.set_ylabel("current, pA/pF") | ||||
|         ax2.legend(frameon=False) | ||||
|  | ||||
|         return res, fig | ||||
|  | ||||
|     def covcor_from_lsq(res): | ||||
| @@ -173,8 +175,8 @@ class Fitter: | ||||
|         plt.ylabel('Variables') | ||||
|         plt.show() | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|  | ||||
|     filename = "ltcc_current.h5" | ||||
|     eid = "0033635a51b096dc449eb9964e70443a67fc16b9587ae3ff6564eea1fa0e3437_2018.06.18 14:48:40" | ||||
| @@ -183,6 +185,8 @@ if __name__ == "__main__": | ||||
|  | ||||
|     fit = Fitter(Model, data) | ||||
|  | ||||
|     res, fig = fit.optimize() | ||||
|  | ||||
|     fit_hist = pd.DataFrame.from_dict(fit.fit_results, orient='index').T | ||||
|     fit_hist.index.name = 'Iterations' | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user