weather-in-poland/main.ipynb

423 lines
228 KiB
Plaintext
Raw Permalink 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/QuLa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L8b0bnPrprRiMfPpEkrbVvZPQF+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/VtrU4tUEgDLhEAJgFvj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R1I7fnK341tqHW2uPy+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/Il7ecAAAACXBIWXMAAAsTAAALEwEA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d1+oITERKQXwCoDnjTGvRm5eFelvZPscrQ5zGYiIiIiIiIiIyJ8wZ0kTAE8AmG2Mudd111gA50WunwfgjbCWgYiIiIiIiIiI/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": {
2020-11-30 22:08:59 +01:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAABIwAAAJcCAYAAACbuD+6AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAACjkUlEQVR4nOzddXiUV/rG8e+JuxsQ3C1AgVIvNerebbduW/vVtr7VrfvWtt5u3bfuti11w4pD0QRCEuKuc35/nCEEigSZvJH7c13vNTPv2DMvIZm555znGGstIiIiIiIiIiIiawR5XYCIiIiIiIiIiLQvCoxERERERERERGQdCoxERERERERERGQdCoxERERERERERGQdCoxERERERERERGQdCoxERERERERERGQdCoxERERkqxlj+hhjrDEmxMPnn22MGbodH9MaYwa08raVxph+rbjd7saYBdtenYiIiEjbUGAkIiLSxRhjrjbGfLLevj82su+vbVtd6xljYoHngBOstfO8qMFaG2OtXdKK231nrR28seu3JKRq74wxzxljbvW6DhEREdk2CoxERES6nm+BXYwxwQDGmG5AKDBmvX0D/LfdLrb3KCRrbYW1dqK1dmZbPWdX1xbHU/9mIiIi7YMCIxERka7nN1xANNp/eXfga2DBevsWW2tz/VO+Dl1zZ2NMqDGm0BgzZv0HNsYcbYxZZowZ0WK62pnGmGzgK/9tzjDGzDPGlBhjPjPG9PbvN8aY+40xBcaYcmPMLGPMiA29AGPMacaYJcaYCmPMUmPMiS32/+B/nCLgRmNMuDHmXmNMtjEm3xjzuDEmssVjXWGMWWWMyTXGnLHe8zxnjHnEGPOR/7l+Mcb0b3F988igTT2PMWaiMWbFRl7LmlDud/8Ut+P8+w8xxswwxpQaY340xmS1uM8yf90zjTFVx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ssYCNMLLWrrLWTvOfrwDmAT1wy7A+77/Z87gQSURERERERERE2ok2aXrtb7b4LW7+fra1NsG/3wAlay6vd5+zgbMBIiMjx/bs2XODj+3z+QgK0mJvgaLjG1g6voGl4xtYOr6Bp2McWDq+gaXjG1g6voGnYxxYOr6BpeMbWJ3p+C5cuLDQWpu6oesCHhgZY2Jwy7jeZq192xhT2jIgMsaUWGs32cdo3LhxdsqUKRu8bvLkyUycOHE7Viwt6fgGlo5vYOn4BpaOb+DpGAeWjm9g6fgGlo5v4OkYB5aOb2Dp+AZWZzq+xpip1tpxG7ouoJGYMSYUeAt42Vr7tn93vr+/0Zo+RwWBrEFERERERERERLZMIFdJM8B/gHnW2vtaXPU+cKr//KnAe4GqQUREREREREREtlxIAB97V+BkYJYxZoZ/3zXAncAbxpgzgeXAsQGsQUREREREREREtlDAAiNr7feA2cjV+wTqeUVERERERESkc2loaGDFihXU1tZ6XQrx8fHMmzfP6zK2SEREBJmZmYSGhrb6PoEcYSQiIiIiIiIiss1WrFhBbGwsffr0wXXA8U5FRQWxsbGe1rAlrLUUFRWxYsUK+vbt2+r7dY514ERERERERESk06qtrSU5OdnzsKgjMsaQnJy8xaOzFBiJiIiIiIiISLunsGjrbc2xU2AkIiIiIiIiIiLrUGAkIiIiIiIiItIKeXl5nHbaafTv35+xY8dy0EEHsXDhwoA+5w033MCXX34Z0OfYEDW9FhERERERERHZDGstRx55JMcddxxvvfUWAL///jv5+fkMGjRoqx6zqamJ4ODgTd7m5ptv3qrH3lYaYSQiIiIiIiIishlff/01oaGhnHnmmc37Ro0axRdffMHo0aMZPXo0PXr04PTTTwfgpZdeYscdd2T06NGcc845NDU1ARATE8Nll13GqFGj+PHHHznqqKMAeO+994i
2020-11-16 01:23:07 +01:00
"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",
2020-11-30 22:08:59 +01:00
"jul_y = gaussian_filter1d(jul_y, sigma=4)\n",
"jun_y = gaussian_filter1d(jun_y, sigma=4)\n",
2020-11-16 01:23:07 +01:00
"\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
}