Skip to content

Commit

Permalink
More optimisation: More compact numpy.save command used.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Nowotny committed Jan 4, 2021
1 parent 568fbaa commit 6e2347f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
15 changes: 4 additions & 11 deletions src/ALsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
1 change: 0 additions & 1 deletion src/exp1_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
12 changes: 3 additions & 9 deletions src/replot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6e2347f

Please sign in to comment.