komunikilo 0.1.5

A chaotic communications simulator.
Documentation
# necessary imports:
import numpy as np

timeLength = 6

# start by defining a function that returns a sine wave with time-dependent frequency
# f_func is a function f(t, f0, k)
def chirp(t, f_func, f0, k):
    return np.sin(2*np.pi*f_func(t, f0, k)*t)

# for a linearly changing frequency, use this for f_func:
def f_linear_chirp(t, f0, k):
    return f0 + k*t

# for exponentially changing frequency, use:
def f_exp_chirp(t, f0, k):
    return f0*k**t

# for a visually useful example, take:
duration = 1 # seconds
fs = 2**13 # sampling rate
t = np.arange(0, timeLength, 1.0/fs)

f0 = 2 # Hz
f1 = 20 # HZ

# the coefficients are then given by
k_test_lin = (f1-f0)/timeLength
k_test_exp = (f1/f0)**(1/timeLength)

print(f'k_lin = {k_test_lin}, k_exp = {k_test_exp}')

# the time series for exsample signals can be created by:
linear_chirp_example = [chirp(x, f_linear_chirp, f0, k_test_lin) for x in t]
exp_chirp_example = [chirp(x, f_exp_chirp, f0, k_test_exp) for x in t]

# to look at the results:
import matplotlib.pyplot as plt
plt.plot(t, linear_chirp_example)
plt.show()
plt.plot(t, exp_chirp_example)
plt.show()