예제 #1
0
def make_plot(cnv_name, test_name, data, d_min, d_max):
    plot = figure(title=test_name,
                  plot_width=700,
                  plot_height=500,
                  min_border=0)

    glyph1 = VArea(x="x1",
                   y1="y01",
                   y2="y1",
                   fill_color="LightCoral",
                   fill_alpha=0.6)
    glyph2 = VArea(x="x2",
                   y1="y02",
                   y2="y2",
                   fill_color="LightBlue",
                   fill_alpha=0.6)
    plot.add_glyph(data, glyph1)
    plot.add_glyph(data, glyph2)

    li1 = LegendItem(label='0 (Absent)', renderers=[plot.renderers[0]])
    li2 = LegendItem(label='1 (Present)', renderers=[plot.renderers[1]])
    legend1 = Legend(items=[li1, li2], location='top_right')
    plot.add_layout(legend1)
    plot.legend.title = cnv_name

    return plot
예제 #2
0
def test_VArea() -> None:
    glyph = VArea()
    assert glyph.x == field("x")
    assert glyph.y1 == field("y1")
    assert glyph.y2 == field("y2")
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y1",
        "y2",
    ], FILL, HATCH, GLYPH)
예제 #3
0
def test_VArea() -> None:
    glyph = VArea()
    assert glyph.x is None
    assert glyph.y1 is None
    assert glyph.y2 is None
    check_fill_properties(glyph)
    check_hatch_properties(glyph)
    check_properties_existence(glyph, [
        "x",
        "y1",
        "y2",
    ], FILL, HATCH, GLYPH)
예제 #4
0
    stdxy = beam_pvs['beam:sigma_x'].value
    maxr = beam_pvs['beam:max_r'].value

    power_on = caget('laser_on')

    return dict(x=avgz, y1=(avgx + stdxy)*power_on, y2=(avgx - stdxy)*power_on)

beamsize_source = ColumnDataSource( data=get_beam_data(beam_pvs) )

def get_fractional_laser_power(laser_pvs, pvdb):
    return (laser_pvs['laser:power'].value)/pvdb['input'][f'{prefix}laser:power']['hilim']
frac_power = get_fractional_laser_power(laser_pvs, pvdb)

avgz = beam_pvs['beam:mean_z'].value
beamsize_plot = figure(plot_height=200, plot_width=800, title="vB24", tools="crosshair,pan,reset,save,wheel_zoom", x_range=[0, avgz[-1]], y_range=[-5,5])
beamsize_glyph = VArea(x="x", y1="y1", y2="y2", fill_color="blue", fill_alpha=frac_power)

beamsize_plot.add_glyph(beamsize_source, beamsize_glyph)
beamsize_plot.xaxis.axis_label = 's (m)'
beamsize_plot.yaxis.axis_label = 'Transverse Beam Size (mm)'

# Transmission plot
T = beam_pvs['beam:transmission'].value
zero = np.zeros( (len(T),) )
Tsource = ColumnDataSource( data=dict(x=avgz, y1=T, y2=zero) )
glyphT = VArea(x="x", y1="y1", y2="y2", fill_color="grey", fill_alpha=frac_power)
transplot = figure(plot_height=200, plot_width=800, title="vB24", tools="crosshair,pan,reset,save,wheel_zoom", x_range=[0, avgz[-1]])
transplot.add_glyph(Tsource, glyphT)
transplot.xaxis.axis_label = 's (m)'
transplot.yaxis.axis_label = 'Transmission (%)'
예제 #5
0
from bokeh.io import curdoc, show

N = 30
x = np.linspace(-2, 3, N)
y1 = np.zeros(N)
y2 = 10 - x**2

source = ColumnDataSource(dict(x=x, y1=y1, y2=y2))

plot = Plot(title=None,
            plot_width=300,
            plot_height=300,
            min_border=0,
            toolbar_location=None)

glyph = VArea(x="x", y1="y1", y2="y2", fill_color="#f46d43")
plot.add_glyph(source, glyph)

xaxis = LinearAxis()
plot.add_layout(xaxis, 'below')

yaxis = LinearAxis()
plot.add_layout(yaxis, 'left')

plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

curdoc().add_root(plot)

show(plot)