Exemplo n.º 1
0
def run():
    """
    Retrieve the records of those simulations that finished in the past
    24 hours and draw their traces into one matplotlib figure as a PDF and
    PNG file.
    """
    (project_path, path_to_src) = util.get_project_and_src_paths()

    path_to_sims = os.path.join(project_path, 'sims')
    db, simdir = simdb.build_database(path_to_sims) # Build the database
    sub_dict = dict(dictdb.filter_dict(db, lambda k, v, p: \
            k == 'end_time' and \
            len(p) >= 2 and p[-2] == 'sim_info' and \
            (datetime.datetime.now() - v).days <= 1))
    
    # Initialize a figure
    fig = pyplot.figure()
    ax = fig.add_subplot(111)
    
    for (k, v) in sub_dict.iteritems():
        # k is the name of the simulation folder in the simdir directory.
        simpath = os.path.join(simdir, k)
            
        # Unpickle the vec.p files in the folder
        with open(os.path.join(simpath, 'v_vec.p')) as vec_file:
            v_vec = pickle.load(vec_file)
        with open(os.path.join(simpath, 't_vec.p')) as vec_file:
            t_vec = pickle.load(vec_file)
        
        # Draw the results to the figure
        ax.plot(t_vec, v_vec)

    # Save as a pdf file and a png file.
    outdir = path_to_sims = os.path.join(project_path, 'analysis')
    fig.savefig(os.path.join(outdir, 'fig1.pdf'))
    fig.savefig(os.path.join(outdir, 'fig1.png'))
Exemplo n.º 2
0
import os, datetime
from neuronpy.util import dictdb
import simdb

import main

main.run()
main.run(["sim_var['asyn_gmax']=2"])
main.run(["sim_var['asyn_gmax']=2", "sim_var['asyn_onset']=30"])
main.run(["sim_var['asyn_onset']=30"])

import fig1

fig1.run()

db, simdir = simdb.build_database() # Build the database
sub_sims = dict(dictdb.filter_dict(db, lambda k, v, p: \
        k == 'end_time' and \
        len(p) >= 2 and p[-2] == 'sim_info' and \
        (datetime.datetime.now() - v).days <= 1))

for some_dir in sub_sims.iterkeys():
    filepath = os.path.join(simdir, some_dir)
    exec_str = 'rm -r -f ' + filepath
    os.system(exec_str)