Thesis:Timing:Beacon (WIP)

This commit is contained in:
Eric-Teunis de Boone 2022-08-29 19:25:53 +02:00
parent 63fd43d633
commit ae3d89dd41
3 changed files with 157 additions and 8 deletions

View file

@ -15,10 +15,9 @@ def ttl(t, t_start=0, frequency=1, width=0.5):
return ( (t%frequency) >= t_start) & ( (t%frequency) < t_start + width)
def main(beacon_type, N_periods=1, overplot_sampling_rates = False, sampling_rate=5, t_start=0, sampling_offset_in_rate=1/4, ax=None, fig_kwargs={'figsize': (4,2)}):
def main(beacon_type, N_periods=1, overplot_sampling_rates = False, sampling_rate=6, t_start=-0.3, sampling_offset_in_rate=1, ax=None, fig_kwargs={'figsize': (4,2)}, N_t=200):
t_end = N_periods - t_start
N_t = 200
if ax is None:
fig, ax = plt.subplots(1,1, **fig_kwargs)
@ -26,7 +25,7 @@ def main(beacon_type, N_periods=1, overplot_sampling_rates = False, sampling_rat
time = np.linspace(t_start, t_end, N_t, endpoint=False)
if beacon_type == 'ttl':
sig_func = lambda t: ttl(t, frequency=1)
sig_func = lambda t: 2*ttl(t, frequency=1) - 1
elif beacon_type == 'sine':
sig_func = lambda t: np.sin(2*np.pi*t)
else:
@ -34,6 +33,16 @@ def main(beacon_type, N_periods=1, overplot_sampling_rates = False, sampling_rat
ax.plot(time, sig_func(time))
ax.grid(True)
ax.set_xlim(t_start, t_end)
ax.set_ylim(-1.5, 1.5)
if True:
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['bottom'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
if overplot_sampling_rates:
sampling_offset = sampling_offset_in_rate * 1/sampling_rate
@ -46,8 +55,7 @@ def main(beacon_type, N_periods=1, overplot_sampling_rates = False, sampling_rat
ax.plot(sample_time, sig_func(sample_time), label='Sampling 2', linestyle='None', marker='+')
ax.set_ylim(top=1.4)
ax.legend(loc="upper center", ncol=2, )
fig.legend(loc="lower center", ncol=2, )
return fig, ax, dict(