fpraktikum/SZ/auswertung/a_1.ipynb
2019-11-23 16:24:16 +01:00

580 lines
16 KiB
Text

{
"cells": [
{
"cell_type": "code",
"execution_count": 52,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from importlib import reload\n",
"import utility\n",
"\n",
"reload(utility)\n",
"from utility import *\n",
"\n",
"from scipy.optimize import curve_fit\n",
"from SecondaryValue import SecondaryValue"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"org_compliance = 0.0098"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"a_an = 26 # cm^2\n",
"a_org = 6.4e-2 # cm^2\n",
"a_fol = 25 # cm^2\n",
"i_ein = 100e-3 # watt/cm^2"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"# anorganic\n",
"an_dark = parse_ccurve('../messungen/191114_OM_VB/1_d_an.dat', compliance=.99)\n",
"an_light = -1*parse_ccurve('../messungen/191114_OM_VB/1_h_an.dat')[::-1]\n",
"fol_dark = parse_ccurve('../messungen/191114_OM_VB/1_d_fol.dat',\n",
" compliance=org_compliance)\n",
"fol_light = parse_ccurve('../messungen/191114_OM_VB/1_h_fol.dat',\n",
" compliance=org_compliance)\n",
"org_dark = parse_ccurve('../messungen/191114_OM_VB/1_d_org.dat',\n",
" compliance=org_compliance)\n",
"org_light = parse_ccurve('../messungen/191114_OM_VB/1_h_or.dat',\n",
" compliance=org_compliance)\n",
"\n",
"all_light = {\n",
" 'an_light': (an_light, a_an),\n",
" 'fol_light': (fol_light, a_fol),\n",
" 'org_light': (org_light, a_org)\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 640x480 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f66b41230a0>)"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(org_light)"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 640x480 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f6698d6dc40>)"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(an_dark, save='A/an_dark_close.pdf', compliance=.01)"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 640x480 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f66926a48b0>)"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(an_dark, save='A/an_dark_all.pdf')\n",
"plot_ccurve(an_light, save='A/an_light_all.pdf')"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0.569698438377934"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%matplotlib qt5\n",
"an_dark_lin = an_dark[90:]\n",
"\n",
"d_i = 0.0001\n",
"\n",
"def lin_rs(x, offset, l):\n",
" return x*l + offset\n",
"\n",
"an_param, an_sigma = curve_fit(lin_rs, an_dark_lin.T[1], an_dark_lin.T[0], sigma=np.ones_like(an_dark_lin.T[0])*d_i, absolute_sigma=True)\n",
"an_sigma = np.sqrt(np.diag(an_sigma))\n",
"\n",
"plt.plot(an_dark.T[1], an_dark.T[0], linestyle='None', marker='x', label='Kennlinie')\n",
"plt.ylabel('Spannung [V]')\n",
"plt.xlabel('Stromstaerke [A]')\n",
"plt.grid()\n",
"plt.plot(an_dark_lin[:,1], lin_rs(an_dark_lin[:,1], *an_param), label='Linearer Fit')\n",
"plt.legend()\n",
"\n",
"plt.savefig('./figs/A/dark_an_lin_fit.pdf', dpi=300)\n",
"R = an_param[0]\n",
"R"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0.00020306167618990354"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"an_sigma[0]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"plt.clf()\n",
"plt.ylabel('Spannung [V]')\n",
"plt.xlabel('Logarthmus der Stromstaerke')\n",
"plt.grid()\n",
"an_u, an_i = an_dark[an_dark[:,1] > 0].T\n",
"RR=R-0.222\n",
"log_i = np.log(an_i)\n",
"plt.plot(log_i, an_u - an_i * RR, linestyle='None', marker='x', label='Kennlinie')\n",
"\n",
"p, _ = curve_fit(lin_rs, log_i[30:], (an_u - an_i * RR)[30:])\n",
"plt.plot(log_i, lin_rs(log_i,*p), label='Fit')\n",
"plt.legend()\n",
"n = p[1]\n",
"i_s = np.exp(-p[0]/p[1])\n",
"plt.savefig('./figs/A/dark_an_lin_fit_end.pdf', dpi=300)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"0.347698438377934"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"RR"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"\n",
"def u(x, i, n, RR):\n",
" return n*np.log((x+i)/i) + x*RR\n",
"plt.clf()\n",
"plt.ylabel('Spannung [V]')\n",
"plt.xlabel('Logarthmus der Stromstaerke')\n",
"plt.grid()\n",
"plt.plot(an_i[10:], an_u[10:], linestyle='None', marker='x', label='Kennlinie')\n",
"plt.plot(an_i, u(an_i, i_s, n, RR), label='Fit')\n",
"plt.legend()\n",
"plt.savefig('./figs/A/dark_an_fit_final.pdf', dpi=300)\n",
"p, _ = curve_fit(u, an_i, an_u, p0=[i_s, n, RR])\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(1.4857909265575078, 9.565464918120711e-08, 0.347698438377934)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Final Parameters\n",
"nn = 11804.5221 * n / (273.15 + 32)\n",
"nn, i_s, RR"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"fig, ax = plot_ccurve(an_dark, label='Dunkel')\n",
"plot_ccurve_line(ax, an_light, label='Hell', marker='x')\n",
"ax.legend()\n",
"fig.show()\n",
"save_fig(fig, 'A/anorg_hell_dunkel.pdf')"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 640x480 with 1 Axes>,\n <matplotlib.axes._subplots.AxesSubplot at 0x7f66bdb739d0>)"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(fol_dark, save='A/fol_dunkel.pdf', area=a_fol)\n",
"plot_ccurve(fol_light, save='A/fol_hell.pdf', area=a_fol, mlp=[4.02000070175182, -0.00050491])"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"ename": "TypeError",
"evalue": "'NoneType' object is not subscriptable",
"output_type": "error",
"traceback": [
"\u001b[0;31m\u001b[0m",
"\u001b[0;31mTypeError\u001b[0mTraceback (most recent call last)",
"\u001b[0;32m<ipython-input-20-88f8fad814c1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mplot_ccurve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0man_dark\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msave\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'A/an_dunkel.pdf'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0marea\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0ma_an\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mplot_ccurve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0man_light\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msave\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'A/an_hell.pdf'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0marea\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0ma_an\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/Documents/Projects/UNI/Prakt/FP/SZ/auswertung/utility.py\u001b[0m in \u001b[0;36mplot_ccurve\u001b[0;34m(ccurve, log, area, compliance, median, mlp, save, **pyplot_args)\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0mcompliance\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmedian\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mccurve\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m plot_ccurve_line(ax, ccurve, area=area, compliance=compliance,\n\u001b[0m\u001b[1;32m 42\u001b[0m mlp=mlp, **pyplot_args)\n\u001b[1;32m 43\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlog\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/Documents/Projects/UNI/Prakt/FP/SZ/auswertung/utility.py\u001b[0m in \u001b[0;36mplot_ccurve_line\u001b[0;34m(ax, ccurve, area, marker, compliance, mlp, **pyplot_args)\u001b[0m\n\u001b[1;32m 54\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0marea\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 55\u001b[0m \u001b[0mc\u001b[0m \u001b[0;34m/=\u001b[0m \u001b[0marea\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 56\u001b[0;31m \u001b[0mmlp\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmlp\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0marea\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 57\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 58\u001b[0m ax.errorbar(v, c, linestyle='None', marker=marker, markersize=2, alpha=1,\n",
"\u001b[0;31mTypeError\u001b[0m: 'NoneType' object is not subscriptable"
]
}
],
"source": [
"plot_ccurve(an_dark, save='A/an_dunkel.pdf', area=a_an)\n",
"plot_ccurve(an_light, save='A/an_hell.pdf', area=a_an)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(<Figure size 640x480 with 1 Axes>,\n",
" <matplotlib.axes._subplots.AxesSubplot at 0x7f4234ee40b8>)"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_ccurve(org_dark, save='A/org_dunkel.pdf', area=a_org)\n",
"plot_ccurve(org_light, save='A/org_hell.pdf', area=a_org)"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"an_light {'j_c': 0.02630074615384615, 'u_cc': 0.5599925566487172, 'u_mlp': 0.30999911523151735, 'p_mlp': 0.156638522040846, 'ff': 0.40904859440059965, 'eta': 0.06024558540032538, 'i_mlp': array(-0.505287), 'p_ein': 2.6}\n",
"fol_light {'j_c': 3.2946186e-05, 'u_cc': 7.129314361652983, 'u_mlp': 4.02000070175182, 'p_mlp': 0.002029756267025768, 'ff': 0.3456614690624081, 'eta': 0.0008119025068103072, 'i_mlp': array(-0.00050491), 'p_ein': 2.5}\n",
"org_light {'j_c': 0.0040643187499999995, 'u_cc': 0.9183601229960922, 'u_mlp': 0.7400008818112345, 'p_mlp': 0.00016271274581558095, 'ff': 0.6811469583998824, 'eta': 0.025423866533684523, 'i_mlp': array(-0.00021988), 'p_ein': 0.0064}\n"
]
}
],
"source": [
"for name, (ccurve, area) in all_light.items():\n",
" print(name, analyze_ccurve(ccurve, area, i_ein))"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"fig, ax = plot_ccurve(an_dark, area=a_an, label='Dunkelkennlinie')\n",
"plot_ccurve_line(ax, an_light, area=a_an, label='Hellkennlinie')\n",
"ax.legend()\n",
"save_fig(fig, 'A/anorg_combined.pdf')"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"fig, ax = plot_ccurve(an_light, area=a_an, label='Anorganisch', mlp=[.30999911523151735, -0.505287])\n",
"plot_ccurve_line(ax, org_light, area=a_org, label='O1', mlp=[0.740000881811234,-0.00021988 ])\n",
"plot_ccurve_line(ax, fol_light, area=a_fol, label='O2')\n",
"ax.legend()\n",
"ax.set_xlim([-1, 1])\n",
"save_fig(fig, 'A/all_combined.pdf')"
]
}
],
"metadata": {
"kernelspec": {
"argv": [
"/usr/bin/python3",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "Python 3",
"env": null,
"interrupt_mode": "signal",
"language": "python",
"metadata": null,
"name": "python3"
},
"name": "a_1.ipynb"
},
"nbformat": 4,
"nbformat_minor": 2
}