From 394ce529c581e64ad28e482d1d2b7ed452b1a63d Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:38:38 -0500 Subject: [PATCH 01/13] update dependencies --- environment.yml | 1 + pyproject.toml | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/environment.yml b/environment.yml index e136b109..f8c2c32d 100644 --- a/environment.yml +++ b/environment.yml @@ -40,6 +40,7 @@ dependencies: - shapely - spotpy - statsmodels + - typing_extensions - xarray >=2022.12.0,<2023.9.0 # xarray v2023.9.0 is incompatible with xclim<=0.45.0 - xclim >=0.43 - xesmf diff --git a/pyproject.toml b/pyproject.toml index a4581320..fe6854b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ dependencies = [ "pandas<2.0; python_version == '3.8'", "pandas; python_version >= '3.9'", "pint>=0.20", + "platformdirs", "pydantic>=2.0", "pymbolic", "raven-hydro==0.2.4", @@ -57,6 +58,7 @@ dependencies = [ "scipy", "spotpy", "statsmodels", + "typing-extensions", "xarray>=2022.12.0,<2023.9.0", # xarray v2023.9.0 is incompatible with xclim<=0.45.0 "xclim>=0.43.0", "xskillscore" @@ -75,7 +77,6 @@ dev = [ "hvplot", "isort", "mypy", - "platformdirs", "pre-commit", "pytest", "pytest-cov", @@ -105,7 +106,6 @@ docs = [ "myst_nb", "nbsphinx", "numpydoc", - "pandoc", "pymetalink", "salib", "s3fs", @@ -119,7 +119,7 @@ docs = [ gis = [ "affine", "fiona>=1.9", - "geopandas>=0.9.0", + "geopandas>=0.13.0", "gdal", "lxml", "pyogrio", From 842c36e4b46ae763ad70fc583bc3e9556ba3aca2 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:39:28 -0500 Subject: [PATCH 02/13] update pydantic --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index f8c2c32d..588c60ac 100644 --- a/environment.yml +++ b/environment.yml @@ -29,7 +29,7 @@ dependencies: - pint >=0.20 - platformdirs - pre-commit - - pydantic >=1.10.8,<2.0 + - pydantic >=2.0 - pymbolic - pyogrio - pyproj >=3.0 From 37406e72132cd5af4eb7182f6d38480bff3f8939 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:43:27 -0500 Subject: [PATCH 03/13] update readthedocs dependencies and update sed call in main.yml --- .github/workflows/main.yml | 2 +- docs/conf.py | 21 +++++++++++++-------- environment-rtd.yml | 5 +++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f31346de..aa37e332 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -117,7 +117,7 @@ jobs: - name: Patch Environment File if: matrix.os == 'windows-latest' run: | - sed -i 's/climpred >=2.2.0/xesmf/' environment.yml + sed -i 's/climpred >=2.4.0/xesmf/' environment.yml - name: Setup Conda (Micromamba) with Python${{ matrix.python-version }} uses: mamba-org/setup-micromamba@v1 with: diff --git a/docs/conf.py b/docs/conf.py index b82a6dcc..74a8a766 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -52,7 +52,7 @@ linkcheck_ignore = [ r"https://www.ouranos.ca", # bad ssl certificate # Added on 2023-03-06: Wiley does not allow linkcheck requests (error 403) - r"https://doi.org/10.1029/2020WR029229" + r"https://doi.org/10.1029/2020WR029229", ] nbsphinx_custom_formats = { @@ -68,7 +68,7 @@ nb_execution_excludepatterns = [ "configuration.md", "notebooks/*.ipynb", - "notebooks/paper/*.ipynb" + "notebooks/paper/*.ipynb", ] # nbsphinx_execute = "auto" @@ -94,6 +94,7 @@ "clisops", "fiona", "gdal", + "h5netcdf", "netCDF4", "osgeo", "geopandas", @@ -150,8 +151,15 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".jupyter_cache", "jupyter_execute", "notebooks/paper", - "notebooks/HydroShare_integration.ipynb", ] +exclude_patterns = [ + "_build", + "Thumbs.db", + ".DS_Store", + ".jupyter_cache", + "jupyter_execute", + "notebooks/paper", + "notebooks/HydroShare_integration.ipynb", +] # The name of the Pygments (syntax highlighting) style to use. pygments_style = "sphinx" @@ -160,10 +168,7 @@ todo_include_todos = False # Suppress "WARNING: unknown mimetype for ..." when building EPUB. -suppress_warnings = [ - "epub.unknown_project_files", - "mystnb.unknown_mime_type" -] +suppress_warnings = ["epub.unknown_project_files", "mystnb.unknown_mime_type"] # -- Options for HTML output ------------------------------------------- diff --git a/environment-rtd.yml b/environment-rtd.yml index dd8882a3..ef166c67 100644 --- a/environment-rtd.yml +++ b/environment-rtd.yml @@ -22,7 +22,7 @@ dependencies: # - netCDF4 # mocked - notebook - pandoc - - pydantic >=1.10.8,<2.0 + - pydantic >2.0 - salib - seaborn - sphinx @@ -30,7 +30,8 @@ dependencies: - sphinx-click - sphinx-codeautolink - sphinx-copybutton - - sphinx_rtd_theme >=1.0 + - sphinx-rtd-theme >=1.0 - sphinxcontrib-napoleon + - typing_extensions - wheel # - xarray # mocked From 7822d30f5d6b4d4c336c64cd8cf69a34f74670b2 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:46:11 -0500 Subject: [PATCH 04/13] re-enable autodoc-pydantic --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 74a8a766..bdf6932f 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,7 +46,7 @@ "sphinx_click", "sphinx_codeautolink", "sphinx_copybutton", - # "sphinxcontrib.autodoc_pydantic", + "sphinxcontrib.autodoc_pydantic", ] linkcheck_ignore = [ From 52cb17050c555c1caee0be2384188d861c7fdddb Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 12 Jan 2024 10:50:09 -0500 Subject: [PATCH 05/13] typo fix --- environment-rtd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment-rtd.yml b/environment-rtd.yml index ef166c67..c3f9b26f 100644 --- a/environment-rtd.yml +++ b/environment-rtd.yml @@ -22,7 +22,7 @@ dependencies: # - netCDF4 # mocked - notebook - pandoc - - pydantic >2.0 + - pydantic >=2.0 - salib - seaborn - sphinx From 66c5e52487e26754394d26a620739efba87c8809 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 12 Jan 2024 11:10:52 -0500 Subject: [PATCH 06/13] disable autodoc-pydantic --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index bdf6932f..32cc0e07 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,7 +46,7 @@ "sphinx_click", "sphinx_codeautolink", "sphinx_copybutton", - "sphinxcontrib.autodoc_pydantic", + # "sphinxcontrib.autodoc_pydantic", # FIXME: Does not seem to be compatible with RavenPy codebase. ] linkcheck_ignore = [ From 854414bec467ee14f2a8347f94e0dec62625d034 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:12:11 -0500 Subject: [PATCH 07/13] fix some test data loading --- tests/test_cli.py | 105 ++++++++++++++++++++++++++++++++++++---------- tox.ini | 1 + 2 files changed, 84 insertions(+), 22 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 99ddf4b8..dd39a2f5 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,4 +1,5 @@ import re +from shutil import copyfile import netCDF4 as nc4 from click.testing import CliRunner @@ -13,6 +14,16 @@ def test_generate_grid_weights_with_nc_input_and_2d_coords( ): runner = CliRunner() output_path = tmp_path / "bla.rvt" + + copyfile( + get_local_testdata("raven-routing-sample/VIC_streaminputs.nc"), + tmp_path / "VIC_streaminputs.nc", + ) + copyfile( + get_local_testdata("raven-routing-sample/finalcat_hru_info.zip"), + tmp_path / "finalcat_hru_info.zip", + ) + params = [ "-c", "HRU_ID", @@ -21,8 +32,8 @@ def test_generate_grid_weights_with_nc_input_and_2d_coords( "lat", "-o", output_path, - get_local_testdata("raven-routing-sample/VIC_streaminputs.nc"), - get_local_testdata("raven-routing-sample/finalcat_hru_info.zip"), + tmp_path / "VIC_streaminputs.nc", + tmp_path / "finalcat_hru_info.zip", ] params = list(map(str, params)) @@ -48,13 +59,19 @@ def test_generate_grid_weights_with_multiple_subids( # needs a "routing-file-path" with multiple gauges runner = CliRunner() output_path = tmp_path / "bla.rvt" + + copyfile( + get_local_testdata("raven-routing-sample/VIC_streaminputs.nc"), + tmp_path / "VIC_streaminputs.nc", + ) + copyfile( + get_local_testdata("raven-routing-sample/finalcat_hru_info.zip"), + tmp_path / "finalcat_hru_info.zip", + ) + params = [ - get_local_testdata( - "raven-routing-sample/VIC_streaminputs.nc", - ), - get_local_testdata( - "raven-routing-sample/finalcat_hru_info.zip", - ), + tmp_path / "VIC_streaminputs.nc", + tmp_path / "finalcat_hru_info.zip", "-c", "HRU_ID", "-v", @@ -89,13 +106,19 @@ def test_generate_grid_weights_with_nc_input_and_1d_coords( ): runner = CliRunner() output_path = tmp_path / "bla.rvt" + + copyfile( + get_local_testdata("raven-routing-sample/era5-test-dataset-crop.nc"), + tmp_path / "era5-test-dataset-crop.nc", + ) + copyfile( + get_local_testdata("raven-routing-sample/finalcat_hru_info.zip"), + tmp_path / "finalcat_hru_info.zip", + ) + params = [ - get_local_testdata( - "raven-routing-sample/era5-test-dataset-crop.nc", - ), - get_local_testdata( - "raven-routing-sample/finalcat_hru_info.zip", - ), + tmp_path / "era5-test-dataset-crop.nc", + tmp_path / "finalcat_hru_info.zip", "--var-names", "longitude", "latitude", @@ -124,13 +147,23 @@ def test_generate_grid_weights_with_nc_input_and_1d_coords( def test_generate_grid_weights_with_shp_input(self, tmp_path, get_local_testdata): runner = CliRunner() output_path = tmp_path / "bla.rvt" + + copyfile( + get_local_testdata("raven-routing-sample/OTT_sub.zip"), + tmp_path / "OTT_sub.zip", + ) + copyfile( + get_local_testdata("raven-routing-sample/finalcat_hru_info.zip"), + tmp_path / "finalcat_hru_info.zip", + ) + params = [ "-c", "HRU_ID", "-o", output_path, - get_local_testdata("raven-routing-sample/OTT_sub.zip"), - get_local_testdata("raven-routing-sample/finalcat_hru_info.zip"), + tmp_path / "OTT_sub.zip", + tmp_path / "finalcat_hru_info.zip", ] params = map(str, params) @@ -154,6 +187,16 @@ def test_generate_grid_weights_with_weight_rescaling( ): runner = CliRunner() output_path = tmp_path / "bla.rvt" + + copyfile( + get_local_testdata("raven-routing-sample/OTT_sub.zip"), + tmp_path / "OTT_sub.zip", + ) + copyfile( + get_local_testdata("raven-routing-sample/finalcat_hru_info.zip"), + tmp_path / "finalcat_hru_info.zip", + ) + params = [ "--area-error-threshold", "0.42", @@ -161,10 +204,8 @@ def test_generate_grid_weights_with_weight_rescaling( "HRU_ID", "-o", output_path, - get_local_testdata("raven-routing-sample/OTT_sub.zip"), - get_local_testdata( - "raven-routing-sample/finalcat_hru_info.zip", - ), + tmp_path / "OTT_sub.zip", + tmp_path / "finalcat_hru_info.zip", ] params = map(str, params) @@ -189,13 +230,23 @@ def test_aggregate_forcings_to_hrus(self, tmp_path, get_local_testdata): runner = CliRunner() output_nc_file_path = tmp_path / "aggreg.nc" output_weight_file_path = tmp_path / "weight_aggreg.rvt" - params = [ + + copyfile( get_local_testdata( "raven-routing-sample/VIC_streaminputs.nc", ), + tmp_path / "VIC_streaminputs.nc", + ) + copyfile( get_local_testdata( "raven-routing-sample/VIC_streaminputs_weights.rvt", ), + tmp_path / "VIC_streaminputs_weights.rvt", + ) + + params = [ + tmp_path / "VIC_streaminputs.nc", + tmp_path / "VIC_streaminputs_weights.rvt", "-v", "Streaminputs", "--output-nc-file", @@ -243,9 +294,19 @@ def test_aggregate_forcings_to_hrus_with_nodata(self, tmp_path, get_local_testda runner = CliRunner() output_nc_file_path = tmp_path / "aggreg.nc" output_weight_file_path = tmp_path / "weight_aggreg.rvt" - params = [ + + copyfile( get_local_testdata("raven-routing-sample/VIC_test_nodata.nc"), + tmp_path / "VIC_test_nodata.nc", + ) + copyfile( get_local_testdata("raven-routing-sample/VIC_test_nodata_weights.rvt"), + tmp_path / "VIC_test_nodata_weights.rvt", + ) + + params = [ + tmp_path / "VIC_test_nodata.nc", + tmp_path / "VIC_test_nodata_weights.rvt", "-v", "et", "--dim-names", diff --git a/tox.ini b/tox.ini index b2c6a2aa..0164f7a1 100644 --- a/tox.ini +++ b/tox.ini @@ -39,6 +39,7 @@ passenv = COVERALLS_* GDAL_VERSION GITHUB_* + LD_LIBRARY_PATH LD_PRELOAD RAVENPY_* extras = From 7b7ffbf4b451dc463b54efcef2a00eb7b0ccf1b8 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 12 Jan 2024 13:29:43 -0500 Subject: [PATCH 08/13] fix error message --- ravenpy/extractors/routing_product.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ravenpy/extractors/routing_product.py b/ravenpy/extractors/routing_product.py index 725d6a4b..f0802f04 100644 --- a/ravenpy/extractors/routing_product.py +++ b/ravenpy/extractors/routing_product.py @@ -31,7 +31,7 @@ def open_shapefile(path: Union[str, os.PathLike]): elif isinstance(path, geopandas.GeoDataFrame): df = path else: - raise NotImplementedError + raise NotImplementedError(path) return df From 3d47ce5e8685658dacc72862eaaabc00b7211199 Mon Sep 17 00:00:00 2001 From: Trevor James Smith <10819524+Zeitsperre@users.noreply.github.com> Date: Fri, 12 Jan 2024 14:09:20 -0500 Subject: [PATCH 09/13] add single-threaded conda test --- .github/workflows/main.yml | 11 ++++++++++- tox.ini | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa37e332..95e1f556 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -103,12 +103,16 @@ jobs: include: - os: ubuntu-latest python-version: "3.9" + xdist: false - os: ubuntu-latest python-version: "3.10" + xdist: true - os: ubuntu-latest python-version: "3.11" + xdist: true - os: macos-latest python-version: "3.9" + xdist: true defaults: run: shell: bash -l {0} @@ -138,7 +142,12 @@ jobs: - name: List installed packages run: | conda list - - name: Test RavenPy + - name: Test RavenPy (single-threaded) + if: matrix.xdist == false + run: | + pytest --cov --numprocesses=0 + - name: Test RavenPy (multi-threaded) + if: matrix.xdist == true run: | pytest --cov --numprocesses=logical - name: Report coverage diff --git a/tox.ini b/tox.ini index 0164f7a1..101a85ce 100644 --- a/tox.ini +++ b/tox.ini @@ -34,6 +34,7 @@ platform = macos: darwin setenv = PYTEST_ADDOPTS = --numprocesses=logical --durations=10 + PYTHONPATH = {toxinidir} passenv = CI COVERALLS_* From 54458d02b066bca1a56a724e74329e12fdf6acef Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 8 Feb 2024 10:57:00 -0500 Subject: [PATCH 10/13] always use pytest-xdist --- .github/workflows/main.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 95e1f556..aa37e332 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -103,16 +103,12 @@ jobs: include: - os: ubuntu-latest python-version: "3.9" - xdist: false - os: ubuntu-latest python-version: "3.10" - xdist: true - os: ubuntu-latest python-version: "3.11" - xdist: true - os: macos-latest python-version: "3.9" - xdist: true defaults: run: shell: bash -l {0} @@ -142,12 +138,7 @@ jobs: - name: List installed packages run: | conda list - - name: Test RavenPy (single-threaded) - if: matrix.xdist == false - run: | - pytest --cov --numprocesses=0 - - name: Test RavenPy (multi-threaded) - if: matrix.xdist == true + - name: Test RavenPy run: | pytest --cov --numprocesses=logical - name: Report coverage From 7577c99057e44ecb727612f1d2979682faed91a7 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:01:36 -0500 Subject: [PATCH 11/13] pin linting tool versions --- .pre-commit-config.yaml | 14 +++++++------- environment.yml | 3 +++ pyproject.toml | 6 +++--- tox.ini | 5 +++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 01d1d8c5..80c806ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,12 +32,12 @@ repos: hooks: - id: toml-sort-fix - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black exclude: ^docs/ - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 args: [ '--config=setup.cfg' ] @@ -52,11 +52,11 @@ repos: args: [ '--py38-plus' ] additional_dependencies: [ 'pyupgrade==3.15.0' ] - id: nbqa-black - additional_dependencies: [ 'black==23.12.1' ] + additional_dependencies: [ 'black==24.1.1' ] - id: nbqa-isort additional_dependencies: [ 'isort==5.13.2' ] - repo: https://github.com/kynan/nbstripout - rev: 0.6.1 + rev: 0.7.1 hooks: - id: nbstripout files: ".ipynb" @@ -70,14 +70,14 @@ repos: rev: v0.3.9 hooks: - id: blackdoc - additional_dependencies: [ 'black==23.12.1' ] + additional_dependencies: [ 'black==24.1.1' ] - repo: https://github.com/adrienverge/yamllint.git - rev: v1.33.0 + rev: v1.34.0 hooks: - id: yamllint args: [ '--config-file=.yamllint.yaml' ] - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.27.3 + rev: 0.28.0 hooks: - id: check-github-workflows - id: check-readthedocs diff --git a/environment.yml b/environment.yml index 588c60ac..07433fe0 100644 --- a/environment.yml +++ b/environment.yml @@ -7,12 +7,14 @@ dependencies: - raven-hydro ==0.2.4 - libgcc # for mixing raven-hydro from PyPI with conda environments - affine + - black >=24.1.1 - cftime - cf_xarray - click - climpred >=2.4.0 - dask - fiona >=1.9 + - flake8 >=7.0.0 - flit - gdal >=3.1 - geopandas >=0.13.0 @@ -20,6 +22,7 @@ dependencies: - haversine - holoviews - hvplot + - isort >=5.13.2 - lxml - matplotlib - netcdf4 diff --git a/pyproject.toml b/pyproject.toml index fe6854b8..ce39e027 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,16 +66,16 @@ dependencies = [ [project.optional-dependencies] dev = [ - "black>=23.3.0", + "black>=24.1.1", "bump2version", "coverage", "coveralls", "filelock", - "flake8", + "flake8>=7.0.0", "flit", "holoviews", "hvplot", - "isort", + "isort>=5.13.2", "mypy", "pre-commit", "pytest", diff --git a/tox.ini b/tox.ini index 101a85ce..89d6a601 100644 --- a/tox.ini +++ b/tox.ini @@ -13,8 +13,9 @@ opts = [testenv:black] skip_install = True deps = - flake8 - black + flake8 >=7.0.0 + black >=24.1.1 + isort >=5.13.2 commands = make lint allowlist_externals = From 2138216ecf646b1f1593b1d2fb41ebf9214da8ea Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:03:26 -0500 Subject: [PATCH 12/13] run pre-commit hooks --- docs/notebooks/06_Raven_calibration.ipynb | 30 +++++++++---------- .../Assess_probabilistic_flood_risk.ipynb | 26 ++++++++-------- .../Managing_Jupyter_Environments.ipynb | 16 +++++----- ravenpy/config/rvs.py | 6 ++-- ravenpy/utilities/forecasting.py | 6 ++-- ravenpy/utilities/geoserver.py | 1 + ravenpy/utilities/graphs.py | 1 + ravenpy/utilities/io.py | 3 +- ravenpy/utilities/mk_test.py | 1 + ravenpy/utilities/nb_graphs.py | 1 + ravenpy/utilities/testdata.py | 1 + 11 files changed, 49 insertions(+), 43 deletions(-) diff --git a/docs/notebooks/06_Raven_calibration.ipynb b/docs/notebooks/06_Raven_calibration.ipynb index 668de93f..289cf21f 100644 --- a/docs/notebooks/06_Raven_calibration.ipynb +++ b/docs/notebooks/06_Raven_calibration.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "4a5f03fb", + "id": "0", "metadata": {}, "source": [ "# 06 - Calibration of a Raven hydrological model" @@ -10,7 +10,7 @@ }, { "cell_type": "markdown", - "id": "d1ce69fb", + "id": "1", "metadata": {}, "source": [ "## Calibration of a Raven model\n", @@ -23,7 +23,7 @@ { "cell_type": "code", "execution_count": null, - "id": "565a7b6c", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -38,7 +38,7 @@ }, { "cell_type": "markdown", - "id": "cbfe7818", + "id": "3", "metadata": {}, "source": [ "## Preparing the model to be calibrated on a given watershed\n", @@ -48,7 +48,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bf6a2500", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -65,7 +65,7 @@ }, { "cell_type": "markdown", - "id": "e5611922", + "id": "5", "metadata": {}, "source": [ "The process is very similar to setting up a hydrological model. We first need to create the model with its configuration. We must provide the same information as before, except for the model parameters since those need to be calibrated." @@ -74,7 +74,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2105f6ea", + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -129,7 +129,7 @@ }, { "cell_type": "markdown", - "id": "40c8371c", + "id": "7", "metadata": {}, "source": [ "## Spotpy Calibration\n", @@ -140,7 +140,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c089720", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -160,7 +160,7 @@ }, { "cell_type": "markdown", - "id": "2b6351b2", + "id": "9", "metadata": {}, "source": [ "Now that the model is setup and configured and that `SpotSetup` object exists, we need to create a sampler from `spotpy` module which will optimize the hydrological model paramaters. You can see that we are using the DDS algorithm to optimize the parameters:\n", @@ -175,7 +175,7 @@ { "cell_type": "code", "execution_count": null, - "id": "77d168a1", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -197,7 +197,7 @@ }, { "cell_type": "markdown", - "id": "f789c674", + "id": "11", "metadata": {}, "source": [ "## Analysing the calibration results\n", @@ -207,7 +207,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ae1fc2c4", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -234,7 +234,7 @@ }, { "cell_type": "markdown", - "id": "d22ea8c6-173d-44e9-82c2-cf87a0227180", + "id": "13", "metadata": {}, "source": [ "## Next steps\n", @@ -244,7 +244,7 @@ }, { "cell_type": "markdown", - "id": "c4655f07", + "id": "14", "metadata": {}, "source": [ "## List of Model-Boundaries\n", diff --git a/docs/notebooks/Assess_probabilistic_flood_risk.ipynb b/docs/notebooks/Assess_probabilistic_flood_risk.ipynb index d8642d5c..a8cb349e 100644 --- a/docs/notebooks/Assess_probabilistic_flood_risk.ipynb +++ b/docs/notebooks/Assess_probabilistic_flood_risk.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "chinese-dealer", + "id": "0", "metadata": {}, "source": [ "# Probabilistic flood risk assessment\n", @@ -13,7 +13,7 @@ { "cell_type": "code", "execution_count": null, - "id": "79d923bd-4ce5-41f1-a441-f439b23fc388", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": null, - "id": "descending-bedroom", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -43,7 +43,7 @@ }, { "cell_type": "markdown", - "id": "genuine-dodge", + "id": "3", "metadata": {}, "source": [ "Perform the time series analysis on observed data for the catchment using the frequency analysis WPS capabilities." @@ -52,7 +52,7 @@ { "cell_type": "code", "execution_count": null, - "id": "quiet-queens", + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -71,7 +71,7 @@ { "cell_type": "code", "execution_count": null, - "id": "appointed-toner", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -96,7 +96,7 @@ }, { "cell_type": "markdown", - "id": "explicit-accent", + "id": "6", "metadata": {}, "source": [ "## Probabilistic forecast\n", @@ -107,7 +107,7 @@ { "cell_type": "code", "execution_count": null, - "id": "excessive-apparatus", + "id": "7", "metadata": { "pycharm": { "is_executing": true @@ -172,7 +172,7 @@ }, { "cell_type": "markdown", - "id": "8308cde3", + "id": "8", "metadata": {}, "source": [ "Now that the configuration is ready, launch the ESP forecasting tool to generate an ensemble hydrological forecast:" @@ -181,7 +181,7 @@ { "cell_type": "code", "execution_count": null, - "id": "0c0b126a", + "id": "9", "metadata": { "pycharm": { "is_executing": true @@ -201,7 +201,7 @@ { "cell_type": "code", "execution_count": null, - "id": "embedded-patrol", + "id": "10", "metadata": { "pycharm": { "is_executing": true @@ -220,7 +220,7 @@ { "cell_type": "code", "execution_count": null, - "id": "british-bunch", + "id": "11", "metadata": { "pycharm": { "is_executing": true @@ -247,7 +247,7 @@ }, { "cell_type": "markdown", - "id": "surface-constitutional", + "id": "12", "metadata": {}, "source": [ "### Results analysis\n", diff --git a/docs/notebooks/Managing_Jupyter_Environments.ipynb b/docs/notebooks/Managing_Jupyter_Environments.ipynb index d4414954..c82b7c66 100644 --- a/docs/notebooks/Managing_Jupyter_Environments.ipynb +++ b/docs/notebooks/Managing_Jupyter_Environments.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "4f561d83-4d79-4896-a4d5-723dadf9dceb", + "id": "0", "metadata": {}, "source": [ "# Managing Jupyter Environments\n", @@ -16,7 +16,7 @@ { "cell_type": "code", "execution_count": null, - "id": "df83766d-036e-4685-b90b-7c2887967eba", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ }, { "cell_type": "markdown", - "id": "121d9b5e-23b0-4948-8acb-616602c3df02", + "id": "2", "metadata": {}, "source": [ "This has failed because the package is not currently installed. Let's install it using mamba. The same command can be used with pip, simply replace \"mamba\" with \"pip\"." @@ -37,7 +37,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a29b12d8-4e9e-4aeb-abf9-9096dd6e24a5", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -49,7 +49,7 @@ }, { "cell_type": "markdown", - "id": "b5b07347-c7e2-48ee-b525-6cd3bd0bff51", + "id": "4", "metadata": {}, "source": [ "We can now import the newly installed package:" @@ -58,7 +58,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5a82d19e-79e6-4529-9b3b-a6fc5d2a4b60", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -68,7 +68,7 @@ }, { "cell_type": "markdown", - "id": "88cc7291-d5b4-4df7-9746-d0183380be3a", + "id": "6", "metadata": {}, "source": [ "## Resetting the environment\n", @@ -83,7 +83,7 @@ }, { "cell_type": "markdown", - "id": "e67814b2-d84a-47dd-8c34-a02d6b7903c3", + "id": "7", "metadata": {}, "source": [ "## Exporting your environment\n", diff --git a/ravenpy/config/rvs.py b/ravenpy/config/rvs.py index 60851535..9478b520 100644 --- a/ravenpy/config/rvs.py +++ b/ravenpy/config/rvs.py @@ -201,9 +201,9 @@ class RVH(RV): sub_basin_properties: Optional[rc.SubBasinProperties] = optfield( alias="SubBasinProperties" ) - sb_group_property_multiplier: Optional[ - Sequence[rc.SBGroupPropertyMultiplier] - ] = optfield(alias="SBGroupPropertyMultiplier") + sb_group_property_multiplier: Optional[Sequence[rc.SBGroupPropertyMultiplier]] = ( + optfield(alias="SBGroupPropertyMultiplier") + ) hrus: Optional[rc.HRUs] = optfield(alias="HRUs") hru_group: Optional[Sequence[rc.HRUGroup]] = optfield(alias="HRUGroup") reservoirs: Optional[Sequence[rc.Reservoir]] = optfield(alias="Reservoirs") diff --git a/ravenpy/utilities/forecasting.py b/ravenpy/utilities/forecasting.py index a5132a8f..01dcdbbb 100644 --- a/ravenpy/utilities/forecasting.py +++ b/ravenpy/utilities/forecasting.py @@ -456,8 +456,8 @@ def compute_forecast_flood_risk( f"File created on {dt.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')} " f"UTC on the PAVICS-Hydro service available at {domain}." ) - out.attrs[ - "title" - ] = "Identification of ensemble members that exceed a certain flow threshold." + out.attrs["title"] = ( + "Identification of ensemble members that exceed a certain flow threshold." + ) return out diff --git a/ravenpy/utilities/geoserver.py b/ravenpy/utilities/geoserver.py index 5ea4d60b..d69656ba 100644 --- a/ravenpy/utilities/geoserver.py +++ b/ravenpy/utilities/geoserver.py @@ -12,6 +12,7 @@ For example, many function's logic essentially consists in creating the layer name. We could have a function that returns the layer name, and then other functions expect the layer name. """ + import inspect import json import os diff --git a/ravenpy/utilities/graphs.py b/ravenpy/utilities/graphs.py index 50f63d77..1b37c155 100644 --- a/ravenpy/utilities/graphs.py +++ b/ravenpy/utilities/graphs.py @@ -6,6 +6,7 @@ - mean_annual_hydrograph - spaghetti_annual_hydrograph """ + from pathlib import Path from typing import Sequence, Union diff --git a/ravenpy/utilities/io.py b/ravenpy/utilities/io.py index c2a05438..d71a27a9 100644 --- a/ravenpy/utilities/io.py +++ b/ravenpy/utilities/io.py @@ -1,4 +1,5 @@ """Tools for reading and writing geospatial data formats.""" + import logging import os import tarfile @@ -7,7 +8,7 @@ import zipfile from pathlib import Path from re import search -from typing import Iterable, List, Optional, Sequence, Tuple, Union +from typing import List, Optional, Sequence, Tuple, Union from . import gis_import_error_message diff --git a/ravenpy/utilities/mk_test.py b/ravenpy/utilities/mk_test.py index 08facbfe..e1788d6d 100644 --- a/ravenpy/utilities/mk_test.py +++ b/ravenpy/utilities/mk_test.py @@ -2,6 +2,7 @@ Created on Wed Jul 29 09:16:06 2015 @author: Michael Schramm """ + from typing import Optional, Tuple, Union import numpy as np diff --git a/ravenpy/utilities/nb_graphs.py b/ravenpy/utilities/nb_graphs.py index 74c31e10..a4ed6394 100644 --- a/ravenpy/utilities/nb_graphs.py +++ b/ravenpy/utilities/nb_graphs.py @@ -4,6 +4,7 @@ The graphic outputs are meant to be displayed in a notebook. In a console, use `hvplot.show(fig)` to render the figures. """ + import matplotlib import numpy as np import xarray as xr diff --git a/ravenpy/utilities/testdata.py b/ravenpy/utilities/testdata.py index 40f23ac6..5f39ffd6 100644 --- a/ravenpy/utilities/testdata.py +++ b/ravenpy/utilities/testdata.py @@ -1,4 +1,5 @@ """Tools for searching for and acquiring test data.""" + import hashlib import logging import re From fac0978ae8e1dd67ef27a74272d0691752846563 Mon Sep 17 00:00:00 2001 From: Zeitsperre <10819524+Zeitsperre@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:14:27 -0500 Subject: [PATCH 13/13] add some version pins for pandas --- environment.yml | 4 ++-- pyproject.toml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/environment.yml b/environment.yml index 07433fe0..ea552a02 100644 --- a/environment.yml +++ b/environment.yml @@ -28,7 +28,7 @@ dependencies: - netcdf4 - numpy <1.25 - owslib <0.29.0 # see: https://github.com/geopython/OWSLib/issues/871 - - pandas + - pandas <2.2.0 # xclim <0.48.0 is incompatible with pandas >=2.2.0 - pint >=0.20 - platformdirs - pre-commit @@ -45,6 +45,6 @@ dependencies: - statsmodels - typing_extensions - xarray >=2022.12.0,<2023.9.0 # xarray v2023.9.0 is incompatible with xclim<=0.45.0 - - xclim >=0.43 + - xclim >=0.43,<0.48 - xesmf - xskillscore diff --git a/pyproject.toml b/pyproject.toml index ce39e027..698eecee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,8 +47,8 @@ dependencies = [ "netCDF4", "numpy<1.25", "owslib>=0.24.1,<0.29", # see: https://github.com/geopython/OWSLib/issues/871 - "pandas<2.0; python_version == '3.8'", - "pandas; python_version >= '3.9'", + "pandas<2.0.0; python_version == '3.8'", + "pandas<2.2.0; python_version >= '3.9'", "pint>=0.20", "platformdirs", "pydantic>=2.0", @@ -60,7 +60,7 @@ dependencies = [ "statsmodels", "typing-extensions", "xarray>=2022.12.0,<2023.9.0", # xarray v2023.9.0 is incompatible with xclim<=0.45.0 - "xclim>=0.43.0", + "xclim>=0.43.0,<0.48.0", "xskillscore" ]