Skip to content

Commit

Permalink
fixup: Format Python code with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 10, 2023
1 parent d3c4d9d commit b95cb84
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/geofabrics/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1693,21 +1693,27 @@ def add_coarse_dems(
logging.info(f"Incorporating coarse DEMs: {coarse_dem_paths}")
for coarse_dem_path in coarse_dem_paths:
# Check if any areas still without values - exit if none
no_value_mask = self._dem.z.rolling(
dim={"x": buffer_cells, "y": buffer_cells},
min_periods=1,
).count().isnull()
no_value_mask = (
self._dem.z.rolling(
dim={"x": buffer_cells, "y": buffer_cells},
min_periods=1,
)
.count()
.isnull()
)
if no_value_mask.any():
logging.info(
f"No land areas greater than the cell buffer {buffer_cells}"
" without LiDAR values. Ignoring all remaining coarse DEMs."
)
return False
# Check for overlap with the Coarse DEM
coarse_dem_bounds = rioxarray.rioxarray.open_rasterio(
coarse_dem_path, masked=True).squeeze(
"band", drop=True
).set_crs(self.catchment_geometry.crs["horizontal"]).rio.bounds()
coarse_dem_bounds = (
rioxarray.rioxarray.open_rasterio(coarse_dem_path, masked=True)
.squeeze("band", drop=True)
.set_crs(self.catchment_geometry.crs["horizontal"])
.rio.bounds()
)
coarse_dem_bounds = geopandas.GeoDataFrame(
{
"geometry": [
Expand All @@ -1725,7 +1731,9 @@ def add_coarse_dems(
)

# Add the coarse DEM data where there's no LiDAR updating the extents
no_value_mask = no_value_mask.rio.clip(coarse_dem_bounds.geometry.values, drop=False)
no_value_mask = no_value_mask.rio.clip(
coarse_dem_bounds.geometry.values, drop=False
)
if no_value_mask.any():
logging.info(f"\t\tAdd data from coarse DEM: {coarse_dem_path.name}")
# Create a mask defining the region without values to populate
Expand Down Expand Up @@ -1771,7 +1779,7 @@ def _add_coarse_dem_no_chunking(
extents=extents, # by reference, so "total" trimmed to coarse DEM bounds
set_foreshore=self.drop_offshore_lidar,
)

# create dictionary defining raster options
# Set search radius to the diagonal cell length to ensure corners covered
raster_options = {
Expand Down

0 comments on commit b95cb84

Please sign in to comment.