Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeitsperre authored Oct 11, 2024
2 parents c2fcaf9 + 6f00c91 commit 4007149
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"project_slug": "xhydro",
"project_short_description": "Hydrological analysis library built with xarray.",
"pypi_username": "TC-FF",
"version": "0.4.0",
"version": "0.4.1-dev.0",
"use_pytest": "y",
"use_black": "y",
"use_conda": "y",
Expand Down
14 changes: 14 additions & 0 deletions docs/notebooks/gis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,13 @@
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can also extract the surface properties for the same `gpd.GeoDataFrame` : "
]
},
{
"cell_type": "code",
"execution_count": 10,
Expand Down Expand Up @@ -972,6 +979,13 @@
"xhgis.surface_properties(gdf)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Again, for convenience, we can output the results in `xarray.Dataset` format : "
]
},
{
"cell_type": "code",
"execution_count": 11,
Expand Down
7 changes: 5 additions & 2 deletions docs/notebooks/hydrological_modelling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"metadata": {},
"outputs": [],
"source": [
"import planetary_computer\n",
"\n",
"import xhydro as xh\n",
"import xhydro.modelling as xhm\n",
"\n",
Expand All @@ -52,7 +54,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "3",
"metadata": {
"editable": true,
Expand Down Expand Up @@ -166,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "7",
"metadata": {},
"outputs": [],
Expand All @@ -179,6 +181,7 @@
"# Acquire the Copernicus DEM for the area covered by the watershed\n",
"catalog = pystac_client.Client.open(\n",
" \"https://planetarycomputer.microsoft.com/api/stac/v1\",\n",
" modifier=planetary_computer.sign_inplace,\n",
")\n",
"search = catalog.search(\n",
" collections=[\"cop-dem-glo-90\"],\n",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ target-version = [
]

[tool.bumpversion]
current_version = "0.4.0"
current_version = "0.4.1-dev.0"
commit = true
commit_args = "--no-verify"
tag = false
Expand Down
2 changes: 1 addition & 1 deletion src/xhydro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@

__author__ = """Thomas-Charles Fortier Filion"""
__email__ = "tcff_hydro@outlook.com"
__version__ = "0.4.0"
__version__ = "0.4.1-dev.0"
12 changes: 7 additions & 5 deletions src/xhydro/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import planetary_computer
import pystac_client
import rasterio
import rasterio.features
Expand Down Expand Up @@ -270,11 +271,9 @@ def _recursive_upstream_lookup(


def _flatten(x, dim="time"):
# FIXME: assert statements should only be found in test code
assert isinstance(x, xr.DataArray) # noqa: S101
if len(x[dim].values) > len(set(x[dim].values)):
x = x.groupby(dim).map(stackstac.mosaic)

if isinstance(x, xr.DataArray):
if len(x[dim].values) > len(set(x[dim].values)):
x = x.groupby(dim).map(stackstac.mosaic)
return x


Expand Down Expand Up @@ -324,6 +323,7 @@ def surface_properties(

catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)

search = catalog.search(
Expand Down Expand Up @@ -489,6 +489,7 @@ def land_use_classification(
"""
catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)
collection = catalog.get_collection(collection)
ia = ItemAssetsExtension.ext(collection)
Expand Down Expand Up @@ -552,6 +553,7 @@ def land_use_plot(
"""
catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)

collection = catalog.get_collection(collection)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_xhydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ def test_package_metadata():
contents = f.read()
assert """Thomas-Charles Fortier Filion""" in contents
assert '__email__ = "tcff_hydro@outlook.com"' in contents
assert '__version__ = "0.4.0"' in contents
assert '__version__ = "0.4.1-dev.0"' in contents

0 comments on commit 4007149

Please sign in to comment.