Changed formatting, some conflicts yet to be resolved
This commit is contained in:
parent
f887c94a70
commit
645d908000
7
Data.py
7
Data.py
@ -9,17 +9,16 @@ class Data:
|
||||
self.datasets = []
|
||||
|
||||
with h5py.File(self.filename, "r") as h5:
|
||||
|
||||
if 1:
|
||||
print(f"Atribuudid grupis '{group_key}'")
|
||||
grp = h5[group_key]
|
||||
|
||||
self.current = grp["current_raw"][()] / grp.attrs["c_mem"]
|
||||
self.current_t = grp["current_t"][()]
|
||||
self.ECal = grp.attrs["vrev"]
|
||||
self.gGaL = grp.attrs["gmax"]
|
||||
self.eid = group_key
|
||||
|
||||
|
||||
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)
|
||||
|
22
fitter.py
22
fitter.py
@ -37,7 +37,7 @@ class Fitter:
|
||||
return current
|
||||
|
||||
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()
|
||||
|
||||
if tau > 0:
|
||||
@ -46,7 +46,7 @@ class Fitter:
|
||||
return np.convolve(current, k[::-1], mode="same")
|
||||
|
||||
def cost_func(self, parameters: np.ndarray):
|
||||
|
||||
|
||||
model = self.model()
|
||||
|
||||
gGaL, ECal, K_pc_half, tau_xfer, tau_RC, offset = parameters
|
||||
@ -65,7 +65,6 @@ class Fitter:
|
||||
err = np.mean(res**2) # mean squared error
|
||||
self.iteration += 1
|
||||
print(self.iteration, parameters.tolist(), "err", err)
|
||||
|
||||
# measured_fluo = self.data.fluo
|
||||
# fluo_interplolator = interp1d(self.time_domain, model.calculated_fluo)
|
||||
# calculated_fluo = fluo_interplolator(self.data.fluo_time)
|
||||
@ -120,9 +119,8 @@ class Fitter:
|
||||
'tau_xfer': tau_xfer,
|
||||
'tau_RC': tau_RC,
|
||||
'offset': offset,
|
||||
'mean_squared_error': err })
|
||||
'mean_squared_error': err})
|
||||
|
||||
|
||||
model = self.model()
|
||||
|
||||
model.ECaL = ECal
|
||||
@ -168,15 +166,16 @@ class Fitter:
|
||||
return cov, cor
|
||||
|
||||
def plot_correlation_matrix(cor):
|
||||
plt.imshow(cor, cmap='viridis', interpolation='nearest')
|
||||
plt.colorbar(label='Correlation')
|
||||
plt.title('Correlation Matrix')
|
||||
plt.xlabel('Variables')
|
||||
plt.ylabel('Variables')
|
||||
plt.show()
|
||||
plt.imshow(cor, cmap='viridis', interpolation='nearest')
|
||||
plt.colorbar(label='Correlation')
|
||||
plt.title('Correlation Matrix')
|
||||
plt.xlabel('Variables')
|
||||
plt.ylabel('Variables')
|
||||
plt.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
filename = "ltcc_current.h5"
|
||||
eid = "0033635a51b096dc449eb9964e70443a67fc16b9587ae3ff6564eea1fa0e3437_2018.06.18 14:48:40"
|
||||
|
||||
@ -191,7 +190,6 @@ if __name__ == "__main__":
|
||||
res_filename = res_filename.replace(" ", "_").replace(":", "-")
|
||||
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
|
||||
fig.savefig(f"plot_{eid_cleaned}.png")
|
||||
fig.savefig(f"plot_{eid_cleaned}.pdf")
|
||||
|
Loading…
Reference in New Issue
Block a user