本文整理汇总了Python中reprep.Report.data_pylab方法的典型用法代码示例。如果您正苦于以下问题:Python Report.data_pylab方法的具体用法?Python Report.data_pylab怎么用?Python Report.data_pylab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reprep.Report
的用法示例。
在下文中一共展示了Report.data_pylab方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: interval_histogram
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def interval_histogram(group, configuration, saccades): #@UnusedVariable
interval = saccades[:]['time_passed']
edges = (2.0 ** numpy.array(range(1, 21))) / 1000
# centers = (edges[1:]+edges[:-1])/2
h, edges_ = numpy.histogram(interval, bins=edges, normed=True) #@UnusedVariable
bin_width = numpy.diff(edges);
hn = h / bin_width;
print 'h', h
print 'hn', hn
print 'edges', edges
print 'width', bin_width
r = Report()
attach_description(r, description)
node_id = 'inthist'
with r.data_pylab(node_id) as pylab:
pylab.loglog(bin_width, h, 'x-')
pylab.title('not normalized')
pylab.xlabel('interval bin width (s)')
pylab.ylabel('density (s)')
node_id = 'inthistn'
with r.data_pylab(node_id) as pylab:
pylab.loglog(bin_width, hn, 'x-')
pylab.title('normalized by bin width')
pylab.xlabel('interval bin width (s)')
pylab.ylabel('density (s)')
return r
示例2: sample_var_time_correlation
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def sample_var_time_correlation(
sample, expdata, configuration, saccades, #@UnusedVariable
variables, delays, type='pearson'):
# all together
R, P, labels = get_correlation_matrix(saccades, variables, delays,
type)
# Significance
S = P < 0.01
nvars = len(variables)
Rhalf = R[:nvars, :]
Phalf = P[:nvars, :]
Shalf = S[:nvars, :]
ylabels = labels[:nvars]
r = Report()
attach_description(r, create_description(variables, delays, type))
with r.data_pylab('correlation') as pylab:
draw_correlation_figure(pylab, labels, ylabels, Rhalf)
rshow = lambda x: "%+.2f" % x
r.table('correlation_values', values_to_strings(Rhalf, rshow),
cols=labels, rows=ylabels, caption="%s coefficient" % type)
r.table('pvalues', values_to_strings(Phalf, pvalue_format),
cols=labels, rows=ylabels, caption="p-values")
with r.data_pylab('significance') as pylab:
draw_significance_figure(pylab, labels, ylabels, Shalf)
return r
示例3: hist_plots
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def hist_plots(d):
# TO
vars = [ ('C', d.C, {}),
('y', cov2corr(d.y_cov, False), {}),
('y_dot', cov2corr(d.y_dot_cov, False), {}),
('y_dot_sign', cov2corr(d.y_dot_sign_cov, False), {}) ]
r = Report()
f = r.figure(cols=5)
for var in vars:
label = var[0]
x = var[1]
nid = "hist_%s" % label
with r.data_pylab(nid) as pylab:
pylab.hist(x.flat, bins=128)
f.sub(nid, 'histogram of correlation of %s' % label)
order = scale_score(x)
r.data('order%s' % label, order).display('posneg').add_to(f, 'ordered')
nid = "hist2_%s" % label
with r.data_pylab(nid) as pylab:
pylab.plot(x.flat, order.flat, '.', markersize=0.2)
pylab.xlabel(label)
pylab.ylabel('order')
f.sub(nid, 'histogram of correlation of %s' % label)
h = create_histogram_2d(d.C, x, resolution=128)
r.data('h2d_%s' % label, numpy.flipud(h.T)).display('scale').add_to(f)
return r
示例4: create_report
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def create_report(data, image, outdir):
r = Report('%s_stats' % image)
xcorr = data['results']
lags = data['lags']
T = lags * (1.0 / 60) * 1000
mean_xcorr = numpy.mean(xcorr, axis=0)
min_xcorr = numpy.min(xcorr, axis=0)
max_xcorr = numpy.max(xcorr, axis=0)
with r.data_pylab('some') as pylab:
for i in range(0, 1000, 50):
pylab.plot(T, xcorr[i, :], 'x-', label='%d' % i)
pylab.axis([T[0], T[-1], -0.5, 1])
pylab.xlabel('delay (ms)')
pylab.ylabel('autocorrelation')
pylab.legend()
with r.data_pylab('mean_xcorr') as pylab:
pylab.plot(T, mean_xcorr, 'x-')
pylab.plot([T[0], T[-1]], [0, 0], 'k-')
pylab.plot([0, 0], [-0.5, 1], 'k-')
pylab.axis([T[0], T[-1], -0.5, 1.1])
pylab.xlabel('delay (ms)')
pylab.ylabel('autocorrelation')
with r.data_pylab('various') as pylab:
pylab.plot(T, mean_xcorr, 'gx-', label='mean')
pylab.plot(T, min_xcorr, 'bx-', label='min')
pylab.plot(T, max_xcorr, 'rx-', label='max')
pylab.plot([T[0], T[-1]], [0, 0], 'k-')
pylab.plot([0, 0], [-0.5, 1], 'k-')
pylab.axis([T[0], T[-1], -0.5, 1.1])
pylab.xlabel('delay (ms)')
pylab.ylabel('autocorrelation')
pylab.legend()
f = r.figure()
f.sub('some', caption='Autocorrelation of some receptors')
f.sub('mean_xcorr', caption='Mean autocorrelation')
f.sub('various', caption='Mean,min,max')
filename = os.path.join(outdir, r.id + '.html')
resources = os.path.join(outdir, 'images')
print 'Writing to %s' % filename
r.to_html(filename, resources)
return r
示例5: main
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def main():
N = 100
num_svds = 8
radius_deg = 180
kernels = [identity, linear01_sat, pow3_sat, pow7_sat]
# kernels = [linear01_sat, pow3_sat, pow7_sat]
r = Report('eig analysis')
# warps_desc = ", ".join(['%.2f' % x for x in warps])
caption = """ This figure shows that on S^1 things can be warped easily.
The initial distribution of {N} points, with radius {radius_deg}.
""".format(**locals())
f = r.figure(caption=caption)
mime = 'application/pdf'
figsize = (4, 3)
with r.data_pylab('kernels', mime=mime, figsize=figsize) as pylab:
for kernel in kernels:
x = np.linspace(-1, +1, 256)
y = kernel(x)
pylab.plot(x, y, label=kernel.__name__)
pylab.axis([-1, 1, -1, 1])
pylab.xlabel('Cosine between orientations')
pylab.ylabel('Correlation')
pylab.legend(loc='lower right')
r.last().add_to(f, caption='Correlation kernels')
for ndim in [2, 3]:
S = get_distribution(ndim, N, radius_deg)
C = cosines_from_directions(S)
D = distances_from_directions(S)
assert np.degrees(D.max()) <= 2 * radius_deg
with r.data_pylab('svds%d' % ndim,
mime=mime, figsize=figsize) as pylab:
for kernel in kernels:
Cw = kernel(C)
# TODO:
# Cw = cos(kernel(D))
s = svds(Cw, num_svds)
pylab.semilogy(s, 'x-', label=kernel.__name__)
pylab.legend(loc='center right')
r.last().add_to(f,
caption='Singular value for different kernels (ndim=%d)' % ndim)
filename = 'cbc_demos/kernels.html'
print("Writing to %r." % filename)
r.to_html(filename)
示例6: group_var_joint
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def group_var_joint(group, configuration, saccades, #@UnusedVariable
var1, delay1, var2, delay2):
var1delay = get_delay_desc_string(delay1)
var2delay = get_delay_desc_string(delay2)
r = Report()
attach_description(r, description.format(var1=var1, var2=var2,
var1delay=var1delay, var2delay=var2delay))
node_id = 'joint_%s%d_%s%d' % (var1.id, delay1, var2.id, delay2)
with r.data_pylab(node_id) as pylab:
colors = ['r', 'g', 'b', 'm', 'k'] * 50
for sample, saccades_for_sample in iterate_over_samples(saccades): #@UnusedVariable
x = saccades_for_sample[var1.field]
y = saccades_for_sample[var2.field]
x, y = get_delayed(x, delay1, y, delay2)
color = colors.pop()
pylab.plot(x, y, "%s." % color, markersize=MS)
pylab.axis([var1.interesting[0], var1.interesting[1],
var2.interesting[0], var2.interesting[1]]
)
pylab.xlabel('%s (%s)' % (var1.name, var1.unit))
pylab.ylabel('%s (%s)' % (var2.name, var2.unit))
node_id += "_log"
with r.data_pylab(node_id) as pylab:
colors = ['r', 'g', 'b', 'm', 'k'] * 50
for sample, saccades_for_sample in iterate_over_samples(saccades): #@UnusedVariable
x = saccades_for_sample[var1.field]
y = saccades_for_sample[var2.field]
x, y = get_delayed(x, delay1, y, delay2)
color = colors.pop()
pylab.loglog(x, y, "%s." % color, markersize=MS)
pylab.axis([var1.interesting[0], var1.interesting[1],
var2.interesting[0], var2.interesting[1]]
)
pylab.xlabel('%s (%s)' % (var1.name, var1.unit))
pylab.ylabel('%s (%s)' % (var2.name, var2.unit))
return r
示例7: group_var_hist
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def group_var_hist(group, configuration, saccades, variable): #@UnusedVariable
lb = variable.interesting[0]
ub = variable.interesting[1]
x = saccades[variable.field]
if variable.mod:
M = variable.interesting[1]
x = numpy.fmod(x + M, M)
hist, bin_edges = numpy.histogram(x, bins=variable.density_bins,
range=variable.interesting, normed=True)
bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2
r = Report()
attach_description(r, description.format(var=variable, ub=ub, lb=lb))
with r.data_pylab('histogram') as pylab:
pylab.plot(bin_centers, hist, 'b-')
pylab.ylabel('density')
pylab.xlabel('%s (%s)' % (variable.name, variable.unit))
pylab.axis([lb, ub, 0, variable.density_max_y])
return r
示例8: sample_var_hist
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def sample_var_hist(sample, expdata, configuration, #@UnusedVariable
saccades, variable):
lb = variable.interesting[0]
ub = variable.interesting[1]
x = saccades[variable.field]
if variable.mod:
M = variable.interesting[1]
x = numpy.fmod(x + M, M)
# TODO: we don't strictly enforce the bounds and we do not compute
# how many are left out
hist, bin_edges = numpy.histogram(x, bins=variable.density_bins,
range=variable.interesting, normed=True)
bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2
r = Report()
attach_description(r, description.format(var=variable, ub=ub, lb=lb))
with r.data_pylab('histogram') as pylab:
pylab.plot(bin_centers, hist, 'b-')
pylab.ylabel('density')
pylab.xlabel('%s (%s)' % (variable.name, variable.unit))
pylab.axis([lb, ub, 0, variable.density_max_y])
return r
示例9: plot_simulated_sample_trajectories
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def plot_simulated_sample_trajectories(
sample, exp_data, configuration, saccades): #@UnusedVariable
x = [0]
y = [0]
theta = 0
for saccade in saccades:
dt = saccade['time_passed']
xp = x[-1] + numpy.cos(theta) * dt * v
yp = y[-1] + numpy.sin(theta) * dt * v
x.append(xp)
y.append(yp)
theta += numpy.radians(saccade['amplitude']) * saccade['sign']
r = Report()
attach_description(r, description)
with r.data_pylab('simulated_trajectory') as pylab:
pylab.plot(x, y, 'b-')
pylab.xlabel('x position (m)')
pylab.ylabel('y position (m)')
pylab.axis('equal')
return r
示例10: plot_raw_trajectories
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def plot_raw_trajectories(sample, exp_data): #@UnusedVariable
thetas = numpy.radians(exp_data[:]['orientation'])
T = exp_data[:]['timestamp']
x = [0]
y = [0]
dt = T[1] - T[0]
for i in range(len(thetas)):
theta = thetas[i]
xp = x[-1] + numpy.cos(theta) * dt * v
yp = y[-1] + numpy.sin(theta) * dt * v
x.append(xp)
y.append(yp)
r = Report()
attach_description(r, description)
with r.data_pylab('simulated_trajectory') as pylab:
pylab.plot(x, y, 'b-')
pylab.xlabel('x position (m)')
pylab.ylabel('y position (m)')
pylab.axis('equal')
return r
示例11: group_sign_hist
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def group_sign_hist(group, configuration, saccades): #@UnusedVariable
r = Report()
attach_description(r, description)
left_percentage = []
for sample, saccades_for_sample in iterate_over_samples(saccades): #@UnusedVariable
sign = saccades_for_sample['sign']
left, = numpy.nonzero(sign == +1)
perc = len(left) * 100.0 / len(sign)
left_percentage.append(perc)
left_percentage = numpy.array(left_percentage)
N = len(left_percentage)
with r.data_pylab('sign_hist') as pylab:
R = range(N)
right_percentage = -left_percentage + 100
pylab.bar(left=R, height=left_percentage, color='b')
pylab.bar(left=R, height=right_percentage, bottom=left_percentage,
color='#faacb6')
pylab.plot([0], [0])
pylab.ylabel('percentage of left turns')
pylab.xlabel('sample')
pylab.axis([0, N, 0, 100])
return r
示例12: compute_general_statistics
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def compute_general_statistics(id, db, samples, interval_function,
signal, signal_component):
r = Report(id)
x = get_all_data_for_signal(db, samples, interval_function,
signal, signal_component)
limit = 0.3
perc = [0.001, limit, 1, 10, 25, 50, 75, 90, 99, 100 - limit, 100 - 0.001]
xp = map(lambda p: "%.3f" % scipy.stats.scoreatpercentile(x, p), perc)
lower = scipy.stats.scoreatpercentile(x, limit)
upper = scipy.stats.scoreatpercentile(x, 100 - limit)
f = r.figure()
with r.data_pylab('histogram') as pylab:
bins = numpy. linspace(lower, upper, 100)
pylab.hist(x, bins=bins)
f.sub('histogram')
labels = map(lambda p: "%.3f%%" % p, perc)
r.table("percentiles", data=[xp], cols=labels, caption="Percentiles")
r.table("stats", data=[[x.mean(), x.std()]], cols=['mean', 'std.dev.'],
caption="Other statistics")
print "Computing correlation..."
corr, lags = xcorr(x, maxlag=20)
print "...done."
with r.data_pylab('cross_correlation') as pylab:
delta = (1.0 / 60) * lags * 1000;
pylab.plot(delta, corr, 'o-')
pylab.axis([min(delta), max(delta), -0.7, 1.1])
pylab.xlabel('delay (ms)')
f = r.figure()
f.sub('cross_correlation')
return r
示例13: create_report_delayed
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def create_report_delayed(exp_id, delayed, description):
delays = numpy.array(sorted(delayed.keys()))
r = Report(exp_id)
r.text("description", description)
f = r.figure(cols=3)
# max and sum of correlation for each delay
# corr_max = []
corr_mean = []
for delay in delays:
data = delayed[delay]
a = data["action_image_correlation"]
id = "delay%d" % delay
# rr = r.node('delay%d' % delay)
r.data(id, a).data_rgb("retina", add_reflines(posneg(values2retina(a))))
corr_mean.append(numpy.abs(a).mean())
caption = "delay: %d (max: %.3f, sum: %f)" % (delay, numpy.abs(a).max(), numpy.abs(a).sum())
f.sub(id, caption=caption)
timestamp2ms = lambda x: x * (1.0 / 60) * 1000
peak = numpy.argmax(corr_mean)
peak_ms = timestamp2ms(delays[peak])
with r.data_pylab("mean") as pylab:
T = timestamp2ms(delays)
pylab.plot(T, corr_mean, "o-")
pylab.ylabel("mean correlation field")
pylab.xlabel("delay (ms) ")
a = pylab.axis()
pylab.plot([0, 0], [a[2], a[3]], "k-")
y = a[2] + (a[3] - a[2]) * 0.1
pylab.text(+5, y, "causal", horizontalalignment="left")
pylab.text(-5, y, "non causal", horizontalalignment="right")
pylab.plot([peak_ms, peak_ms], [a[2], max(corr_mean)], "b--")
y = a[2] + (a[3] - a[2]) * 0.2
pylab.text(peak_ms + 10, y, "%d ms" % peak_ms, horizontalalignment="left")
f = r.figure("stats")
f.sub("mean")
a = delayed[int(delays[peak])]["action_image_correlation"]
r.data_rgb("best_delay", add_reflines(posneg(values2retina(a))))
return r
示例14: sample_var_joint
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def sample_var_joint(sample, expdata, configuration, saccades, #@UnusedVariable
var1, delay1, var2, delay2):
x = saccades[var1.field]
y = saccades[var2.field]
x, y = get_delayed(x, delay1, y, delay2)
var1delay = get_delay_desc_string(delay1)
var2delay = get_delay_desc_string(delay2)
r = Report()
attach_description(r, description.format(var1=var1, var2=var2,
var1delay=var1delay,
var2delay=var2delay))
node_id = 'joint_%s%d_%s%d' % (var1.id, delay1, var2.id, delay2)
with r.data_pylab(node_id) as pylab:
pylab.plot(x, y, "b.", markersize=MS)
pylab.axis([var1.interesting[0], var1.interesting[1],
var2.interesting[0], var2.interesting[1]]
)
pylab.xlabel('%s (%s)' % (var1.name, var1.unit))
pylab.ylabel('%s (%s)' % (var2.name, var2.unit))
node_id += '_log'
with r.data_pylab(node_id) as pylab:
pylab.loglog(x, y, "b.", markersize=MS)
pylab.axis([var1.interesting[0], var1.interesting[1],
var2.interesting[0], var2.interesting[1]]
)
pylab.xlabel('%s (%s)' % (var1.name, var1.unit))
pylab.ylabel('%s (%s)' % (var2.name, var2.unit))
return r
示例15: raw_theta_hist
# 需要导入模块: from reprep import Report [as 别名]
# 或者: from reprep.Report import data_pylab [as 别名]
def raw_theta_hist(sample, exp_data): #@UnusedVariable
thetas = numpy.fmod(exp_data[:]['orientation'] + 360, 360)
r = Report()
attach_description(r, description)
with r.data_pylab('simulated_trajectory') as pylab:
pylab.hist(thetas, bins=90, normed=True)
pylab.xlabel('orientation (degrees)')
pylab.ylabel('density')
# TODO: choose ymax
a = pylab.axis()
pylab.axis([0, 360, 0, a[3]])
return r