Skip to content

Commit

Permalink
Merge pull request #23 from TerrainBento/master
Browse files Browse the repository at this point in the history
update for v2.0.0b1
  • Loading branch information
kbarnhart committed Feb 16, 2020
2 parents b6d3ff8 + c08f15b commit 2b7caeb
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 67 deletions.
10 changes: 6 additions & 4 deletions .travis.yml
Expand Up @@ -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=
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -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)


Expand All @@ -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:
Expand Down
12 changes: 9 additions & 3 deletions appveyor.yml
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion binder/postBuild
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Expand Up @@ -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
4 changes: 2 additions & 2 deletions docs/source/index.rst
Expand Up @@ -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
------------
Expand Down
4 changes: 2 additions & 2 deletions environment-dev.yml
Expand Up @@ -12,13 +12,13 @@ dependencies:
# for the package
- scipy
- numpy
- landlab>=1.10.1, <2.0
- landlab>=2.0.0b4
# for the notebooks
- jupyter
- holoviews
- pandas
- tqdm
- plotnine>=0.6.0
- terrainbento>=1.1
- terrainbento>=2.0.0b1
- gdal
- rasterio
61 changes: 18 additions & 43 deletions notebooks/OtherIO_options.ipynb
Expand Up @@ -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))"
]
Expand Down Expand Up @@ -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] "
]
},
{
Expand All @@ -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)"
]
},
{
Expand All @@ -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": {},
Expand All @@ -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\")"
]
Expand Down Expand Up @@ -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. "
]
},
{
Expand Down Expand Up @@ -459,7 +434,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.8.1"
}
},
"nbformat": 4,
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -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.0.0b4"],
)
8 changes: 4 additions & 4 deletions umami/calculations/metric/chi_intercept_gradient.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion umami/calculations/residual/discretized_misfit.py
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions umami/utils/create_landlab_components.py
Expand Up @@ -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

0 comments on commit 2b7caeb

Please sign in to comment.