From 2c8b666ff40938083c2fe38380f674eb6976f369 Mon Sep 17 00:00:00 2001 From: Katy Barnhart Date: Thu, 30 Jan 2020 16:45:40 -0700 Subject: [PATCH 1/6] update versions --- environment-dev.yml | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/environment-dev.yml b/environment-dev.yml index 7a35f48..8b5e6e6 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -12,13 +12,13 @@ dependencies: # for the package - scipy - numpy - - landlab>=1.10.1, <2.0 + - landlab>=2.0b4 # for the notebooks - jupyter - holoviews - pandas - tqdm - plotnine>=0.6.0 - - terrainbento>=1.1 + - terrainbento>=2.0 - gdal - rasterio diff --git a/setup.py b/setup.py index 51c3da2..ec03d2f 100644 --- a/setup.py +++ b/setup.py @@ -28,5 +28,5 @@ long_description_content_type="text/markdown", zip_safe=False, packages=find_packages(), - install_requires=["scipy", "numpy", "landlab>=1.10.1, <2.0"], + install_requires=["scipy", "numpy", "landlab>=2.0b4"], ) From f7eae6add6ab2219970fc62521f090f77985b2c0 Mon Sep 17 00:00:00 2001 From: Katy Barnhart Date: Thu, 30 Jan 2020 16:46:32 -0700 Subject: [PATCH 2/6] disable warnings --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 2aa28d2..039ae4f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,6 +16,7 @@ filterwarnings = testpaths = umami tests norecursedirs = .* *.egg* build dist examples addopts = + --disable-pytest-warnings --ignore setup.py --ignore versioneer.py --ignore umami/_version.py From 4bf40b37eb55787320228ee83f4f5ff398504790 Mon Sep 17 00:00:00 2001 From: Katy Barnhart Date: Thu, 30 Jan 2020 16:46:57 -0700 Subject: [PATCH 3/6] fix 2.0 incompatibilities --- notebooks/OtherIO_options.ipynb | 61 +++++++----------------- umami/utils/create_landlab_components.py | 4 +- 2 files changed, 20 insertions(+), 45 deletions(-) diff --git a/notebooks/OtherIO_options.ipynb b/notebooks/OtherIO_options.ipynb index d619785..92bfc27 100644 --- a/notebooks/OtherIO_options.ipynb +++ b/notebooks/OtherIO_options.ipynb @@ -177,9 +177,8 @@ "outputs": [], "source": [ "rmg = RasterModelGrid((nrows, ncols),\n", - " dx=dx,\n", - " dy=dy,\n", - " xy_lower_left=xy_lower_left)\n", + " xy_spacing=(dx, dy),\n", + " xy_of_lower_left=xy_lower_left)\n", "\n", "z = rmg.add_field(\"topographic__elevation\", elevations.astype(float))" ] @@ -268,17 +267,15 @@ "metadata": {}, "outputs": [], "source": [ - "factor = 10\n", + "factor = 11\n", "nnodes = int(rmg.x_of_node.size / factor)\n", - "np.random.seed(42)\n", + "np.random.seed(27)\n", "\n", - "random_x = np.random.uniform(low=rmg.x_of_node.min(),\n", - " high=rmg.x_of_node.max(),\n", - " size=nnodes)\n", - "\n", - "random_y = np.random.uniform(low=rmg.y_of_node.min(),\n", - " high=rmg.y_of_node.max(),\n", - " size=nnodes)" + "# select a random subset of x_of_node and y_of_node and permute by a small quantity.\n", + "# permute only in x, which allows the ordering of nodes to be maintained \n", + "index = np.linspace(0, rmg.x_of_node.size-1, nnodes, dtype=int)\n", + "random_x = rmg.x_of_node[index] + 0.4 * rmg.spacing[0] * np.random.randn(index.size)\n", + "random_y = rmg.y_of_node[index] " ] }, { @@ -296,8 +293,8 @@ "source": [ "plt.plot(rmg.x_of_node, rmg.y_of_node, 'k.', markersize=2, label=\"Raster Points\")\n", "plt.plot(random_x, random_y, 'm.', label=\"Irregular Points\")\n", - "plt.ylim(0, 0.025)\n", - "plt.xlim(0, 0.025)" + "plt.xlim(-105.40, -105.375)\n", + "plt.ylim(40.00, 40.025)" ] }, { @@ -313,35 +310,13 @@ "metadata": {}, "outputs": [], "source": [ - "interp_obj = RegularGridInterpolator((rmg.y_of_node.reshape(\n", - " rmg.shape)[:, 0], rmg.x_of_node.reshape(rmg.shape)[0, :]),\n", - " z.reshape(rmg.shape))\n", + "interp_obj = RegularGridInterpolator((rmg.y_of_node.reshape(rmg.shape)[:, 0], \n", + " rmg.x_of_node.reshape(rmg.shape)[0, :]),\n", + " z.reshape(rmg.shape), bounds_error=False, fill_value=None)\n", "\n", "interp_z = interp_obj((random_y, random_x))" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Before we create the `VoronoiDelaunayGrid` we have one more step to do. The Landlab model grid uses a standard method of ordering model grid nodes. Node order starts in the lower left corner and ends in the upper right. If we want to be able to add our elevation data to the grid, we need to sort the grid nodes into the Landlab grid order, so the order will not change when the grid is made. \n", - "\n", - "We do this by creating a numpy array that combines the random x and y locations, and the interpolated z values. We then sort first by x and then by y. " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vals = np.vstack((random_x, random_y, interp_z))\n", - "\n", - "# sort by x then by y\n", - "sort_by_x = vals[:, vals[0, :].argsort()]\n", - "sort_by_xy = sort_by_x[:, sort_by_x[1, :].argsort()]" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -357,8 +332,8 @@ "metadata": {}, "outputs": [], "source": [ - "vdg = VoronoiDelaunayGrid(sort_by_xy[0], sort_by_xy[1])\n", - "z = vdg.add_field(\"node\", \"topographic__elevation\", sort_by_xy[2])\n", + "vdg = VoronoiDelaunayGrid(random_x, random_y)\n", + "z = vdg.add_field(\"topographic__elevation\", interp_z, at=\"node\")\n", "\n", "imshow_grid(vdg, z, cmap=\"terrain\")" ] @@ -418,7 +393,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Comparing the metric values for the two grids, we can see that they are slightly different in absolute value but very close based on percent change. " + "Comparing the metric values for the two grids, we can see that the mean is slightly different in absolute value but very close based on percent change and the 10th percentile is identical. " ] }, { @@ -459,7 +434,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.8.1" } }, "nbformat": 4, diff --git a/umami/utils/create_landlab_components.py b/umami/utils/create_landlab_components.py index 570921f..0b579ec 100644 --- a/umami/utils/create_landlab_components.py +++ b/umami/utils/create_landlab_components.py @@ -12,10 +12,10 @@ def _create_landlab_components( # Run ChiFinder kwds = chi_finder_kwds or {} - cf = ChiFinder(grid, noclobber=False, **kwds) + cf = ChiFinder(grid, clobber=True, **kwds) cf.calculate_chi() # run distance upstream. - _ = calculate_flow__distance(grid, add_to_grid=True, noclobber=False) + _ = calculate_flow__distance(grid, add_to_grid=True, clobber=True) return fa, cf From 5270abc5fb03d9cb68bcdbed047f8ba848b17090 Mon Sep 17 00:00:00 2001 From: Katy Barnhart Date: Fri, 14 Feb 2020 16:19:31 -0700 Subject: [PATCH 4/6] wip --- binder/postBuild | 2 +- environment-dev.yml | 4 ++-- setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/binder/postBuild b/binder/postBuild index a9f042c..2cd2ab7 100644 --- a/binder/postBuild +++ b/binder/postBuild @@ -7,7 +7,7 @@ conda install jupyter conda install holoviews conda install pandas conda install plotnine>=0.6.0 -conda install terrainbento>=1.10.1 +conda install terrainbento>=2b conda install tqdm conda install rasterio diff --git a/environment-dev.yml b/environment-dev.yml index 8b5e6e6..5aed72e 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -12,13 +12,13 @@ dependencies: # for the package - scipy - numpy - - landlab>=2.0b4 + - landlab>=2.0.0b4 # for the notebooks - jupyter - holoviews - pandas - tqdm - plotnine>=0.6.0 - - terrainbento>=2.0 + - terrainbento>=2b - gdal - rasterio diff --git a/setup.py b/setup.py index ec03d2f..b04f718 100644 --- a/setup.py +++ b/setup.py @@ -28,5 +28,5 @@ long_description_content_type="text/markdown", zip_safe=False, packages=find_packages(), - install_requires=["scipy", "numpy", "landlab>=2.0b4"], + install_requires=["scipy", "numpy", "landlab>=2.0.0b4"], ) From 96baa5aa01d2def8717c7cb6129f9d62a0dcb51f Mon Sep 17 00:00:00 2001 From: Katy Barnhart Date: Fri, 14 Feb 2020 16:39:46 -0700 Subject: [PATCH 5/6] work on ci --- .travis.yml | 10 ++++++---- Makefile | 2 +- appveyor.yml | 12 +++++++++--- docs/Makefile | 2 +- environment-dev.yml | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6730b60..2e13b43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,9 @@ os: - osx env: matrix: - - CONDA_ENV=3.7 - CONDA_ENV=3.6 + - CONDA_ENV=3.7 + - CONDA_ENV=3.8 global: - MPLBACKEND=Agg - secure: myTUfRQ7EgOxtCSSRxeTAOg4Q+0W9sEngk35jkW6iSwKtuN94t7Tn/XiTy7U2AM38XVGxyfy0R1EwsPiz01xYkRWYDpzLZWP/AuLs1FaUMGC9XwLEspSORZx7QKJ+MUwRHaoBvWXk+1EvT4jbbFoLoK8Ih5Jhdg8kvHIbXd85B5XmzvNyOBxpvPWXq81KwF/Ipc/IRKpJAaHJZ5OIBEAdxYNuVoQpe/yX57eW8IbeDYVG4HchcsXvGksP7LpR7ajrjCAxDzJA9U2XfufnFuyvFDw+LA1vZxbrzn1gjBH3O1Eb5iTrEuxIIx+EW6MdxjbR1Rh3te4a2I9uBoO8J/vMOEpDl62ywHN6H/YwXTFb+ihyOSOU3D4uV3Ob2SuQVsKgKV1tKoiVX6MgDM/p7C9gKcGxR/vpobHf8abBlRgE6QDxJNb2a70cHGO58kB3UROgOpmrNjdK3vDF5ZWg1HS+GV0Kns2m6aVk3mQI8il9HR465ckMJxrIvUJkqe5qMK9iD1l9WzFjQ/pOtQ63f32cDijNpZ6aACNZqdrqlEAVpQVYNZlSUideUE2TYmwyjZmrArWCFPvqqewW7CDtZAZl/IXg7W9x+M0eEDBHi2y64ERO1FpR3VyxcaYAfN3PhD+CzpIWd2aQwSARzjFiZiF364w8gey17+H2TcnhncbZhE= @@ -24,11 +25,11 @@ jobs: - conda activate umami_docs - pip install -e . script: - - make -C docs clean html + - make -C docs clean html linkcheck - stage: deploy if: tag =~ v.*$ os: osx - env: CONDA_ENV=3.7 + env: CONDA_ENV=3.8 script: - pip install twine wheel - python setup.py bdist_wheel @@ -61,6 +62,7 @@ install: - pip install -e . script: - pip install pytest pytest-cov coveralls -- pip install jupyter pandas plotnine holoviews terrainbento tqdm rasterio +- pip install jupyter pandas plotnine holoviews tqdm rasterio +- pip install terrainbento --pre - pytest umami tests/ --doctest-modules --cov=umami --cov-report=xml:$(pwd)/coverage.xml -vvv after_success: coveralls diff --git a/Makefile b/Makefile index 62d1aa2..830e535 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ clean-test: ## remove test and coverage artifacts rm -fr .pytest_cache lint: ## check style with flake8 - flake8 umami --exclude=examples + flake8 umami flake8 tests pretty: ## reformat files to make them look pretty diff --git a/appveyor.yml b/appveyor.yml index 399f8f7..ba554a9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,12 +6,17 @@ environment: - TARGET_ARCH: x64 CONDA_NPY: 111 CONDA_INSTALL_LOCN: C:\\Miniconda37-x64 - CONDA_PY: 3.7 + CONDA_PY: 3.6 - TARGET_ARCH: x64 CONDA_NPY: 111 CONDA_INSTALL_LOCN: C:\\Miniconda36-x64 - CONDA_PY: 3.6 + CONDA_PY: 3.7 + + - TARGET_ARCH: x64 + CONDA_NPY: 111 + CONDA_INSTALL_LOCN: C:\\Miniconda37-x64 + CONDA_PY: 3.8 platform: - x64 @@ -28,7 +33,8 @@ install: - cmd: set PYTHONUNBUFFERED=1 - cmd: conda config --set always_yes yes - cmd: pip install pytest - - cmd: pip install jupyter pandas plotnine holoviews terrainbento tqdm + - cmd: pip install jupyter pandas plotnine holoviews tqdm + - cmd: pip install terrainbento --pre - cmd: conda install rasterio -c conda-forge - cmd: conda install landlab -c conda-forge - cmd: conda info diff --git a/docs/Makefile b/docs/Makefile index 3f0e4f1..ba2a4fe 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -19,4 +19,4 @@ help: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -W diff --git a/environment-dev.yml b/environment-dev.yml index 5aed72e..fe45374 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -19,6 +19,6 @@ dependencies: - pandas - tqdm - plotnine>=0.6.0 - - terrainbento>=2b + - terrainbento>=2.0.0b1 - gdal - rasterio From 22a85441e3e45dcb55702e3fd7791d64428f364f Mon Sep 17 00:00:00 2001 From: Katy Barnhart Date: Sat, 15 Feb 2020 11:57:21 -0700 Subject: [PATCH 6/6] doc linkcheck passes --- README.md | 4 ++-- docs/source/index.rst | 4 ++-- umami/calculations/metric/chi_intercept_gradient.py | 8 ++++---- umami/calculations/residual/discretized_misfit.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5da7da0..e727209 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Build status](https://ci.appveyor.com/api/projects/status/0ehba569dttgsuyv?svg=true)](https://ci.appveyor.com/project/kbarnhart/umami) [![Coverage Status](https://coveralls.io/repos/github/TerrainBento/umami/badge.svg?branch=master)](https://coveralls.io/github/TerrainBento/umami?branch=master) [![Anaconda-Server Badge](https://anaconda.org/conda-forge/umami/badges/installer/conda.svg)](https://conda.anaconda.org/conda-forge) -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TerrainBento/umami/master?filepath=notebooks%2FWelcome.ipynb) +[![Binder](https://static.mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TerrainBento/umami/master?filepath=notebooks%2FWelcome.ipynb) [![DOI](https://joss.theoj.org/papers/10.21105/joss.01776/status.svg)](https://doi.org/10.21105/joss.01776) @@ -15,7 +15,7 @@ with [terrainbento](https://github.com/TerrainBento/terrainbento) and other models built with the [Landlab Toolkit](https://github.com/landlab/landlab). Examples can be found in the `notebooks` directory (or on Binder -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TerrainBento/umami/master?filepath=notebooks%2FWelcome.ipynb) +[![Binder](https://static.mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/TerrainBento/umami/master?filepath=notebooks%2FWelcome.ipynb) ). Umami offers two primary classes: diff --git a/docs/source/index.rst b/docs/source/index.rst index 792cc47..59fccf5 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -52,9 +52,9 @@ To get help or ask questions, please make an `issue on GitHub`_. Installation Instructions ------------------------- -Installation is described on `this`_ section of the README. +Installation is described in `the README`_ . -.. _this: https://github.com/TerrainBento/umami#where-to-get-it +.. _the README: https://github.com/TerrainBento/umami Contributing ------------ diff --git a/umami/calculations/metric/chi_intercept_gradient.py b/umami/calculations/metric/chi_intercept_gradient.py index b9a3aaf..39b74fc 100644 --- a/umami/calculations/metric/chi_intercept_gradient.py +++ b/umami/calculations/metric/chi_intercept_gradient.py @@ -15,14 +15,14 @@ def chi_intercept(chi_finder): This is a loose wrapper around the Landlab function `ChiFinder.best_fit_chi_elevation_gradient_and_intercept`_. - .. _ChiFinder.best_fit_chi_elevation_gradient_and_intercept: https://landlab.readthedocs.io/en/release/landlab.components.chi_index.html#landlab.components.chi_index.ChiFinder.best_fit_chi_elevation_gradient_and_intercept + .. _ChiFinder.best_fit_chi_elevation_gradient_and_intercept: https://landlab.readthedocs.io/en/master/reference/components/index.html#landlab.components.ChiFinder.best_fit_chi_elevation_gradient_and_intercept Parameters ---------- chi_finder : an instance of a `ChiFinder`_ - .. _ChiFinder: https://landlab.readthedocs.io/en/release/landlab.components.chi_index.html + .. _ChiFinder: https://landlab.readthedocs.io/en/master/reference/components/chi_index.html Returns @@ -78,14 +78,14 @@ def chi_gradient(chi_finder): This is a loose wrapper around the Landlab function `ChiFinder.best_fit_chi_elevation_gradient_and_intercept`_. - .. _ChiFinder.best_fit_chi_elevation_gradient_and_intercept: https://landlab.readthedocs.io/en/release/landlab.components.chi_index.html#landlab.components.chi_index.ChiFinder.best_fit_chi_elevation_gradient_and_intercept + .. _ChiFinder.best_fit_chi_elevation_gradient_and_intercept: https://landlab.readthedocs.io/en/master/reference/components/index.html#landlab.components.ChiFinder.best_fit_chi_elevation_gradient_and_intercept Parameters ---------- chi_finder : an instance of a `ChiFinder`_ - .. _ChiFinder: https://landlab.readthedocs.io/en/release/landlab.components.chi_index.html + .. _ChiFinder: https://landlab.readthedocs.io/en/master/reference/components/chi_index.html Returns diff --git a/umami/calculations/residual/discretized_misfit.py b/umami/calculations/residual/discretized_misfit.py index 88abb93..c80243d 100644 --- a/umami/calculations/residual/discretized_misfit.py +++ b/umami/calculations/residual/discretized_misfit.py @@ -18,7 +18,7 @@ def discretized_misfit( The following Binder notebook shows example usage of this umami calculation. - .. image:: https://mybinder.org/badge_logo.svg + .. image:: https://static.mybinder.org/badge_logo.svg :target: https://mybinder.org/v2/gh/TerrainBento/umami/master?filepath=notebooks%2FDiscretizedMisfit.ipynb The ``discretized_misfit`` calculation first classifies each grid cell in