diff --git a/in/parameters.json b/in/parameters.json index 9085ee5..b9adfbb 100644 --- a/in/parameters.json +++ b/in/parameters.json @@ -4,7 +4,7 @@ "hillslope_id" : -1, "no_flow_area" : 0.30, "min_cells:" : 10, - "hill_type" : 'constant', + "hill_type" : "constant", "depth:" : 2.1 } } diff --git a/run.ipynb b/run.ipynb deleted file mode 100644 index 9ef916a..0000000 --- a/run.ipynb +++ /dev/null @@ -1,750 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "from toolbox_runner import list_tools\n", - "import json" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "# Pick a tool, read input parameters, run\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "#tool2use = 'make_geometry'\n", - "#tool2use = 'write_facmat'\n", - "#tool2use = 'write_precip'\n", - "#tool2use = 'write_climate'\n", - "#tool2use = 'write_printout'\n", - "tool2use = 'write_surface_pob'\n", - "#tool2use = 'write_control'" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "write_surface_pob: CATFLOW surface attributes FROM tbr_rdwd:latest VERSION: 0.1" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'geometry': './in/make_geometry_out/geom.Rds',\n", - " 'lu': 33,\n", - " 'precid': 1,\n", - " 'climid': 1,\n", - " 'windid': [1, 1, 1, 1],\n", - " 'output.file': '/out/surface.pob'}" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "with open('./in/parameters.json') as f:\n", - " kwargs = json.load(f)[tool2use]\n", - "kwargs" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test/1678098622_write_surface_pob.tar.gz" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test\", **kwargs)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "# Set up a (manual) workflow, use one tool after the other\n", - "\n", - "For now, results of individual tools (`/out/*`) are manually unziped and copied to `./test_tool_workflow/toolname`" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "## Tool 1: **make_geometry**\n", - "\n", - "- load tool\n", - "- initialize input parameters\n", - "- run tool with input parameters\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "make_geometry: CATFLOW model geometry FROM tbr_catflow:latest VERSION: 0.1" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pick tool\n", - "tool2use = 'make_geometry'\n", - "\n", - "# load tool\n", - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "tool-specific keyword arguments:" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [], - "source": [ - "kwargs = {'xh': [1.0, 1.526316, 2.052632, 2.578947, 3.105263, 3.631579, 4.157895, 4.684211, 5.210526, 5.736842, 6.263158, 6.789474, 7.315789, 7.842105, 8.368421, 8.894737, 9.421053, 9.947368, 10.473684, 11.0],\n", - " 'yh': [2, 2.31578947368421, 2.63157894736842, 2.94736842105263, 3.26315789473684, 3.57894736842105, 3.89473684210526, 4.21052631578947, 4.52631578947368, 4.84210526315789, 5.15789473684211, 5.47368421052632, 5.78947368421053, 6.10526315789474, 6.42105263157895, 6.73684210526316, 7.05263157894737, 7.36842105263158, 7.68421052631579, 8],\n", - " 'zh': [8, 7.93799037087873, 7.85250472327737, 7.7258147867945, 7.55028053799672, 7.33022074461027, 7.08085558055934, 6.82458019656734, 6.58548160620157, 6.38344134488803, 6.22926777664632, 6.12204982962276, 6.04938005825495, 5.9903924186702, 5.92087100395428, 5.81917894272337, 5.67155585985099, 5.47548689620891, 5.24031843389046, 4.98496977590764],\n", - " 'bh': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],\n", - " 'tot.area': 12,\n", - " 'dyy': 2,\n", - " 'xsi': [0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1],\n", - " 'eta': [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1],\n", - " 'htyp': 1}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test_tool_workflow/01make_geometry/1678366251_make_geometry.tar.gz" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test_tool_workflow/01make_geometry/\", **kwargs)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tool 2: **write_facmat**\n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "write_facmat: CATFLOW multiplier matrices FROM tbr_catflow:latest VERSION: 0.1" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pick tool\n", - "tool2use = 'write_facmat'\n", - "\n", - "# load tool\n", - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "use geometry file from tool `make_geometry`" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [], - "source": [ - "kwargs = {'geometry': './test_tool_workflow/01make_geometry/1678366251_make_geometry/out/geom.Rds',\n", - " 'write_soilhyd_ini': True,\n", - " 'write_soil_types': True,\n", - " 'fac': './test_tool_workflow/input_files/fac.dat'}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test_tool_workflow/02write_facmat/1678366305_write_facmat.tar.gz" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test_tool_workflow/02write_facmat/\", **kwargs)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tool 3: **write_precip**" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "write_precip: CATFLOW precipitation time series FROM tbr_catflow:latest VERSION: 0.1" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pick tool\n", - "tool2use = 'write_precip'\n", - "\n", - "# load tool\n", - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "kwargs = {'raindat': './test_tool_workflow/input_files/raindat.csv',\n", - " 'start.time': '01.01.2004 00:00:00',\n", - " 'time.unit': 'h',\n", - " 'faktor.p': 1}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test_tool_workflow/03write_precip/1678366330_write_precip.tar.gz" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test_tool_workflow/03write_precip/\", **kwargs)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tool 4: write_climate" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "write_climate: CATFLOW climatic data FROM tbr_catflow:latest VERSION: 0.1" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pick tool\n", - "tool2use = 'write_climate'\n", - "\n", - "# load tool\n", - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [], - "source": [ - "kwargs = {'climadat': './test_tool_workflow/input_files/climadat.csv',\n", - " 'start.time': '01.01.2004 00:00:00',\n", - " 'time.unit': 'h',\n", - " 'rBilart': 1,\n", - " 'ref.height': 8,\n", - " 'sw0': -6,\n", - " 'sw1': 0.7,\n", - " 'sw2': 0.00028,\n", - " 'trueb': 1.5,\n", - " 'truebf': 0.1,\n", - " 'NA.flag': -999}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test_tool_workflow/04write_climate/1678366349_write_climate.tar.gz" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test_tool_workflow/04write_climate/\", **kwargs)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tool 5: write_printout" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "write_printout: CATFLOW printout times FROM tbr_catflow:latest VERSION: 0.1" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pick tool\n", - "tool2use = 'write_printout'\n", - "\n", - "# load tool\n", - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "kwargs = {'start.time': '01.01.2004 00:00:00',\n", - " 'end.time': '03.01.2004 00:00:00',\n", - " 'intervall': 0.5,\n", - " 'time.unit': 'h',\n", - " 'flag': 1}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test_tool_workflow/05write_printout/1678366373_write_printout.tar.gz" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test_tool_workflow/05write_printout/\", **kwargs)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tool 6: write_surface_pob" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "write_surface_pob: CATFLOW surface attributes FROM tbr_catflow:latest VERSION: 0.1" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pick tool\n", - "tool2use = 'write_surface_pob'\n", - "\n", - "# load tool\n", - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [], - "source": [ - "kwargs = {\"geometry\": \"./test_tool_workflow/01make_geometry/1678366251_make_geometry/out/geom.Rds\",\n", - " \"lu\": 33,\n", - " \"precid\": 1,\n", - " \"climid\": 1,\n", - " \"windid\": [1, 1, 1, 1]\n", - " }" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test_tool_workflow/06write_surface_pob/1678366405_write_surface_pob.tar.gz" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test_tool_workflow/06write_surface_pob/\", **kwargs)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tool 7: write_control" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "write_control: CATFLOW project control file FROM tbr_catflow:latest VERSION: 0.1" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pick tool\n", - "tool2use = 'write_control'\n", - "\n", - "# load tool\n", - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [], - "source": [ - "kwargs = {\n", - " \"start.date\": \"01.01.2004 00:00:00.00\",\n", - " \"end.date\": \"03.01.2004 00:00:00\",\n", - " \"geo.file\": \"./test_tool_workflow/01make_geometry/1678366251_make_geometry/out/geom.Rds\"\n", - "}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test_tool_workflow/07write_control/1678366433_write_control.tar.gz" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test_tool_workflow/07write_control\", **kwargs)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tool 8: complete_file_structure" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "complete_file_structure: Create additional files to start a CATFLOW model run FROM tbr_catflow:latest VERSION: 0.1" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pick tool\n", - "tool2use = 'complete_file_structure'\n", - "\n", - "# load tool\n", - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test_tool_workflow/08complete_file_structure/1678366464_complete_file_structure.tar.gz" - ] - }, - "execution_count": 24, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test_tool_workflow/08complete_file_structure\")" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Tool 9: make_geometry_from_tif" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "make_geometry_from_tif: Create CATFLOW geometry from .tif files via representative hillslopes. FROM tbr_catflow:latest VERSION: 0.1" - ] - }, - "execution_count": 36, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# pick tool\n", - "tool2use = 'make_geometry_from_tif'\n", - "\n", - "# load tool\n", - "tool = list_tools(as_dict=True)[tool2use]\n", - "tool" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [], - "source": [ - "kwargs = {\n", - " \"flow_accumulation\": \"./in/geoprocessing/flow_acccumulation.tif\",\n", - " \"basin\": \"./in/geoprocessing/basin.tif\",\n", - " \"elevation2river\": \"./in/geoprocessing/elev2riv.tif\",\n", - " \"distance2river\": \"./in/geoprocessing/dist2riv.tif\",\n", - " \"dem\": \"./in/geoprocessing/dem.tif\",\n", - " \"aspect\": \"./in/geoprocessing/aspect.tif\",\n", - " \"river_id\": \"./in/geoprocessing/river_id.tif\"\n", - "}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "./test_tool_workflow/09make_geometry_from_tif/1678374520_make_geometry_from_tif.tar.gz" - ] - }, - "execution_count": 38, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "tool.run(result_path=\"./test_tool_workflow/09make_geometry_from_tif\", **kwargs)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3.9.13 ('base')", - "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.9.13" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "8d0c1a6128e2cf3746a6d81235a4b20520a40a7ad1294ee2bfe8689bde885c31" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}