{ "cells": [ { "cell_type": "markdown", "id": "858a1a52", "metadata": {}, "source": [ "# Groundwater Production Dossier (GPD)\n", "A Groundwater Production Dossier contains the production figures of a groundwater use system." ] }, { "cell_type": "code", "execution_count": null, "id": "ebf77d42", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import brodata" ] }, { "cell_type": "code", "execution_count": null, "id": "6e256c8b", "metadata": {}, "outputs": [], "source": [ "gpd = brodata.gpd.GroundwaterProductionDossier.from_bro_id(\"GPD000000012107\")\n", "gpd" ] }, { "cell_type": "markdown", "id": "4cca9bb6", "metadata": {}, "source": [ "There are multiple reports in this Groundwater Production Dossier, where each report contains multiple volume-registrations. The metadata of the reports are contained in the attribute `report`, and the volumes are contained in the attribute `volumeSeries`. These two pandas DataFrames are linked to eachother by the column `reportId`." ] }, { "cell_type": "code", "execution_count": null, "id": "a66bd0f4", "metadata": {}, "outputs": [], "source": [ "gpd.report" ] }, { "cell_type": "markdown", "id": "83c98f75", "metadata": {}, "source": [ "Show the volume-series" ] }, { "cell_type": "code", "execution_count": null, "id": "b5b075ed", "metadata": {}, "outputs": [], "source": [ "gpd.volumeSeries" ] }, { "cell_type": "markdown", "id": "d9a48aaa", "metadata": {}, "source": [ "Plot the volume series and separate volumes by the `waterInOut` attribute; for injections, further separate by `temperatureIn`." ] }, { "cell_type": "code", "execution_count": null, "id": "88bf61e0", "metadata": {}, "outputs": [], "source": [ "f, ax = plt.subplots(figsize=(10, 6))\n", "ax.axhline(0, color=\"black\", lw=0.5)\n", "for waterInOut in gpd.volumeSeries[\"waterInOut\"].unique():\n", " maskInOut = gpd.volumeSeries[\"waterInOut\"] == waterInOut\n", " for temperatureIn in gpd.volumeSeries.loc[maskInOut, \"temperatureIn\"].unique():\n", " if pd.isna(temperatureIn):\n", " maskTemperatureIn = gpd.volumeSeries[\"temperatureIn\"].isna()\n", " label = f\"{waterInOut}\"\n", " else:\n", " maskTemperatureIn = gpd.volumeSeries[\"temperatureIn\"] == temperatureIn\n", " label = f\"{waterInOut} - {temperatureIn}\"\n", " mask = maskInOut & maskTemperatureIn\n", " df = gpd.volumeSeries.loc[mask]\n", "\n", " # sort by the column `beginDate`\n", " df = df.sort_values(\"beginDate\")\n", "\n", " # make a matplotlib plot of the volume series, with a constant value between beginDate and endDate\n", " x = df.loc[:, [\"beginDate\", \"endDate\"]].values.ravel()\n", "\n", " y = np.vstack((df[\"volume\"].values, df[\"volume\"].values)).transpose().ravel()\n", " if waterInOut == \"onttrokken\":\n", " y = -y\n", "\n", " # make sure to draw a line between the endDate of one row and the beginDate of the next row if they are not consecutive\n", " mask = (\n", " df[\"endDate\"].values[:-1] + pd.Timedelta(1, \"D\")\n", " != df[\"beginDate\"].values[1:]\n", " )\n", " ind = ((np.where(mask)[0] + 1) * 2).tolist()\n", " ind = [0] + ind + [len(x)]\n", "\n", " # get next color from the color cycle\n", " color = ax._get_lines.get_next_color()\n", " for i in range(len(ind) - 1):\n", " ax.plot(\n", " x[ind[i] : ind[i + 1]],\n", " y[ind[i] : ind[i + 1]],\n", " label=label if i == 0 else None,\n", " color=color,\n", " )\n", "\n", "ax.set_xlim(gpd.volumeSeries[\"beginDate\"].min(), gpd.volumeSeries[\"endDate\"].max())\n", "ax.legend();" ] }, { "cell_type": "markdown", "id": "23b2a4ae", "metadata": {}, "source": [ "Show the rest of the contents of the Groundwater Production Dossier." ] }, { "cell_type": "code", "execution_count": null, "id": "c549f6f6", "metadata": {}, "outputs": [], "source": [ "gpd_data = gpd.to_dict()\n", "gpd_data.pop(\"report\")\n", "gpd_data.pop(\"volumeSeries\")\n", "gpd_data" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }