weather-in-poland/main.ipynb

423 lines
243 KiB
Plaintext
Raw Normal View History

2020-11-16 01:23:07 +01:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Analiza temperatury w Polsce na wybranych przykładach (dane z okresu 1901-2016)\n",
"\n",
"Dane pobrane z: [worldbank.org](worldbank.org).\n",
"\n",
"Plik CSV: https://climateknowledgeportal.worldbank.org/api/data/get-download-data/historical/tas/1901-2016/POL/Poland"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"data = {}\n",
"\n",
"with open(\"tas_1901_2016_POL.csv\") as f:\n",
"\n",
" # przeczytaj plik, iteruj po liniach...\n",
" for line in f.readlines():\n",
"\n",
" # wyłuskaj interesujące nas wartości\n",
" t_str, y_str, m_str = line.split(\",\")\n",
"\n",
" # konwertuj odczytane wartości na odpowiednie typy\n",
" t, y, m = float(t_str), int(y_str), m_str.strip().lower()\n",
"\n",
" # zapisz do zmiennej\n",
" data[y] = data.get(y, {})\n",
" data[y][m] = t"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Przykład 1. Najzimniejszy oraz najcieplejszy miesiąc w Polsce"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Najniższa średnia temperatura wystąpiła jan 1942: -10.882°C\n",
"Najwyższa średnia temperatura wystąpiła jul 1994: 21.1785°C\n"
]
}
],
"source": [
"# dane początkowe\n",
"top_y, top_m, top_t = 0, 0, 0\n",
"bot_y, bot_m, bot_t = 0, 0, 0\n",
"\n",
"# przez każdy rok w zestawie danych...\n",
"for year in data:\n",
"\n",
" # przygotuj słowniki po wartościach temperatur i nazwach miesięcy\n",
" months = data[year].values()\n",
" temperatures = {v: k for k, v in data[year].items()}\n",
"\n",
" # znajdź minima i maksima\n",
" max_months, min_months = max(months), min(months)\n",
"\n",
" # dokonaj porównania z poprzednimi wartościami\n",
" if top_t < max_months:\n",
" top_y = year\n",
" top_t = max_months\n",
" top_m = temperatures[top_t]\n",
"\n",
" if bot_t > min_months:\n",
" bot_y = year\n",
" bot_t = min_months\n",
" bot_m = temperatures[bot_t]\n",
"\n",
"# wypisz wyniki\n",
"print(f\"Najniższa średnia temperatura wystąpiła {bot_m} {bot_y}: {bot_t}°C\")\n",
"print(f\"Najwyższa średnia temperatura wystąpiła {top_m} {top_y}: {top_t}°C\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Przygotuj notes do wyświetlania wykresów"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# zaimportuj bibliotekę do obsługi wykresów\n",
"from matplotlib import pyplot as plt\n",
"\n",
"# rysuj wykres w notatniku\n",
"%matplotlib inline\n",
"\n",
"# ustaw rozmiar wykresu\n",
"plt.rcParams[\"figure.figsize\"] = (20.0, 10.0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Stwórz funkcję pomocniczą do rysowania wykresów w wygodny sposób."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"def graph(ox, oy, margin_x=5, step_x=10, margin_y=2, step_y=2):\n",
" plt.grid()\n",
" plt.legend()\n",
" plt.xlabel(\"Rok\")\n",
" plt.ylabel(\"Temperatura\")\n",
" plt.title(\"Wykres średniej temperatury\")\n",
"\n",
" min_x, max_x = round(min(ox)) - margin_x, round(max(ox)) + margin_x\n",
" min_y, max_y = round(min(oy)) - margin_y, round(max(oy)) + margin_y\n",
" plt.xticks(range(int(min_x), int(max_x), step_x))\n",
" plt.yticks(range(int(min_y), int(max_y), step_y))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Przykład 2. Zaprezentuj odkryte minimum i maksimum temperatur za pomocą wykresów"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Najcieplejszy rok na przestrzeni miesięcy"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABI4AAAJcCAYAAACfTe+HAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAABJ6klEQVR4nO3de7hcZXk/7s8DAVGCoJBSC2pQNIJEQahnNAGrVBRaaz1U/UmxUntQVFrF2lp7plprsdr6tWrRam1T1GpFLbYaxVZETgqKsahRghwUFY2AEH1/f8wkbnbWTnbIXnvtDPd9XXNlZq01az3zzIE9H953TbXWAgAAAADT7TR0AQAAAAAsTIIjAAAAADoJjgAAAADoJDgCAAAAoJPgCAAAAIBOgiMAAAAAOgmOABhMVS2tqlZViwY8/qVVddAc7rNV1YGz3HZ9Vd1rFtsdWVVrtr86tldVraiqdUPXsaOpqjdW1R8MXceOrqruMf7c2Hk79zOrzx4ASARHAGyjqnpZVX1o2rL/m2HZ0+a3utmrqj2SnJHkV1prlw1RQ2ttcWvtK7PY7pzW2rKZ1m9LWLXQVdUZVfWnQ9cxH6rqTVW1pqp+XFUnTFt3h6p6bVV9o6q+U1V/V1W7TFl/UFV9tKqur6rLq+oXZzjGK8avj8f0/HC2qLX2vNbanwxx7El6f7TWvj7+3PjRdu5nVp89AJAIjgDYdp9I8vCN/8e7qu6WZJckh01bduB42zkx16OSWmvfb62taK19br6OeXs3H/3c3mPM83P+2SS/meTCjnWnJjkiySFJ7pvkQUl+P9lU4/uSfCDJXZOclOQdVXXfqTuoqnsn+eUkV/VU/+C8RwGgf4IjALbVZzIKig4d3z4yyceSrJm27MuttW+Mp4I9ceOdq2qXqvpWVR02fcdV9UtVtbaqDpkyje05VfX1JB8db3NiVV02HoXxn1V1z/HyGo/QuLaqvldV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bnPrprRiMfPpEkrbVvZPQF+Jeqaq8kP5/NRyL8bpI3tO5RG1dMuX7PJKePp0x8N8m3M/oCs18bTdd5fUajXa6t0YmH7zx9Z621HyR5apLnJbmqRtPI7jfD8ZYkuVOSC6Yc88Pj5ckooJi6/dc66r96yvUbkizu2GZrx9lW90xyysZ9jfd393G9G10z5fqNHben1zn9cW7c1z2TvHfKcS5L8qOMvtRudt+q2rmqTqvR1LbvZfSlOUn2yW33zdbapules3zNzXj/jB7b1Ody6uNNRqHISRmFH9dvR91b8mcZjVy5OKP31r9nFMhd01q7JaNRXsdm9Po6JcmqjEbRJKMg459aa2u38Xh7ZOaRLRt1vp638Xmd/r6Zen2fjMKw6f3fb4btk9Fr8H833mitfT2j8OmeMzyGV2c0+u/sGk1ZPXXa+q5evCPJE8cjFp+S5JzW2tRzR01//3yr/eQE1jeO/+167890/629H5PR49slo8+xje+//5fRqKtkFCxWkvOq6vM1bSrtRlX1kKr6WI2mBl6f0Wfjxuft7hkFqdPN5jPruo4ezOZxAbDACI4AuC0+ldFUkudm9AU9rbXvJfnGeNk3WmtfnbL92zKaovDLST7VWrty2v4em+T3q+qXOo7Vply/Ismvt9b2mnK5Y2vtf8c1vK61dniSgzMa/fO7XcW31v6ztfZzGY3e+GJGUyi6jvetjL7c3H/K8fZso6ksyeikw3efsv09uo43C1s7zra6IsmfTevTnVprW5qCtDXTH+c3phzr56cda7dpz/HUnv5KkuMzmqa0Z0YjKJKfTMuauu1GN2T0JXWjn562vus+W3vNben+38itQ4epjzcZTcd7QkbnQ3rElOU/2Eqds9Zau7G19tuttf1aa/fKaKrUBa21H4/Xf6619ujW2t6ttcdlNK3rvPH
"text/plain": [
"<Figure size 1440x720 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# przygotuj dane, oś OX\n",
"x = range(1, len(data[top_y].keys())+1)\n",
"y = list(data[top_y].values())\n",
"\n",
"# narysuj dane\n",
"plt.bar(x, y, label=f\"Temperatury w {top_y}\")\n",
"graph(x, y, step_x=1, margin_x=1)\n",
"\n",
"# popraw labelki\n",
"plt.title(f\"Wykres średniej temperatury roku {top_y} z najgorętszym miesiącem\")\n",
"plt.xlabel(\"Miesiąc\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Najzimniejszy rok na przestrzeni miesięcy"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABJQAAAJcCAYAAACvwf6mAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAABL+0lEQVR4nO3dfbxlZV03/s8XBoUYxMIRFc2xxFFkFIJ8Rmd8SBOTW/MxrAiLvO1WUewX3XabVhZZVPjQrYaKlk+TRSrkY3mETEtQclAcb7UxBwENFRgEZeD6/bH3wJkz55w5iznrrD2H9/v1mtecvdbaa33Pd++z5+zPXNe1q7UWAAAAAFiovYYuAAAAAIA9i0AJAAAAgE4ESgAAAAB0IlACAAAAoBOBEgAAAACdCJQAAAAA6ESgBMCgqmp1VbWqWjHg9S+uqvst4jlbVd17gcduraqfWMBxx1TVpt2vjt1VVeuqasvQdexpquoNVfV/FnDcgn4mbsX1F/wzVFX/u6rOXOwahrAY/ayqL1TVusWpCIDlQqAEQGdV9dtV9cEZ2/7fHNuetbTVLVxVHZDkrCS/0Fq7ZIgaWmsrW2tfW8Bx57fW1sy1v0uINemq6qyq+oOh61gKVfWmqtpUVTdV1Qkz9t2+qv68qr5ZVd+tqr+sqn1mOcehVXV9Vf3NtG3HVtW/VNX3quryqjpz/HwfTGvtea2131/AcQv6mbgV15/3Z2jGsX/YWvvVxa5hCIvRz9ba/VtrU4tUEgDLhEAJgFvjvCQP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fnK341tqHW2uPy+h/5L+U0eiE2a733xm9kbn/tOsd2Eb
"text/plain": [
"<Figure size 1440x720 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# przygotuj dane, oś OX\n",
"x = range(1, len(data[bot_y].keys())+1)\n",
"y = list(data[bot_y].values())\n",
"\n",
"# narysuj dane\n",
"plt.bar(x, y, label=f\"Temperatury w {bot_y}\")\n",
"graph(x, y, step_x=1, margin_x=1)\n",
"\n",
"# popraw labelki\n",
"plt.title(f\"Wykres średniej temperatury roku {bot_y} z najzimniejszym miesiącem\")\n",
"plt.xlabel(\"Miesiąc\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"### Przykład 3. Na podstawie informacji o najgorętszym miesiącu roku przygotuj wykres wzrostu średniej temperatury w okresie wakacyjnym na przestrzeni lat."
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"Najgorętszym miesiącem był lipiec więc to głównie na nim oprzemy naszą analizę."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"# przygotuj dane\n",
"x = list(data.keys())\n",
"jun_y = [data[y][\"jun\"] for y in data.keys()]\n",
"jul_y = [data[y][\"jul\"] for y in data.keys()]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Tu następuje faktyczne rysowanie wykresu dla miesięcy wakacyjnych."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABIwAAAJcCAYAAACbuD+6AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwY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ITERKQXwCoDnjTGvRm5eFelvZPscrQ5zGYiIiIiIiIiIyJ8wZ0kTAE8AmG2Mudd111gA50WunwfgjbCWgYiIiIiIiIiI/CsJ8bX3B3AugBkiMj1y258A3AngJRG5CMBiAKeFuAxERERERERERORTaAEjY8wkAJLg7kPDel8iIiIiIiIiqluqq6uxdOlSVFZW5npR0LJlS8yePTvXi+FLo0aN0LVrV5SWlnp+TpgZRkREREREREREGVu6dCmaN2+OHj16QDvg5E5FRQWaN2+e02XwwxiDdevWYenSpejZs6fn59WNeeCIiIiIiIiIqM6qrKxEmzZtch4sKkQigjZt2vjOzmLAiIiIiIiIiIjyHoNF6Utn7BgwIiIiIiIiIiKiKAwYERERERERERF5sHLlSpx//vno3bs3hg4dimOOOQbff/99qO954403Yty4caG+Rzxsek1ERERERERElIIxBieddBJOP/10vPLKKwCAr7/+GqtWrcJuu+2W1mvW1NSguLg46WNuueWWtF47U8wwIiIiIiIiIiJK4eOPP0ZpaSkuuuiin24bNGgQPvjgAwwePBiDBw9Gly5dcMEFFwAA/v3vf2PYsGEYPHgwLr30UtTU1AAAmjVrhquuugqDBg3Cp59+ipN
"text/plain": [
"<Figure size 1440x720 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# pierwszy zestaw danych\n",
"plt.subplot(2, 1, 1)\n",
"plt.plot(x, jun_y, \"b\", label=\"Czerwiec\", linewidth=2)\n",
"graph(x, jun_y)\n",
"\n",
"# drugi zestaw danych\n",
"plt.subplot(2, 1, 2)\n",
"plt.plot(x, jul_y, \"c\", label=\"Lipiec\", linewidth=2)\n",
"graph(x, jul_y)\n",
"\n",
"# pokaż wykres\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Przykład 4: Hipoteza: Dane sugerują stabilny poziom średniej miesięcznej temperatury na przestrzeni prawie stu lat, ale ostatnie dwadzieścia lat zdają się mieć znaczący trend wzrostowy.\n",
"\n",
"Aby się temu lepiej przyjrzeć, wygładzę dane korzystając z filtra Gaussa\n",
"oraz nałożę na siebie wykresy by móc wygodniej porównać trend\n",
"sąsiadujących ze sobą miesięcy."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABIwAAAJcCAYAAACbuD+6AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAADRXUlEQVR4nOzdd3ib1dnH8e+RLe+9HduxsxNnk4TVsjel7L1HSyllb14ou2VTZksplD0LZZRdRtgECGQ404njvfde0nn/kJImIcNJLEu2f5/r0mX7kfScWyeOLd/Pfe5jrLWIiIiIiIiIiIis5fB3ACIiIiIiIiIiEliUMBIRERERERERkQ0oYSQiIiIiIiIiIhtQwkhERERERERERDaghJGIiIiIiIiIiGxACSMREREREREREdmAEkYiIiKy3YwxOcYYa4wJ9uP4ecaYSf14TmuMGdvHx7YaY0b34XF7GGNW7Hh0IiIiIgNDCSMREZFhxhhzrTHmvY2O5W/m2IkDG13fGWOigaeAk621y/wRg7U2ylpb0IfHfWGtnbC5+7clSRXojDFPGWNu83ccIiIismOUMBIRERl+Pgd2N8YEARhj0gEnMHOjY2O9j+0X/V2FZK1tsdbuba1dNFBjDncDMZ/6NxMREQkMShiJiIgMP9/jSRDN8H69B/ApsGKjY6utteXeJV+/XvtkY4zTGFNrjJm58YmNMccYYwqNMVPWW652jjGmGPjE+5izjTHLjDENxpgPjDHZ3uPGGPMXY0y1MabZGLPYGDNlUy/AGHOmMabAGNNijFljjDllveNfec9TB9xkjAk1xtxjjCk2xlQZYx41xoSvd64rjTEVxphyY8zZG43zlDHmEWPMO96x5hljxqx3/7rKoC2NY4zZ2xhTupnXsjYpt9C7xO0E7/HDjDELjDGNxpivjTHT1ntOoTfuRcaYNmP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lgEZeLZhfdr7sKfxJJFERERERERERCRADEjTa2+zxc/xrN8vttbGeY8boGHt1xs951zgXIDw8PBZWVlZmzy32+3G4dBmb76i+fUtza9vaX59S/Pre5pj39L8+pbm17c0v76nOfYtza9vaX59ayjN78qVK2uttcmbus/nCSNjTBSebVz/ZK39tzGmcf0EkTGmwVq7xT5Gs2fPtj/88MMm75s7dy577713P0Ys69P8+pbm17c0v76l+fU9zbFvaX59S/PrW5pf39Mc+5bm17c0v741lObXGDPfWjt7U/f5NCVmjHECrwHPW2v/7T1c5e1vtLbPUbUvYxARERERERERkW3jy13SDPAEsMxae996d70FnOH9/AzgTV/FICIiIiIiIiIi2y7Yh+f+BXAasNgYs8B77P+AO4BXjDHnAEXA8T6MQUREREREREREtpHPEkbW2i8Bs5m799vR8/f09FBaWkpsbCzLli3b0dMNO2FhYWRmZuJ0Ov0dioiIiIiIiIgEGF9WGPlUaWkp0dHRJCYmEhMT4+9wBhVrLXV1dZSWljJq1Ch/hyMiIiIiIiIiAWbQ7gPX2dlJYmIinlZJsi2MMSQmJtLZ2envUEREREREREQkAA3ahBGgZNEO0NyJiIiIiIiIyOYM6oSRiIiIiIiIiIj0PyWMdkBlZSUnnngiY8aMYdasWRx66KGsXLnSp2PecMMNfPTRRz4dQ0RERERERESGt0Hb9NrfrLUcddRRnHHGGbz00ksALFy4kKqqKsaPH79d53S5XAQFBW3xMbfccst2nVtEREREREREpK9UYbSdPv30U5xOJ+edd966Y9OnT+e///0vM2bMYMaMGWRkZHDWWWcB8Nxzz7HzzjszY8YMfve73+FyuQCIiori8ssvZ/r06Xz99dccffTRALz55puEh4f
"text/plain": [
"<Figure size 1440x720 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# użyj filtra Gaussa oraz wygładź dane\n",
"from scipy.ndimage.filters import gaussian_filter1d\n",
"\n",
"jul_y = gaussian_filter1d(jul_y, sigma=2)\n",
"jun_y = gaussian_filter1d(jun_y, sigma=2)\n",
"\n",
"# poinformuj plt o chęci nałożenia wykresów\n",
"plt.plot(x, jun_y, \"b\", label=\"Czerwiec\", linewidth=2)\n",
"plt.plot(x, jul_y, \"c\", label=\"Lipiec\", linewidth=2)\n",
"\n",
"# przygotuj wspólną listę osi OY dla funkcji rysującej\n",
"import numpy as np\n",
"y = np.concatenate((jul_y, jun_y))\n",
"graph(x, y, margin_y=1, step_y=1)\n",
"\n",
"# pokaż wykres\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"### Wniosek: tendencja wzrostowa średnich temperatur w okresie wakacyjnym na przestrzeni lat jest wyrażnie widoczna w ostatnim dwudziestoleciu."
]
}
],
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}