reflow-oven-control-sw/measurement-data/Analog Measurement Analysis.ipynb

169 lines
4.0 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"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Read in Measurements"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"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": [
"constant_sampling['temp_calculated'] = constant_sampling.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=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",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Startup of Moving Average Filter with $\\alpha' = 0.005$"
]
},
{
"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()"
]
}
],
"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
}