From 378c9f717d1253e0e2c1e5bd3b94cdd1df7c2cd9 Mon Sep 17 00:00:00 2001 From: Anthony Aufdenkampe Date: Mon, 16 Dec 2024 15:07:17 -0600 Subject: [PATCH] Fixed example Notebook 1; updated conda env yml files @PaulDudaRESPEC, @timcera, @rburghol & @austinorr, the example 1 notebook now works by installing from the conda environment file. Most importantly this example notebook provides an example of how the IO manager should be used, as described in https://github.com/respec/HSPsquared/issues/182#issuecomment-2542252660 --- README.rst | 25 +- environment.yml | 90 ++-- environment_dev.yml | 81 ++-- examples/1_Intro_to_HSP2.ipynb | 837 +++++++++++++++++---------------- src/hsp2/hsp2/__init__.py | 3 +- src/hsp2/hsp2tools/__init__.py | 2 - 6 files changed, 534 insertions(+), 504 deletions(-) diff --git a/README.rst b/README.rst index 2e45865b..e4003f95 100644 --- a/README.rst +++ b/README.rst @@ -71,7 +71,7 @@ Install From Pre-built Packages ------------------------------- Python Package Index (PyPI) +++++++++++++++++++++++++++ -Starting with version 0.11.0a1 we provide a PyPI wheel package for HSP2 which +Starting with version 0.11.0a1 we provide `a PyPI wheel package for HSP2`_ which should work on any supported platform for Python 3.10, 3.11, and 3.12. .. code-block:: console @@ -113,13 +113,17 @@ Option 1: Install using "conda" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Follow these steps to install using the conda_ package manager. -1. Install the Anaconda Python Distribution +1. Install Miniconda or Anaconda Python Distribution ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Install the `latest release`_ of the Anaconda Distribution, which includes the -conda package manager, a complete Python (and R) data science stack, and the -Anaconda Navigator GUI. Follow `Anaconda Installation`_ documentation. +We recommend installing the light-weight Miniconda_ that includes Python, the +conda_ environment and package management system, and their dependencies. + +NOTE: Follow conda defaults to install in your local user directory. DO NOT +install for all users, to avoid substantial headaches with permissions. + +If you have already installed the Anaconda Distribution, you can use it to +complete the next steps, but you may need to update to the `latest release`_. -A lighter-weight alternative is to install Miniconda_. 2. Create a Conda Environment for HSP2 Modeling (optional) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -147,6 +151,14 @@ Install the necessary and optional packages for HSP2 in the new environment: cd /path/to/module/hsp2 pip install . # or "pip install -e ." to install in editable mode +**Alternately**, you can replace all of the create and install steps above by +creating the new environment from the included `environment.yml` file +from this single line of code: + +.. code-block:: console + + conda env create --file=environment.yml --solver=libmamba + You should now be able to run the Tutorials and create your own Jupyter Notebooks! @@ -223,6 +235,7 @@ The HSP2 API is designed to be used in Python scripts and Jupyter notebooks. .. _`initial release`: https://github.com/respec/HSPsquared/releases/tag/0.7.7 .. _`GNU Affero General Public License (AGPL), copyrighted 2017 by RESPEC`: https://github.com/respec/HSPsquared/blob/master/LICENSE .. _JupyterLab: https://jupyterlab.readthedocs.io/en/stable/ +.. _`a PyPI wheel package for HSP2`: https://pypi.org/project/hsp2/ .. _conda: https://docs.conda.io/en/latest/ .. _`latest release`: https://docs.anaconda.com/anaconda/reference/release-notes/ .. _`Anaconda Installation`: https://docs.anaconda.com/anaconda/install/ diff --git a/environment.yml b/environment.yml index b48ba137..b415421c 100644 --- a/environment.yml +++ b/environment.yml @@ -1,58 +1,50 @@ --- -name: hsp2_py38 +name: hsp2_py310 channels: - - conda-forge + - conda-forge + - nodefaults # Speeds solving env, by limiting the number of options dependencies: - # Aligned with Anaconda 2021.05 (May 13, 2021) - # package management - - conda - - conda-build - - pip + # Python 3.10 was default for Anaconda 2023.03-0 (Mar 20, 2023) + # https://docs.anaconda.com/free/anaconda/release-notes/#anaconda-2023-03-0-mar-20-2023 + # package management + - conda + - conda-build + - conda-libmamba-solver + - pip - # Running HSP2 - - python =3.8* - - scipy # Scipy also installs numpy - # Pandas installs most scientific Python modules, such as Numpy, etc. - - pandas ==1.2.* - - numba ==0.53.1 - - numpy ==1.20.* # for compatibility with numba version <0.53 - # latest compatible with both versions of PyTables & h5py below - # - doesn't work with setup.py - - hdf5 ==1.10.6 - - pytables ==3.6.1 - - h5py >=3.1 - - hdf5plugin # HDF5 compression filters for h5py & jupyterlab_hdf - - cltoolbox + # Running HSP2 + - python =3.10 + - scipy # Scipy also installs numpy + # Pandas installs most scientific Python modules, such as Numpy, etc. + - pandas 2 + - numba + - numpy + - hdf5 + - pytables + - h5py + - hdf5plugin # HDF5 compression filters for h5py & jupyterlab_hdf + - cltoolbox - # Interactivity & Visualization via Jupyter Notebooks - # (optional, but required for tutorials) - - jupyterlab ==3.0.* # also installs classic Jupyter notbook - - ipympl # jupyter-matplotlib, https://github.com/matplotlib/ipympl - - nodejs # required for many JupyterLab extensions - # Conda environment & package access extension from within Jupyter - - nb_conda - # HoloViz, https://holoviz.org - - hvplot # hvPlot installs most HoloViz libs, including matplotlib - - ipywidgets # Required for HoloViz interactivity in Jupyter notebooks + # Operational Model (om) + - pyparsing - # Dev tools (optional) - - python-language-server - # Includes both the server extension (jupyter-lsp) and pyls third-party - # server (python-language-server) - - jupyter-lsp-python - - jupyterlab-lsp # Docs at https://github.com/krassowski/jupyterlab-lsp + # Interactivity & Visualization via Jupyter Notebooks (optional, + # but required for tutorials) + - jupyterlab # also installs classic Jupyter notbook + - ipympl # jupyter-matplotlib, https://github.com/matplotlib/ipympl + - nodejs # required for many JupyterLab extensions + # HoloViz, https://holoviz.org + - hvplot # hvPlot installs most HoloViz libs, including matplotlib + - ipywidgets # Required for HoloViz interactivity in Jupyter notebooks + - ipywidgets_bokeh + - jupyter_bokeh # for VSCode - # Operational Model (om) - - pyparsing + # Dev tools (optional) + - python-lsp-server # Language Server Protocol (LSP) extension for Python (pylsp) + - jupyterlab-lsp # Provides both server extension and lab extension - # PIP install requirements only if it is not possible with conda - # https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#using-pip-in-an-environment - # Optional, but recommended for tutorials - - pip: - # https://github.com/lckr/jupyterlab-variableInspector - # - lckr-jupyterlab-variableinspector - # Explore HDF5 files in JupyterLab. Requires an additional step to install. - # - jupyterlab_hdf - # Installation instructions: - # https://github.com/jupyterlab/jupyterlab-hdf5#installation + # PIP install requirements only if it is not possible with conda + # https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#using-pip-in-an-environment + - pip: + - hsp2 diff --git a/environment_dev.yml b/environment_dev.yml index 85648071..878c42a5 100644 --- a/environment_dev.yml +++ b/environment_dev.yml @@ -1,47 +1,49 @@ --- name: hsp2_py311_dev channels: - - conda-forge - - nodefaults # Speeds solving env, by limiting the number of options + - conda-forge + - nodefaults # Speeds solving env, by limiting the number of options dependencies: - # Python 3.11 is supported by Anaconda since 2023.03-0 (Mar 20, 2023) - # https://docs.anaconda.com/free/anaconda/release-notes/#anaconda-2023-03-0-mar-20-2023 - # package management - - conda - - conda-build - - conda-libmamba-solver - - pip + # Python 3.11 was default for Anaconda 2023.07-0 (Jul 11, 2023) + # https://docs.anaconda.com/free/anaconda/release-notes/#anaconda-2023-03-0-mar-20-2023 + # package management + - conda + - conda-build + - conda-libmamba-solver + - pip - # Running HSP2 - - python =3.11 - - scipy # Scipy also installs numpy - # Pandas installs most scientific Python modules, such as Numpy, etc. - - pandas >=2.0 - - numba - - numpy - - hdf5 - - pytables - - h5py - - hdf5plugin # HDF5 compression filters for h5py & jupyterlab_hdf - # - dask # for future performance enhancements - - cltoolbox + # Running HSP2 + - python =3.11 + - scipy # Scipy also installs numpy + # Pandas installs most scientific Python modules, such as Numpy, etc. + - pandas >=2.0 + - numba + - numpy + - hdf5 + - pytables + - h5py + - hdf5plugin # HDF5 compression filters for h5py & jupyterlab_hdf + # - dask # for future performance enhancements + - cltoolbox - # Operational Model (om) - - pyparsing + # Operational Model (om) + - pyparsing - # Interactivity & Visualization via Jupyter Notebooks (optional, - # but required for tutorials) - - jupyterlab # also installs classic Jupyter notbook - - ipympl # jupyter-matplotlib, https://github.com/matplotlib/ipympl - - nodejs # required for many JupyterLab extensions - # HoloViz, https://holoviz.org - - hvplot # hvPlot installs most HoloViz libs, including matplotlib - - ipywidgets # Required for HoloViz interactivity in Jupyter notebooks + # Interactivity & Visualization via Jupyter Notebooks (optional, + # but required for tutorials) + - jupyterlab # also installs classic Jupyter notbook + - ipympl # jupyter-matplotlib, https://github.com/matplotlib/ipympl + - nodejs # required for many JupyterLab extensions + # HoloViz, https://holoviz.org + - hvplot # hvPlot installs most HoloViz libs, including matplotlib + - ipywidgets # Required for HoloViz interactivity in Jupyter notebooks + - ipywidgets_bokeh + - jupyter_bokeh # for VSCode - # Dev tools (optional) - # Language Server Protocol (LSP) extension for Python (pylsp) - - python-lsp-server + # Dev tools (optional) + # Language Server Protocol (LSP) extension for Python (pylsp) + - python-lsp-server # Rope for Completions and renaming # Pyflakes linter to detect various errors # McCabe linter for complexity checking @@ -51,9 +53,10 @@ dependencies: # YAPF for code formatting (preferred over autopep8) # flake8 for error checking (disabled by default) # pylint for code linting (disabled by default) - - jupyterlab-lsp # Provides both server extension and lab extension + - jupyterlab-lsp # Provides both server extension and lab extension - # PIP install requirements only if it is not possible with conda - # https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#using-pip-in-an-environment - - pip: + # PIP install requirements only if it is not possible with conda + # https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#using-pip-in-an-environment + - pip: + # For Dev environment, we recommend using the `conda build` command to install diff --git a/examples/1_Intro_to_HSP2.ipynb b/examples/1_Intro_to_HSP2.ipynb index ed350cf0..67516224 100644 --- a/examples/1_Intro_to_HSP2.ipynb +++ b/examples/1_Intro_to_HSP2.ipynb @@ -34,56 +34,184 @@ "source": [ "# Installation and Setup\n", "\n", - "## Install HSP2\n", - "\n", - "Carefully follow our **[Installation Instructions](https://github.com/respec/HSPsquared#installation)**, especially including:\n", - "- Creating a virtual environment for HSP2 (step 3)\n", - "- Adding HSPsquared to your Python path (step 4)" + "This notebook is designed to be run from: \n", + "- a cloned or copied version of the [HSPsquared](https://github.com/respec/HSPsquared) respository and \n", + "- a custom virtual environment as described in our **[HSP2 Installation](https://github.com/respec/HSPsquared#hsp2-installation) Instructions**, especially including:\n", + " - Creating a virtual environment for HSP2 (step 3)\n", + " - Adding HSP2 to your Python path (step 4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Python Imports" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### General Imports" ] }, { "cell_type": "code", "execution_count": 1, + "metadata": { + "execution": { + "iopub.execute_input": "2024-05-21T17:40:19.613424Z", + "iopub.status.busy": "2024-05-21T17:40:19.613169Z", + "iopub.status.idle": "2024-05-21T17:40:19.737150Z", + "shell.execute_reply": "2024-05-21T17:40:19.736693Z", + "shell.execute_reply.started": "2024-05-21T17:40:19.613404Z" + } + }, + "outputs": [], + "source": [ + "import os\n", + "from pathlib import Path\n", + "\n", + "import tables" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Import HSP2" + ] + }, + { + "cell_type": "code", + "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'hsp2_py38'" + "'hsp2_py310'" ] }, - "execution_count": 1, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Confirm that your active environment for this notebook is the one you created for HSP2.\n", - "import os\n", - "\n", "os.environ[\"CONDA_DEFAULT_ENV\"]" ] }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# Install HSP2, HSP2 Tools, and HSP2 IO Utillties\n", + "from hsp2 import hsp2, hsp2tools, hsp2io" + ] + }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## Import Python Dependencies\n", - "- Most dependancies get installed when you import the `HSP2` and `HSP2tools` modules. " + "### If you get `ModuleNotFoundError`\n", + "\n", + "If you get `ModuleNotFoundError`, you need to install hsp2 into your environment, either using \n", + "- `pip` (see [HSP2 Installation](https://github.com/respec/HSPsquared#hsp2-installation) Instructions) for normal use, or using\n", + "- [`conda develop`](https://docs.conda.io/projects/conda-build/en/latest/resources/commands/conda-develop.html) if you want to develop HSP2.\n", + "\n", + "If using the development environment, the following steps will install in develop mode:\n", + "1. Run the [`conda develop`](https://docs.conda.io/projects/conda-build/en/latest/resources/commands/conda-develop.html) command in your terminal with your local absolute path to the `src` directory of this repo.\n", + "2. Restart the kernel.\n", + "3. Rerun the import statements above." ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "PosixPath('/Users/aaufdenkampe/Documents/Python/respec.HSPsquared')" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Find project directory (i.e. the parent to `/examples` directory for this notebook)\n", + "project_path = Path.cwd().parent\n", + "project_path" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "PosixPath('/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/src')" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Your source directory should be: \n", + "src_path = project_path / 'src' \n", + "src_path" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### To install in developer mode:\n", + "- Copy from the output of `src_path` from the cell above, and \n", + "- Paste it after `!conda develop` in the cell below (replacing the previous user's path). \n", + " - NOTE 1: If your path has any blank spaces, you must enclose the path with quotes.\n", + " - NOTE 2: The Jupyter `!` magic command runs a the follwoing terminal command from this notebook." + ] + }, + { + "cell_type": "code", + "execution_count": 6, "metadata": { "execution": { - "iopub.execute_input": "2024-05-21T17:40:19.613424Z", - "iopub.status.busy": "2024-05-21T17:40:19.613169Z", - "iopub.status.idle": "2024-05-21T17:40:19.737150Z", - "shell.execute_reply": "2024-05-21T17:40:19.736693Z", - "shell.execute_reply.started": "2024-05-21T17:40:19.613404Z" + "iopub.execute_input": "2024-05-21T17:40:25.655357Z", + "iopub.status.busy": "2024-05-21T17:40:25.654849Z", + "iopub.status.idle": "2024-05-21T17:40:25.768746Z", + "shell.execute_reply": "2024-05-21T17:40:25.768142Z", + "shell.execute_reply.started": "2024-05-21T17:40:25.655339Z" } }, + "outputs": [], + "source": [ + " # !conda develop '/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/src'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You now need to **restart the Python kernel** for this notebook, if the path didn't already exist." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, "outputs": [ { "data": { @@ -116,10 +244,10 @@ " \n", " \n", " Python\n", - " 3.10.14 | packaged by conda-forge | (main, Mar...\n", + " 3.10.16 | packaged by conda-forge | (main, Dec...\n", " \n", " \n", - " HSP2\n", + " hsp2\n", " n/a\n", " \n", " \n", @@ -128,35 +256,35 @@ " \n", " \n", " numba\n", - " 0.59.1\n", + " 0.60.0\n", " \n", " \n", " pandas\n", - " 1.5.3\n", + " 2.0.0\n", " \n", " \n", " matplotlib\n", - " 3.8.4\n", + " 3.9.4\n", " \n", " \n", " tables\n", - " 3.9.2\n", + " 3.10.1\n", " \n", " \n", " h5py\n", - " 3.11.0\n", + " 3.12.1\n", " \n", " \n", " os\n", - " Linux-5.15.0-91-generic-x86_64-with-glibc2.35\n", + " macOS-14.7.1-arm64-arm-64bit\n", " \n", " \n", " processor\n", - " x86_64\n", + " arm\n", " \n", " \n", " Date/Time\n", - " 2024-05-21T13:40:19.728733\n", + " 2024-12-16T14:54:23.519387\n", " \n", " \n", "\n", @@ -165,76 +293,28 @@ "text/plain": [ " version\n", "name \n", - "Python 3.10.14 | packaged by conda-forge | (main, Mar...\n", - "HSP2 n/a\n", + "Python 3.10.16 | packaged by conda-forge | (main, Dec...\n", + "hsp2 n/a\n", "numpy 1.26.4\n", - "numba 0.59.1\n", - "pandas 1.5.3\n", - "matplotlib 3.8.4\n", - "tables 3.9.2\n", - "h5py 3.11.0\n", - "os Linux-5.15.0-91-generic-x86_64-with-glibc2.35\n", - "processor x86_64\n", - "Date/Time 2024-05-21T13:40:19.728733" + "numba 0.60.0\n", + "pandas 2.0.0\n", + "matplotlib 3.9.4\n", + "tables 3.10.1\n", + "h5py 3.12.1\n", + "os macOS-14.7.1-arm64-arm-64bit\n", + "processor arm\n", + "Date/Time 2024-12-16T14:54:23.519387" ] }, - "execution_count": 2, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "import os\n", - "from pathlib import Path\n", - "\n", - "import tables\n", - "from hsp2 import hsp2, hsp2tools\n", - "from hsp2.hsp2io import hdf, io\n", - "\n", "# Confirm installed versions of HSP2 and key dependencies\n", - "hsp2.versions([\"matplotlib\", \"tables\", \"h5py\"])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### If you get HSP2 `ModuleNotFoundError`:\n", - "\n", - "If you get this error:\n", - "```python\n", - "ModuleNotFoundError: No module named 'HSP2'\n", - "```\n", - "Then:\n", - "1. Run the following terminal command with your local absolute path to this repo.\n", - " - NOTE: Here we use Jupyter `!` magic command to run from the terminal via this notebook. \n", - "2. Restart the kernel.\n", - "3. Rerun the import statements above." - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "execution": { - "iopub.execute_input": "2024-05-21T17:40:25.655357Z", - "iopub.status.busy": "2024-05-21T17:40:25.654849Z", - "iopub.status.idle": "2024-05-21T17:40:25.768746Z", - "shell.execute_reply": "2024-05-21T17:40:25.768142Z", - "shell.execute_reply.started": "2024-05-21T17:40:25.655339Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/bin/bash: line 1: conda-develop: command not found\n" - ] - } - ], - "source": [ - "!conda-develop /Users/aaufdenkampe/Documents/Python/respec.HSPsquared/" + "hsp2.versions([\"matplotlib\", \"tables\", \"h5py\"])\n", + "# TODO: need to fix hsp2 version links" ] }, { @@ -248,50 +328,31 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 8, "metadata": { "execution": { - "iopub.execute_input": "2024-05-21T17:40:35.309422Z", - "iopub.status.busy": "2024-05-21T17:40:35.309181Z", - "iopub.status.idle": "2024-05-21T17:40:35.312823Z", - "shell.execute_reply": "2024-05-21T17:40:35.312344Z", - "shell.execute_reply.started": "2024-05-21T17:40:35.309405Z" + "iopub.execute_input": "2024-05-21T17:40:36.407261Z", + "iopub.status.busy": "2024-05-21T17:40:36.406989Z", + "iopub.status.idle": "2024-05-21T17:40:36.409351Z", + "shell.execute_reply": "2024-05-21T17:40:36.408997Z", + "shell.execute_reply.started": "2024-05-21T17:40:36.407244Z" } }, "outputs": [ { "data": { "text/plain": [ - "PosixPath('/home/tim/programming/HSPsquared/examples')" + "PosixPath('/Users/aaufdenkampe/Documents/Python/respec.HSPsquared')" ] }, - "execution_count": 4, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "# Get your current working directory, for reference\n", - "Path.cwd()" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "execution": { - "iopub.execute_input": "2024-05-21T17:40:36.407261Z", - "iopub.status.busy": "2024-05-21T17:40:36.406989Z", - "iopub.status.idle": "2024-05-21T17:40:36.409351Z", - "shell.execute_reply": "2024-05-21T17:40:36.408997Z", - "shell.execute_reply.started": "2024-05-21T17:40:36.407244Z" - } - }, - "outputs": [], - "source": [ - "# Set your project directory to your local folder for your clone of the HSPsquared repository\n", - "\n", - "project_folder = Path(\"/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/\")" + "# Project directory, found above, is local folder for your clone or copy of the HSPsquared repository\n", + "project_path" ] }, { @@ -307,7 +368,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 9, "metadata": { "execution": { "iopub.execute_input": "2024-05-21T18:52:11.477985Z", @@ -322,17 +383,18 @@ "name": "stdout", "output_type": "stream", "text": [ - "../tests/test10/HSP2results/test10.uci\n", + "/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/tests/test10/HSP2results/test10.uci\n", "File exists? True\n", - "../tests/test10/HSP2results/test10.wdm\n", + "/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/tests/test10/HSP2results/test10.wdm\n", "File exists? True\n" ] } ], "source": [ - "# Set input data paths, using our Test10 example\n", + "# Get input data paths for the Test10 example\n", + "# Using `pathlib` concatenation\n", + "inputs_path = project_path / 'tests' / 'test10' / 'HSP2results' \n", "\n", - "input_data_folder = Path(\"../tests/test10/HSP2results/\")\n", "\n", "input_files = [\n", " \"test10.uci\",\n", @@ -340,16 +402,16 @@ "]\n", "\n", "# HSPF User Control Inputs text file\n", - "input_uci_path = input_data_folder / input_files[0]\n", + "input_uci_filepath = inputs_path / input_files[0]\n", "\n", - "print(input_uci_path)\n", - "print(f\"File exists? {input_uci_path.exists()}\")\n", + "print(input_uci_filepath)\n", + "print(f\"File exists? {input_uci_filepath.exists()}\")\n", "\n", "# HSPF Watershed Data Management Fortran binary file for timeseries inputs\n", - "input_wdm_path = input_data_folder / input_files[1]\n", + "input_wdm_filepath = inputs_path / input_files[1]\n", "\n", - "print(input_wdm_path)\n", - "print(f\"File exists? {input_wdm_path.exists()}\")" + "print(input_wdm_filepath)\n", + "print(f\"File exists? {input_wdm_filepath.exists()}\")" ] }, { @@ -361,7 +423,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 10, "metadata": { "execution": { "iopub.execute_input": "2024-05-21T17:40:42.208083Z", @@ -373,61 +435,26 @@ }, "outputs": [ { - "ename": "PermissionError", - "evalue": "[Errno 13] Permission denied: '/Users'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1175\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1174\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1175\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_accessor\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1176\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/examples/_TutorialData'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1175\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1174\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1175\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_accessor\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1176\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/examples'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1175\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1174\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1175\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_accessor\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1176\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/Users/aaufdenkampe/Documents/Python/respec.HSPsquared'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1175\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1174\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1175\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_accessor\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1176\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/Users/aaufdenkampe/Documents/Python'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1175\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1174\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1175\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_accessor\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1176\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/Users/aaufdenkampe/Documents'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1175\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1174\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1175\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_accessor\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1176\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m:\n", - "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/Users/aaufdenkampe'", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mPermissionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[7], line 7\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[38;5;66;03m# Create temporary directory, which we ignore in Git\u001b[39;00m\n\u001b[1;32m 6\u001b[0m tutoral_temp_path \u001b[38;5;241m=\u001b[39m project_folder \u001b[38;5;241m/\u001b[39m output_data_folder\n\u001b[0;32m----> 7\u001b[0m \u001b[43mtutoral_temp_path\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparents\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexist_ok\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mFolder exists? \u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;28mstr\u001b[39m(tutoral_temp_path\u001b[38;5;241m.\u001b[39mexists()) )\n", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1179\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1177\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m parents \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mparent \u001b[38;5;241m==\u001b[39m \u001b[38;5;28mself\u001b[39m:\n\u001b[1;32m 1178\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m\n\u001b[0;32m-> 1179\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparent\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparents\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexist_ok\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 1180\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmkdir(mode, parents\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, exist_ok\u001b[38;5;241m=\u001b[39mexist_ok)\n\u001b[1;32m 1181\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n\u001b[1;32m 1182\u001b[0m \u001b[38;5;66;03m# Cannot rely on checking for EEXIST, since the operating system\u001b[39;00m\n\u001b[1;32m 1183\u001b[0m \u001b[38;5;66;03m# could give priority to other errors like EACCES or EROFS\u001b[39;00m\n", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1179\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1177\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m parents \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mparent \u001b[38;5;241m==\u001b[39m \u001b[38;5;28mself\u001b[39m:\n\u001b[1;32m 1178\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m\n\u001b[0;32m-> 1179\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparent\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparents\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexist_ok\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 1180\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmkdir(mode, parents\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, exist_ok\u001b[38;5;241m=\u001b[39mexist_ok)\n\u001b[1;32m 1181\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n\u001b[1;32m 1182\u001b[0m \u001b[38;5;66;03m# Cannot rely on checking for EEXIST, since the operating system\u001b[39;00m\n\u001b[1;32m 1183\u001b[0m \u001b[38;5;66;03m# could give priority to other errors like EACCES or EROFS\u001b[39;00m\n", - " \u001b[0;31m[... skipping similar frames: Path.mkdir at line 1179 (3 times)]\u001b[0m\n", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1179\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1177\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m parents \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mparent \u001b[38;5;241m==\u001b[39m \u001b[38;5;28mself\u001b[39m:\n\u001b[1;32m 1178\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m\n\u001b[0;32m-> 1179\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparent\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparents\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexist_ok\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 1180\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmkdir(mode, parents\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, exist_ok\u001b[38;5;241m=\u001b[39mexist_ok)\n\u001b[1;32m 1181\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n\u001b[1;32m 1182\u001b[0m \u001b[38;5;66;03m# Cannot rely on checking for EEXIST, since the operating system\u001b[39;00m\n\u001b[1;32m 1183\u001b[0m \u001b[38;5;66;03m# could give priority to other errors like EACCES or EROFS\u001b[39;00m\n", - "File \u001b[0;32m~/anaconda3/envs/hsp2_310/lib/python3.10/pathlib.py:1175\u001b[0m, in \u001b[0;36mPath.mkdir\u001b[0;34m(self, mode, parents, exist_ok)\u001b[0m\n\u001b[1;32m 1171\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1172\u001b[0m \u001b[38;5;124;03mCreate a new directory at this given path.\u001b[39;00m\n\u001b[1;32m 1173\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1174\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1175\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_accessor\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmkdir\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmode\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1176\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mFileNotFoundError\u001b[39;00m:\n\u001b[1;32m 1177\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m parents \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mparent \u001b[38;5;241m==\u001b[39m \u001b[38;5;28mself\u001b[39m:\n", - "\u001b[0;31mPermissionError\u001b[0m: [Errno 13] Permission denied: '/Users'" + "name": "stdout", + "output_type": "stream", + "text": [ + "Folder exists? True\n" ] } ], "source": [ "# Create temporary data output folder, where you want to store your outputs\n", - "\n", - "output_data_folder = Path(\"examples/_TutorialData\")\n", + "tutoral_temp_path = project_path / 'examples' / '_TutorialData'\n", "\n", "# Create temporary directory, which we ignore in Git\n", - "tutoral_temp_path = project_folder / output_data_folder\n", "tutoral_temp_path.mkdir(parents=True, exist_ok=True)\n", "\n", - "print(\"Folder exists? \" + str(tutoral_temp_path.exists()))" + "print('Folder exists? ', tutoral_temp_path.exists())" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 11, "metadata": { "execution": { "iopub.execute_input": "2024-05-21T17:40:43.187481Z", @@ -449,12 +476,9 @@ ], "source": [ "# Create path for temporary data output file\n", - "\n", "output_file = \"test10.h5\" # HSP2 data HDF5 binary file, for all inputs and outputs\n", "\n", - "output_hdf5_path = (\n", - " project_folder / output_data_folder / output_file\n", - ") # pathlib concatenation\n", + "output_hdf5_path = tutoral_temp_path / output_file\n", "\n", "print(output_hdf5_path)\n", "print(\"File exists? \" + str(output_hdf5_path.exists()))\n", @@ -489,15 +513,15 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 18.2 s, sys: 621 ms, total: 18.8 s\n", - "Wall time: 18.9 s\n" + "CPU times: user 6.19 s, sys: 314 ms, total: 6.5 s\n", + "Wall time: 6.58 s\n" ] } ], @@ -507,13 +531,13 @@ "# from the HSPF *.uci text file in Fortran punchard format\n", "# to the HDF5 file\n", "\n", - "HSP2tools.readUCI(input_uci_path, output_hdf5_path)\n", - "# NOTE that parsing this text file is not very efficient!" + "hsp2tools.readUCI(input_uci_filepath, output_hdf5_path)\n", + "# NOTE that parsing this text file is not very efficient, takign 8-20 seconds" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -531,7 +555,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -557,8 +581,8 @@ "135 reading from wdm\n", "136 reading from wdm\n", "140 reading from wdm\n", - "CPU times: user 2.88 s, sys: 70.1 ms, total: 2.95 s\n", - "Wall time: 3.05 s\n" + "CPU times: user 1.45 s, sys: 66.3 ms, total: 1.52 s\n", + "Wall time: 1.74 s\n" ] }, { @@ -597,7 +621,7 @@ " TS039\n", " 1976-01-01 00:00:00\n", " 1977-01-01 00:00:00\n", - " 1H\n", + " 1h\n", " 8784\n", " PREC\n", " -999.0\n", @@ -630,7 +654,7 @@ " TS046\n", " 1976-01-01 00:00:00\n", " 1977-01-01 00:00:00\n", - " 2H\n", + " 2h\n", " 4392\n", " SOLR\n", " -999.0\n", @@ -663,7 +687,7 @@ " TS121\n", " 1976-01-01 00:00:00\n", " 1977-01-01 00:00:00\n", - " 2H\n", + " 2h\n", " 4392\n", " ATMP\n", " -999.0\n", @@ -674,7 +698,7 @@ " TS122\n", " 1976-01-01 00:00:00\n", " 1977-01-01 00:00:00\n", - " 2H\n", + " 2h\n", " 4392\n", " ATMP\n", " -999.0\n", @@ -685,7 +709,7 @@ " TS123\n", " 1976-01-01 00:00:00\n", " 1977-01-01 00:00:00\n", - " 2H\n", + " 2h\n", " 4392\n", " ATMP\n", " -999.0\n", @@ -740,7 +764,7 @@ " TS131\n", " 1976-01-01 00:00:00\n", " 1977-01-01 00:00:00\n", - " 1H\n", + " 1h\n", " 8784\n", " PREC\n", " -999.0\n", @@ -751,7 +775,7 @@ " TS132\n", " 1976-01-01 00:00:00\n", " 1977-01-01 00:00:00\n", - " 1H\n", + " 1h\n", " 8784\n", " PREC\n", " -999.0\n", @@ -807,22 +831,22 @@ "" ], "text/plain": [ - " Start Stop Freq Length TSTYPE TFILL \\\n", - "TS039 1976-01-01 00:00:00 1977-01-01 00:00:00 1H 8784 PREC -999.0 \n", + " Start Stop Freq Length TSTYPE TFILL \n", + "TS039 1976-01-01 00:00:00 1977-01-01 00:00:00 1h 8784 PREC -999.0 \\\n", "TS041 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 EVAP -999.0 \n", "TS042 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 WIND -999.0 \n", - "TS046 1976-01-01 00:00:00 1977-01-01 00:00:00 2H 4392 SOLR -999.0 \n", + "TS046 1976-01-01 00:00:00 1977-01-01 00:00:00 2h 4392 SOLR -999.0 \n", "TS113 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 FLOW -999.0 \n", "TS119 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 FLOW -999.0 \n", - "TS121 1976-01-01 00:00:00 1977-01-01 00:00:00 2H 4392 ATMP -999.0 \n", - "TS122 1976-01-01 00:00:00 1977-01-01 00:00:00 2H 4392 ATMP -999.0 \n", - "TS123 1976-01-01 00:00:00 1977-01-01 00:00:00 2H 4392 ATMP -999.0 \n", + "TS121 1976-01-01 00:00:00 1977-01-01 00:00:00 2h 4392 ATMP -999.0 \n", + "TS122 1976-01-01 00:00:00 1977-01-01 00:00:00 2h 4392 ATMP -999.0 \n", + "TS123 1976-01-01 00:00:00 1977-01-01 00:00:00 2h 4392 ATMP -999.0 \n", "TS124 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 DEWP -999.0 \n", "TS125 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 DEWP -999.0 \n", "TS126 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 DEWP -999.0 \n", "TS127 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 SEDM -999.0 \n", - "TS131 1976-01-01 00:00:00 1977-01-01 00:00:00 1H 8784 PREC -999.0 \n", - "TS132 1976-01-01 00:00:00 1977-01-01 00:00:00 1H 8784 PREC -999.0 \n", + "TS131 1976-01-01 00:00:00 1977-01-01 00:00:00 1h 8784 PREC -999.0 \n", + "TS132 1976-01-01 00:00:00 1977-01-01 00:00:00 1h 8784 PREC -999.0 \n", "TS134 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 WTMP -999.0 \n", "TS135 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 CLDC -999.0 \n", "TS136 1976-01-01 00:00:00 1977-01-01 00:00:00 1D 366 FLOW -999.0 \n", @@ -850,7 +874,7 @@ "TS140 COLIND COLUMN INDICATOR MEIER POND SUMMER-WINTER OUTLET " ] }, - "execution_count": 11, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -861,7 +885,11 @@ "# from the HSPF Watershd Data Management (WDM) file in Fortran binary format\n", "# to the HDF5 file\n", "\n", - "HSP2tools.readWDM(input_wdm_path, output_hdf5_path)" + "hsp2tools.readWDM(input_wdm_filepath, output_hdf5_path)\n", + "\n", + "# NOTE: The `readWDM()` function has been sped up with Numba, which compiles it the\n", + "# first time you runs. The second time will use the precompiled code, executing \n", + "# 80 times faster! Try it!" ] }, { @@ -886,16 +914,16 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 12, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -903,14 +931,13 @@ "source": [ "## Create instance of HSPFIO.HDF5 class, from the file created by reading HSPF inputs\n", "\n", - "hdf5_instance = HSP2IO.hdf.HDF5(output_hdf5_path)\n", - "\n", + "hdf5_instance = hsp2io.hdf.HDF5(output_hdf5_path)\n", "hdf5_instance" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -919,7 +946,7 @@ "['/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/examples/_TutorialData/test10.h5']" ] }, - "execution_count": 13, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -934,16 +961,16 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 14, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -951,14 +978,14 @@ "source": [ "## Create an instance of the IOManager: Management class for IO operations needed to execute the HSP2 model\n", "\n", - "io_manager = HSP2IO.io.IOManager(hdf5_instance)\n", + "io_manager = hsp2io.io.IOManager(hdf5_instance)\n", "\n", "io_manager" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -966,33 +993,33 @@ "output_type": "stream", "text": [ "\u001b[0;31mType:\u001b[0m IOManager\n", - "\u001b[0;31mString form:\u001b[0m \n", - "\u001b[0;31mFile:\u001b[0m ~/Documents/Python/respec.HSPsquared/HSP2IO/io.py\n", + "\u001b[0;31mString form:\u001b[0m \n", + "\u001b[0;31mFile:\u001b[0m ~/miniconda3/envs/hsp2_py310/lib/python3.10/site-packages/hsp2/hsp2io/io.py\n", "\u001b[0;31mDocstring:\u001b[0m Management class for IO operations needed to execute the HSP2 model\n", "\u001b[0;31mInit docstring:\u001b[0m\n", - "io_combined: SupportsReadUCI & SupportsReadTS & SupportsWriteTS & SupportsWriteLogging / None \n", - " Intended to allow users with a object that combines protocols for \n", - " UCI, Input, Output and Log a shortcut where only a \n", - " single argument needs to be provided. If UCI, Input, Output and/or \n", - " Log are not specified this argument will be used as the default. \n", + "io_combined: SupportsReadUCI & SupportsReadTS & SupportsWriteTS & SupportsWriteLogging / None\n", + " Intended to allow users with a object that combines protocols for\n", + " UCI, Input, Output and Log a shortcut where only a\n", + " single argument needs to be provided. If UCI, Input, Output and/or\n", + " Log are not specified this argument will be used as the default.\n", "uci: SupportsReadUCI/None (Default None)\n", - " A class instance implementing the SupportReadUCI protocol. \n", - " This class acts as the data source for UCI information. \n", + " A class instance implementing the SupportReadUCI protocol.\n", + " This class acts as the data source for UCI information.\n", " The argument io_combined be used in place by default if this argument is not specified.\n", "input: SupportsReadUCI/None (Default None)\n", - " A class instance implementing SupportReadTS protocol. \n", - " This class acts as the data source for any input timeseries. \n", + " A class instance implementing SupportReadTS protocol.\n", + " This class acts as the data source for any input timeseries.\n", " The argument io_combined be used in place by default if this argument is not specified.\n", "output: SupportsWriteTS & SupportsReadTS / None (Default None)\n", " A class implementing SupportsWriteTS & SupportReadTS protocol\n", - " This class acts as the location for outputing result timeseries as \n", - " well as the data source should those result timeseries be needed for \n", - " inputs into a model modules. \n", + " This class acts as the location for outputing result timeseries as\n", + " well as the data source should those result timeseries be needed for\n", + " inputs into a model modules.\n", " The argument io_combined be used in place by default if this argument is not specified.\n", "log: SupportsWriteLogging/None (Default None)\n", " A class implementing SupportWriteLogging protocol. This class\n", " This class acts as the location to output logging information.\n", - " The argument io_combined be used in place by default if this argument is not specified.\n" + " The argument io_combined be used in place by default if this argument is not specified." ] } ], @@ -1019,100 +1046,99 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "2022-06-23 10:03:45.64 Processing started for file ./; saveall=False\n", - "2022-06-23 10:03:51.39 Simulation Start: 1976-01-01 00:00:00, Stop: 1977-01-01 00:00:00\n", - "2022-06-23 10:03:51.39 PERLND P001 DELT(minutes): 60\n", - "2022-06-23 10:03:53.14 SNOW\n", - "2022-06-23 10:03:54.27 PWATER\n", - "2022-06-23 10:03:54.84 PSTEMP\n", - "2022-06-23 10:03:54.85 PWTGAS\n", - "2022-06-23 10:03:54.88 RCHRES R001 DELT(minutes): 60\n", - "2022-06-23 10:03:54.91 HYDR\n", - "2022-06-23 10:03:55.17 ADCALC\n", - "2022-06-23 10:03:55.20 CONS\n", - "2022-06-23 10:03:55.53 HTRCH\n", - "2022-06-23 10:03:55.56 SEDTRN\n", - "2022-06-23 10:03:55.62 RQUAL\n", - "2022-06-23 10:03:56.53 GQUAL\n", - "2022-06-23 10:03:57.72 GENER G001 DELT(minutes): 60\n", - "GENER 'G001' encountered unsupported feature during initialization and may not function correctly. Unsupported feature: 'Invalid SVOL. GENER module does not currently support reading TimeSeries for 'RCHRES''\n", - "2022-06-23 10:03:57.72 RCHRES R002 DELT(minutes): 60\n", - "2022-06-23 10:03:57.75 HYDR\n", - "2022-06-23 10:03:57.82 ADCALC\n", - "2022-06-23 10:03:57.83 CONS\n", - "2022-06-23 10:03:57.84 HTRCH\n", - "2022-06-23 10:03:57.84 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", - "2022-06-23 10:03:57.85 SEDTRN\n", - "2022-06-23 10:03:57.86 Error count 3598: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", - "2022-06-23 10:03:57.88 RQUAL\n", - "2022-06-23 10:03:58.24 GQUAL\n", - "2022-06-23 10:03:58.98 RCHRES R003 DELT(minutes): 60\n", - "2022-06-23 10:03:59.01 HYDR\n", - "2022-06-23 10:03:59.04 ADCALC\n", - "2022-06-23 10:03:59.05 CONS\n", - "2022-06-23 10:03:59.06 HTRCH\n", - "2022-06-23 10:03:59.06 Error count 3: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", - "2022-06-23 10:03:59.07 SEDTRN\n", - "2022-06-23 10:03:59.08 Error count 513: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", - "2022-06-23 10:03:59.10 RQUAL\n", - "2022-06-23 10:03:59.43 GQUAL\n", - "2022-06-23 10:04:00.02 RCHRES R004 DELT(minutes): 60\n", - "2022-06-23 10:04:00.09 HYDR\n", - "2022-06-23 10:04:00.16 ADCALC\n", - "2022-06-23 10:04:00.17 CONS\n", - "2022-06-23 10:04:00.18 HTRCH\n", - "2022-06-23 10:04:00.18 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", - "2022-06-23 10:04:00.19 SEDTRN\n", - "2022-06-23 10:04:00.21 Error count 6720: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", - "2022-06-23 10:04:00.22 RQUAL\n", - "2022-06-23 10:04:00.59 GQUAL\n", - "2022-06-23 10:04:01.38 IMPLND I001 DELT(minutes): 60\n", - "2022-06-23 10:04:01.39 SNOW\n", - "2022-06-23 10:04:01.50 IWATER\n", - "2022-06-23 10:04:01.56 SOLIDS\n", - "2022-06-23 10:04:01.57 IWTGAS\n", - "2022-06-23 10:04:01.59 IQUAL\n", - "2022-06-23 10:04:01.61 RCHRES R005 DELT(minutes): 60\n", - "2022-06-23 10:04:01.64 HYDR\n", - "2022-06-23 10:04:01.68 ADCALC\n", - "2022-06-23 10:04:01.69 CONS\n", - "2022-06-23 10:04:01.70 HTRCH\n", - "2022-06-23 10:04:01.70 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", - "2022-06-23 10:04:01.71 SEDTRN\n", - "2022-06-23 10:04:01.73 RQUAL\n", - "2022-06-23 10:04:02.10 GQUAL\n", - "2022-06-23 10:04:02.94 GENER G002 DELT(minutes): 60\n", - "GENER 'G002' encountered unsupported feature during initialization and may not function correctly. Unsupported feature: 'Invalid SVOL. GENER module does not currently support reading TimeSeries for 'RCHRES''\n", - "2022-06-23 10:04:02.94 Done; Run time is about 00:17.2 (mm:ss)\n", + "2024-12-16 14:54:31.88 Processing started for file /Users/aaufdenkampe/Documents/Python/respec.HSPsquared/examples/_TutorialData/test10.h5; saveall=False\n", + "2024-12-16 14:54:36.00 Simulation Start: 1976-01-01 00:00:00, Stop: 1977-01-01 00:00:00\n", + "2024-12-16 14:54:36.01 PERLND P001 DELT(minutes): 60\n", + "2024-12-16 14:54:36.30 SNOW\n", + "2024-12-16 14:54:36.83 PWATER\n", + "2024-12-16 14:54:37.04 PSTEMP\n", + "2024-12-16 14:54:37.05 PWTGAS\n", + "2024-12-16 14:54:37.06 RCHRES R001 DELT(minutes): 60\n", + "2024-12-16 14:54:37.07 HYDR\n", + "2024-12-16 14:54:41.33 ADCALC\n", + "2024-12-16 14:54:41.35 CONS\n", + "2024-12-16 14:54:41.39 HTRCH\n", + "2024-12-16 14:54:41.41 SEDTRN\n", + "2024-12-16 14:54:41.43 RQUAL\n", + "2024-12-16 14:54:41.78 GQUAL\n", + "2024-12-16 14:54:42.32 GENER G001 DELT(minutes): 60\n", + "2024-12-16 14:54:42.32 RCHRES R002 DELT(minutes): 60\n", + "2024-12-16 14:54:42.33 HYDR\n", + "2024-12-16 14:54:44.85 ADCALC\n", + "2024-12-16 14:54:44.85 CONS\n", + "2024-12-16 14:54:44.86 HTRCH\n", + "2024-12-16 14:54:44.86 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", + "2024-12-16 14:54:44.86 SEDTRN\n", + "2024-12-16 14:54:44.87 Error count 3598: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", + "2024-12-16 14:54:44.87 RQUAL\n", + "2024-12-16 14:54:45.02 GQUAL\n", + "2024-12-16 14:54:45.32 RCHRES R003 DELT(minutes): 60\n", + "2024-12-16 14:54:45.33 HYDR\n", + "2024-12-16 14:54:45.35 ADCALC\n", + "2024-12-16 14:54:45.35 CONS\n", + "2024-12-16 14:54:45.36 HTRCH\n", + "2024-12-16 14:54:45.36 Error count 3: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", + "2024-12-16 14:54:45.36 SEDTRN\n", + "2024-12-16 14:54:45.37 Error count 513: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", + "2024-12-16 14:54:45.37 RQUAL\n", + "2024-12-16 14:54:45.50 GQUAL\n", + "2024-12-16 14:54:45.73 RCHRES R004 DELT(minutes): 60\n", + "2024-12-16 14:54:45.76 HYDR\n", + "2024-12-16 14:54:45.78 ADCALC\n", + "2024-12-16 14:54:45.79 CONS\n", + "2024-12-16 14:54:45.79 HTRCH\n", + "2024-12-16 14:54:45.79 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", + "2024-12-16 14:54:45.80 SEDTRN\n", + "2024-12-16 14:54:45.80 Error count 6720: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", + "2024-12-16 14:54:45.81 RQUAL\n", + "2024-12-16 14:54:45.95 GQUAL\n", + "2024-12-16 14:54:46.31 IMPLND I001 DELT(minutes): 60\n", + "2024-12-16 14:54:46.31 SNOW\n", + "2024-12-16 14:54:46.36 IWATER\n", + "2024-12-16 14:54:46.38 SOLIDS\n", + "2024-12-16 14:54:46.39 IWTGAS\n", + "2024-12-16 14:54:46.39 IQUAL\n", + "2024-12-16 14:54:46.40 RCHRES R005 DELT(minutes): 60\n", + "2024-12-16 14:54:46.41 HYDR\n", + "2024-12-16 14:54:46.43 ADCALC\n", + "2024-12-16 14:54:46.43 CONS\n", + "2024-12-16 14:54:46.44 HTRCH\n", + "2024-12-16 14:54:46.44 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", + "2024-12-16 14:54:46.44 SEDTRN\n", + "2024-12-16 14:54:46.45 RQUAL\n", + "2024-12-16 14:54:46.60 GQUAL\n", + "2024-12-16 14:54:46.97 GENER G002 DELT(minutes): 60\n", + "2024-12-16 14:54:46.97 Done; Run time is about 00:15.0 (mm:ss)\n", "\n", "\n", " version\n", - "Python 3.8.12 | packaged by conda-forge | (default, O...\n", - "HSP2 0.10.1\n", - "numpy 1.20.3\n", - "numba 0.53.1\n", - "pandas 1.2.5\n", - "jupyterlab 3.2.8\n", - "notebook 6.4.7\n", - "os macOS-10.16-x86_64-i386-64bit\n", - "processor i386\n", - "Date/Time 2022-06-23 10:04:03\n", - "CPU times: user 16.8 s, sys: 610 ms, total: 17.4 s\n", - "Wall time: 17.4 s\n" + "name \n", + "Python 3.10.16 | packaged by conda-forge | (main, Dec...\n", + "hsp2 n/a\n", + "numpy 1.26.4\n", + "numba 0.60.0\n", + "pandas 2.0.0\n", + "jupyterlab 4.3.3\n", + "notebook n/a\n", + "os macOS-14.7.1-arm64-arm-64bit\n", + "processor arm\n", + "Date/Time 2024-12-16T14:54:47.418260\n", + "CPU times: user 14.7 s, sys: 428 ms, total: 15.1 s\n", + "Wall time: 15.5 s\n" ] } ], "source": [ "%%time\n", - "# This model should take 2-4 minutes to run the first time\n", - "HSP2.main(io_manager, saveall=False)" + "# This model should take 1-4 minutes to run the first time\n", + "hsp2.main(io_manager, saveall=False)" ] }, { @@ -1132,7 +1158,7 @@ "\n", "Note the total run time before and after you rerun the model. You'll notice the model runs much faster the second time.\n", "- During the first model run, numba compiles specified code blocks, then saves the complied code.\n", - "- During all subsequent model runs, numba-compiled code is used directly, avoiding the time to compile, saving 1-2 minutes of runtime." + "- During all subsequent model runs, numba-compiled code is used directly, avoiding the time to compile, executing **~11x faster**!" ] }, { @@ -1147,7 +1173,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -1156,7 +1182,7 @@ "['/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/examples/_TutorialData/test10.h5']" ] }, - "execution_count": 17, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -1168,7 +1194,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -1178,7 +1204,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -1187,7 +1213,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -1196,7 +1222,7 @@ "['/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/examples/_TutorialData/test10.h5']" ] }, - "execution_count": 20, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -1208,14 +1234,15 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "Closing remaining open files:/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/examples/_TutorialData/test10.h5...done\n" + "/Users/aaufdenkampe/miniconda3/envs/hsp2_py310/lib/python3.10/site-packages/tables/file.py:114: UnclosedFileWarning: Closing remaining open file: /Users/aaufdenkampe/Documents/Python/respec.HSPsquared/examples/_TutorialData/test10.h5\n", + " warnings.warn(UnclosedFileWarning(msg))\n" ] } ], @@ -1226,7 +1253,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -1235,7 +1262,7 @@ "[]" ] }, - "execution_count": 22, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -1259,93 +1286,92 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "2022-06-23 10:04:03.69 Processing started for file ./; saveall=True\n", - "2022-06-23 10:04:10.12 Simulation Start: 1976-01-01 00:00:00, Stop: 1977-01-01 00:00:00\n", - "2022-06-23 10:04:10.12 PERLND P001 DELT(minutes): 60\n", - "2022-06-23 10:04:10.21 SNOW\n", - "2022-06-23 10:04:10.43 PWATER\n", - "2022-06-23 10:04:10.77 PSTEMP\n", - "2022-06-23 10:04:10.81 PWTGAS\n", - "2022-06-23 10:04:11.00 RCHRES R001 DELT(minutes): 60\n", - "2022-06-23 10:04:11.03 HYDR\n", - "2022-06-23 10:04:11.17 ADCALC\n", - "2022-06-23 10:04:11.18 CONS\n", - "2022-06-23 10:04:11.27 HTRCH\n", - "2022-06-23 10:04:11.40 SEDTRN\n", - "2022-06-23 10:04:11.74 RQUAL\n", - "2022-06-23 10:04:14.21 GQUAL\n", - "2022-06-23 10:04:16.23 GENER G001 DELT(minutes): 60\n", - "GENER 'G001' encountered unsupported feature during initialization and may not function correctly. Unsupported feature: 'Invalid SVOL. GENER module does not currently support reading TimeSeries for 'RCHRES''\n", - "2022-06-23 10:04:16.23 RCHRES R002 DELT(minutes): 60\n", - "2022-06-23 10:04:16.25 HYDR\n", - "2022-06-23 10:04:16.36 ADCALC\n", - "2022-06-23 10:04:16.37 CONS\n", - "2022-06-23 10:04:16.43 HTRCH\n", - "2022-06-23 10:04:16.44 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", - "2022-06-23 10:04:16.55 SEDTRN\n", - "2022-06-23 10:04:16.56 Error count 3598: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", - "2022-06-23 10:04:16.79 RQUAL\n", - "2022-06-23 10:04:18.75 GQUAL\n", - "2022-06-23 10:04:20.10 RCHRES R003 DELT(minutes): 60\n", - "2022-06-23 10:04:20.13 HYDR\n", - "2022-06-23 10:04:20.23 ADCALC\n", - "2022-06-23 10:04:20.24 CONS\n", - "2022-06-23 10:04:20.32 HTRCH\n", - "2022-06-23 10:04:20.32 Error count 3: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", - "2022-06-23 10:04:20.44 SEDTRN\n", - "2022-06-23 10:04:20.45 Error count 513: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", - "2022-06-23 10:04:20.73 RQUAL\n", - "2022-06-23 10:04:22.47 GQUAL\n", - "2022-06-23 10:04:23.67 RCHRES R004 DELT(minutes): 60\n", - "2022-06-23 10:04:23.74 HYDR\n", - "2022-06-23 10:04:23.85 ADCALC\n", - "2022-06-23 10:04:23.86 CONS\n", - "2022-06-23 10:04:23.92 HTRCH\n", - "2022-06-23 10:04:23.93 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", - "2022-06-23 10:04:24.04 SEDTRN\n", - "2022-06-23 10:04:24.06 Error count 6720: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", - "2022-06-23 10:04:24.31 RQUAL\n", - "2022-06-23 10:04:26.15 GQUAL\n", - "2022-06-23 10:04:27.62 IMPLND I001 DELT(minutes): 60\n", - "2022-06-23 10:04:27.63 SNOW\n", - "2022-06-23 10:04:27.84 IWATER\n", - "2022-06-23 10:04:27.94 SOLIDS\n", - "2022-06-23 10:04:27.97 IWTGAS\n", - "2022-06-23 10:04:28.03 IQUAL\n", - "2022-06-23 10:04:28.14 RCHRES R005 DELT(minutes): 60\n", - "2022-06-23 10:04:28.17 HYDR\n", - "2022-06-23 10:04:28.28 ADCALC\n", - "2022-06-23 10:04:28.28 CONS\n", - "2022-06-23 10:04:28.35 HTRCH\n", - "2022-06-23 10:04:28.36 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", - "2022-06-23 10:04:28.47 SEDTRN\n", - "2022-06-23 10:04:28.73 RQUAL\n", - "2022-06-23 10:04:30.57 GQUAL\n", - "2022-06-23 10:04:31.98 GENER G002 DELT(minutes): 60\n", - "GENER 'G002' encountered unsupported feature during initialization and may not function correctly. Unsupported feature: 'Invalid SVOL. GENER module does not currently support reading TimeSeries for 'RCHRES''\n", - "2022-06-23 10:04:31.98 Done; Run time is about 00:28.2 (mm:ss)\n", + "2024-12-16 14:54:47.46 Processing started for file /Users/aaufdenkampe/Documents/Python/respec.HSPsquared/examples/_TutorialData/test10.h5; saveall=True\n", + "2024-12-16 14:54:49.73 Simulation Start: 1976-01-01 00:00:00, Stop: 1977-01-01 00:00:00\n", + "2024-12-16 14:54:49.73 PERLND P001 DELT(minutes): 60\n", + "2024-12-16 14:54:49.76 SNOW\n", + "2024-12-16 14:54:49.83 PWATER\n", + "2024-12-16 14:54:49.94 PSTEMP\n", + "2024-12-16 14:54:49.96 PWTGAS\n", + "2024-12-16 14:54:50.03 RCHRES R001 DELT(minutes): 60\n", + "2024-12-16 14:54:50.04 HYDR\n", + "2024-12-16 14:54:50.11 ADCALC\n", + "2024-12-16 14:54:50.11 CONS\n", + "2024-12-16 14:54:50.14 HTRCH\n", + "2024-12-16 14:54:50.19 SEDTRN\n", + "2024-12-16 14:54:50.30 RQUAL\n", + "2024-12-16 14:54:51.13 GQUAL\n", + "2024-12-16 14:54:51.85 GENER G001 DELT(minutes): 60\n", + "2024-12-16 14:54:51.85 RCHRES R002 DELT(minutes): 60\n", + "2024-12-16 14:54:51.86 HYDR\n", + "2024-12-16 14:54:51.91 ADCALC\n", + "2024-12-16 14:54:51.92 CONS\n", + "2024-12-16 14:54:51.94 HTRCH\n", + "2024-12-16 14:54:51.94 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", + "2024-12-16 14:54:51.98 SEDTRN\n", + "2024-12-16 14:54:51.99 Error count 3598: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", + "2024-12-16 14:54:52.07 RQUAL\n", + "2024-12-16 14:54:52.63 GQUAL\n", + "2024-12-16 14:54:53.11 RCHRES R003 DELT(minutes): 60\n", + "2024-12-16 14:54:53.13 HYDR\n", + "2024-12-16 14:54:53.18 ADCALC\n", + "2024-12-16 14:54:53.18 CONS\n", + "2024-12-16 14:54:53.20 HTRCH\n", + "2024-12-16 14:54:53.20 Error count 3: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", + "2024-12-16 14:54:53.24 SEDTRN\n", + "2024-12-16 14:54:53.24 Error count 513: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", + "2024-12-16 14:54:53.32 RQUAL\n", + "2024-12-16 14:54:53.85 GQUAL\n", + "2024-12-16 14:54:54.24 RCHRES R004 DELT(minutes): 60\n", + "2024-12-16 14:54:54.26 HYDR\n", + "2024-12-16 14:54:54.32 ADCALC\n", + "2024-12-16 14:54:54.32 CONS\n", + "2024-12-16 14:54:54.35 HTRCH\n", + "2024-12-16 14:54:54.35 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", + "2024-12-16 14:54:54.39 SEDTRN\n", + "2024-12-16 14:54:54.40 Error count 6720: SEDTRN: Warning -- bed storage of sediment size fraction sand is empty\n", + "2024-12-16 14:54:54.48 RQUAL\n", + "2024-12-16 14:54:55.07 GQUAL\n", + "2024-12-16 14:54:55.58 IMPLND I001 DELT(minutes): 60\n", + "2024-12-16 14:54:55.59 SNOW\n", + "2024-12-16 14:54:55.66 IWATER\n", + "2024-12-16 14:54:55.69 SOLIDS\n", + "2024-12-16 14:54:55.70 IWTGAS\n", + "2024-12-16 14:54:55.72 IQUAL\n", + "2024-12-16 14:54:55.75 RCHRES R005 DELT(minutes): 60\n", + "2024-12-16 14:54:55.76 HYDR\n", + "2024-12-16 14:54:55.82 ADCALC\n", + "2024-12-16 14:54:55.82 CONS\n", + "2024-12-16 14:54:55.85 HTRCH\n", + "2024-12-16 14:54:55.85 Error count 1: HTRCH: Water temperature is above 66 C (150 F) -- In most cases, this indicates an instability in advection\n", + "2024-12-16 14:54:55.89 SEDTRN\n", + "2024-12-16 14:54:55.98 RQUAL\n", + "2024-12-16 14:54:56.58 GQUAL\n", + "2024-12-16 14:54:57.10 GENER G002 DELT(minutes): 60\n", + "2024-12-16 14:54:57.11 Done; Run time is about 00:09.6 (mm:ss)\n", "\n", "\n", " version\n", - "Python 3.8.12 | packaged by conda-forge | (default, O...\n", - "HSP2 0.10.1\n", - "numpy 1.20.3\n", - "numba 0.53.1\n", - "pandas 1.2.5\n", - "jupyterlab 3.2.8\n", - "notebook 6.4.7\n", - "os macOS-10.16-x86_64-i386-64bit\n", - "processor i386\n", - "Date/Time 2022-06-23 10:04:32\n", - "CPU times: user 26.5 s, sys: 1.7 s, total: 28.2 s\n", - "Wall time: 28.4 s\n" + "name \n", + "Python 3.10.16 | packaged by conda-forge | (main, Dec...\n", + "hsp2 n/a\n", + "numpy 1.26.4\n", + "numba 0.60.0\n", + "pandas 2.0.0\n", + "jupyterlab 4.3.3\n", + "notebook n/a\n", + "os macOS-14.7.1-arm64-arm-64bit\n", + "processor arm\n", + "Date/Time 2024-12-16T14:54:57.117542\n", + "CPU times: user 9.23 s, sys: 491 ms, total: 9.73 s\n", + "Wall time: 9.67 s\n" ] } ], @@ -1354,14 +1380,14 @@ "# Setup IO Manager and run the model, as recommended,\n", "# all within a Python `with` statement as a context manager\n", "\n", - "with HSP2IO.hdf.HDF5(output_hdf5_path) as hdf5_instance:\n", - " io_manager = HSP2IO.io.IOManager(hdf5_instance)\n", - " HSP2.main(io_manager, saveall=True)" + "with hsp2io.hdf.HDF5(output_hdf5_path) as hdf5_instance:\n", + " io_manager = hsp2io.io.IOManager(hdf5_instance)\n", + " hsp2.main(io_manager, saveall=True)" ] }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -1370,7 +1396,7 @@ "[]" ] }, - "execution_count": 24, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -1393,11 +1419,8 @@ } ], "metadata": { - "interpreter": { - "hash": "776e005896af2bdd35b514f04d0649047a67df21e3539ef9c16d2c229e31ef47" - }, "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "hsp2_py310", "language": "python", "name": "python3" }, @@ -1411,7 +1434,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.10.16" }, "toc-autonumbering": true, "toc-showmarkdowntxt": false diff --git a/src/hsp2/hsp2/__init__.py b/src/hsp2/hsp2/__init__.py index 695a77b0..9112f6cc 100644 --- a/src/hsp2/hsp2/__init__.py +++ b/src/hsp2/hsp2/__init__.py @@ -9,4 +9,5 @@ from hsp2.hsp2.mainDoE import main as mainDoE from hsp2.hsp2.utilities import flowtype, versions -__version__ = version("hsp2") +# __version__ = version("hsp2") +# from _version import __version__ diff --git a/src/hsp2/hsp2tools/__init__.py b/src/hsp2/hsp2tools/__init__.py index 3abb0e8d..30f105d8 100644 --- a/src/hsp2/hsp2tools/__init__.py +++ b/src/hsp2/hsp2tools/__init__.py @@ -14,5 +14,3 @@ from .readUCI import readUCI from .readWDM import readWDM from .restart import restart - -__version__ = version("hsp2")