{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Working with GSFLOW control file parameters\n", "\n", "This tutorial shows how to access, edit, remove, and add new control file\n", "parameters and packages to a GSFLOW model using pyGSFLOW" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Package import\n", "import os\n", "import gsflow" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load a demonstration model" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "model_ws = os.path.join(\"..\", \"..\", \"data\", \"sagehen\", \"gsflow\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Control file is loaded\n", "Working on loading PRMS model ...\n", "Prms model loading ...\n", "------------------------------------\n", "Reading parameter file : saghen_new_par_0.params\n", "------------------------------------\n", "Warning: ncascade data type will be infered from data supplied\n", "Warning: ncascdgw data type will be infered from data supplied\n", "Warning: ndays data type will be infered from data supplied\n", "Warning: ndepl data type will be infered from data supplied\n", "Warning: ndeplval data type will be infered from data supplied\n", "Warning: nevap data type will be infered from data supplied\n", "Warning: ngw data type will be infered from data supplied\n", "Warning: ngwcell data type will be infered from data supplied\n", "Warning: nhru data type will be infered from data supplied\n", "Warning: nhrucell data type will be infered from data supplied\n", "Warning: nlake data type will be infered from data supplied\n", "Warning: nlake_hrus data type will be infered from data supplied\n", "Warning: nmonths data type will be infered from data supplied\n", "Warning: nobs data type will be infered from data supplied\n", "Warning: nrain data type will be infered from data supplied\n", "Warning: nreach data type will be infered from data supplied\n", "Warning: nsegment data type will be infered from data supplied\n", "Warning: nsnow data type will be infered from data supplied\n", "Warning: nsol data type will be infered from data supplied\n", "Warning: nssr data type will be infered from data supplied\n", "Warning: nsub data type will be infered from data supplied\n", "Warning: ntemp data type will be infered from data supplied\n", "Warning: one data type will be infered from data supplied\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "------------------------------------\n", "Reading parameter file : saghen_new_par_1.params\n", "------------------------------------\n", "------------------------------------\n", "Reading parameter file : saghen_new_par_2.params\n", "------------------------------------\n", "------------------------------------\n", "Reading parameter file : saghen_new_par_3.params\n", "------------------------------------\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "PRMS model loaded ...\n", "Working on loading MODFLOW files ....\n", " loading iuzfbnd array...\n", " loading irunbnd array...\n", " loading vks array...\n", " loading eps array...\n", " loading thts array...\n", "stress period 1:\n", " loading finf array...\n", "stress period 2:\n", "MODFLOW files are loaded ... \n" ] } ], "source": [ "control_file = os.path.join(model_ws, \"saghen_new_cont.control\")\n", "gsf = gsflow.GsflowModel.load_from_file(control_file)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Accessing the ControlFile object" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "control = gsf.control" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Getting parameter values from the ControlFile object\n", "The `get_values()` method allows the user to get a list of parameter values" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "csv_out = control.get_values(\"csv_output_file\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adjusting parameter values\n", "The `set_values()` method allows the user to adjust control file parameter\n", "values" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "csv_out = \"gsflow_example.csv\"\n", "control.set_values(\"csv_output_file\", [csv_out,])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Removing a parameter\n", "The `remove_record()` method will remove a parameter value from the ControlFile\n", "object" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "control.remove_record(\"csv_output_file\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adding a new parameter\n", "The `add_record()` method allows users to add new records to the ControlFile\n", "object." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Warning: csv_output_file data type will be infered from data supplied\n" ] } ], "source": [ "csv_out = \"gsflow_example.csv\"\n", "control.add_record(\"csv_output_file\", [csv_out,])" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }