示例#1
0
          alpha=0.4,
          linewidth=0.5)

ax.legend(loc='lower right')

# Add difference
ax = plt.subplot(gs[3, 0], sharex=ax)
ax.set_xlabel('x')
diff_factor = 1.e-7
ax.set_ylabel(r'diff., $\times10^{-7}$')

diff = integral_n - integral_a
ax.bar(x_edges[:-1], diff / diff_factor, bar_width * 2.0, align='edge')

# Freeze axis limits and draw bin edges
ax.autoscale(enable=True, axis='y')
ymin, ymax = ax.get_ylim()
ax.vlines(integrator.points.xedges.data(),
          ymin,
          ymax,
          linestyle='--',
          alpha=0.4,
          linewidth=0.5)

# Save figure and graph as images
savefig(tutorial_image_name('png'))

savegraph(fcn.sum, tutorial_image_name('png', suffix='graph'), rankdir='TB')

plt.show()
示例#2
0
print('    <no functions executed>')
print()

print('Done')

integrator.print()
print()

print(dbg1b.debug.target.data().sum(), dbg2b.debug.target.data().sum())

# # Label transformations
hist.hist.setLabel('Input histogram\n(bins definition)')
integrator.points.setLabel('Sampler\n(Gauss-Legendre)')
sin_t.sin.setLabel('sin(x)')
cos1_arg.sum.setLabel('k1*x')
cos2_arg.sum.setLabel('k2*x')
cos1_t.cos.setLabel('cos(k1*x)')
cos2_t.cos.setLabel('cos(k2*x)')
int1.setLabel('Integrator 1\n(convolution)')
int2.setLabel('Integrator 2\n(convolution)')
fcn1.sum.setLabel('a1*sin(x) + b1*cos(k1*x)')
fcn2.sum.setLabel('a2*sin(x) + b2*cos(k2*x)')
dbg1a.debug.setLabel('Debug 1\n(before integral 1)')
dbg2a.debug.setLabel('Debug 2\n(before integral 2)')
dbg1b.debug.setLabel('Debug 1\n(after integral 1)')
dbg2b.debug.setLabel('Debug 2\n(after integral 2)')

savegraph(int_points, tutorial_image_name('png', suffix='graph'), rankdir='TB')

plt.show()
示例#3
0
# Save figure
savefig(tutorial_image_name('png'))

# Add integration points and save
ax.scatter(X, Y, c='red', marker='.', s=0.2)
ax.set_xlim(-0.5, 0.5)
ax.set_ylim(0.0, 1.0)

savefig(tutorial_image_name('png', suffix='zoom'))

# Plot 3d function and a histogram
fig = plt.figure()
ax = plt.subplot(111,
                 xlabel='x',
                 ylabel='y',
                 title=r'$\sin(ax+by)$',
                 projection='3d')
ax.minorticks_on()
ax.view_init(elev=17., azim=-33)

# Draw the function and integrals
integrator.hist.hist.plot_surface(cmap='viridis', colorbar=True)
sin_t.sin.result.plot_wireframe_vs(X, Y, rstride=8, cstride=8)

# Save the figure and the graph
savefig(tutorial_image_name('png', suffix='3d'))
savegraph(sin_t.sin, tutorial_image_name('png', suffix='graph'), rankdir='TB')

plt.show()
示例#4
0
hist1 = C.Histogram(edges, data1)
hist1.hist.setLabel('Input histogram 1')

hist2 = C.Histogram(edges, data2)
hist2.hist.setLabel('Input histogram 2')

hist3 = C.Histogram(edges, data3)
hist3.hist.setLabel('Input histogram 3')

#
# Bind outputs
#
suffix = '' if cfg.split_transformations else 'merged_'
savegraph(b.context.outputs.smearing_matrix.values(),
          tutorial_image_name('png', suffix=suffix + 'graph0'),
          rankdir='TB')

hist1 >> b.context.inputs.smearing_matrix.values(nested=True)
hist1 >> b.context.inputs.eres.D1.values(nested=True)
hist2 >> b.context.inputs.eres.D2.values(nested=True)
hist3 >> b.context.inputs.eres.D3.values(nested=True)
print(b.context)

savegraph(hist1,
          tutorial_image_name('png', suffix=suffix + 'graph1'),
          rankdir='TB')

#
# Plot
#
示例#5
0
文件: 07_graphviz.py 项目: gnafit/gna
for i, p in enumerate(points_list):
    p.points.setLabel('Sum input:\nP{:d}'.format(i))
tfactor.points.setLabel('Scale S')
tsum.sum.setLabel('Sum of matrices')
tprod.product.setLabel('Scaled matrix')
tprod.product.product.setLabel('result')

tsum.print()
print()

tprod.print()
print()

print('The sum:')
print(tsum.transformations[0].outputs[0].data())
print()

print('The scale:')
print(tfactor.transformations[0].outputs[0].data())
print()

print('The scaled sum:')
print(tprod.transformations[0].outputs[0].data())
print()

from gna.graphviz import savegraph
savegraph(tprod.transformations[0], tutorial_image_name('dot'), rankdir='TB')
savegraph(tprod.transformations[0], tutorial_image_name('pdf'), rankdir='TB')
savegraph(tprod.transformations[0], tutorial_image_name('png'), rankdir='TB')