Commit b86baa50 authored by Thomas Bruns's avatar Thomas Bruns
Browse files

initial coomit

parent c5dbf7f1
......@@ -9,7 +9,7 @@ import numpy as np
from bokeh.io import curdoc
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 primes import primes
......@@ -21,27 +21,35 @@ def update_data(attrname, old, new):
# pri = primes[(primes<=10*p0) & (primes>p0)]
pri = primes[(primes<=10*p0)]
d = []
p = []
for fs in f_std:
try:
f1 = (pri[pri/p0<=fs])[-1]/p0 # lower limit
pr1 = (pri[pri/p0<=fs])[-1] # lower limit prime
f1 = pr1/p0 # lower limit frequency
r1 = (f1-fs)/fs
except:
r1 = 0.5
f2 = (pri[pri/p0>fs])[0]/p0 # upper limit
pr2 = (pri[pri/p0>fs])[0] # upper limit prime
f2 = pr2/p0 # upper limit frequency
r2 = (f2-fs)/fs
r = r1 if (np.abs(r1)<np.abs(r2)) else r2
d.append(r)
print( f1 if (np.abs(r1)<np.abs(r2)) else f2)
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)))
source.data = dict(x=f_std,y=np.array(d))
base.value = """Base = %d """ % p0
deviation.text = str(np.amax(np.abs(d))) # display maximum deviation
dd = 100*np.amax(np.abs(np.array(d)))
print("%2.2f %%" % dd)
print(p)
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 = 7
base = TextInput(value="""Base = xx""")
deviation = Div(text="max")
# Set up plot
source = ColumnDataSource(data=dict(x=[], y=[]))
......@@ -62,7 +70,7 @@ offset.on_change('value', update_data)
# Set up layouts and add to document
inputs = row(offset, base)
inputs = row(offset, base, deviation)
curdoc().add_root(column(inputs, plot, width=800))
curdoc().title = "Sliders"
\ No newline at end of file
curdoc().title = "Sliders"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment