Skip to content
Snippets Groups Projects
Commit 2fff5f97 authored by Thomas Bruns's avatar Thomas Bruns
Browse files

.

parent c5dbf7f1
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Created on Tue Dec 22 17:15:45 2020 Created on Tue Dec 22 17:15:45 2020
@author: bruns01 @author: bruns01
""" """
import numpy as np import numpy as np
from bokeh.io import curdoc from bokeh.io import curdoc
from bokeh.layouts import column, row from bokeh.layouts import column, row
from bokeh.models import ColumnDataSource, Slider, TextInput from bokeh.models import ColumnDataSource, Slider, TextInput,Div
from bokeh.plotting import figure from bokeh.plotting import figure
from primes import primes from primes import primes
# Set up callbacks # Set up callbacks
def update_data(attrname, old, new): def update_data(attrname, old, new):
f_std = np.array([1.0, 1.25, 1.6, 2.0, 2.5, 3.2, 4.0, 5.0, 6.3, 8.0 ]) f_std = np.array([1.0, 1.25, 1.6, 2.0, 2.5, 3.2, 4.0, 5.0, 6.3, 8.0 ])
p0 = primes[new] p0 = primes[new]
# pri = primes[(primes<=10*p0) & (primes>p0)] # pri = primes[(primes<=10*p0) & (primes>p0)]
pri = primes[(primes<=10*p0)] pri = primes[(primes<=10*p0)]
d = [] d = []
for fs in f_std: p = []
try: for fs in f_std:
f1 = (pri[pri/p0<=fs])[-1]/p0 # lower limit try:
r1 = (f1-fs)/fs pr1 = (pri[pri/p0<=fs])[-1] # lower limit prime
except: f1 = pr1/p0 # lower limit frequency
r1 = 0.5 r1 = (f1-fs)/fs
f2 = (pri[pri/p0>fs])[0]/p0 # upper limit except:
r2 = (f2-fs)/fs r1 = 0.5
pr2 = (pri[pri/p0>fs])[0] # upper limit prime
r = r1 if (np.abs(r1)<np.abs(r2)) else r2 f2 = pr2/p0 # upper limit frequency
d.append(r) r2 = (f2-fs)/fs
print( f1 if (np.abs(r1)<np.abs(r2)) else f2)
r = r1 if (np.abs(r1)<np.abs(r2)) else r2
source.data = dict(x=f_std,y=np.array(d)) d.append(r)
base.value = """Base = %d """ % p0 p.append((pr1 if (np.abs(r1)<np.abs(r2)) else pr2))
#print( f1 if (np.abs(r1)<np.abs(r2)) else f2)
#print( ("%d/%d" % (pr1,p0)) if (np.abs(r1)<np.abs(r2)) else ("%d/%d" % (pr2,p0)))
f_std = np.array([1.0, 1.25, 1.6, 2.0, 2.5, 3.2, 4.0, 5.0, 6.3, 8.0 ]) source.data = dict(x=f_std,y=np.array(d))
p0 = 7 base.value = """Base = %d """ % p0
deviation.text = str(np.amax(np.abs(d))) # display maximum deviation
base = TextInput(value="""Base = xx""") dd = 100*np.amax(np.abs(np.array(d)))
print("%2.2f %%" % dd)
# Set up plot print(p)
source = ColumnDataSource(data=dict(x=[], y=[]))
f_std = np.array([1.0, 1.25, 1.6, 2.0, 2.5, 3.2, 4.0, 5.0, 6.3, 8.0 ])
update_data("offset",0,5) p0 = 7
plot = figure(plot_height=400, plot_width=800, title="prime ratio frequencies", base = TextInput(value="""Base = xx""")
tools="crosshair,pan,reset,save,wheel_zoom", deviation = Div(text="max")
x_range=[1.0, 10.0], y_range=[-0.1, 0.2])
# Set up plot
plot.circle('x', 'y', source=source, radius=.05) source = ColumnDataSource(data=dict(x=[], y=[]))
update_data("offset",0,5)
# Set up widgets
offset = Slider(title="offset", value=5, start=0, end=50, step=1) plot = figure(plot_height=400, plot_width=800, title="prime ratio frequencies",
tools="crosshair,pan,reset,save,wheel_zoom",
offset.on_change('value', update_data) x_range=[1.0, 10.0], y_range=[-0.1, 0.2])
plot.circle('x', 'y', source=source, radius=.05)
# Set up layouts and add to document
inputs = row(offset, base)
# Set up widgets
curdoc().add_root(column(inputs, plot, width=800)) offset = Slider(title="offset", value=5, start=0, end=50, step=1)
curdoc().title = "Sliders"
\ No newline at end of file offset.on_change('value', update_data)
# Set up layouts and add to document
inputs = row(offset, base, deviation)
curdoc().add_root(column(inputs, plot, width=800))
curdoc().title = "Sliders"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment