Commit 9e416d70 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Add dB scale

parent df9e2c1f
......@@ -37,6 +37,8 @@ def set_stoprequest(event):
signal = 0.
prev_signal = 0.
y_scale_is_logarithmic = False
datafile = open(f"data{int(Time.now().unix)}.txt", "w")
print("Time (UTC),separation (deg),azimuth from north (deg), elevation (deg), signal, source", file=datafile)
......@@ -180,6 +182,7 @@ while not stoprequest:
maxsignal = signal
if signal < minsignal:
minsignal = signal
noiselevel = 75 # TODO: infer this from data
scatter_data = scatterplot.get_offsets()
scatter_data = np.vstack((scatter_data, [separation.deg, signal]))
......@@ -188,10 +191,29 @@ while not stoprequest:
prev_points = ax.scatter([separation.deg], [signal], s=50, color='red')
ax.set_ylim((0.9 * minsignal, 1.1 * maxsignal))
if minsignal < 1000:
if (not y_scale_is_logarithmic) and minsignal < 1000:
# Attenuator on
y_scale_is_logarithmic = True
ax.set_yscale("log")
yticks = []
yticklabels = []
ytick = noiselevel
db = 0
while ytick < ax.get_ylim()[1]:
yticks.append(ytick)
yticklabels.append(f"{db} dB")
ytick *= 10**0.1
db += 1
while len(yticks) > 15:
yticks = yticks[::2]
yticklabels = yticklabels[::2]
ax.set_yticks(yticks)
ax.set_yticklabels(yticklabels)
ax.get_yaxis().set_tick_params(which='minor', size=0)
ax.get_yaxis().set_tick_params(which='minor', width=0)
ax.set_ylabel("Relatieve intensiteit")
update_legend(ax, closest_source)
# show the plot
......
Markdown is supported
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