Changed formatting, some conflicts yet to be resolved

This commit is contained in:
ralf 2024-07-11 10:58:18 +03:00
parent f887c94a70
commit 645d908000
2 changed files with 13 additions and 16 deletions

View File

@ -9,11 +9,9 @@ class Data:
self.datasets = [] self.datasets = []
with h5py.File(self.filename, "r") as h5: with h5py.File(self.filename, "r") as h5:
if 1: if 1:
print(f"Atribuudid grupis '{group_key}'") print(f"Atribuudid grupis '{group_key}'")
grp = h5[group_key] grp = h5[group_key]
self.current = grp["current_raw"][()] / grp.attrs["c_mem"] self.current = grp["current_raw"][()] / grp.attrs["c_mem"]
self.current_t = grp["current_t"][()] self.current_t = grp["current_t"][()]
self.ECal = grp.attrs["vrev"] self.ECal = grp.attrs["vrev"]
@ -21,5 +19,6 @@ class Data:
self.eid = group_key self.eid = group_key
def get_current_slice(self, times: np.ndarray): def get_current_slice(self, times: np.ndarray):
interpolator = interp1d(self.current_t, self.current, fill_value="extrapolate") interpolator = interp1d(self.current_t, self.current,
fill_value="extrapolate")
return interpolator(times) return interpolator(times)

View File

@ -37,7 +37,7 @@ class Fitter:
return current return current
k = np.zeros(current.size) k = np.zeros(current.size)
k[k.size // 2 :] = np.exp(-np.arange(k.size // 2) / np.abs(tau)) k[k.size // 2:] = np.exp(-np.arange(k.size // 2) / np.abs(tau))
k /= k.sum() k /= k.sum()
if tau > 0: if tau > 0:
@ -65,7 +65,6 @@ class Fitter:
err = np.mean(res**2) # mean squared error err = np.mean(res**2) # mean squared error
self.iteration += 1 self.iteration += 1
print(self.iteration, parameters.tolist(), "err", err) print(self.iteration, parameters.tolist(), "err", err)
# measured_fluo = self.data.fluo # measured_fluo = self.data.fluo
# fluo_interplolator = interp1d(self.time_domain, model.calculated_fluo) # fluo_interplolator = interp1d(self.time_domain, model.calculated_fluo)
# calculated_fluo = fluo_interplolator(self.data.fluo_time) # calculated_fluo = fluo_interplolator(self.data.fluo_time)
@ -120,8 +119,7 @@ class Fitter:
'tau_xfer': tau_xfer, 'tau_xfer': tau_xfer,
'tau_RC': tau_RC, 'tau_RC': tau_RC,
'offset': offset, 'offset': offset,
'mean_squared_error': err }) 'mean_squared_error': err})
model = self.model() model = self.model()
@ -168,15 +166,16 @@ class Fitter:
return cov, cor return cov, cor
def plot_correlation_matrix(cor): def plot_correlation_matrix(cor):
plt.imshow(cor, cmap='viridis', interpolation='nearest') plt.imshow(cor, cmap='viridis', interpolation='nearest')
plt.colorbar(label='Correlation') plt.colorbar(label='Correlation')
plt.title('Correlation Matrix') plt.title('Correlation Matrix')
plt.xlabel('Variables') plt.xlabel('Variables')
plt.ylabel('Variables') plt.ylabel('Variables')
plt.show() plt.show()
if __name__ == "__main__": if __name__ == "__main__":
filename = "ltcc_current.h5" filename = "ltcc_current.h5"
eid = "0033635a51b096dc449eb9964e70443a67fc16b9587ae3ff6564eea1fa0e3437_2018.06.18 14:48:40" eid = "0033635a51b096dc449eb9964e70443a67fc16b9587ae3ff6564eea1fa0e3437_2018.06.18 14:48:40"
@ -191,7 +190,6 @@ if __name__ == "__main__":
res_filename = res_filename.replace(" ", "_").replace(":", "-") res_filename = res_filename.replace(" ", "_").replace(":", "-")
fit_hist.to_csv(res_filename, index=True) fit_hist.to_csv(res_filename, index=True)
eid_cleaned = re.sub(r'[^\w.-]', '', eid) # Eemalda kõik eritähed ja jääb alles alphanumbrilised tähed, sidekriipsud ja punktid eid_cleaned = re.sub(r'[^\w.-]', '', eid) # Eemalda kõik eritähed ja jääb alles alphanumbrilised tähed, sidekriipsud ja punktid
fig.savefig(f"plot_{eid_cleaned}.png") fig.savefig(f"plot_{eid_cleaned}.png")
fig.savefig(f"plot_{eid_cleaned}.pdf") fig.savefig(f"plot_{eid_cleaned}.pdf")