Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/matroos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: matroos

on:
push:
branches:
- master
pull_request:
branches:
- master
- dev
schedule:
- cron: '0 0 * * 1'

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- name: Test matroos api
python: "3.11"
toxenv: matroos

name: ${{ matrix.name }}
env:
# Color Output
# Rich (pip)
FORCE_COLOR: 1
# Tox
PY_COLORS: 1
# Pytest
PYTEST_ADDOPTS: "--color=yes"
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
check-latest: true

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox

- name: Setup tox environment
run: tox -e ${{ matrix.toxenv }} --notest

- name: Test
run: tox -e ${{ matrix.toxenv }} --skip-pkg-install
19 changes: 10 additions & 9 deletions docs/examples/00_hydropandas_objects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@
"## Obs<a id=GroundwaterObs></a>\n",
"\n",
"Creating an `Obs` object is very similar to creating a `DataFrame`. Below we create 3 differente Obs objects:\n",
"- an empty Obs\n",
"- an Obs with only metadata \n",
"- an Obs with metadata and measurements"
"\n",
"1. an empty Obs\n",
"2. an Obs with only metadata \n",
"3. an Obs with metadata and measurements"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -177,14 +178,14 @@
}
],
"source": [
"# create an empty Obs object\n",
"# 1. create an empty Obs object\n",
"o1 = hpd.Obs(name=\"my empty obs\")\n",
"display(o1)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -287,7 +288,7 @@
}
],
"source": [
"# create an Obs object with only metadata\n",
"# 2. create an Obs object with only metadata\n",
"o2 = hpd.Obs(\n",
" name=\"my_observation\",\n",
" x=10,\n",
Expand All @@ -302,7 +303,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -454,7 +455,7 @@
}
],
"source": [
"# create an Obs object with both metadata and measurements\n",
"# 3. create an Obs object with both metadata and measurements\n",
"meas_df = pd.DataFrame(\n",
" index=pd.date_range(start=\"2020-01-01\", periods=10, freq=\"D\"),\n",
" data={\"value\": np.random.rand(10)},\n",
Expand Down
70 changes: 36 additions & 34 deletions docs/examples/10_borehole.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"source": [
"# select extent with a buffer around gw_bro\n",
"p = Point(gw_bro.x, gw_bro.y)\n",
"extent = np.array(p.buffer(750).bounds).astype(int)[[0, 2, 1, 3]]\n",
"extent = np.array(p.buffer(1000).bounds).astype(int)[[0, 2, 1, 3]]\n",
"\n",
"# get bro ids of borehole data\n",
"gdf = brodata.bhr.get_characteristics(extent=extent)"
Expand All @@ -98,6 +98,13 @@
" [line.project(point) for point in gdf[\"geometry\"]], gdf.index\n",
")\n",
"\n",
"# specify colors\n",
"colors = brodata.plot.lithology_colors.copy()\n",
"colors[\"sterkZandigSilt\"] = (243, 225, 100)\n",
"colors[\"siltigZandMetGrind\"] = (220, 200, 80)\n",
"colors[\"siltigZand\"] = (243, 225, 150)\n",
"colors[\"zwakGrindigZand\"] = (231, 210, 70)\n",
"\n",
"# plot values\n",
"xticks = []\n",
"xticklabels = []\n",
Expand All @@ -111,6 +118,7 @@
" drilling=bro_id,\n",
" ax=axes[0],\n",
" linewidth=20,\n",
" colors=colors,\n",
" )\n",
" xticks.append(distance_along_line[bro_id])\n",
" xticklabels.append(bro_id[-7:])\n",
Expand Down Expand Up @@ -175,12 +183,12 @@
{
"cell_type": "code",
"execution_count": null,
"id": "da2179cd",
"id": "efcd292a",
"metadata": {},
"outputs": [],
"source": [
"# get Bodemkundig booronderzoek (BHR-P), Geotechnisch booronderzoek (BHR-GT) is preferred but not yet available via geost\n",
"boreholes = geost.bro_api_read(\"BHR-P\", bbox=[int(i) for i in p.buffer(2000).bounds])"
"# get Bodemkundig booronderzoek (BHR-GT)\n",
"boreholes = geost.bro_api_read(\"BHR-GT\", bbox=[int(i) for i in p.buffer(1000).bounds])"
]
},
{
Expand All @@ -190,56 +198,42 @@
"metadata": {},
"outputs": [],
"source": [
"# specify colors for soil types\n",
"color_dic = {\n",
" \"sterkSiltigZand\": [\n",
" 0.9137254901960784,\n",
" 0.7490196078431373,\n",
" 0.22745098039215686,\n",
" 1.0,\n",
" ],\n",
" \"matigSiltigZand\": [\n",
" 0.9568627450980393,\n",
" 0.8705882352941177,\n",
" 0.25098039215686274,\n",
" 1.0,\n",
" ],\n",
" \"uiterstSiltigeKlei\": [\n",
" 0.3333333333333333,\n",
" 0.4196078431372549,\n",
" 0.1843137254901961,\n",
" 1.0,\n",
" ],\n",
" \"matigZandigeKlei\": [0.0, 0.5764705882352941, 0.15294117647058825, 1.0],\n",
" \"zwakSiltigZand\": [1.0, 0.9921568627450981, 0.28627450980392155, 1.0],\n",
"}\n",
"\n",
"# add colors based on column 'standard_name'\n",
"col = \"standardSoilName\"\n",
"boreholes.data.df[\"color\"] = boreholes.data.df[col].map(color_dic)\n",
"col = \"geotechnicalSoilName\" # \"standardSoilName\"\n",
"boreholes.data.df[\"color\"] = boreholes.data.df[col].map(colors)\n",
"\n",
"# plot borehole data\n",
"f, axes = plt.subplots(figsize=(16, 8), ncols=2)\n",
"labels = []\n",
"for i, (bro_id, df) in enumerate(boreholes.data.df.groupby(\"nr\")):\n",
"for i, (xy, df) in enumerate(boreholes.data.df.groupby(\"x\")):\n",
" df[\"top\"] = df[\"surface\"] - df[\"top\"]\n",
" df[\"bottom\"] = df[\"surface\"] - df[\"bottom\"]\n",
" for _, row in df.iterrows():\n",
" color = [c / 255 for c in row[\"color\"]] + [1.0]\n",
" if row[col] in labels:\n",
" axes[0].fill_between(\n",
" [i - 0.25, i + 0.25],\n",
" [row[\"top\"], row[\"top\"]],\n",
" [row[\"bottom\"], row[\"bottom\"]],\n",
" color=row[\"color\"],\n",
" color=color,\n",
" )\n",
" else:\n",
" axes[0].fill_between(\n",
" [i - 0.25, i + 0.25],\n",
" [row[\"top\"], row[\"top\"]],\n",
" [row[\"bottom\"], row[\"bottom\"]],\n",
" color=row[\"color\"],\n",
" color=color,\n",
" label=row[col],\n",
" )\n",
" labels.append(row[col])\n",
"axes[0].set_xticks(np.arange(0, i + 1), boreholes.data.df[\"nr\"].unique())\n",
"axes[0].set_xticks(\n",
" np.arange(0, i + 1), boreholes.data.df.sort_values(\"x\")[\"nr\"].unique()\n",
")\n",
"# Rotate and align the xtick labels\n",
"for label in axes[0].get_xticklabels():\n",
" label.set_rotation(45)\n",
" label.set_ha(\"right\")\n",
"\n",
"if boreholes.header.vertical_reference == 5709:\n",
" axes[0].set_ylabel(\"m NAP\")\n",
"axes[0].set_xlim(-0.5, i + 1.5)\n",
Expand All @@ -262,6 +256,14 @@
"# basemap\n",
"ctx.add_basemap(axes[1], crs=28992)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e6068c8",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading
Loading