206 lines
5.8 KiB
Plaintext
206 lines
5.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from IPython.core.display import display, HTML\n",
|
|
"display(HTML(\"<style>.container { width:100% !important; }</style>\"))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import matplotlib.pyplot as plt\n",
|
|
"import pandas as pd\n",
|
|
"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"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Read in Measurements"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"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')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Calculation Function for $\\vartheta(R_{PT1000})$\n",
|
|
"$\\vartheta(R_{PT1000}) = \\frac{-\\alpha R_0 + \\sqrt{\\alpha^2R_0^2 - 4\\beta R_0 \\left(R_0 - R_{PT1000}\\right)}}{2\\beta R_0}$\n",
|
|
"\n",
|
|
"with\n",
|
|
"* $\\alpha = 3.9083 \\cdot 10^{-3}$\n",
|
|
"* $\\beta = -5.7750 \\cdot 10^{-7}$\n",
|
|
"* $R_0 = 1000~\\Omega$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"R_zero = 1000.0\n",
|
|
"A = 3.9083E-3\n",
|
|
"B = -5.7750E-7\n",
|
|
"\n",
|
|
"def calc_temp(resistance):\n",
|
|
" temp = (-R_zero * A + np.sqrt(R_zero*R_zero * A * A - 4* R_zero * B * (R_zero - resistance)))/(2*R_zero*B)\n",
|
|
" return temp"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Description of ADC Value"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"print(constant_sampling['adc_results.pa2_raw'].describe())"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"--------------------\n",
|
|
"# Calculate Temperature from Resistance Value"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"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"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Histograms -- Starting from Index 100"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"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()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Startup of Moving Average Filter with $\\alpha' = 0.005$\n",
|
|
"\n",
|
|
"Filter difference equation: $y[n] = (1-\\alpha')y[n-1] + \\alpha'x[n]$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(28,6), sharex=True)\n",
|
|
"data = constant_sampling['ext_lf_corr'][:20]\n",
|
|
"ax[0].plot(constant_sampling['Time'][:20], data)\n",
|
|
"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": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.8.1"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|