diff options
Diffstat (limited to 'sync-measurement.ipynb')
-rw-r--r-- | sync-measurement.ipynb | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/sync-measurement.ipynb b/sync-measurement.ipynb index 90c9cfb..927afe4 100644 --- a/sync-measurement.ipynb +++ b/sync-measurement.ipynb @@ -11,7 +11,8 @@ "source": [ "%matplotlib inline\n", "import numpy as np\n", - "import time;\n", + "import time\n", + "import scipy\n", "from scipy import signal\n", "import matplotlib.pyplot as plt\n", "import matplotlib.colors as mpcol\n", @@ -47,7 +48,9 @@ "n_steps = 64\n", "amps = np.linspace(0.001, a_max, num = n_steps)\n", "txgains = (50, 55, 60, 65, 70, 75, 81, 82, 83, 84, 85, 86, 87, 88, 89)\n", - "rxgains = (50, 40, 40, 25, 25, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20)" + "rxgains = (50, 40, 40, 25, 25, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20)\n", + "txgains = (75, 81, 84, 85, 88, 89)\n", + "rxgains = (20, 20, 20, 20, 20, 20)" ] }, { @@ -65,10 +68,13 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "deletable": true, + "editable": true + }, "outputs": [], "source": [ - "sg.gen_ramps(path=\"./input.dat\", amplitudes=amps)" + "sg.gen_ramps(path=\"./input.dat\", n_periods=64, pause=8, amplitudes=amps)" ] }, { @@ -135,8 +141,12 @@ " \n", " bins = np.linspace(+0.5/n_steps,a_max + 0.5/n_steps,num=n_steps)\n", " res = []\n", - " a_out_abs = np.abs(a_out)\n", - " a_in_abs = np.abs(a_in)\n", + " \n", + " a_out_up = scipy.signal.resample(a_out, a_out.shape[0] * 8)\n", + " a_in_up = scipy.signal.resample(a_in, a_in.shape[0] * 8)\n", + " \n", + " a_out_abs = np.abs(a_out_up)\n", + " a_in_abs = np.abs(a_in_up)\n", " for ampl_1, ampl_2 in zip(bins, bins[1:]):\n", " res.append(du.get_amp_ratio(ampl_1, ampl_2, a_out_abs, a_in_abs))\n", " del a_out_abs\n", @@ -145,7 +155,7 @@ " \n", " res = []\n", " for ampl_1, ampl_2 in zip(bins, bins[1:]):\n", - " res.append(du.get_phase(ampl_1, ampl_2, a_out, a_in))\n", + " res.append(du.get_phase(ampl_1, ampl_2, a_out_up, a_in_up))\n", " mean_phase, var_phase = zip(*res)\n", " return mean_amp, var_amp, mean_phase, var_phase, db" ] @@ -169,6 +179,7 @@ }, "outputs": [], "source": [ + "reload(du)\n", "res = []\n", "\n", "for txgain, rxgain in zip(txgains, rxgains):\n", @@ -195,12 +206,13 @@ " res_tmp = extract_measurement(a_in, a_out, txgain, a_max, n_steps, debug=True)\n", " \n", " def is_finite(r): return np.all([np.all(np.isfinite(c)) for c in r])\n", - " def has_small_jumps(mean_amp): return np.max(np.abs(np.diff(mean_amp))) / np.median(np.abs(np.diff(mean_amp))) < 100\n", + " #def has_small_jumps(mean_amp): return np.max(np.abs(np.diff(mean_amp))) / np.median(np.abs(np.diff(mean_amp))) < 100\n", " \n", - " if is_finite(res_tmp) and has_small_jumps(res_tmp[0]):\n", + " #TODO\n", + " if is_finite(res_tmp): # and 1 + has_small_jumps(res_tmp[0]):\n", " break\n", " else:\n", - " print (is_finite(res_tmp), has_small_jumps(res_tmp[0]))\n", + " print (is_finite(res_tmp))#, has_small_jumps(res_tmp[0]))\n", " \n", " res.append(res_tmp)" ] |