Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion dissmodel/geo/raster/sync_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,16 @@ def synchronize(self) -> None:

Does nothing if ``land_use_types`` has not been set yet (safe to
call before ``setup()`` completes).

If a state variable was loaded from a temporal catalog entry (shape
``(time, y, x)``), the first slice is used as the initial state.
After the first step the model always writes back 2D arrays, so
subsequent snapshots are 2D unconditionally.
"""
if not hasattr(self, "land_use_types"):
return
for name in self.land_use_types:
self.backend.set(name + "_past", self.backend.get(name).copy())
arr = self.backend.get(name)
if arr.ndim > 2:
arr = arr[0]
self.backend.set(name + "_past", arr.copy())
2 changes: 2 additions & 0 deletions dissmodel/io/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def _write_geotiff(
name,
np.full((rows, cols), nodata, dtype=dtype),
)
if np.issubdtype(np.dtype(dtype), np.integer):
arr = np.where(np.isfinite(arr), arr, nodata)
arrays.append(arr.astype(dtype))
names = [name for name, _, _ in band_spec]
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "dissmodel"
version = "0.6.1"
version = "0.6.2"
description = "Discrete Spatial Modeling framework for raster and vector simulations"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.10"
Expand Down
Loading