Add measurements to analysis of target code for temperature measurements
This commit is contained in:
parent
23e754ab2a
commit
8af10dd52c
5949
measurement-data/1000OhmSampling1ms.csv
Normal file
5949
measurement-data/1000OhmSampling1ms.csv
Normal file
File diff suppressed because it is too large
Load Diff
12577
measurement-data/1000OhmSampling1ms_later.csv
Normal file
12577
measurement-data/1000OhmSampling1ms_later.csv
Normal file
File diff suppressed because it is too large
Load Diff
104974
measurement-data/1000OhmSamplingTimerTriggered800ARR.csv
Normal file
104974
measurement-data/1000OhmSamplingTimerTriggered800ARR.csv
Normal file
File diff suppressed because it is too large
Load Diff
@ -75,6 +75,36 @@
|
|||||||
" return temp"
|
" return temp"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def plot_histogram(ax, data, bin_count, title, signal_name):\n",
|
||||||
|
" n, bins, patches = ax.hist(data, bin_count, density=1, color='navy')\n",
|
||||||
|
" mu = np.mean(data)\n",
|
||||||
|
" sigma = np.std(data)\n",
|
||||||
|
" y = ((1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-0.5 * (1 / sigma * (bins - mu))**2))\n",
|
||||||
|
" ax.plot(bins, y, color='darkorange')\n",
|
||||||
|
" ax.set_title(title)\n",
|
||||||
|
" ax.set_ylabel(signal_name + ' probability (normalized)')\n",
|
||||||
|
" ax.set_xlabel(signal_name)\n",
|
||||||
|
" # Plot sigma and mu lines\n",
|
||||||
|
" ax.axvline(x=mu-sigma, ls='--', color='magenta')\n",
|
||||||
|
" ax.axvline(x=mu+sigma, ls='--', color='magenta')\n",
|
||||||
|
" ax.axvline(x=mu, ls='--', color='lawngreen')\n",
|
||||||
|
"\n",
|
||||||
|
" #Plot textbox\n",
|
||||||
|
" textstr = '\\n'.join((\n",
|
||||||
|
" r'$\\mu=%.2f$' % (mu, ),\n",
|
||||||
|
" r'$\\sigma=%.3f$' % (sigma, ),\n",
|
||||||
|
" r'$N_{Sa} =%d$' % (len(data), )))\n",
|
||||||
|
" props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)\n",
|
||||||
|
" ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=14,\n",
|
||||||
|
" verticalalignment='top', bbox=props)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@ -117,33 +147,14 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"fig, axes = plt.subplots(nrows=3, ncols=3, figsize=(28,20))\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",
|
"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",
|
"signal_list = [('ext_lf_corr', 20), ('temp_calculated', 20)]\n",
|
||||||
|
"\n",
|
||||||
|
"fig, axes = plt.subplots(nrows=len(plot_data), ncols=len(signal_list), figsize=(28,20))\n",
|
||||||
"\n",
|
"\n",
|
||||||
"for (data_df, title, start_idx), ax_rows in zip(plot_data, axes):\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",
|
" 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, color='navy')\n",
|
" plot_histogram(ax, data_df[sig[0]][start_idx:], sig[1], title,sig[0])\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, color='darkorange')\n",
|
|
||||||
" ax.set_title(title)\n",
|
|
||||||
" ax.set_ylabel(sig[0] + ' probability (normalized)')\n",
|
|
||||||
" ax.set_xlabel(sig[0])\n",
|
|
||||||
" # Plot sigma and mu lines\n",
|
|
||||||
" ax.axvline(x=mu-sigma, ls='--', color='magenta')\n",
|
|
||||||
" ax.axvline(x=mu+sigma, ls='--', color='magenta')\n",
|
|
||||||
" ax.axvline(x=mu, ls='--', color='lawngreen')\n",
|
|
||||||
" \n",
|
|
||||||
" #Plot textbox\n",
|
|
||||||
" textstr = '\\n'.join((\n",
|
|
||||||
" r'$\\mu=%.2f$' % (mu, ),\n",
|
|
||||||
" r'$\\sigma=%.2f$' % (sigma, ),\n",
|
|
||||||
" r'$N_{Sa} =%d$' % (len(data_df[sig[0]][start_idx:], ))))\n",
|
|
||||||
" props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)\n",
|
|
||||||
" ax.text(0.05, 0.95, textstr, transform=ax.transAxes, fontsize=14,\n",
|
|
||||||
" verticalalignment='top', bbox=props)\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
" \n",
|
" \n",
|
||||||
"plt.tight_layout()\n",
|
"plt.tight_layout()\n",
|
||||||
@ -310,6 +321,66 @@
|
|||||||
"ax.set_title('Cooldown without airflow | Convection has to be taken into account') \n",
|
"ax.set_title('Cooldown without airflow | Convection has to be taken into account') \n",
|
||||||
"plt.show()"
|
"plt.show()"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"---\n",
|
||||||
|
"# Target Implementation Sampling of 1k Resistor"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Histograms"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"# Read in data\n",
|
||||||
|
"kilo_ohm_sampling1 = pd.read_csv(r'1000OhmSampling1ms.csv')\n",
|
||||||
|
"kilo_ohm_sampling2 = pd.read_csv(r'1000OhmSampling1ms_later.csv')\n",
|
||||||
|
"kilo_ohm_sampling2_fast = pd.read_csv(r'1000OhmSamplingTimerTriggered800ARR.csv')\n",
|
||||||
|
"plot_data_tuples = [(kilo_ohm_sampling1, 'Day 1 Sampling'), (kilo_ohm_sampling2, 'Day 2 sampling'), (kilo_ohm_sampling2_fast,'Day 2 sampling faster (ARR=700)')]\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\n",
|
||||||
|
"# def plot_histogram(ax, data, bin_count, title, signal_name):\n",
|
||||||
|
"# def calculate_temp_for_df(data_frame, resistance_col_name='ext_lf_corr', temp_col_name='temp_calculated'):\n",
|
||||||
|
"\n",
|
||||||
|
"fig, axes = plt.subplots(nrows=len(plot_data_tuples), ncols=2, sharex='col', figsize=(28, 16))\n",
|
||||||
|
"\n",
|
||||||
|
"for df, title in plot_data_tuples:\n",
|
||||||
|
" calculate_temp_for_df(df, resistance_col_name='pt1000_res_raw_lf')\n",
|
||||||
|
"\n",
|
||||||
|
"for (df,title),ax in zip(plot_data_tuples, axes):\n",
|
||||||
|
" plot_histogram(ax[0], df['pt1000_res_raw_lf'], 20, title, 'PT1000 Resistance')\n",
|
||||||
|
" plot_histogram(ax[1], df['temp_calculated'], 20, title, 'Calculated Temperature in °C')\n",
|
||||||
|
"\n",
|
||||||
|
"plt.tight_layout()\n",
|
||||||
|
"plt.show()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"calc_temp(1097)"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
Loading…
Reference in New Issue
Block a user