{ "cells": [ { "cell_type": "markdown", "id": "83ff842c", "metadata": {}, "source": [ "# Site Assessment Data (SAD)\n", "Site Assessment Data examines the presence of contaminating substances in the soil at a specific location. In this registration object, the investigation concerns the quality of terrestrial soils and drier bank areas, as well as groundwater. In addition, the nature of any contamination is determined: which substances occur in concentrations higher than the natural background value? The extent of the contamination is also assessed by comparing the measured concentrations with the permitted levels based on a national or local regulatory framework." ] }, { "cell_type": "code", "execution_count": null, "id": "47819eec", "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import geopandas as gpd\n", "import brodata" ] }, { "cell_type": "code", "execution_count": null, "id": "77a2f28f", "metadata": {}, "outputs": [], "source": [ "sad = brodata.sad.SiteAssessmentData.from_bro_id(\"SAD000000011742\")\n", "sad" ] }, { "cell_type": "markdown", "id": "5102e85e", "metadata": {}, "source": [ "Plot the geometry of the Site Assessment Data, together with the measurementPoints." ] }, { "cell_type": "code", "execution_count": null, "id": "fcbee8a5", "metadata": {}, "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(8, 8))\n", "gpd.GeoDataFrame(geometry=[sad.geometry]).plot(ax=ax)\n", "sad.measurementPoint.plot(ax=ax, color=\"red\", markersize=50)\n", "for index in sad.measurementPoint.index:\n", " point = sad.measurementPoint.geometry.loc[index]\n", " ax.annotate(index, (point.x, point.y), textcoords=\"offset points\", xytext=(0,10), ha='center')\n", "ax.axis(\"equal\");" ] }, { "cell_type": "markdown", "id": "859bbe06", "metadata": {}, "source": [ "Show the contents of the attribute `measurementPoint`, which is a geopandas GeoDataFrame." ] }, { "cell_type": "code", "execution_count": null, "id": "221ebca2", "metadata": {}, "outputs": [], "source": [ "sad.measurementPoint" ] }, { "cell_type": "markdown", "id": "54e117a1", "metadata": {}, "source": [ "Plot lithology logs for all measurement points." ] }, { "cell_type": "code", "execution_count": null, "id": "bfa5a6cc", "metadata": {}, "outputs": [], "source": [ "f, ax = plt.subplots(figsize=(15,6))\n", "for i, name in enumerate(sad.measurementPoint.index):\n", " df = sad.measurementPoint.at[name,'DescriptiveBoreholeLog']['layer']\n", " brodata.plot.bro_lithology_advanced(df, x=i, width=0.6, soil_name_column='soilName', ax=ax, bro_id=name)\n", " # plot filter if available\n", " if isinstance(sad.measurementPoint.at[name,'filter'], pd.DataFrame):\n", " fs = sad.measurementPoint.at[name,'filter']\n", " for fi in fs.index:\n", " y = [ -fs.at[fi,'upperBoundary'], -fs.at[fi,'lowerBoundary'] ]\n", " ax.plot([i, i], y, color='k', linewidth=3, linestyle=':', solid_capstyle=\"butt\")\n", "ax.set_xlim(-0.5, len(sad.measurementPoint) - 0.5)\n", "ax.set_xticks(range(len(sad.measurementPoint)))\n", "ax.set_xticklabels(sad.measurementPoint.index, fontdict={'rotation':45, 'ha':'right'})\n", "ax.set_ylim(-sad.measurementPoint['finalDepth'].max()-0.1, 0.0)\n", "ax.set_axisbelow(True)\n", "ax.grid(True)\n", "ax.set_ylabel('Depth (m)');" ] }, { "cell_type": "markdown", "id": "517dd9fc", "metadata": {}, "source": [ "Sampling analysis results for a measurement filter are stored as a pandas DataFrame." ] }, { "cell_type": "code", "execution_count": null, "id": "9bc60185", "metadata": {}, "outputs": [], "source": [ "name = \"1786310\"\n", "filters = sad.measurementPoint.at[name, \"filter\"]\n", "df = filters.iloc[0]['groundwaterSampleAnalysis']\n", "\n", "# add the parameter description\n", "parameter_list = brodata.gar.get_parameter_list()\n", "# add a description when a parameter is in the parameter list\n", "df[\"parameter_description\"] = \"\"\n", "for index in df.index:\n", " param = df.at[index, \"parameter\"]\n", " if param in parameter_list.index:\n", " df.at[index, \"parameter_description\"] = parameter_list.at[param, \"description\"]\n", "df" ] }, { "cell_type": "markdown", "id": "99298158", "metadata": {}, "source": [ "Display the `mixedSampleAnalysis` attribute, a DataFrame containing mixed-sample analyses." ] }, { "cell_type": "code", "execution_count": null, "id": "3ad2da44", "metadata": {}, "outputs": [], "source": [ "sad.mixedSampleAnalysis" ] }, { "cell_type": "markdown", "id": "4bde4be8", "metadata": {}, "source": [ "The `analysis` column contains a DataFrame with analysis results per sample. Show the results for the first sample." ] }, { "cell_type": "code", "execution_count": null, "id": "65c6ab2b", "metadata": {}, "outputs": [], "source": [ "sad.mixedSampleAnalysis.iloc[0]['analysis']" ] }, { "cell_type": "markdown", "id": "86ef910c", "metadata": {}, "source": [ "Show the rest of the contents of the Site Assessment Data." ] }, { "cell_type": "code", "execution_count": null, "id": "dcb3898c", "metadata": {}, "outputs": [], "source": [ "sad_data = sad.to_dict()\n", "sad_data.pop(\"measurementPoint\")\n", "sad_data.pop(\"mixedSampleAnalysis\")\n", "sad_data" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }