diff --git a/src/ALsim.py b/src/ALsim.py index 4fe9b3b..bfd58c9 100644 --- a/src/ALsim.py +++ b/src/ALsim.py @@ -133,23 +133,16 @@ def ALsim(n_glo, n, N, t_total, dt, rec_state, rec_spikes, odors, hill_exp, prot if state_bufs: # only save the time array if anything is being saved t_array= np.arange(0.0,t_total,model.dT) - file= open(dirname+label+"_t.bin", "wb") - np.save(file, t_array) + np.save(dirname+label+"_t.bin", t_array) for p in state_bufs: state_bufs[p]= np.vstack(state_bufs[p]) - file= open(dirname+label+"_"+p+".bin", "wb") - np.save(file, state_bufs[p]) - file.close() + np.save(dirname+label+"_"+p+".bin", state_bufs[p]) for pop in rec_spikes: spike_t[pop]= np.hstack(spike_t[pop]) - file= open(dirname+label+pop+"_spike_t.bin", "wb") - np.save(file, spike_t[pop]) - file.close() + np.save(dirname+label+pop+"_spike_t.bin", spike_t[pop]) spike_ID[pop]= np.hstack(spike_ID[pop]) - file= open(dirname+label+pop+"_spike_ID.bin", "wb") - np.save(file, spike_ID[pop]) - file.close() + np.save(dirname+label+pop+"_spike_ID.bin", spike_ID[pop]) return state_bufs, spike_t, spike_ID #with open('exp1_plots.py') as f: exec(f.read()) diff --git a/src/exp1_plots.py b/src/exp1_plots.py index c546a60..f0c5dd2 100644 --- a/src/exp1_plots.py +++ b/src/exp1_plots.py @@ -48,7 +48,6 @@ def exp1_plots(state_bufs, spike_t, spike_ID, plot_raster, plot_sdf, t_total, dt if n[pop] > 1: sdfs= make_sdf(spike_t[pop], spike_ID[pop]//n[pop], np.arange(0,n_glo), -3*sigma_sdf, t_total+3*sigma_sdf, dt_sdf, sigma_sdf) - print(sdfs.shape) plt.figure() plt.imshow(sdfs/n[pop], extent=[-3*sigma_sdf,t_total+3*sigma_sdf,0,n_glo], aspect='auto') plt.title("average SDF of "+pop+" in each glomerulus") diff --git a/src/replot.py b/src/replot.py index 7e50de5..f0e050d 100644 --- a/src/replot.py +++ b/src/replot.py @@ -11,18 +11,12 @@ dirname= dirname+"/" for pop, var in rec_state: lbl= pop+"_"+var - file= open(dirname+label+"_"+lbl+".bin", "rb") - state_bufs[lbl]= np.load(file, ) - file.close() + state_bufs[lbl]= np.load(dirname+label+"_"+lbl+".bin") spike_t= dict() spike_ID= dict() for pop in rec_spikes: - file= open(dirname+label+pop+"_spike_t.bin", "rb") - spike_t[pop]= np.load(file) - file.close() - file= open(dirname+label+pop+"_spike_ID.bin", "rb") - spike_ID[pop]= np.load(file) - file.close() + spike_t[pop]= np.load(dirname+label+pop+"_spike_t.bin") + spike_ID[pop]= np.load(dirname+label+pop+"_spike_ID.bin") exp1_plots(state_bufs, spike_t, spike_ID, plot_raster, plot_sdf, t_total, dt, n_glo, n, N, dirname, label)