def save (name_trace, trace): name = 'I_Gen_'+name_trace+'_'+str(time_step/ms)+'_ev'+str(int(eval_time/second)) head = 't (s)\t' series_list = [duration_time_series[0:eval_points]] for i,ix in enumerate(plot_indices): head = head + plot_labels[i]+'\t' series_list += [trace[ix]] save_plot_list(name, head, series_list) print("Written data in: ", name) return
def fitfunc_verbose(indv, save_traces = False): trace = get_trace(indv) norm_trace = norm_trace_avg_unitary_2points(trace,s1,e1,s2,e2) fwd_trace=(trace[:, eval_start:n_points]) bkw_trace=(trace[:, n_points+eval_start:2*n_points]) norm_f_trace = (norm_trace[:, eval_start:n_points]) norm_b_trace = (norm_trace[:, n_points+eval_start:2*n_points]) # plots plot_labels = ['AS', 'DA', 'VA', 'DB', 'VB'] plot_indices = [0,2,4,10,6] for j in plot_indices: plot(eval_time_series, fwd_trace[j], label = 'v_'+labels[j]) xlabel('Time (s)') ylabel('V') title('Forward traces') legend(loc='upper right') show() for j in plot_indices: plot(eval_time_series, norm_f_trace[j], label = 'v_'+labels[j]) xlabel('Time (s)') ylabel('dV') title('Norm Forward traces') legend(loc='upper right') show() for j in plot_indices: plot(eval_time_series, bkw_trace[j], label = 'v_'+labels[j]) xlabel('Time (s)') ylabel('V') title('Backward traces') legend(loc='upper right') show() for j in plot_indices: plot(eval_time_series, norm_b_trace[j], label = 'v_'+labels[j]) xlabel('Time (s)') ylabel('dV') title('Norm Backward traces') legend(loc='upper right') show() #only for final testing fw+bkw+fw # for j in plot_indices: # plot(arange(3*n_points)*time_step ,trace[j], label = 'v_'+labels[j]) # xlabel('Time (s)') # ylabel('V') # title('Full traces (forward + backward)') # legend(loc='upper right') # show() # for j in plot_indices: # plot(arange(3*n_points-transient_points)*time_step ,norm_trace[j][:], label = 'v_'+labels[j]) # xlabel('Time (s)') # ylabel('V') # title('Full traces norm (forward + backward)') # legend(loc='upper right') # show() print('fitness normalized') print('f1=', f1(norm_f_trace, norm_b_trace, time_step/second, eval_time/second)) print('f2=', f2(norm_f_trace, norm_b_trace, time_step/second, eval_time/second)) print('f3=', f3(norm_f_trace, norm_b_trace)) print('f3_mod=', f3_mod(norm_f_trace, norm_b_trace)) f = fitness(norm_f_trace, norm_b_trace, time_step/second) print('f=', f) print('fitness not normalized') print('f1=', f1(fwd_trace, bkw_trace, time_step/second, eval_time/second)) print('f2=', f2(fwd_trace, bkw_trace, time_step/second, eval_time/second)) print('f3=', f3(fwd_trace, bkw_trace)) print('f3_mod=', f3_mod(fwd_trace, bkw_trace)) f = fitness(fwd_trace, bkw_trace, time_step/second) print('f=', f) if (save_traces): def save (name_trace, trace): name = 'I_Gen_'+name_trace+'_'+str(time_step/ms)+'_ev'+str(int(eval_time/second)) head = 't (s)\t' series_list = [duration_time_series[0:eval_points]] for i,ix in enumerate(plot_indices): head = head + plot_labels[i]+'\t' series_list += [trace[ix]] save_plot_list(name, head, series_list) print("Written data in: ", name) return names = ['norm_Ftrace','F_trace','norm_Btrace','B_trace'] traces = [norm_f_trace, fwd_trace, norm_b_trace, bkw_trace] for i in range(0,4): save(names[i],traces[i]) name = 'I_Gen_'+'Full_trace_'+str(time_step/ms)+'_dur'+str(int(3*duration/second)) head = 't (s)\t' series_list = [arange(3*n_points)*time_step] for i,ix in enumerate(plot_indices): head = head + plot_labels[i]+'\t' series_list += [trace[ix]] save_plot_list(name, head, series_list) print("Written data in: ", name) name = 'I_Gen_'+'Full_trace_norm_'+str(time_step/ms)+'_dur'+str(int(3*duration/second)) head = 't (s)\t' series_list = [arange(3*n_points)*time_step] for i,ix in enumerate(plot_indices): head = head + plot_labels[i]+'\t' series_list += [norm_trace[ix]] save_plot_list(name, head, series_list) print("Written data in: ", name) return f
# plt.plot(eval_time_series, a2, label = 'a2') # plt.xlabel('Time (s)') # plt.ylabel('a') # plt.legend(loc='upper right') # plt.title(ablation_type+' ablations') # plt.show() # plt.plot(a1, a2) # plt.xlabel('a1') # plt.ylabel('a2') # plt.show() # see decomposition of all fwd indices # plot_traces_color(loco_indices, norm_v_traces, eval_time_series, loco_colors,'norm loco traces with '+ablation_type+' ablated') # sys.exit() name = 'K_ABL_a1_a2_h' + str( t_step * 1000) + '_I' + str(I_max) + '_ev' + str(t_eval) head = 't (s)\tI (pA)' series_list = [duration_time_series[0:eval_points], I_shape[0:eval_points]] for ab in abl_runs: head = head + '\t a1' + ab + '\t a2' + ab series_list += [abl_runs[ab]['a1'], abl_runs[ab]['a2']] save_plot_list(name, head, series_list) print("Written data in: ", name)