def histogram_plot(states, height, width, data_top, data_source, n_ticks, n_minor_ticks=0, fill_color=None): '''Create a bokeh histogram using quad shapes''' from bokeh.plotting import Figure # Create histogram object hist_obj = Figure(plot_height=height, plot_width=width, title="", toolbar_location=None) # Data top is string of var name from data_source fill_color = '#f0f5f5' if fill_color == None else fill_color hist_obj.quad(top=data_top, bottom=0, source=data_source, left="left", right="right", fill_color=fill_color, line_color='black') # set number of major and minor ticks hist_obj.xaxis[0].ticker.desired_num_ticks = n_ticks hist_obj.xaxis[0].ticker.num_minor_ticks = n_minor_ticks hist_obj.y_range = Range1d(0, 1) hist_obj.x_range = Range1d(states[0] - 0.5, states[-1] + 0.5) return hist_obj
def make_precipitation_plot(source): plot = Figure(x_axis_type="datetime", plot_width=1000, plot_height=125, min_border_left=50, min_border_right=50, min_border_top=0, min_border_bottom=0, toolbar_location=None) plot.title = None plot.quad(top='actual_precipitation', bottom=0, left='left', right='right', color=Greens4[1], source=source) # fixed attributes plot.border_fill_color = "whitesmoke" plot.yaxis.axis_label = "Precipitation (in)" plot.axis.major_label_text_font_size = "8pt" plot.axis.axis_label_text_font_size = "8pt" plot.axis.axis_label_text_font_style = "bold" plot.x_range = DataRange1d(range_padding=0.0, bounds=None) plot.y_range = DataRange1d(range_padding=0.0, bounds=None) plot.grid.grid_line_alpha = 0.3 plot.grid[0].ticker.desired_num_ticks = 12 return plot
def performance(): plot = Figure(x_axis_type="datetime", tools="save", toolbar_location=None, plot_width=1000, plot_height=300) l1 = plot.line(x="time", y="power_out", source=source_perfomance, line_color="green", name="local") plot.add_tools(HoverTool(renderers=[l1])) plot.select(dict(type=HoverTool)).tooltips = [("Date", "@hover_time"), ("Performance", "@power_out")] l2 = plot.line(x="time", y="avg_perf", source=source_perfomance, line_color="red", name="global") plot.x_range = DataRange1d(range_padding=0.0, bounds=None) plot.title = "Plant Performance" return plot
def createPlots(): ######################################## BS Pressure Plot ######################################## sourceBuySell, sourceVolume = requestHoseData() pBuySell = Figure(plot_width=PLOT_WIDTH, plot_height=BUYSELL_PLOT_HEIGHT, name="pltBuySell") pBuySell.xaxis.ticker = [8.75, 9, 9.5, 10, 10.5, 11, 11.5, 13, 13.5, 14, 14.5, 14.75] pBuySell.xaxis.major_label_overrides = { 8.5: "8:30", 8.75: "8:45", 9: "9:00", 9.5: "9:30", 10: "10:00", 10.5: "10:30", 11: "11:00", 11.5: "11:30", 13: "13:00", 13.5: "13:30", 14: "14:00", 14.5: "14:30", 14.75: "14:45"} pBuySell.line(x='index', y='buyPressure', source=sourceBuySell, color='green', legend_label="Tổng đặt mua", name="glyphSellPressure") pBuySell.line(x='index', y='sellPressure', source=sourceBuySell, color='red', legend_label="Tổng đặt bán", name="glyphBuyPressure") wz = WheelZoomTool(dimensions="width"); pBuySell.add_tools(wz); pBuySell.toolbar.active_scroll = wz pBuySell.toolbar.logo = None pBuySell.axis[0].visible = False pBuySell.legend.location = "top_left" pBuySell.legend.click_policy = "hide" pBuySell.legend.background_fill_alpha = 0.0 ######################################## Volume Plot ######################################## pVolume = Figure(width=PLOT_WIDTH, height=VOLUME_PLOT_HEIGHT, tools="pan, reset", name="pltVolume") pVolume.toolbar.logo = None wz = WheelZoomTool(dimensions="height"); pVolume.add_tools(wz); pVolume.toolbar.active_scroll = wz pVolume.vbar(x='index', top='totalValue', width=1 /60, color='blue', source=sourceVolume, fill_alpha=LIQUIDITY_ALPHA, line_alpha=LIQUIDITY_ALPHA, name="glyphTotalValue", legend_label="Thanh khoản toàn tt") pVolume.vbar(x='index', top='nnBuy', width=1/1.2/60, color='green', source=sourceVolume ,name="glyphNNBuy", legend_label="NN mua",) pVolume.vbar(x='index', top='nnSell', width=1/1.2/60, color='red', source=sourceVolume ,name="glyphNNSell", legend_label="NN bán",) pVolume.x_range = pBuySell.x_range pVolume.y_range=Range1d(-10, 45) pVolume.legend.location = "top_left" pVolume.legend.click_policy = "hide" pVolume.legend.background_fill_alpha = 0.0 ######################################### OHLC plot ######################################### orders, source, pressure = requestPSData() plotOhlc = createOhlcPlot(source) pCandle, divCandle = hookupFigure(plotOhlc) # "divCustomJS" "pltOHLC" "glyphOHLCSegment" pDebug = Paragraph(text=f"""["num_ps_orders": "{len(orders['index'])}"]\n""" """""", width=DIV_TEXT_WIDTH, height=100, name="pDebug") ################################# Putting all plots together ################################ def activation_function(): pBuySell._document.add_periodic_callback(lambda: updateDoc(pBuySell._document), 500) print("Document activated !") return pCandle, pBuySell, pVolume, divCandle , activation_function, sourceBuySell, sourceVolume, pDebug
def make_plot(source, AverageTemp, Parcentile_5_Min, Parcentile_5_Max, Parcentile_25_Min, Parcentile_25_Max, MinTemp, MaxTemp, plotDate, cityName): plot = Figure(title='Optional Task # 1 : Growing Degree-day for ' + cityName, x_axis_type="datetime", plot_width=1000, title_text_font_size='12pt', tools="", toolbar_location=None) colors = Blues4[0:3] plot.circle(MaxTemp, MinTemp, alpha=0.9, color="#66ff33", fill_alpha=0.2, size=10, source=source, legend='2015') plot.quad(top=Parcentile_5_Max, bottom=Parcentile_5_Min, left='left', right='right', source=source, color="#e67300", legend="Percentile 5-95") plot.quad(top=Parcentile_25_Max, bottom=Parcentile_25_Min, left='left', right='right', source=source, color="#66ccff", legend="percentile 25-75") plot.line(plotDate, AverageTemp, source=source, line_color='Red', line_width=0.75, legend='AverageTemp') plot.border_fill_color = "whitesmoke" plot.xaxis.axis_label = "Months" plot.yaxis.axis_label = "Temperature (C)" plot.axis.major_label_text_font_size = "10pt" plot.axis.axis_label_text_font_size = "12pt" plot.axis.axis_label_text_font_style = "bold" plot.x_range = DataRange1d(range_padding=0.0, bounds=None) plot.grid.grid_line_alpha = 0.3 plot.grid[0].ticker.desired_num_ticks = 12 return plot
def utilization_bar(max_y): plot = Figure( plot_width= 150, # this is more for the ratio, because we have auto-width scaling plot_height=150, tools=[], # no tools needed for this one title='Utilization') plot.toolbar.logo = None # hides logo plot.x_range = Range1d(0, 1) plot.y_range = Range1d( 0, max_y) # sometimes you want it to be way less than 1, to see it move plot.xaxis.visible = False # hide x axis # Add input buffer manager = Manager() plot._input_buffer = manager.dict() return plot
def make_plot(source, title): print("make plot") plot = Figure(x_axis_type="datetime", plot_width=1000, tools="", toolbar_location=None) plot.title = title colors = Blues4[0:3] plot.quad(top='record_max_temp', bottom='record_min_temp', left='left', right='right', color=colors[2], source=source, legend="Record") plot.quad(top='average_max_temp', bottom='average_min_temp', left='left', right='right', color=colors[1], source=source, legend="Average") plot.quad(top='actual_max_temp', bottom='actual_min_temp', left='left', right='right', color=colors[0], alpha=0.5, line_color="black", source=source, legend="Actual") # fixed attributes plot.border_fill_color = "whitesmoke" plot.xaxis.axis_label = None plot.yaxis.axis_label = "Temperature (F)" plot.axis.major_label_text_font_size = "8pt" plot.axis.axis_label_text_font_size = "8pt" plot.axis.axis_label_text_font_style = "bold" plot.x_range = DataRange1d(range_padding=0.0, bounds=None) plot.grid.grid_line_alpha = 0.3 plot.grid[0].ticker.desired_num_ticks = 12 return plot
def make_plot(source,AverageTemp,Parcentile_5_Min,Parcentile_5_Max,Parcentile_25_Min,Parcentile_25_Max,MinTemp,MaxTemp,plotDate,cityName): plot = Figure(title='Optional Task # 1 : Growing Degree-day for '+cityName, x_axis_type="datetime", plot_width=1000, title_text_font_size='12pt', tools="", toolbar_location=None) colors = Blues4[0:3] plot.circle(MaxTemp,MinTemp, alpha=0.9, color="#66ff33", fill_alpha=0.2, size=10,source=source,legend ='2015') plot.quad(top=Parcentile_5_Max, bottom=Parcentile_5_Min, left='left',right='right', source=source,color="#e67300", legend="Percentile 5-95") plot.quad(top=Parcentile_25_Max, bottom=Parcentile_25_Min,left='left',right='right', source=source,color="#66ccff",legend="percentile 25-75") plot.line(plotDate,AverageTemp,source=source,line_color='Red', line_width=0.75, legend='AverageTemp') plot.border_fill_color = "whitesmoke" plot.xaxis.axis_label = "Months" plot.yaxis.axis_label = "Temperature (C)" plot.axis.major_label_text_font_size = "10pt" plot.axis.axis_label_text_font_size = "12pt" plot.axis.axis_label_text_font_style = "bold" plot.x_range = DataRange1d(range_padding=0.0, bounds=None) plot.grid.grid_line_alpha = 0.3 plot.grid[0].ticker.desired_num_ticks = 12 return plot
def make_plot(source, title): plot = Figure(x_axis_type="datetime", plot_width=1000, tools="", toolbar_location=None) plot.title = title colors = Blues4[0:3] plot.quad(top='record_max_temp', bottom='record_min_temp', left='left', right='right', color=colors[2], source=source, legend="Record") plot.quad(top='average_max_temp', bottom='average_min_temp', left='left', right='right', color=colors[1], source=source, legend="Average") plot.quad(top='actual_max_temp', bottom='actual_min_temp', left='left', right='right', color=colors[0], alpha=0.5, line_color="black", source=source, legend="Actual") # fixed attributes plot.border_fill_color = "whitesmoke" plot.xaxis.axis_label = None plot.yaxis.axis_label = "Temperature (F)" plot.axis.major_label_text_font_size = "8pt" plot.axis.axis_label_text_font_size = "8pt" plot.axis.axis_label_text_font_style = "bold" plot.x_range = DataRange1d(range_padding=0.0, bounds=None) plot.grid.grid_line_alpha = 0.3 plot.grid[0].ticker.desired_num_ticks = 12 return plot
def histogram_plot(states, height, width, data_top, data_source, n_ticks, n_minor_ticks=0, fill_color=None): '''Create a bokeh histogram using quad shapes''' from bokeh.plotting import Figure # Create histogram object hist_obj = Figure(plot_height=height, plot_width=width, title="", toolbar_location=None) # Data top is string of var name from data_source fill_color = '#f0f5f5' if fill_color==None else fill_color hist_obj.quad(top=data_top, bottom=0, source=data_source, left="left", right="right", fill_color=fill_color, line_color='black') # set number of major and minor ticks hist_obj.xaxis[0].ticker.desired_num_ticks = n_ticks hist_obj.xaxis[0].ticker.num_minor_ticks = n_minor_ticks hist_obj.y_range = Range1d(0, 1) hist_obj.x_range = Range1d(states[0]-0.5, states[-1]+0.5) return hist_obj
#sn = (spec_dict[template_to_start_with].flux * 1.e16 * 100. ) ** 0.5 signal_to_noise = simulate_exposure(luvoir, lumos, spec_dict[template_to_start_with].wave, spec_dict[template_to_start_with].flux, 1.0) flux_cut = spec_dict[template_to_start_with].flux flux_cut[spec_dict[template_to_start_with].wave < lumos.lambda_range[0]] = -999. flux_cut[spec_dict[template_to_start_with].wave > lumos.lambda_range[0]] = -999. spectrum_template = ColumnDataSource(data=dict(w=spec_dict[template_to_start_with].wave, f=spec_dict[template_to_start_with].flux, \ w0=spec_dict[template_to_start_with].wave, f0=spec_dict[template_to_start_with].flux, \ flux_cut=flux_cut, sn=signal_to_noise)) # set up the flux plot flux_plot = Figure(plot_height=400, plot_width=800, tools="crosshair,hover,pan,reset,resize,save,box_zoom,wheel_zoom", outline_line_color='black', x_range=[900, 2000], y_range=[0, 4e-16], toolbar_location='right') flux_plot.x_range=Range1d(900,2000,bounds=(900,2000)) flux_plot.y_range=Range1d(0,4e-16,bounds=(0,None)) flux_plot.background_fill_color = "beige" flux_plot.background_fill_alpha = 0.5 flux_plot.yaxis.axis_label = 'Flux' flux_plot.xaxis.axis_label = 'Wavelength' flux_plot.line('w', 'f', source=spectrum_template, line_width=3, line_color='firebrick', line_alpha=0.7, legend='Source Flux') flux_plot.line(lumos.wave, lumos.bef, line_width=3, line_color='darksalmon', line_alpha=0.7, legend='Background') # set up the flux plot sn_plot = Figure(plot_height=400, plot_width=800, tools="crosshair,hover,pan,reset,resize,save,box_zoom,wheel_zoom", outline_line_color='black', x_range=[900, 2000], y_range=[0, 40], toolbar_location='right')
def temp(request): month = request.GET['month'] cnx = DB.connect(host='ec500-nasa.csmyiysxb7lc.us-east-1.rds.amazonaws.com',user='******',passwd='nasaenvironment',db='environment') cur = cnx.cursor() #cur.execute("SELECT VERSION()") #data = cur.fetchone() #print "Database Version:%s" % data sql = "SELECT * FROM environment.Temp_Deviation_Monthly WHERE Month=%s" %month year =[] month=[] USCRN =[] CLIMDIV =[] CMBUSHCN =[] try: cur.execute(sql) data=cur.fetchall() for row in data: year.append(row[0]) month.append(row[1]) USCRN.append(row[2]) CLIMDIV.append(row[3]) CMBUSHCN.append(row[4]) except: print "Error: unable to fecth data" plot = Figure(x_range=[1895,2016], y_range=[-10,8], plot_width=1000, tools="", toolbar_location=None) plot.title = "Plot of temprature of month %s from 1895-2015" % month[0] colors = Blues4[0:3] plot.border_fill_color = "whitesmoke" plot.xaxis.axis_label = "Year" plot.yaxis.axis_label = "Temperature (F)" plot.axis.major_label_text_font_size = "8pt" plot.axis.axis_label_text_font_size = "8pt" plot.axis.axis_label_text_font_style = "bold" plot.x_range = DataRange1d(range_padding=0.0, bounds=None) plot.grid.grid_line_alpha = 0.3 plot.grid[0].ticker.desired_num_ticks = 12 plot.line(year, USCRN, color='#A6CEE3', legend='AAPL') plot.line(year, CLIMDIV, color='#B2DF8A', legend='GOOG') plot.line(year, CMBUSHCN, color='#33A02C', legend='IBM') #fig=plt.figure(figsize=(16,12)) #plt.xlabel('Year') #plt.ylabel('Temprature') #plt.style.use('ggplot') #plt.plot(year,USCRN,'ro-') #plt.plot(year,CLIMDIV,'go-') #plt.plot(year,CMBUSHCN,'bo-') #plt.axis([1895,2016,-10,8]) #plt.title('Plot of temprature of month %s from 1895-2015' %month[0]) #os.remove(os.getcwd() + '\Temprature.png') #plt.savefig(os.path.join(BASE_DIR, 'static\img\Temprature.png'),dpi=80) #plt.savefig(os.path.join(BASE_DIR, 'static\img\Temprature2.png'),dpi=80) #fig.clf() #plt.close(fig) #img=open(os.getcwd() + '\Temprature.png',"rb") #response = django.http.HttpResponse(content_type="image/png") #plt.savefig(response, format="png") #img=open("Temprature.png", "rb") #img.save(response, "PNG") #img.close() #image_bytes = requests.get(os.path.join(BASE_DIR, 'static\img\Temprature.png').content #image_bytes.save(response,"PNG")#lambda x: x.startswith('Temprature') #f = open(os.path.join(BASE_DIR, 'static\img\Temprature.png'),"rb") #img = f.read() #f.close() cur.close() cnx.close() script,div=components(plot) return render(request, "temp.html",{"this_script": script, "this_div": div})
# initialize the plot data update_source_data(True) # make the plot responsive to slider changes standard_deviation_slider.on_change( 'value', lambda attr, old_value, new_value: update_source_data(True)) cutoff_slider.on_change( 'value', lambda attr, old_value, new_value: update_source_data(False)) # create the figure p = Figure(title='Normal Distribution') p.scatter(source=source, x='x', y='y', color='green', alpha='alpha', radius=0.1) p.x_range = Range1d(start=-8, end=8) p.y_range = Range1d(start=-8, end=8) content = column(standard_deviation_slider, cutoff_slider, p) # register the figure curdoc().add_root(content) curdoc().title = 'Normal Distribution'
def temp(request): month = request.GET['month'] cnx = DB.connect( host='ec500-nasa.csmyiysxb7lc.us-east-1.rds.amazonaws.com', user='******', passwd='nasaenvironment', db='environment') cur = cnx.cursor() #cur.execute("SELECT VERSION()") #data = cur.fetchone() #print "Database Version:%s" % data sql = "SELECT * FROM environment.Temp_Deviation_Monthly WHERE Month=%s" % month year = [] month = [] USCRN = [] CLIMDIV = [] CMBUSHCN = [] try: cur.execute(sql) data = cur.fetchall() for row in data: year.append(row[0]) month.append(row[1]) USCRN.append(row[2]) CLIMDIV.append(row[3]) CMBUSHCN.append(row[4]) except: print "Error: unable to fecth data" plot = Figure(x_range=[1895, 2016], y_range=[-10, 8], plot_width=1000, tools="", toolbar_location=None) plot.title = "Plot of temprature of month %s from 1895-2015" % month[0] colors = Blues4[0:3] plot.border_fill_color = "whitesmoke" plot.xaxis.axis_label = "Year" plot.yaxis.axis_label = "Temperature (F)" plot.axis.major_label_text_font_size = "8pt" plot.axis.axis_label_text_font_size = "8pt" plot.axis.axis_label_text_font_style = "bold" plot.x_range = DataRange1d(range_padding=0.0, bounds=None) plot.grid.grid_line_alpha = 0.3 plot.grid[0].ticker.desired_num_ticks = 12 plot.line(year, USCRN, color='#A6CEE3', legend='AAPL') plot.line(year, CLIMDIV, color='#B2DF8A', legend='GOOG') plot.line(year, CMBUSHCN, color='#33A02C', legend='IBM') #fig=plt.figure(figsize=(16,12)) #plt.xlabel('Year') #plt.ylabel('Temprature') #plt.style.use('ggplot') #plt.plot(year,USCRN,'ro-') #plt.plot(year,CLIMDIV,'go-') #plt.plot(year,CMBUSHCN,'bo-') #plt.axis([1895,2016,-10,8]) #plt.title('Plot of temprature of month %s from 1895-2015' %month[0]) #os.remove(os.getcwd() + '\Temprature.png') #plt.savefig(os.path.join(BASE_DIR, 'static\img\Temprature.png'),dpi=80) #plt.savefig(os.path.join(BASE_DIR, 'static\img\Temprature2.png'),dpi=80) #fig.clf() #plt.close(fig) #img=open(os.getcwd() + '\Temprature.png',"rb") #response = django.http.HttpResponse(content_type="image/png") #plt.savefig(response, format="png") #img=open("Temprature.png", "rb") #img.save(response, "PNG") #img.close() #image_bytes = requests.get(os.path.join(BASE_DIR, 'static\img\Temprature.png').content #image_bytes.save(response,"PNG")#lambda x: x.startswith('Temprature') #f = open(os.path.join(BASE_DIR, 'static\img\Temprature.png'),"rb") #img = f.read() #f.close() cur.close() cnx.close() script, div = components(plot) return render(request, "temp.html", { "this_script": script, "this_div": div })
source = ColumnDataSource(data=dict()) tools = 'pan,wheel_zoom,xbox_select,reset' corr = Figure(plot_width=400, plot_height=400, title='', title_text_font_size='10pt', tools='pan,wheel_zoom,box_select,reset') corr.circle('t1_returns', 't2_returns', size=2, source=source, selection_color="orange", selection_alpha=0.5) ts1 = Figure(plot_width=800, plot_height=200, title='', tools=tools, x_axis_type='datetime', title_text_font_size='8pt') ts1.circle('date', 't1', size=2, source=source, selection_color="orange") ts2 = Figure(plot_width=800, plot_height=200, title='', tools=tools, x_axis_type='datetime', title_text_font_size='8pt') ts2.x_range = ts1.x_range ts2.circle('date', 't2', size=2, source=source, selection_color="orange") # set up callbacks def ticker1_change(attrname, old, new): ticker2.options = nix(new, DEFAULT_TICKERS) update() def ticker2_change(attrname, old, new): ticker1.options = nix(new, DEFAULT_TICKERS) update() def update(selected=None): t1, t2 = ticker1.value, ticker2.value
cratio=Cratio * 1e9, spec=spec * 1e9, downerr=(spec - sig) * 1e9, uperr=(spec + sig) * 1e9)) ################################ # BOKEH PLOTTING ################################ snr_plot = Figure(plot_height=400, plot_width=750, tools="crosshair,pan,reset,resize,save,box_zoom,wheel_zoom", x_range=[0.3, 2.7], y_range=[0, 1], toolbar_location='right') snr_plot.x_range = Range1d(0.3, 2.7, bounds=(0.3, 2.7)) snr_plot.y_range = Range1d(0.0, 1.2, bounds=(0.3, 5.0)) snr_plot.background_fill_color = "beige" snr_plot.background_fill_alpha = 0.5 snr_plot.yaxis.axis_label = 'F_p/F_s (x10^9)' snr_plot.xaxis.axis_label = 'Wavelength [micron]' snr_plot.line('lam', 'cratio', source=planet, line_width=2.0, color="green", alpha=0.7) snr_plot.circle('lam', 'spec', source=planet,
<span style="font-size: 15px; font-weight: bold; color: #696">type</span> </div> <div> <span style="font-size: 15px; font-weight: bold; color: #696">D = </span> <span style="font-size: 15px; font-weight: bold; color: #696;">@r</span> <span style="font-size: 15px; font-weight: bold; color: #696;"> pc</span> </div> <div> <span style="font-size: 15px; font-weight: bold; color: #696">C = </span> <span style="font-size: 15px; font-weight: bold; color: #696;">@complete</span> </div> </div> """) plot1.add_tools(hover) hover = plot1.select(dict(type=HoverTool)) plot1.x_range = Range1d(-50, 50, bounds=(-50, 50)) plot1.y_range = Range1d(-50, 50, bounds=(-50, 50)) plot1.background_fill_color = "black" plot1.background_fill_alpha = 1.0 plot1.yaxis.axis_label = 'Yield' plot1.xaxis.axis_label = ' ' plot1.xaxis.axis_line_width = 0 plot1.yaxis.axis_line_width = 0 plot1.xaxis.axis_line_color = 'black' plot1.yaxis.axis_line_color = 'black' plot1.border_fill_color = "black" plot1.min_border_left = 80 # main glyphs for planet circles star_syms = plot1.circle('x', 'y', source=star_points, name="star_points_to_hover", \ fill_color='color', line_color='color', radius=0.5, line_alpha=0.5, fill_alpha=0.7)
</div> <div> <span style="font-size: 15px; font-weight: bold; color: #696">S/N = </span> <span style="font-size: 15px; font-weight: bold; color: #696;">@y</span> </div> </div> """) # Set up plot snr_plot = Figure(plot_height=400, plot_width=800, tools="crosshair,pan,reset,resize,save,box_zoom,wheel_zoom", x_range=[120, 2300], y_range=[0, 40], toolbar_location='right') snr_plot.x_range = Range1d(120, 2300, bounds=(120, 2300)) snr_plot.add_tools(hover) snr_plot.background_fill_color = "beige" snr_plot.background_fill_alpha = 0.5 snr_plot.yaxis.axis_label = 'SNR' snr_plot.xaxis.axis_label = 'Wavelength (nm)' snr_plot.text(5500, 20, text=['V'], text_align='center', text_color='red') snr_plot.line('x', 'y', source=source, line_width=3, line_alpha=1.0) snr_plot.circle('x', 'y', source=source, fill_color='white', line_color='blue', size=10)
left='timel', right='timer', source=source, alpha=0.5, color='RoyalBlue', line_color="black", line_alpha=0.5, legend='Min/Max') p.line(x='time', y='mean_t', source=source, color='red', line_width=1.5, alpha=0.8, legend='Average') p.x_range = DataRange1d(range_padding=0, bounds=None) p.yaxis.axis_label = "Temperature (C)" p.xaxis.axis_label = 'Month' # Select Data based on input info def select_data(): #p.title = p.title + str(' (Wait..)') global station_IDs # Make Stations ID's as a list station_IDs = [] [station_IDs.append(int(n)) for n in station_IDs_str.value.split()] # Select Data based on input info logic_str = ('WHERE year=' + str(selected_year.value) + ' AND station_id=' + str(station_IDs[0]))
source1 = ColumnDataSource(data=dict(x=data_x[0], y=data_y[0])) source2 = ColumnDataSource(data=dict(x=data_x[1], y=data_y[1])) source3 = ColumnDataSource(data=dict(x=data_x[2], y=data_y[2])) return [source1, source2, source3] source = init_source() oSource = list(source) # dessin p = Figure(plot_width=400, plot_height=400) # Axes p.y_range = Range1d(start=0, end=100) p.x_range = Range1d(start=0, end=50) # dessin for i in range(3): p.line(x='x', y='y', line_width=2, line_color=color[i], source=source[i]) # création du bouton bt = Button(label="Lance", button_type="success") # fonction de callback callback = CustomJS(args=dict(source=source, p=p, anim=anim), code=""" var x = new Array(source.length) var y = new Array(source.length) var c = new Array(source.length) // coefficient de la droite
alpha_p1=alpha_P1, alpha_p2=alpha_P2, beta_p0=beta_P0, beta_p1=beta_P1, beta_p2=beta_P2, sarah_p0=sarah_P0, sarah_p1=sarah_P1, sarah_p2=sarah_P2)) p = Figure(tools='', toolbar_location=None, height=800, width=850) p.grid.grid_line_color = None p.axis.visible = False p.grid.grid_line_color = None p.axis.visible = False p.y_range = Range1d(-.25, 1.35) p.x_range = Range1d(-.15, 1.55) # plot simplex left_corner = [0.0, 0.0] right_corner = [np.sqrt(2), 0.0] top_corner = [np.sqrt(2) / 2.0, np.sqrt(6) / 2.0] p.line([left_corner[0], top_corner[0]], [left_corner[1], top_corner[1]], color='black', line_width=2) p.line([right_corner[0], top_corner[0]], [right_corner[1], top_corner[1]], color='black', line_width=2) p.line([left_corner[0], right_corner[0]], [left_corner[1], right_corner[1]], color='black', line_width=2)
# Set up plot box_select = BoxSelectTool() plot1 = Figure(plot_height=500, plot_width=770, x_axis_type=None, y_axis_type=None, tools=["pan,reset,tap,wheel_zoom,save", box_select], x_range=[-75, 75], y_range=[-50, 50], toolbar_location='left') plot1.image_url(url=["http://luvoir.stsci.edu/M83.jpeg"], x=[-75], y=[50], w=150, h=100) plot1.x_range = Range1d(-75, 75, bounds=(-75, 75)) plot1.y_range = Range1d(-50, 50, bounds=(-50, 50)) shutters = plot1.square('x', 'y', source=shutter_positions, fill_color='yellow', fill_alpha=0.2, line_color=None, size=20, name="my_shutters") shutters.selection_glyph = Square(fill_alpha=0.5, fill_color="green", line_color='green', line_width=3) shutters.nonselection_glyph = Square(fill_alpha=0.2, fill_color="yellow",
grate4=ColumnDataSource(dict(x=londf.values[:,0]-kgx*kmult,y=londf.values[:,2]-kgy*kmult)) grate5=ColumnDataSource(dict(x=londf.values[:,0]-kgx,y=londf.values[:,2])) grate6=ColumnDataSource(dict(x=londf.values[:,0]+kgx,y=londf.values[:,2])) grate7=ColumnDataSource(dict(x=londf.values[:,0],y=londf.values[:,2]+kgy)) grate8=ColumnDataSource(dict(x=londf.values[:,0],y=londf.values[:,2]-kgy)) p.line(x='x',y='y',source=grate1, color="red",line_width=5) p.line(x='x',y='y',source=grate2, color="red",line_width=5) p.line(x='x',y='y',source=grate3, color="red",line_width=5) p.line(x='x',y='y',source=grate4, color="red",line_width=5) p.line(x='x',y='y',source=grate5, color="red",line_width=5) p.line(x='x',y='y',source=grate6, color="red",line_width=5) p.line(x='x',y='y',source=grate7, color="red",line_width=5) p.line(x='x',y='y',source=grate8, color="red",line_width=5) p.x_range=Range1d(-1 , 1) p.y_range=Range1d(-1 , 1) def update(): tilt=float(tiltin.value)*np.pi/180 wl=2.997e4/float(freqin.value) wlout.text='Wavelength = '+str(wl)+' cm' kgy=wl/float(dyin.value) if lattice.value=='Triangular': kgx=2*wl/float(dxin.value) kmult=0.5 else: kgx=wl/float(dxin.value) kmult=1 kgxout.text='kgx = '+str(kgx)
SNR = cp*Dts/np.sqrt((cp + 2*cb)*Dts) # Calculate 1-sigma errors sig= Cratio/SNR # Add gaussian noise to flux ratio spec = Cratio + np.random.randn(len(Cratio))*sig planet = ColumnDataSource(data=dict(lam=lam, cratio=Cratio*1e9, spec=spec*1e9, downerr=(spec-sig)*1e9, uperr=(spec+sig)*1e9)) ################################ # BOKEH PLOTTING ################################ snr_plot = Figure(plot_height=400, plot_width=750, tools="crosshair,pan,reset,resize,save,box_zoom,wheel_zoom", x_range=[0.3, 2.7], y_range=[0, 1], toolbar_location='right') snr_plot.x_range = Range1d(0.3, 2.7, bounds=(0.3, 2.7)) snr_plot.y_range = Range1d(0.0, 1.2, bounds=(0.3, 5.0)) snr_plot.background_fill_color = "beige" snr_plot.background_fill_alpha = 0.5 snr_plot.yaxis.axis_label='F_p/F_s (x10^9)' snr_plot.xaxis.axis_label='Wavelength [micron]' snr_plot.line('lam','cratio',source=planet,line_width=2.0, color="green", alpha=0.7) snr_plot.circle('lam', 'spec', source=planet, fill_color='red', line_color='black', size=8) snr_plot.segment('lam', 'downerr', 'lam', 'uperr', source=planet, line_width=1, line_color='grey', line_alpha=0.5) def change_filename(attrname, old, new): format_button_group.active = None instruction0 = Div(text="""Choose a file rootname here
Yb = gamma.ppf(1 - PFA, N) K = 1 * N xdBseries = np.array([x * 0.1 for x in range(0, 501)]) xdBseries = xdBseries - 10 vprobdet = np.vectorize(pd.probdet) PDseries = vprobdet(N, Yb, K, xdBseries) source = ColumnDataSource(data=dict(snr=xdBseries, pd=PDseries)) plot = Figure(plot_width=435, plot_height=400) plot.line('snr', 'pd', source=source) plot.x_range = Range1d(-10, 40) def update(attrname, old, new): PFA = float(pfa.value) N = slider1.value Yb = gamma.ppf(1 - PFA, N) if case.value == "Case 1": K = 1 elif case.value == "Case 2": K = N elif case.value == "Case 3": K = 2 elif case.value == "Case 4": K = 2 * N
fill_color='pink', line_width=0) p1.patch([0.003, 0.04, 0.04, 0.003, 0.003], [100, 100, 30000., 30000., 10000.], alpha=0.6, fill_color='lightblue', line_width=0) p1.patch([3, 3000, 3000, 30, 3], [300, 300, 30000., 30000., 300.], alpha=0.6, fill_color='purple', line_width=0) p1.yaxis.axis_label = 'Planet Mass / Earth' p1.xaxis.axis_label = 'Semi-major Axis / Snow Line' p1.xaxis.axis_label_text_font_style = 'bold' p1.yaxis.axis_label_text_font_style = 'bold' p1.xaxis[0].formatter = NumeralTickFormatter(format="0.00") p1.x_range = Range1d(0.003, 3000, bounds=(0.003, 3000)) p1.y_range = Range1d(0.01, 30000, bounds=(0.01, 30000)) techniques = [ 'RV', 'Space Transits', 'Ground Transits', 'Microlensing', 'Direct Imaging' ] checkbox_button_group = CheckboxGroup( labels=["RV", "Transits", "Microlensing", "Direct Imaging"], active=[0, 1, 2, 3]) # transits - ground tground = Table.read( '/Users/tumlinson/Dropbox/LUVOIR_STDT/luvoir_simtools/planetspace/transit_ground.dat', format='ascii', names=['name', 'msini', 'semi', 'mstar'])
spec=spec * 1e9, downerr=(spec - sig) * 1e9, uperr=(spec + sig) * 1e9)) ################################ # BOKEH PLOTTING ################################ snr_plot = Figure(plot_height=400, plot_width=800, title="LUVOIR Coronagraphic Simulator", tools="crosshair,pan,reset,resize,save,box_zoom,wheel_zoom", x_range=[0.2, 3.0], y_range=[0, 1], toolbar_location='right') snr_plot.x_range = Range1d(0.2, 3, bounds=(0.2, 3)) snr_plot.background_fill_color = "beige" snr_plot.background_fill_alpha = 0.5 snr_plot.yaxis.axis_label = 'F_p/F_s (x10^9)' snr_plot.xaxis.axis_label = 'Wavelength [micron]' snr_plot.line('lam', 'cratio', source=planet, line_width=2.0, color="green", alpha=0.7) snr_plot.circle('lam', 'spec', source=planet, fill_color='red',
plot_height=240, tools=[skr_hover, "pan,box_zoom,reset,crosshair, lasso_select"]) p1.line('wl', 'med_resid', source=skyres_source) p2 = Figure(title='WAVG_RESID_WAVE', x_axis_label='Angstrom', plot_width=720, plot_height=240, tools=[wavg_hover, "pan,box_zoom,reset,crosshair, lasso_select"]) p2.line('wl', 'wavg_resid', source=skyres_source) '''p1.circle('wl', 'med_resid', source=skyres_source, alpha = 0, size=1, hover_alpha=1, hover_fill_color='orange', hover_line_color='red') ''' '''p2.circle('wl', 'wavg_resid', source=skyres_source, alpha=0, size=1, hover_alpha=1, hover_fill_color='orange', hover_line_color='red')''' p1.x_range = p2.x_range info, nlines = write_info('skyresid', tests['skyresid']) txt = PreText(text=info, height=nlines * 20, width=p2.plot_width) info_col = Div(text=write_description('skyresid'), width=p2.plot_width) p2txt = column(widgetbox(info_col), p1, p2) #layout=column(p1,p2) curdoc().add_root(p2txt) curdoc().title = "SKYRESID"