{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Examples of using the `lsmaker.utils` module to export and visualize results from a GFLOW simulation" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2024-02-21T02:43:27.436721Z", "iopub.status.busy": "2024-02-21T02:43:27.436337Z", "iopub.status.idle": "2024-02-21T02:43:28.356515Z", "shell.execute_reply": "2024-02-21T02:43:28.355987Z" } }, "outputs": [], "source": [ "from pathlib import Path\n", "import matplotlib.pyplot as plt\n", "import rasterio\n", "import lsmaker\n", "import geopandas as gpd\n", "\n", "plt.rcParams['figure.figsize'] = 10, 10" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2024-02-21T02:43:28.359062Z", "iopub.status.busy": "2024-02-21T02:43:28.358627Z", "iopub.status.idle": "2024-02-21T02:43:28.361916Z", "shell.execute_reply": "2024-02-21T02:43:28.361462Z" } }, "outputs": [], "source": [ "# GFLOW model parameters for test case\n", "solver_x0 = 671467.1 # origin of GFLOW solver coordinates in NAD 27 UTM 15\n", "solver_y0 = 4997427.91\n", "epsg = 26715 # projected coordinate system reference\n", "inpath = Path('../lsmaker/tests/data/')\n", "dem = inpath / 'dem.tif' # dem for model area\n", "clipto = inpath / 'testnearfield.shp' # extent for output rasters\n", "grd = inpath / 'test.grd' # Surfer GRD file from GFLOW solution\n", "xtr = inpath / 'test.xtr' # Extract file from GFLOW solution\n", "output_folder = Path('temp') # folder for writing output rasters\n", "\n", "# make the output folder if it doesn't exist\n", "output_folder.mkdir(exist_ok=True)\n", " \n", "output_streamflow_shapefile = output_folder / 'streamflow.shp'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### make a shapefile of the streamflow results" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2024-02-21T02:43:28.363710Z", "iopub.status.busy": "2024-02-21T02:43:28.363543Z", "iopub.status.idle": "2024-02-21T02:43:28.484138Z", "shell.execute_reply": "2024-02-21T02:43:28.483640Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/runner/work/linesink-maker/linesink-maker/lsmaker/utils/gflow_results.py:202: UserWarning: Column names longer than 10 characters will be truncated when saved to ESRI Shapefile.\n", " gdf.to_file(outshp, **kwargs)\n" ] } ], "source": [ "lsmaker.utils.write_streamflow_shapefile(xtr, outshp=output_streamflow_shapefile, \n", " solver_x0=solver_x0, solver_y0=solver_y0, epsg=epsg)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### read in and plot the streamflow" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2024-02-21T02:43:28.533968Z", "iopub.status.busy": "2024-02-21T02:43:28.533739Z", "iopub.status.idle": "2024-02-21T02:43:28.640496Z", "shell.execute_reply": "2024-02-21T02:43:28.640069Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " | x1 | \n", "y1 | \n", "x2 | \n", "y2 | \n", "spec_head | \n", "calc_head | \n", "discharge | \n", "width | \n", "resistance | \n", "depth | \n", "baseflow | \n", "overlandfl | \n", "BC_pct_err | \n", "label | \n", "geometry | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "687767.261456 | \n", "5.005139e+06 | \n", "687666.619544 | \n", "5.005053e+06 | \n", "1457.01 | \n", "1456.764 | \n", "-6.366638 | \n", "7.766733 | \n", "0.3 | \n", "3.0 | \n", "0.0 | \n", "0.0 | \n", "0.042977 | \n", "LS_000061_0101 | \n", "LINESTRING (687767.261 5005139.240, 687666.620... | \n", "
1 | \n", "687666.619544 | \n", "5.005053e+06 | \n", "687582.238712 | \n", "5.005071e+06 | \n", "1457.01 | \n", "1456.474 | \n", "-13.887300 | \n", "7.766733 | \n", "0.3 | \n", "3.0 | \n", "0.0 | \n", "0.0 | \n", "0.042901 | \n", "LS_000061_0201 | \n", "LINESTRING (687666.620 5005053.399, 687582.239... | \n", "
2 | \n", "687582.238712 | \n", "5.005071e+06 | \n", "687634.670408 | \n", "5.005190e+06 | \n", "1457.00 | \n", "1456.602 | \n", "-10.304160 | \n", "7.766711 | \n", "0.3 | \n", "3.0 | \n", "0.0 | \n", "0.0 | \n", "0.043006 | \n", "LS_000061_0301 | \n", "LINESTRING (687582.239 5005071.270, 687634.670... | \n", "
3 | \n", "687634.670408 | \n", "5.005190e+06 | \n", "687768.261200 | \n", "5.005140e+06 | \n", "1457.00 | \n", "1456.892 | \n", "-2.787542 | \n", "7.766711 | \n", "0.3 | \n", "3.0 | \n", "0.0 | \n", "0.0 | \n", "0.043086 | \n", "LS_000061_0401 | \n", "LINESTRING (687634.670 5005189.700, 687768.261... | \n", "
4 | \n", "688403.589368 | \n", "5.006317e+06 | \n", "688378.269632 | \n", "5.006088e+06 | \n", "1463.90 | \n", "1463.847 | \n", "-1.363574 | \n", "7.781718 | \n", "0.3 | \n", "3.0 | \n", "0.0 | \n", "0.0 | \n", "0.044174 | \n", "LS_000068_0101 | \n", "LINESTRING (688403.589 5006316.649, 688378.270... | \n", "