L1-python/source/Plotting II.ipynb

990 lines
111 KiB
Plaintext
Raw Permalink Normal View History

2023-01-20 16:04:53 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Feuille 2 - UE Projet CMI-L1\n",
"Reading files with Pandas, ploting and fitting data"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"# pandas is a Python package providing fast, flexible, and expressive data \n",
"# structures designed to make working with “relational” or “labeled” data \n",
"# both easy and intuitive. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## I) Files : reading typical format files\n",
"we propose to work with some column data :\n",
"* csv : column data delimited by \",\" or \";\" with headers\n",
"* txt : column data delimited by spaces with headers\n",
"* raw : column data delimited by spaces without headers\n",
"* dat : column data formatted delimited by spaces\n",
"* xlsx : excel data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### a) CSV files"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x;y;er\r",
"\r\n",
"1;1;0.2\r",
"\r\n",
"2;4;0.2\r",
"\r\n",
"3;8;0.3\r",
"\r\n",
"4;17;0.4\r",
"\r\n",
"5;24;0.2"
]
}
],
"source": [
"!cat data.csv"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" x y er\n",
"0 1 1 0.2\n",
"1 2 4 0.2\n",
"2 3 8 0.3\n",
"3 4 17 0.4\n",
"4 5 24 0.2\n"
]
}
],
"source": [
"# read file\n",
"d = pd.read_csv(\"data.csv\",delimiter=\";\")\n",
"print(d)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### b) Raw files with headers"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"x y er\r",
"\r\n",
"1 1 0.2\r",
"\r\n",
"2 4 0.2\r",
"\r\n",
"3 8 0.3\r",
"\r\n"
]
}
],
"source": [
"# text files\n",
"!cat data.txt"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" x y er\n",
"0 1 1 0.2\n",
"1 2 4 0.2\n",
"2 3 8 0.3\n"
]
}
],
"source": [
"# read file\n",
"dtext = pd.read_csv(\"data.txt\")\n",
"print(dtext)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### c) Raw files without headers"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 1 0.2\r",
"\r\n",
"2 4 0.2\r",
"\r\n",
"3 8 0.3\r",
"\r\n"
]
}
],
"source": [
"# raw values\n",
"!cat data.raw"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0 1 2\n",
"0 1 1 0.2\n",
"1 2 4 0.2\n",
"2 3 8 0.3\n"
]
}
],
"source": [
"# read raw file\n",
"draw = pd.read_csv(\"data.raw\",delimiter=\" \", header = None)\n",
"print(draw)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### d) Formatted file"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0 1\n",
"0 0.0 0.894520\n",
"1 100.0 0.849616\n",
"2 200.0 0.806313\n",
"3 300.0 0.763861\n",
"4 400.0 0.722299\n",
"5 500.0 0.681680\n",
"6 600.0 0.642211\n",
"7 700.0 0.603411\n",
"8 800.0 0.565199\n",
"9 900.0 0.528873\n",
"10 1000.0 0.492817\n"
]
}
],
"source": [
"# read raw file\n",
"fwidths = [11,10]\n",
"dexpe = pd.read_fwf(\"expe.dat\",delimiter=\" \",header = None, widths = fwidths)\n",
"print(dexpe)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### e) Excel data"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" data Unnamed: 1 Unnamed: 2\n",
"0 x y er\n",
"1 1 1 0.2\n",
"2 2 4 0.2\n",
"3 3 8 0.3\n",
"4 4 17 0.4\n",
"5 5 24 0.2\n"
]
}
],
"source": [
"d = pd.read_excel(\"data.xlsx\")\n",
"print(d)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### More formats\n",
"see references https://pandas.pydata.org/docs/getting_started/intro_tutorials/01_table_oriented.html"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<img src=\"02_io_readwrite.svg\" width=\"800\" height=\"500\"/>"
],
"text/plain": [
"<IPython.core.display.Image object>"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# import image module\n",
"from IPython.display import Image\n",
" \n",
"# get the image\n",
"Image(url=\"02_io_readwrite.svg\", width=800, height=500)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## II) Filling variables"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" x y er\n",
"0 1 1 0.2\n",
"1 2 4 0.2\n",
"2 3 8 0.3\n",
"3 4 17 0.4\n",
"4 5 24 0.2\n"
]
}
],
"source": [
"# read file\n",
"d = pd.read_csv(\"data.csv\",delimiter=\";\")\n",
"print(d)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can use **headers** or **column numbers** to fill the variables"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 1\n",
"1 2\n",
"2 3\n",
"3 4\n",
"4 5\n",
"Name: x, dtype: int64 0 1\n",
"1 4\n",
"2 8\n",
"3 17\n",
"4 24\n",
"Name: y, dtype: int64 0 0.2\n",
"1 0.2\n",
"2 0.3\n",
"3 0.4\n",
"4 0.2\n",
"Name: er, dtype: float64\n"
]
}
],
"source": [
"# taking values from headers\n",
"x=d[\"x\"]\n",
"y=d[\"y\"]\n",
"e=d[\"er\"]\n",
"print(x,y,e)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0 1\n",
"1 2\n",
"2 3\n",
"3 4\n",
"4 5\n",
"Name: x, dtype: int64 0 1\n",
"1 4\n",
"2 8\n",
"3 17\n",
"4 24\n",
"Name: y, dtype: int64 0 0.2\n",
"1 0.2\n",
"2 0.3\n",
"3 0.4\n",
"4 0.2\n",
"Name: er, dtype: float64\n"
]
}
],
"source": [
"# taking values from colon .iloc[row,col] or .loc[row,col]\n",
"x=d.iloc[:,0]\n",
"y=d.iloc[:,1]\n",
"e=d.iloc[:,2]\n",
"print(x,y,e)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## III) Plotting data"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0 1\n",
"0 0.0 0.894520\n",
"1 100.0 0.849616\n",
"2 200.0 0.806313\n",
"3 300.0 0.763861\n",
"4 400.0 0.722299\n",
"5 500.0 0.681680\n",
"6 600.0 0.642211\n",
"7 700.0 0.603411\n",
"8 800.0 0.565199\n",
"9 900.0 0.528873\n",
"10 1000.0 0.492817\n"
]
}
],
"source": [
"# read raw file\n",
"fwidths = [11,10]\n",
"dexpe = pd.read_fwf(\"expe.dat\",delimiter=\" \",header = None, widths = fwidths)\n",
"print(dexpe)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"# get x and y\n",
"x=dexpe.iloc[:,0]\n",
"y=dexpe.iloc[:,1]"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7fb0838ea250>"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAGDCAYAAAAxhIflAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAlSUlEQVR4nO3df7xVdZ3v8dcnQEXEwR9kCf6gGTN1VIRzFX8mmYqaP8abV8kmKYsy7U5jOWFzU7s11VynacZyctBMK8V+qZGjSVNDWGaJib/ByCyPOIqYP0gMkc/9Yy1wc/iewzlwNptzzuv5eOwHe33Xd639/e5z2O+z1ve71o7MRJKkjl7T6gZIkjZNBoQkqciAkCQVGRCSpCIDQpJUZEBIkooMCPU7EZER8Rcb+TUfjYi3rue2O0fE0ogY1NvtWsfr7hARcyLihYj4fC/ve6P/DNT7DIgBrv5gWvVYGRHLGpZPb3X7eltEzI6Ilzr0+/sbuQ1rhElm/j4zt8rMVzZmO4CpwNPA1pn5kQ5tPD8i5nTcICK2j4jlEfGXG6uRah0DYoCrP5i2ysytgN8DxzeUXdPq9nUUEYN7YTfnNPY7M4/vhX32RbsAD2b5atmvAwdFxJgO5acB92Xm/U1vnVrOgFBRRLwmIqZFxG8iYklEfCsitq3X7VqfQnh3RDwWEX+IiA9ExP+IiHsj4tmI+FLDvqZExM8i4osR8VxEzI+IIxrW7xgRMyPimYhYGBHva1h3UUR8JyK+ERHPA1MiYv+I+Hn9Ok9ExJciYrNe6PNDEfG2huXBEfF0RIyrl0+IiAfq150dEXt0sp+rIuLTDcuHR0R7/fzrwM7A9+ujl79reD8Hd/P9+FZEfK0+NfRARLR10aeDIuLO+n2/MyIOWtVG4Azg7+p2rHF6LDPbgR8Df91hl+8Crq738b66fc/U7d2xkzbMjoj3NixPiYif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+SpI2kaQGRmT9lHTdQqy/jP7uTdTdTBYgkqQWaPkgtadPx8ssv097ezksvvdTqpmgj22KLLRg9ejRDhgzp9jYGhDSAtLe3M3z4cHbddVfWvPu6+rPMZMmSJbS3tzNmTMevGe+c92KSBpCXXnqJ7bbbznAYYCKC7bbbrsdHjgaENMAYDgPT+vzcDQhJG9WgQYMYO3bs6sfnPve5pr7ezJkzm/4as2fP5vbbS98dtaarrrqKc845Z531dt11V55+uuuv7fjMZz7T7fatL8cgJHXqxrsf5+JbF7Do2WXsOGIo5x29Oyftt2F3vRk6dCjz5s3rnQauw4oVKzjhhBM44YQTmvo6s2fPZquttuKggw5q6us0+sxnPsPHP/7xpr6GRxCSim68+3HOv/4+Hn92GQk8/uwyzr/+Pm68e32/lrxzzz33HLvvvjsLFiwAYPLkyVx++eUAbLXVVnzkIx9h3LhxHHHEESxevBiA3/zmN0yaNInx48dz6KGHMn/+fACmTJnCueeey8SJE/nYxz62xl/tU6ZM4ayzzmLixIm84Q1v4Cc/+Qnvec972GOPPZgyZcrq9syaNYsDDzyQcePGccopp7B06VKg+sv+wgsvZNy4cey9997Mnz+fRx99lMsuu4wvfOELjB07lttuu43vf//7HHDAAey333689a1v5cknn+yy/0uWLOGoo45iv/324/3vfz+Nd9k+6aSTGD9+PHvttRfTp08HYNq0aSxbtoyxY8dy+umnd1pvg2Vmv3mMHz8+JXXuwQcf7Hbdgz77o9zlYzet9Tjosz/aoDa85jWvyX333Xf147rrrsvMzFmzZuWECRNyxowZefTRR6+uD+Q3vvGNzMz85Cc/mWeffXZmZr7lLW/Jhx9+ODMz77jjjpw4cWJmZp5xxhl53HHH5YoVKzIz86tf/erqbc4444w89dRTc+XKlXnjjTfm8OHD8957781XXnklx40bl3f
"text/plain": [
"<Figure size 432x432 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# plot\n",
"fig = plt.figure(figsize=(6,6)) # s\n",
"ax = plt.subplot() \n",
"ax.plot(x,y,\"o\",label=\"Experimental data\")\n",
"ax.set_ylim([0,2])\n",
"ax.set_xlabel(\"t[s]\")\n",
"ax.set_ylabel(\"V[t]\")\n",
"ax.set_title(\"Temporal Evolution of Volume\")\n",
"ax.legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## IV) Fitting data : linear"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"from scipy.optimize import curve_fit\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"def func(x, a, b):\n",
" return a * x + b"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(array([-4.01437909e-04, 8.87155318e-01]), array([[ 1.96723961e-11, -9.83619802e-09],\n",
" [-9.83619802e-09, 6.88533863e-06]]))\n"
]
}
],
"source": [
"popt= curve_fit(func, x, y)\n",
"print(popt)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"[a,b]=popt[0]"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7fb083cadf40>"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAGDCAYAAAAxhIflAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAymUlEQVR4nO3deXxV9Z3/8dcnIUCAQJBNSNgEQUC2EBFcUNxALW5TR6mdStWhtmqntXVE+2vVmY7a2k6ntlqKSl2qaGsBqdVKrVJcoBIgbLIFRElACCAIsib5/P44J8lNOAkJ5HJD8n4+HueRe9b7PTdw3znn+z3fr7k7IiIilSUlugAiIlI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z+zZsxk5ciRZWVlce+217NmzBwj+sr/vvvvIyspi4MCBrFq1ig0bNjB58mR+8YtfMGTIEN555x3+/Oc/c+aZZzJ06FAuuugitmzZUu35b9++nUsuuYShQ4fyjW98g9hetq+66iqGDRvGgAEDmDJlCgCTJk1i3759DBkyhBtuuKHK7Y6ZuzeYadiwYS4iVfvwww9rvO1ZD/3du9/96mHTWQ/9/ZjKkJSU5IMHDy6bXnzxRXd3nz17to8YMcKnTZvmY8aMKdse8N///vfu7v7AAw/4bbfd5u7uF1xwga9Zs8bd3efPn++jR492d/cbb7zRL7/8ci8qKnJ399/97ndl+9x4441+3XXXeUlJic+cOdPT0tJ86dKlXlxc7FlZWb548WIvLCz0c8891/fs2ePu7g8//LA/8MAD7u7evXt3f/TRR93d/bHHHvObb77Z3d3vu+8+f+S
"text/plain": [
"<Figure size 432x432 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure(figsize=(6,6)) # \n",
"ax = plt.subplot() \n",
"ax.plot(x,y,\"o\",label=\"Experimental data\")\n",
"ax.plot(x,func(x,*popt[0]),label=\"Linear model\")\n",
"ax.set_ylim([0,2])\n",
"ax.set_xlabel(\"t[s]\")\n",
"ax.set_ylabel(\"V[t]\")\n",
"ax.set_title(\"Temporal Evolution of Volume\")\n",
"ax.legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## V) Fitting data : non linear"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>0</th>\n",
" <th>1</th>\n",
" <th>2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0.102</td>\n",
" <td>0.319</td>\n",
" <td>0.565</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.204</td>\n",
" <td>0.452</td>\n",
" <td>0.672</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.306</td>\n",
" <td>0.553</td>\n",
" <td>0.744</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.408</td>\n",
" <td>0.639</td>\n",
" <td>0.799</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.510</td>\n",
" <td>0.714</td>\n",
" <td>0.845</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" 0 1 2\n",
"0 0.102 0.319 0.565\n",
"1 0.204 0.452 0.672\n",
"2 0.306 0.553 0.744\n",
"3 0.408 0.639 0.799\n",
"4 0.510 0.714 0.845"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# read raw file\n",
"fwidths = [6,6,6]\n",
"dexpe = pd.read_fwf(\"power.dat\",delimiter=\" \",header = None, widths = fwidths)\n",
"dexpe.head()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"# get x and y\n",
"x =dexpe.iloc[:,0]\n",
"y1=dexpe.iloc[:,1]\n",
"y2=dexpe.iloc[:,2]"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7fb083dbd130>"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAGDCAYAAAAxhIflAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6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ubNmyhebmZgYPTr31shTDguUbOgwXHVBfF9mDOKC+rggtrC4VX4tpx44d9OvXT8FBOjAz+vXrp95liUjkGjZsbcHZk2s4+cMDlIgukooPEICCg6Sln43SccuitW2J6ISW1t38ds0mbh43lIb6Oowg93DzuKFKRBdAVQSIYqupqeGoo45qe0ybNi3W91u4cGHs77FkyRKefjrqXjnt3XnnnVx99dWdHjdo0CA2b858m4JvfvObWbcv4Y477uCDH/wgZtbp9aW4MuUazh/ewFNTTuHP087mqSmnKDgUSMXnIHIVNQba3R/Guro6VqxYkZ8GdmLXrl2ce+65nHvuubG+z5IlS+jduzcf/ehHOz84T775zW/y9a9/PadzRo8ezTnnnMNJJ50UT6OkS5RrKA/qQSRJNwaaWJSTT9u2bWPIkCGsXbsWgAkTJvDDH/4QgN69e/PVr36VESNGcOqpp7Jp0yYA/vSnPzFmzBiOPvpojj/+eNasWQPAxIkT+cpXvsLJJ5/M1772tXZ/tU+cOJErrriCk08+mQ984AP87ne/4+KLL+awww5j4sSJbe1ZvHgxxx57LCNGjOCCCy5g+/btQPCX/fXXX8+IESMYOnQoa9as4dVXX2XGjBncdtttHHXUUTzxxBM89NBDHHPMMQwfPpyPfexj/O1vyfec72jLli2cfvrpDB8+nMsuu4zk6dbnn38+Rx99NIcffjgzZ84EYMqUKbS0tHDUUUd
"text/plain": [
"<Figure size 432x432 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# plot\n",
"fig = plt.figure(figsize=(6,6)) # s\n",
"ax = plt.subplot() \n",
"ax.plot(x,y1,\"o\",label=\"Experimental data 1\")\n",
"ax.plot(x,y2,\"o\",label=\"Experimental data 2\")\n",
"ax.set_ylim([0,2])\n",
"ax.set_xlabel(\"t[s]\")\n",
"ax.set_ylabel(\"V[t]\")\n",
"ax.set_title(\"Temporal Evolution of Volume\")\n",
"ax.legend()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### log-log"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[]"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZsAAAGHCAYAAABmjP8YAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAu4ElEQVR4nO3de3xU9Z3/8deHGCUoJgpYF4LirVkVkFsVL3ithapBli0qtbvitWrVrbpU6K9VcV2xpZYt1dZ7tdaCaJGCP1usWkrrpSsQCiKg6E9LgpWLkoqGEuDz+2Nm4mSYmcxM5sz1/Xw85pHMOWfO+c445s33cr5fc3dERESC1CXfBRARkdKnsBERkcApbEREJHAKGxERCZzCRkREAqewERGRwClsRDpgZm5mh+f4mu+a2RczfO1BZrbVzCqyXa4Orvs5M1tkZh+b2V1ZPnfO/xtIdilsJKvCf+Qij11m1hL1/MJ8ly/bzGyhmW2Led/zc1yGdsHk7n91933cfWcuywFcAWwC9nX3G2PKONnMFsW+wMx6mtl2M+ufq0JKfihsJKvCf+T2cfd9gL8C9VHbHs93+WKZ2R5ZOM010e/b3euzcM5idDDwhse/U/wx4AQzOyRm+wXACnd/PfDSSV4pbCQnzKyLmU0ys7fNbLOZzTaz/cP7+oWbSS42s3Vm9pGZXWlmXzCz5Wa2xczujjrXBDN7ycx+bGbNZrbazM6I2t/bzOaZ2YdmttbMLo/ad6uZPWVmvzCzvwMTzOxYM3slfJ33zexuM9szC+95lZmdE/V8DzPbZGZDws9Hm9nK8HUXmtmRCc7ziJndHvX8VDNrDP/+GHAQMD9cq/pW1Oe5R4qfx2wz+3m4+WulmQ1L8p5OMLPXwp/7a2Z2QqSMwEXAt8LlaNcE6O6NwIvAv8Wc8t+BR8PnuDxcvg/D5e2doAwLzeyyqOcTzOxPUc/dzK42s7fC7+m/zOyw8H/jv4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esYG5DJku/J9fc3ExdXR1r1qwBYPz48TzwwAMA7LPPPtx4440MGTKEM844g40bNwLw9ttvM2rUKIYOHcqIESNYvXo1ABMmTOCGG27gtNNO46abbmpXm5gwYQJXXXUVp512Goceeih/+MMfuOSSSzjyyCOZMGFCW3mee+45jj/+eIYMGcK4cePYunUrEKpx3HLLLQwZMoQBAwawevVq3n33Xe69916mT5/OoEGD+OMf/8j8+fM57rjjGDx4MF/84hf54IMPkr7/zZs386UvfYnBgwfz9a9/neiZzMeMGcPQoUM5+uijuf/++wGYNGkSLS0tDBo0iAsvvDDhcbEGDx6MpjASyZC76xHnMXToUI/1xhtv7LYtkROmvuAH3/TMbo8Tpr6Q8jni6dKlix9zzDFtj1mzZrm7+3PPPefDhw/3mTNn+siRI9uOB/wXv/iFu7tPmTLFv/GNb7i7++mnn+5vvvmmu7u/+uqrftppp7m7+0UXXeRnn32279ixw93df/azn7W95qKLLvLzzz/fd+3a5XPnzvXu3bv78uXLfefOnT5kyBBvaGjwjRs3+ogRI3zr1q3u7n7nnXf6lClT3N394IMP9hkzZri7+z333OOXXnqpu7vfcsstPm3atLYyf/jhh75r1y53d3/ggQf8hhtu2K0s0a699tq2azzzzDMO+MaNG93dffPmze7u/umnn/rRRx/tmzZtcnf3vffeu905Eh0Xz8EHH9x2/ljpfEdECsnTSxv9hKkveL/w36mnlzZmdB5gscf5m6pmtICs39KS1vZUJWpGO/PMM3nyySf5xje+wV/+8pe27V26dOH8888H4Gtf+xpjx45l69atvPzyy4wbN67tuH/84x9tv48bN46Kioq416+vr8fMGDBgAJ/73OcYMGAAAEcffTTvvvsujY2NvPHGG5x44okAbN++neOPP77t9WPHjgV
"text/plain": [
"<Figure size 432x432 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# plot\n",
"fig = plt.figure(figsize=(6,6)) # s\n",
"ax = plt.subplot() \n",
"ax.plot(x,y1,\"o\",label=\"Experimental data 1\")\n",
"ax.plot(x,y2,\"o\",label=\"Experimental data 2\")\n",
"ax.set_xlabel(\"t[s]\")\n",
"ax.set_ylabel(\"V[t]\")\n",
"ax.set_title(\"Temporal Evolution of Volume\")\n",
"ax.legend()\n",
"ax.loglog()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"That's because\n",
"$$ y = x^a + b $$\n",
"gives\n",
"$$\\log(y) = a \\log(x) + \\log(b)$$\n",
"a linear function en log-log scale"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"def func(x, a, b):\n",
" return a * x + b"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"popt= curve_fit(func, np.log(x), np.log(y1))"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0.500\n",
"-0.000\n"
]
}
],
"source": [
"popt[0]\n",
"a=popt[0][0]\n",
"b=popt[0][1]\n",
"print(\"%.3f\" % a)\n",
"print(\"%.3f\" % b)"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[]"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZsAAAGHCAYAAABmjP8YAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAA94ElEQVR4nO3dd3hUddrG8e+TZAKhK9ggClZWEKSp2PuCCoi4ShEBwV7fVXEBV9EVREXX3hsoTbGgWBZdFbu7omDFCLioARUEQw3MJHneP2YSh5iEJGRyJsn9ua65LmbOb855Jo658yvnHHN3REREEikl6AJERKT2U9iIiEjCKWxERCThFDYiIpJwChsREUk4hY2IiCScwkZkK8zMzWyvaj7mUjM7rpLv3c3M1ptZalXXtZXj7m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YiIpJwChsREUk4DaOJiEjCqWcjIiIJp7AREZGEq4or3tZKLVq08DZt2gRdhohIjfLJJ5/86u47FH9dYVOKNm3aMG/evKDLEBGpUcys+CWNAA2jiYhINVDYiIhIwilsREQk4TRnUwGRSITs7Gw2bdoUdCmShOrXr09mZiahUCjoUkSSjsKmArKzs2ncuDFt2rRhy6vbS13n7qxatYrs7Gx23333oMsRSToaRquATZs20bx5cwWN/IGZ0bx5c/V6RUqhsKkgBY2URt8NkdIpbGqY1NRUOnXqVPS46aabEnq8F198MeHHmDt3Lh98UNI9w7Y0adIkLr744q22a9OmDb/+WvYtVm688cZy11fonnvuYa+99sLMtrp/EdmS5mwSaNb8ZUyck8XynFxaNstgZI+29O28bbeYz8jIYMGCBVVT4Fbk5eXRp08f+vTpk9DjzJ07l0aNGnHIIYck9DjxbrzxRsaMGVOh9xx66KH06tWLo446KjFFidRi6tkkyKz5yxj93Bcsy8nFgWU5uYx+7gtmza/Mrd/LtmbNGtq2bUtWVhYAAwcO5OGHHwagUaNGXHHFFXTp0oVjjz2WlStXArBkyRJ69uxJ165dOfzww/nmm28AGDZsGJdffjlHH300f/vb37boTQwbNowLLriAo48+mj322IO3336b4cOHs++++zJs2LCiel577TUOPvhgunTpwmmnncb69euBaI9j7NixdOnShQ4dOvDNN9+wdOlSHnjgAW6//XY6derEu+++y+zZsznooIPo3Lkzxx13HL/88kuZn3/VqlX8+c9/pnPnzpx33nnEX8m8b9++dO3alfbt2/PQQw8BMGrUKHJzc+nUqRNnnHFGqe2K69y5M7qEkUglubseJTy6du3qxX399dd/eK00h0x4w1v/7aU/PA6Z8Ea591GSlJQU33///YseM2bMcHf31157zbt37+7Tp0/3Hj16FLUHfMqUKe7ufv311/tFF13k7u7HHHOMf/vtt+7u/tFHH/nRRx/t7u5Dhw71k046yfPy8tzd/fHHHy96z9ChQ71///5eUFDgs2bN8saNG/vnn3/u+fn53qVLF58/f76vXLnSDz/8cF+/fr27u990001+/fXXu7t769at/a677nJ393vvvddHjBjh7u5jx471iRMnFtW8evVqLygocHf3hx9+2C+//PI/1BLvkksuKTrGSy+95ICvXLnS3d1XrVrl7u4bN2709u3b+6+//uru7g0bNtxiH6W1K0nr1q2L9l9cRb4jIsnk+U+z/ZAJb3ib2O+p5z/NrtR+gHlewu9UDaMlyPKc3Aq9Xl6lDaMdf/zxzJw5k4suuojPPvus6PWUlBT69+8PwODBg+nXrx/r16/ngw8+4LTTTitqt3nz5qJ/n3baaaSmppZ4/N69e2NmdOjQgZ122okOHToA0L59e5YuXUp2djZff/01hx56KADhcJiDDz646P39+vUDoGvXrjz33HMlHiM7O5v+/fvz008/EQ6
"text/plain": [
"<Figure size 432x432 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# plot\n",
"fig = plt.figure(figsize=(6,6)) # s\n",
"ax = plt.subplot() \n",
"ax.plot(x,y1,\"o\",label=\"Experimental data 1\")\n",
"ax.plot(x,x**a+b,\"-\",label=\"Model 1\")\n",
"ax.set_xlabel(\"t[s]\")\n",
"ax.set_ylabel(\"V[t]\")\n",
"ax.set_title(\"Temporal Evolution of Volume\")\n",
"ax.legend()\n",
"ax.loglog()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### VI ) Error bars"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" x y er\n",
"0 1 1 0.2\n",
"1 2 4 0.2\n",
"2 3 8 0.3\n",
"3 4 17 0.4\n",
"4 5 24 0.2\n"
]
}
],
"source": [
"# read file\n",
"d = pd.read_csv(\"data.csv\",delimiter=\";\")\n",
"print(d.head())\n",
"# taking values from headers\n",
"x=d[\"x\"]\n",
"y=d[\"y\"]\n",
"e=d[\"er\"]\n",
"#print(x,y,e)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7fb0828c64f0>"
]
},
"execution_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BPhsRo8AIsCYzs/3lSpLGM2mgZ+ZPgZikz43Aje0qSpLUOt8pKkmFMNAlqRAGuiRNo+G9+3h15wiDW3e0fWwDXZKmyeDWHbz4xjBDO0a49JaBtoe6gS5J02Rgy3b2V/f/7Rvdz8CW9t7dbaBL0jTpXzafOdU9g11z59C/bH5bx2/mPnRJUhus7JvHCQt72L13lOvXrGBl37y2jm+gS9I06unuoqe7q+1hDi65SFIxDHRJKoSBLkmFMNAlqRAGuiQVwkCXpEIY6JJUCANdkgphoEtSIQx0SSqEgS5JhTDQJakQBrokFcJAl6RCGOiSVAgDXZIKYaBLUiEMdEkqhIEuSYUw0CWpEAa6JBXCQJekQhjoklQIA12SCmGgS1IhDHRJKoSBLkmFMNAlqRAGuiQVwkCXpEIY6JJUiEkDPSKOjYgfR8SmiHg+Ij7XoE9ExA0RsTkino2IU6amXEnSeOY20WcU+EJmPhkRPcBgRPwoM1+o6XMecHz1OA34dvWnJGmaTHqFnpmvZ+aT1fYwsAlYVNftIuCOHDMAHB0Rx7S9WknSuJq5Qn9HRCwFVgCP1zUtAl6p2R+qjr1e9/y1wFqAJUuWtFiqJM1+91x5+pSN3fSLohFxFPB94POZubu+ucFT8l0HMm/OzFWZuaq3t7e1SiVJE2oq0COii7EwvzMz723QZQg4tmZ/MfDaoZcnSWpWM3e5BHArsCkzvzlOt/XAZdXdLv3Arsx8fZy+kqQp0Mwa+pnAp4GfR8TT1bEvA0sAMnMdsAE4H9gMvA1c0fZKJUkTmjTQM/OnNF4jr+2TwFXtKkqS1DrfKSpJhTDQJakQBrokFcJAl6RCGOiSVAgDXZIKYaBLUiEMdEkqhIEuSYU
"text/plain": [
"<Figure size 432x432 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"fig = plt.figure(figsize=(6,6)) # s\n",
"ax = plt.subplot() \n",
"ax.errorbar(x,0.1*y,e*2, marker='.', linestyle=\"none\", label=\"data\")\n",
"ax.set_title(\"with error bars\")\n",
"ax.legend()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}