def generic_report(r, dp, trace, annotation=None, axis0=(0, 0, 0, 0)): R = dp.get_res_space() UR = UpperSets(R) plotters = get_all_available_plotters() with r.subsection('S', caption='S') as rr: space = trace.S sequence = trace.get_s_sequence() generic_try_plotters(rr, plotters, space, sequence, axis0=axis0, annotation=annotation) with r.subsection('R', caption='R') as rr: space = UR sequence = trace.get_r_sequence() generic_try_plotters(rr, plotters, space, sequence, axis0=axis0, annotation=annotation)
def generic_plot(f, space, value): plotters = get_all_available_plotters() es = [] for name, plotter in plotters.items(): try: plotter.check_plot_space(space) except NotPlottable as e: es.append(e) # print('Plotter %r cannot plot %r:\n%s' % (name, space, e)) continue axis = plotter.axis_for_sequence(space, [value]) axis = enlarge(axis, 0.15) #print('enlarged: %s' % str(axis)) with f.plot(name) as pylab: plotter.plot(pylab, axis, space, value, params={}) pylab.axis(axis)
def generic_plot(f, space, value): plotters = get_all_available_plotters() es = [] for name, plotter in plotters.items(): try: plotter.check_plot_space(space) except NotPlottable as e: es.append(e) # print('Plotter %r cannot plot %r:\n%s' % (name, space, e)) continue axis = plotter.axis_for_sequence(space, [value]) axis = enlarge(axis, 0.15) #print('enlarged: %s' % str(axis)) with f.plot(name) as pylab: plotter.plot(pylab, axis, space, value, params={}) pylab.axis(axis)
def generic_report(r, dp, trace, annotation=None, axis0=(0, 0, 0, 0)): R = dp.get_res_space() UR = UpperSets(R) plotters = get_all_available_plotters() with r.subsection('S', caption='S') as rr: space = trace.S sequence = trace.get_s_sequence() generic_try_plotters(rr, plotters, space, sequence, axis0=axis0, annotation=annotation) with r.subsection('R', caption='R') as rr: space = UR sequence = trace.get_r_sequence() generic_try_plotters(rr, plotters, space, sequence, axis0=axis0, annotation=annotation)
def plot_value_generic(tag, vu): # @UnusedVariable r = Report() f = r.figure() try: available = dict(get_plotters(get_all_available_plotters(), vu.unit)) assert available except NotPlottable as e: msg = 'No plotters available for %s' % vu.unit raise_wrapped(ValueError, e, msg, compact=True) plotter = list(available.values())[0] axis = plotter.axis_for_sequence(vu.unit, [vu.value]) axis = enlarge(axis, 0.15) with f.plot('generic') as pylab: plotter.plot(pylab, axis, vu.unit, vu.value, params={}) pylab.axis(axis) png_node = r.resolve_url('png') png = png_node.get_raw_data() return png
def plot_value_generic(tag, vu): # @UnusedVariable r = Report() f = r.figure() try: available = dict( get_plotters(get_all_available_plotters(), vu.unit)) assert available except NotPlottable as e: msg = 'No plotters available for %s' % vu.unit raise_wrapped(ValueError, e, msg, compact=True) plotter = list(available.values())[0] axis = plotter.axis_for_sequence(vu.unit, [vu.value]) axis = enlarge(axis, 0.15) with f.plot('generic') as pylab: plotter.plot(pylab, axis, vu.unit, vu.value, params={}) pylab.axis(axis) png_node = r.resolve_url('png') png = png_node.get_raw_data() return png
def _report_loop_sequence(report, R, sips, converged, do_movie): """ Returns a dictionary dict(str: list of png data) """ sequences = {} UR = UpperSets(R) from matplotlib import pylab ieee_fonts(pylab) RepRepDefaults.savefig_params = dict(dpi=400, bbox_inches='tight', pad_inches=0.01, transparent=False) figsize = (2, 2) try: available_plotters = list( get_plotters(get_all_available_plotters(), UR)) except NotPlottable as e: msg = 'Could not find plotter for space UR = %s.' % UR raise_wrapped(DPInternalError, e, msg, UR=UR, compact=True) with report.subsection('sip') as r2: for name, plotter in available_plotters: sequences[name] = [] # sequence of png f = r2.figure(name, cols=5) axis = plotter.axis_for_sequence(UR, sips) axis = list(axis) axis[0] = 0.0 axis[2] = 0.0 axis[1] = min(axis[1], 1000.0) axis[3] = min(axis[3], 1000.0) axis = tuple(axis) visualized_axis = enlarge(axis, extra_space_top * 2) for i, sip in enumerate(sips): with f.plot('step%03d' % i, figsize=figsize) as pylab: logger.debug('Plotting iteration %d/%d' % (i, len(sips))) ieee_spines(pylab) c_orange = '#FFA500' c_red = [1, 0.5, 0.5] plotter.plot(pylab, axis, UR, R.U(R.get_bottom()), params=dict(color_shadow=c_red, markers=None)) marker_params = dict(markersize=5, markeredgecolor='none') plotter.plot(pylab, axis, UR, sip, params=dict(color_shadow=c_orange, markers_params=marker_params)) conv = converged[i] c_blue = [0.6, 0.6, 1.0] plotter.plot(pylab, axis, UR, conv, params=dict(color_shadow=c_blue)) for c in conv.minimals: p = plotter.toR2(c) pylab.plot(p[0], p[1], 'go', markersize=5, markeredgecolor='none', markerfacecolor='g', clip_on=False) pylab.axis(visualized_axis) from mcdp_ipython_utils.plotting import color_resources, set_axis_colors set_axis_colors(pylab, color_resources, color_resources) if do_movie: node = f.resolve_url('step%03d/png' % i) png = node.raw_data sequences[name].append(png) return sequences
def _report_loop_sequence(report, R, sips, converged, do_movie): """ Returns a dictionary dict(str: list of png data) """ sequences = {} UR = UpperSets(R) from matplotlib import pylab ieee_fonts(pylab) RepRepDefaults.savefig_params = dict(dpi=400, bbox_inches='tight', pad_inches=0.01, transparent=False) figsize = (2, 2) try: available_plotters = list(get_plotters(get_all_available_plotters(), UR)) except NotPlottable as e: msg = 'Could not find plotter for space UR = %s.' % UR raise_wrapped(DPInternalError, e, msg , UR=UR, compact=True) with report.subsection('sip') as r2: for name, plotter in available_plotters: sequences[name] = [] # sequence of png f = r2.figure(name, cols=5) axis = plotter.axis_for_sequence(UR, sips) axis = list(axis) axis[0] = 0.0 axis[2] = 0.0 axis[1] = min(axis[1], 1000.0) axis[3] = min(axis[3], 1000.0) axis = tuple(axis) visualized_axis = enlarge(axis, extra_space_top * 2) for i, sip in enumerate(sips): with f.plot('step%03d' % i, figsize=figsize) as pylab: logger.debug('Plotting iteration %d/%d' % (i, len(sips))) ieee_spines(pylab) c_orange = '#FFA500' c_red = [1, 0.5, 0.5] plotter.plot(pylab, axis, UR, R.U(R.get_bottom()), params=dict(color_shadow=c_red, markers=None)) marker_params = dict(markersize=5, markeredgecolor='none') plotter.plot(pylab, axis, UR, sip, params=dict(color_shadow=c_orange, markers_params=marker_params)) conv = converged[i] c_blue = [0.6, 0.6, 1.0] plotter.plot(pylab, axis, UR, conv, params=dict(color_shadow=c_blue)) for c in conv.minimals: p = plotter.toR2(c) pylab.plot(p[0], p[1], 'go', markersize=5, markeredgecolor='none', markerfacecolor='g', clip_on=False) pylab.axis(visualized_axis) from mcdp_ipython_utils.plotting import color_resources, set_axis_colors set_axis_colors(pylab, color_resources, color_resources) if do_movie: node = f.resolve_url('step%03d/png' % i) png = node.raw_data sequences[name].append(png) return sequences