Show
Ignore:
Timestamp:
05/12/08 18:49:09 (4 years ago)
Author:
LaurentPerrinet
Message:

more polishing to allow easier copy/paste of code

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/retina/benchmark_linear.py

    r170 r172  
    1414""" 
    1515 
    16 import os, datetime, numpy, pylab, shelve 
     16import os, sys, numpy, pylab, shelve 
    1717import progressbar # see http://projects.scipy.org/pipermail/scipy-dev/2008-January/008200.html 
    1818from NeuroTools.parameters import * 
    1919 
    20 N, N_exp = 100, 15 
     20N, N_exp = 1000, 6 
    2121p = ParameterSet({}) 
    22 t_smooth = 10. # ms.  integration time to show fiber activity 
     22t_smooth = 100. # ms.  integration time to show fiber activity 
     23from retina import * 
     24retina = Retina(N) 
    2325 
    24 results = shelve.open('results/benchmark_linear') 
     26name = sys.argv[0].split('.')[0] # name of the current script withpout the '.py' part 
     27results = shelve.open('results/mat-' + name) 
    2528try: 
    2629    #boing # to force recomputing 
     
    3033 
    3134except: 
    32     from retina import * 
    33  
    34     retina = Retina(N) 
    3535    snr  = retina.params['snr']* numpy.linspace(0.1,2.0,N_exp) 
    3636    p.snr = ParameterRange(list(snr)) 
     
    4444    temporal_ON, temporal_OFF = [],[] 
    4545 
    46     pbar=progressbar.ProgressBar(widgets=["calculating", " ", progressbar.Percentage(), ' ', 
     46    pbar=progressbar.ProgressBar(widgets=[name, " ", progressbar.Percentage(), ' ', 
    4747            progressbar.Bar(), ' ', progressbar.ETA()], maxval=N_exp) 
    4848    for i_exp,experiment in enumerate(p.iter_inner()): 
     
    5858        pbar.update(i_exp) 
    5959 
    60  
    61     results = retina.params 
     60     
    6261    results['lower_edges'] = lower_edges 
    6362    results['temporal_ON'] = temporal_ON 
     
    6665    pbar.finish() 
    6766 
     67results.close() 
    6868 
    6969############################################################################### 
     
    8888#pylab.subplot(121) 
    8989#pylab.title('time course')# ON 
    90 pylab.xticks( numpy.round(numpy.linspace(0, results.simtime, 5),0) ) 
     90pylab.xticks( numpy.round(numpy.linspace(0, retina.params.simtime, 5),0) ) 
    9191pylab.ylabel('Firing frequency (Hz)') 
    9292pylab.xlabel('time (ms)') 
     
    103103#pylab.legend() 
    104104 
    105 pylab.savefig('results/benchmark_linear.pdf') #, dpi=300) # 
    106 #pylab.savefig('results/benchmark_linear.png', dpi=300) # 
     105pylab.savefig('results/fig-' + name + '.pdf') 
     106pylab.savefig('results/fig-' + name + '.png', dpi = 300) 
    107107 
    108 results.close() 
     108#TODO: make a plot showing it's the right point process with a histogram