Add new Measurements to analysis

This commit is contained in:
Mario Hüttel 2020-01-27 23:00:43 +01:00
parent bb4ccd0196
commit 5b62891fd4

View File

@ -18,7 +18,11 @@
"source": [
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import numpy as np"
"import numpy as np\n",
"\n",
"from __future__ import print_function\n",
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
"import ipywidgets as widgets"
]
},
{
@ -34,6 +38,9 @@
"metadata": {},
"outputs": [],
"source": [
"two_k_sampling_trafo = pd.read_csv(r'2000OhmSamplingTrafoSupply.csv')\n",
"one_k_sampling_trafo = pd.read_csv(r'1000OhmSamplingTrafoSupply.csv')\n",
"temperature_measurement = pd.read_csv(r'TempSamplingTrafoSupply.csv')\n",
"constant_sampling = pd.read_csv(r'1000OhmSampling.csv')"
]
},
@ -95,7 +102,9 @@
"metadata": {},
"outputs": [],
"source": [
"constant_sampling['temp_calculated'] = constant_sampling.apply(lambda row: calc_temp(row['ext_lf_corr']) , axis=1)\n"
"df_list = [one_k_sampling_trafo, two_k_sampling_trafo, temperature_measurement, constant_sampling]\n",
"for df in df_list:\n",
" df['temp_calculated'] = df.apply(lambda row: calc_temp(row['ext_lf_corr']) , axis=1)\n"
]
},
{
@ -111,15 +120,18 @@
"metadata": {},
"outputs": [],
"source": [
"fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(28,6))\n",
"signal_list = [('adc_results.pa2_raw', 25), ('ext_lf_corr', 25), ('temp_calculated', 25)]\n",
"for ax,sig in zip(axes, signal_list):\n",
" n, bins, patches = ax.hist(constant_sampling[sig[0]][100:], 25, density=1)\n",
" mu = np.mean(constant_sampling[sig[0]][100:])\n",
" sigma = np.std(constant_sampling[sig[0]][100:])\n",
" y = ((1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-0.5 * (1 / sigma * (bins - mu))**2))\n",
" ax.plot(bins, y)\n",
" ax.set_title('Histogram and Standard Deviation of '+sig[0])\n",
"fig, axes = plt.subplots(nrows=3, ncols=3, figsize=(28,15))\n",
"plot_data = [(one_k_sampling_trafo, '1 kOhm Sampling Transformer powered', 0), (two_k_sampling_trafo, '2 kOhm Sampling Transformer powered' , 0), (constant_sampling, '1 kOhm Sampling', 100)]\n",
"signal_list = [('adc_results.pa2_raw', 20), ('ext_lf_corr', 20), ('temp_calculated', 20)]\n",
"\n",
"for (data_df, title, start_idx), ax_rows in zip(plot_data, axes):\n",
" for ax,sig in zip(ax_rows, signal_list):\n",
" n, bins, patches = ax.hist(data_df[sig[0]][start_idx:], sig[1], density=1)\n",
" mu = np.mean(data_df[sig[0]][start_idx:])\n",
" sigma = np.std(data_df[sig[0]][start_idx:])\n",
" y = ((1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-0.5 * (1 / sigma * (bins - mu))**2))\n",
" ax.plot(bins, y)\n",
" ax.set_title('Histogram of '+sig[0]+' for '+title)\n",
"plt.show()"
]
},
@ -127,7 +139,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Startup of Moving Average Filter with $\\alpha' = 0.005$"
"# Startup of Moving Average Filter with $\\alpha' = 0.005$\n",
"\n",
"Filter difference equation: $y[n] = (1-\\alpha')y[n-1] + \\alpha'x[n]$"
]
},
{
@ -142,6 +156,29 @@
"ax[1].plot(constant_sampling['Time'][:20], constant_sampling['temp_calculated'][:20])\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Temperature Plotting"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"idx_count = len(temperature_measurement.index)\n",
"@interact(low=(0,idx_count -1,10), high=(0, idx_count-1, 10))\n",
"def plot_temp(low=0, high=idx_count-1):\n",
" fig, ax = plt.subplots(nrows=3, ncols=1, figsize=(28,9*3), sharex=True)\n",
" ax[0].plot(temperature_measurement['Time'][low:high], temperature_measurement['ext_lf_corr'][low:high])\n",
" ax[1].plot(temperature_measurement['Time'][low:high], temperature_measurement['adc_results.pa2_raw'][low:high])\n",
" ax[2].plot(temperature_measurement['Time'][low:high], temperature_measurement['temp_calculated'][low:high])\n",
" plt.plot()"
]
}
],
"metadata": {