aboutsummaryrefslogtreecommitdiffstats
path: root/sync-measurement.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'sync-measurement.ipynb')
-rw-r--r--sync-measurement.ipynb156
1 files changed, 75 insertions, 81 deletions
diff --git a/sync-measurement.ipynb b/sync-measurement.ipynb
index 0221c3c..90c9cfb 100644
--- a/sync-measurement.ipynb
+++ b/sync-measurement.ipynb
@@ -3,7 +3,10 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": [
"%matplotlib inline\n",
@@ -18,7 +21,10 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": [
"import src.signal_gen as sg\n",
@@ -29,7 +35,10 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": [
"path_in = \"./input.dat\"\n",
@@ -44,19 +53,13 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "from grc.amam_amap import amam_amap"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": [
- "top = amam_amap()\n"
+ "from grc.amam_ampm import amam_ampm"
]
},
{
@@ -65,77 +68,38 @@
"metadata": {},
"outputs": [],
"source": [
- "sg.gen_ramps(amplitudes=amps)"
+ "sg.gen_ramps(path=\"./input.dat\", amplitudes=amps)"
]
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": [
- "def fftlag(signal_original, signal_rec):\n",
- " \"\"\"\n",
- " Efficient way to find lag between two signals\n",
- " Args:\n",
- " signal_original: The signal that has been sent\n",
- " signal_rec: The signal that has been recored\n",
- " \"\"\"\n",
- " c = np.flipud(signal.fftconvolve(signal_original,np.flipud(signal_rec)))\n",
- " #plt.plot(c)\n",
- " return np.argmax(c) - signal_original.shape[0] + 1\n",
- " \n",
- "#pattern = np.array([-2,2,-1,+3,-5,+7])\n",
- "#delays = [0,1,2,3,4]\n",
- "#padding = [0]\n",
- "#padding_fil = [0]\n",
- "#\n",
- "#res = []\n",
- "#for d in delays:\n",
- "# for p in padding:\n",
- "# for p2 in padding_fil:\n",
- "# a = np.concatenate((pattern, np.zeros(p2)))\n",
- "# b = np.concatenate((np.zeros(d), pattern, np.zeros(p)))\n",
- "# res.append((d,conv(a,b)))\n",
- "#res = np.array(res)\n",
- "#plt.plot(zip(*res)[0], zip(*res)[1], 'p')"
+ "top = amam_ampm()"
]
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "def get_amp_ratio(ampl_1, ampl_2, a_out_abs, a_in_abs):\n",
- " idxs = (a_in_abs > ampl_1) & (a_in_abs < ampl_2)\n",
- " ratio = a_out_abs[idxs] / a_in_abs[idxs]\n",
- " return ratio.mean(), ratio.var()\n",
- "\n",
- "def get_phase(ampl_1, ampl_2, a_out, a_in):\n",
- " idxs = (np.abs(a_in) > ampl_1) & (np.abs(a_in) < ampl_2)\n",
- " ratio = np.angle(a_out[idxs], deg=True) - np.angle(a_in[idxs], deg=True)\n",
- " return ratio.mean(), ratio.var()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": [
"def extract_measurement(a_in, a_out, db, a_max, n_steps, debug = False):\n",
@@ -153,8 +117,8 @@
" \n",
" #c = du.lagcorr(np.abs(a_out), np.abs(a_in), 120000)[:,0]\n",
" #c = signal.fftconvolve(a_in, a_out) - a_out.shape[0]\n",
- " delay = fftlag(np.abs(a_in), np.abs(a_out))\n",
- " \n",
+ " #delay = du.fftlag(np.abs(a_in), np.abs(a_out))\n",
+ " delay = du.fftlag(a_in, a_out) #TODO\n",
" \n",
" #delay = np.argmax(c)\n",
" a_out = a_out[delay - 1:]\n",
@@ -174,14 +138,14 @@
" a_out_abs = np.abs(a_out)\n",
" a_in_abs = np.abs(a_in)\n",
" for ampl_1, ampl_2 in zip(bins, bins[1:]):\n",
- " res.append(get_amp_ratio(ampl_1, ampl_2, a_out_abs, a_in_abs))\n",
+ " res.append(du.get_amp_ratio(ampl_1, ampl_2, a_out_abs, a_in_abs))\n",
" del a_out_abs\n",
" del a_in_abs\n",
" mean_amp, var_amp = zip(*res)\n",
" \n",
" res = []\n",
" for ampl_1, ampl_2 in zip(bins, bins[1:]):\n",
- " res.append(get_phase(ampl_1, ampl_2, a_out, a_in))\n",
+ " res.append(du.get_phase(ampl_1, ampl_2, a_out, a_in))\n",
" mean_phase, var_phase = zip(*res)\n",
" return mean_amp, var_amp, mean_phase, var_phase, db"
]
@@ -189,14 +153,20 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": [
"res = []\n",
@@ -238,14 +208,20 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": [
"fig = plt.figure(figsize=(10,10))\n",
@@ -296,42 +272,60 @@
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
- "metadata": {},
+ "metadata": {
+ "deletable": true,
+ "editable": true
+ },
"outputs": [],
"source": []
}