aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorandreas128 <Andreas>2016-12-09 09:38:33 +0100
committerandreas128 <Andreas>2016-12-09 09:38:33 +0100
commitbf1dcd15c041b73aeca73cd1aebe894d3128b4f2 (patch)
tree5714b5995198c7e55c8f11678f27249f8c335a79 /src
parentf2b7d99828e9a9f9d849661a9e24280bbb78f30d (diff)
downloadODR-StaticPrecorrection-bf1dcd15c041b73aeca73cd1aebe894d3128b4f2.tar.gz
ODR-StaticPrecorrection-bf1dcd15c041b73aeca73cd1aebe894d3128b4f2.tar.bz2
ODR-StaticPrecorrection-bf1dcd15c041b73aeca73cd1aebe894d3128b4f2.zip
Add grid search in run.ipynb
Diffstat (limited to 'src')
-rw-r--r--src/__init__.py0
-rw-r--r--src/gen_source.py32
2 files changed, 32 insertions, 0 deletions
diff --git a/src/__init__.py b/src/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/__init__.py
diff --git a/src/gen_source.py b/src/gen_source.py
new file mode 100644
index 0000000..a8c2ef2
--- /dev/null
+++ b/src/gen_source.py
@@ -0,0 +1,32 @@
+import numpy as np
+
+
+def complex_exp(freq, samp_rate, periods, phase_deg=0):
+ t_max = 1.0 * samp_rate / freq * periods
+ t = np.arange(t_max)
+ fac = t / samp_rate * freq
+ phase = 1j * phase_deg/360*2*np.pi
+ ret = np.exp(phase + 1j * 2 * np.pi * fac - 1j * np.pi / 2, dtype=np.complex64)
+ return ret
+ret = complex_exp(10,40,2)
+
+
+def gen_file(frequency_0, frequency_1, x1 = 0, x2 = 0, x3 = 0, x4 = 0, samp_rate = 4000000, path = "./np_twotone"):
+ tone_0 = complex_exp(frequency_0, samp_rate, samp_rate/frequency_1)
+ tone_1 = complex_exp(frequency_1, samp_rate, samp_rate/frequency_0)
+
+ two_tone = (tone_0 + tone_1)
+ two_tone = two_tone \
+ + np.abs(two_tone)**1 * x1 \
+ + np.abs(two_tone)**2 * x2 \
+ + np.abs(two_tone)**3 * x3 \
+ + np.abs(two_tone)**4 * x4
+
+ two_tone = two_tone / np.max(two_tone) * 0.9
+
+ two_tone.tofile(path)
+
+ a_load = np.fromfile(path, dtype=np.complex64)
+ assert(np.isclose(a_load, two_tone).all()), "Inconsistent stored file"
+
+ return path