{ "cells": [ { "cell_type": "markdown", "id": "afdd76ec36f44a0", "metadata": {}, "source": [ "# How to reuse legacy RGA/GAR configuration files?" ] }, { "cell_type": "markdown", "id": "a675199a0611e06", "metadata": {}, "source": [ "## Create model from RGA/GAR files" ] }, { "cell_type": "markdown", "id": "bd1bbe5876c0e9cc", "metadata": {}, "source": [ "Unlike `rameau` that relies on a TOML configuration file, previous \n", "(legacy) versions of the `Gardenia` model relied on configuration files \n", "with custom extensions *\\*.rga* and *\\*.gar*. \n", "\n", "In order to guarantee backward compatibility with older versions of GARDENIA,\n", "there is a utility that allows to create a `Model` from those files." ] }, { "cell_type": "code", "execution_count": 1, "id": "3b2afb00511e059d", "metadata": { "ExecuteTime": { "end_time": "2024-05-24T07:12:56.054701Z", "start_time": "2024-05-24T07:12:54.582990Z" } }, "outputs": [], "source": [ "import rameau.utils as rmu\n", "\n", "model = rmu.create_model_from_rga_gar(\n", " 'model.rga', 'model.gar', gardenia_version='8.8.1'\n", ")" ] }, { "cell_type": "markdown", "id": "d237776591d2610a", "metadata": {}, "source": [ "## Run a simulation" ] }, { "cell_type": "markdown", "id": "9c1bbb8d667a568c", "metadata": {}, "source": [ "Once the `Model` instance is created, it will behave exactly as if it \n", "was created from a TOML configuration file. For example, we can run a \n", "simulation and plot the outputs." ] }, { "cell_type": "code", "execution_count": 2, "id": "8c49a7e9ca554cda", "metadata": { "ExecuteTime": { "end_time": "2024-05-24T07:12:56.134403Z", "start_time": "2024-05-24T07:12:56.055953Z" } }, "outputs": [], "source": [ "sim = model.run_simulation()" ] }, { "cell_type": "code", "execution_count": null, "id": "5c43a56b95da9795", "metadata": { "ExecuteTime": { "end_time": "2024-05-24T07:12:56.713979Z", "start_time": "2024-05-24T07:12:56.135254Z" } }, "outputs": [], "source": [ "ax = sim.get_output('riverflow').plot(ylabel='streamflow [m$^3$.s$^{-1}$]')" ] }, { "cell_type": "code", "execution_count": null, "id": "2ee0d0a642c8b455", "metadata": { "ExecuteTime": { "end_time": "2024-05-24T07:12:57.011155Z", "start_time": "2024-05-24T07:12:56.715208Z" } }, "outputs": [], "source": [ "ax = sim.get_output('watertable').plot(ylabel='piezometric level [m]')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 5 }