# Path: bionet/utils/misc.py
# def func_timer(f):
#     """
#     Time the execution of a function.
# 
#     Parameters
#     ----------
#     f : function
#         Function to time.
#     """
# 
#     def wrapper(*args, **kwargs):
#         start = time.time()
#         res = f(*args, **kwargs)
#         stop = time.time()
#         print 'execution time = %.5f s' % (stop-start)
#         return res
#     return wrapper


import sys
import numpy as np
import matplotlib
import bionet.utils.band_limited as bl
import bionet.utils.plotting as pl
import bionet.ted.iaf as iaf
import bionet.ted.iaf_trig_cuda as iaf_trig_cuda
import pycuda.autoinit
import scikits.cuda.autoinit
from bionet.utils.misc import func_timer
# Distributed under the terms of the BSD license:
# http://www.opensource.org/licenses/bsd-license


# Set matplotlib backend so that plots can be generated without a
# display:
matplotlib.use('AGG')



# For determining output plot file names:
output_name = 'iaf_trig_cuda_demo_'
output_count = 0
output_ext = '.png'

# Define algorithm parameters and input signal:
dur = 0.1
dt = 1e-6
f = 32
bw = 2*np.pi*f
t = np.arange(0, dur, dt)

np.random.seed(0)

noise_power = None
if noise_power == None:
    fig_title = 'IAF Input Signal with no Noise';
else:
    fig_title = 'IAF Input Signal with %d dB of Noise' % noise_power;
print fig_title

# Path: bionet/utils/misc.py
# def func_timer(f):
#     """
#     Time the execution of a function.
# 
#     Parameters
#     ----------
#     f : function
#         Function to time.
#     """
# 
#     def wrapper(*args, **kwargs):
#         start = time.time()
#         res = f(*args, **kwargs)
#         stop = time.time()
#         print 'execution time = %.5f s' % (stop-start)
#         return res
#     return wrapper


# Path: demos/iaf_trig_cuda_demo.py
import sys
import numpy as np
import matplotlib
import bionet.utils.band_limited as bl
import bionet.utils.plotting as pl
import bionet.ted.iaf as iaf
import bionet.ted.iaf_trig_cuda as iaf_trig_cuda
import pycuda.autoinit
import scikits.cuda.autoinit
from bionet.utils.misc import func_timer

# Distributed under the terms of the BSD license:
# http://www.opensource.org/licenses/bsd-license


# Set matplotlib backend so that plots can be generated without a
# display:
matplotlib.use('AGG')



# For determining output plot file names:
output_name = 'iaf_trig_cuda_demo_'
output_count = 0
output_ext = '.png'

# Define algorithm parameters and input signal:
dur = 0.1
dt = 1e-6
f = 32
bw = 2*np.pi*f
t = np.arange(0, dur, dt)

np.random.seed(0)

noise_power = None
if noise_power == None:
    fig_title = 'IAF Input Signal with no Noise';
else:
    fig_title = 'IAF Input Signal with %d dB of Noise' % noise_power;
print fig_title

u = func_timer(bl.gen_band_limited)(dur, dt, f, noise_power)