{ "cells": [ { "cell_type": "markdown", "id": "7a1fb7aa-5d42-4813-8cfc-138d37e190b7", "metadata": {}, "source": [ "# Example 3: Longitudinal Sections" ] }, { "cell_type": "raw", "id": "98bfad50-56ca-4471-b2dc-a2414b2ad77a", "metadata": {}, "source": [ "This example demonstrates how longitudinal sections data read by PT3S can be accessed and used to create plots with Matplotlib." ] }, { "cell_type": "markdown", "id": "1ca1542a-3092-47d7-9b55-0ab34109f2d5", "metadata": {}, "source": [ "# PT3S Release" ] }, { "cell_type": "code", "execution_count": 1, "id": "2689ebcc-02a9-44de-ac1b-95726d4247a7", "metadata": {}, "outputs": [], "source": [ "#pip install PT3S -U --no-deps" ] }, { "cell_type": "markdown", "id": "a029d1e9-1396-4b7d-8e39-5f21f36f2cad", "metadata": {}, "source": [ "# Necessary packages for this Example" ] }, { "cell_type": "raw", "id": "290e65b5-906d-411b-bb61-7ac94fb880d6", "metadata": {}, "source": [ "When running this example for the first time on your machine, please execute the cell below. Afterward, you may need to restart the kernel (using the ‘fast-forward’ button)." ] }, { "cell_type": "code", "execution_count": 2, "id": "74fb2b27-a48a-4dd0-b636-37ffd0b1deaa", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install -q bokeh" ] }, { "cell_type": "markdown", "id": "d7b0e352-85a4-42be-a50d-8bbfcf512811", "metadata": {}, "source": [ "# Imports" ] }, { "cell_type": "code", "execution_count": 3, "id": "0226b804-5149-4dc7-9188-8aad75db325d", "metadata": {}, "outputs": [], "source": [ "import os\n", "import logging\n", "import pandas as pd\n", "import datetime\n", "import numpy as np\n", "import subprocess\n", "\n", "import matplotlib\n", "import matplotlib.pyplot as plt\n", "import matplotlib.dates as mdates\n", "import matplotlib.gridspec as gridspec\n", "import matplotlib.ticker as ticker\n", "import matplotlib.colors as mcolors\n", "from matplotlib.pyplot import Polygon\n", "from matplotlib.ticker import FuncFormatter\n", "from matplotlib.dates import DateFormatter, MinuteLocator\n", "import matplotlib.ticker as ticker\n", "\n", "from bokeh.plotting import figure, show\n", "from bokeh.io import output_notebook\n", "from bokeh.models import CustomJS, ColumnDataSource, CheckboxGroup, LinearAxis, Range1d\n", "from bokeh.layouts import column\n", "\n", "\n", "try:\n", " from PT3S import dxAndMxHelperFcts\n", "except:\n", " import dxAndMxHelperFcts\n", "\n", "try:\n", " from PT3S import Rm\n", "except:\n", " import Rm" ] }, { "cell_type": "code", "execution_count": null, "id": "c4f5edb0-53a1-4cde-a4c0-77ffbd2c805c", "metadata": { "tags": [] }, "outputs": [], "source": [ "import importlib\n", "from importlib import resources" ] }, { "cell_type": "code", "execution_count": 5, "id": "4d173d17-ba35-41b0-b9b1-5e617e84e10e", "metadata": { "tags": [] }, "outputs": [], "source": [ "#importlib.reload(dxAndMxHelperFcts)" ] }, { "cell_type": "markdown", "id": "6ea9586f-0ea5-4b25-8ec9-0d350fa77c24", "metadata": {}, "source": [ "# Logging" ] }, { "cell_type": "code", "execution_count": null, "id": "7c93b42e-919d-4edf-a342-253e67b02132", "metadata": {}, "outputs": [], "source": [ "logger = logging.getLogger()\n", "\n", "if not logger.handlers:\n", " logFileName = r\"Example3.log\"\n", " loglevel = logging.DEBUG\n", "\n", " logging.basicConfig(\n", " filename=logFileName,\n", " filemode='w',\n", " level=loglevel,\n", " format=\"%(asctime)s ; %(name)-60s ; %(levelname)-7s ; %(message)s\"\n", " )\n", "\n", " fileHandler = logging.FileHandler(logFileName)\n", " logger.addHandler(fileHandler)\n", "\n", " consoleHandler = logging.StreamHandler()\n", " consoleHandler.setFormatter(logging.Formatter(\"%(levelname)-7s ; %(message)s\"))\n", " consoleHandler.setLevel(logging.INFO)\n", " logger.addHandler(consoleHandler)\n" ] }, { "cell_type": "markdown", "id": "df38a119-bf7c-47ea-a309-f06dfd9c4e28", "metadata": {}, "source": [ "# Read Model and Results" ] }, { "cell_type": "code", "execution_count": null, "id": "e96fb06c-2451-42b8-9818-532b31106bb9", "metadata": { "tags": [] }, "outputs": [], "source": [ "dbFilename=\"Example3\"\n", "dbFile = resources.files(\"PT3S\").joinpath(\"Examples\", f\"{dbFilename}.db3\")" ] }, { "cell_type": "code", "execution_count": null, "id": "f8b5221c-0fd1-4fbc-abaf-81325ad2629d", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO ; Dx.__init__: dbFile (abspath): c:\\users\\aUserName\\3s\\pt3s\\Examples\\Example3.db3 exists readable ...\n", "INFO ; dxAndMxHelperFcts.readDxAndMx: Model is being recalculated using C:\\3S\\SIR 3S\\SirCalc-90-14-02-10_Potsdam\\SirCalc.exe\n", "INFO ; Mx.setResultsToMxsFile: Mxs: ..\\Examples\\WDExample3\\B1\\V0\\BZ1\\M-1-0-1.1.MXS reading ...\n", "INFO ; dxWithMx.__init__: Example3: processing dx and mx ...\n" ] } ], "source": [ "m=dxAndMxHelperFcts.readDxAndMx(dbFile=dbFile \n", " ,preventPklDump=True\n", " ,maxRecords=-1\n", " ,mxsVecsResults2MxDfVecAggs=[7,13,19,-1]\n", " #,SirCalcExePath=r\"C:\\3S\\SIR 3S\\SirCalc-90-14-02-10_Potsdam\\SirCalc.exe\"\n", ")" ] }, { "cell_type": "markdown", "id": "8311b30d-90d7-4dac-918e-9ab104b44769", "metadata": {}, "source": [ "# Longitudinal Sections: V3_AGSN" ] }, { "cell_type": "code", "execution_count": 9, "id": "17078a88-49f7-42a6-b7ea-04ddd77f6d89", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", " | Pos | \n", "pk | \n", "tk | \n", "LFDNR | \n", "NAME | \n", "XL | \n", "compNr | \n", "nextNODE | \n", "OBJTYPE | \n", "OBJID | \n", "... | \n", "RHO_n | \n", "mlc_n | \n", "('STAT', 'mlc', Timestamp('2023-02-12 23:00:00'), Timestamp('2023-02-12 23:00:00'))_n | \n", "('TIME', 'mlc', Timestamp('2023-02-12 23:00:00'), Timestamp('2023-02-12 23:00:00'))_n | \n", "('TMIN', 'mlc', Timestamp('2023-02-12 23:00:00'), Timestamp('2023-02-13 23:00:00'))_n | \n", "('TMAX', 'mlc', Timestamp('2023-02-12 23:00:00'), Timestamp('2023-02-13 23:00:00'))_n | \n", "('TIME', 'mlc', Timestamp('2023-02-13 06:00:00'), Timestamp('2023-02-13 06:00:00'))_n | \n", "('TIME', 'mlc', Timestamp('2023-02-13 12:00:00'), Timestamp('2023-02-13 12:00:00'))_n | \n", "('TIME', 'mlc', Timestamp('2023-02-13 18:00:00'), Timestamp('2023-02-13 18:00:00'))_n | \n", "('TIME', 'mlc', Timestamp('2023-02-13 23:00:00'), Timestamp('2023-02-13 23:00:00'))_n | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "-1 | \n", "5755933101669454049 | \n", "5755933101669454049 | \n", "1.0 | \n", "Längsschnitt | \n", "0 | \n", "1 | \n", "V-E0 | \n", "ROHR | \n", "5691533564979419761 | \n", "... | \n", "965.700012 | \n", "592.984993 | \n", "592.958713 | \n", "592.962286 | \n", "592.958738 | \n", "602.48758 | \n", "602.03723 | \n", "599.532769 | \n", "602.487611 | \n", "593.486796 | \n", "
0 | \n", "0 | \n", "5755933101669454049 | \n", "5755933101669454049 | \n", "1.0 | \n", "Längsschnitt | \n", "0 | \n", "1 | \n", "V-K1683S | \n", "ROHR | \n", "5691533564979419761 | \n", "... | \n", "965.701172 | \n", "592.958713 | \n", "592.958713 | \n", "592.962286 | \n", "592.958738 | \n", "602.48758 | \n", "602.03723 | \n", "599.532769 | \n", "602.487611 | \n", "593.486796 | \n", "
1 | \n", "1 | \n", "5755933101669454049 | \n", "5755933101669454049 | \n", "1.0 | \n", "Längsschnitt | \n", "0 | \n", "1 | \n", "V-K1693S | \n", "ROHR | \n", "5048873293262650113 | \n", "... | \n", "965.702148 | \n", "592.937202 | \n", "592.937202 | \n", "592.941546 | \n", "592.937253 | \n", "602.419501 | \n", "601.971421 | \n", "599.479587 | \n", "602.419561 | \n", "593.464211 | \n", "
2 | \n", "2 | \n", "5755933101669454049 | \n", "5755933101669454049 | \n", "1.0 | \n", "Längsschnitt | \n", "0 | \n", "1 | \n", "V-K2163S | \n", "ROHR | \n", "5715081934973525403 | \n", "... | \n", "965.702637 | \n", "592.926449 | \n", "592.926449 | \n", "592.931165 | \n", "592.926512 | \n", "602.385399 | \n", "601.938456 | \n", "599.452945 | \n", "602.385474 | \n", "593.452897 | \n", "
3 | \n", "3 | \n", "5755933101669454049 | \n", "5755933101669454049 | \n", "1.0 | \n", "Längsschnitt | \n", "0 | \n", "1 | \n", "V-K2043S | \n", "ROHR | \n", "5413647981880727734 | \n", "... | \n", "965.703735 | \n", "592.901884 | \n", "592.901884 | \n", "592.907361 | \n", "592.901971 | \n", "602.306951 | \n", "601.862619 | \n", "599.391653 | \n", "602.307055 | \n", "593.426847 | \n", "
5 rows × 85 columns
\n", "\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"
\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"
\\n\"+\n \"