Skip to content

Commit

Permalink
Merge branch 'master' into change_mat_aa_to_mat_a
Browse files Browse the repository at this point in the history
  • Loading branch information
pesekon2 committed Sep 3, 2024
2 parents cbbdb40 + 09da730 commit 7776b58
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 87 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./tests/data/
36 changes: 36 additions & 0 deletions HowToRelease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# How to release

Update SMODERP2D version in:

- `smoderp2d/__init__.py`
- `bin/qgis/smoderp2d-plugin/metadata.txt`
- `pyproject.toml`

Checkout the version:

```
export SMODERP2D_VERSION=<version>
git checkout v$SMODERP2D_VERSION
```

Build the package:

```
pip3 wheel .
```

Upload package to PyPi:

```
python3 -m twine upload smoderp2d-${SMODERP2D_VERSION}-py3-none-any.whl
```

Build QGIS plugin:

```
(cd ./bin/qgis/smoderp2d-plugin/; ./scripts/build_package.sh)
```

Upload `bin/qgis/smoderp2d-plugin/zip_build/smoderp2d_plugin.zip` to
QGIS Plugin repository.
14 changes: 3 additions & 11 deletions bin/grass/r.smoderp2d/r.smoderp2d.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,17 @@ <h2>DESCRIPTION</h2>

<h2>EXAMPLE</h2>

<h3>Nucice dataset</h3>
<h3>Create GRASS location and import sample dataset</h3>

<div class="code"><pre>
grass -c EPSG:5514 /tmp/smoderp2d-nucice --exec python3 tests/data/import_grass.py tests/data/nucice
grass -c /tmp/smoderp2d-nucice/test
</pre></div>

<h3>Rain simulation dataset</h3>

<div class="code"><pre>
grass -c EPSG:5514 /tmp/smoderp2d-rainsim --exec python3 tests/data/import_grass.py tests/data/rain_sim
grass -c /tmp/smoderp2d-rainsim/test
</pre></div>

<h3>Perform computation</h3>

<div class="code"><pre>
./bin/grass/r.smoderp2d/r.smoderp2d.py \
r.smoderp2d \
elevation=dem@PERMANENT \
soil=soils@PERMANENT \
soil_type_fieldname=Soil \
Expand All @@ -43,8 +36,7 @@ <h2>SEE ALSO</h2>

<em>
<a href="r.watershed.html">r.watershed</a>,
<a href="r.terraflow.html">r.terraflow</a>,
<a href="r.filldir.html">r.filldir</a>
<a href="r.terraflow.html">r.terraflow</a>
</em>

<h2>REFERENCES</h2>
Expand Down
127 changes: 67 additions & 60 deletions bin/grass/r.smoderp2d/r.smoderp2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# MODULE: r.smoderp2d
# AUTHOR(S): Martin Landa and SMODERP2D development team
# PURPOSE: Performs SMODERP2D soil erosion model.
# COPYRIGHT: (C) 2018-2023 by Martin Landa and Smoderp2d development team
# COPYRIGHT: (C) 2018-2024 by Martin Landa and Smoderp2d development team
#
# This program is free software under the GNU General Public
# License (>=v3.0) and comes with ABSOLUTELY NO WARRANTY.
Expand All @@ -24,125 +24,132 @@
# %end
# %flag
# % key: t
# % description: Export temporary data
# % description: Generate also temporary data
# % guisection: Advanced
# %end
# %option G_OPT_R_ELEV
# % description: Input surface raster
# % guisection: Data preparation
# % guisection: Spatial data
# %end
# %option G_OPT_V_INPUT
# % key: soil
# % label: Input soil polygon features
# % guisection: Data preparation
# % label: Soil polygons feature layer
# % guidependency: soil_type_fieldname
# % guisection: Spatial data
# %end
# %option G_OPT_DB_COLUMN
# % key: soil_type_fieldname
# % description: Soil types
# % description: Field with the soil type identifier
# % required: yes
# % guisection: Data preparation
# % guisection: Spatial data
# %end
# %option G_OPT_V_INPUT
# % key: vegetation
# % label: Input land use polygon features
# % guisection: Data preparation
# % label: Landuse polygons feature layer
# % guidependency: vegetation_type_fieldname
# % guisection: Spatial data
# %end
# %option G_OPT_DB_COLUMN
# % key: vegetation_type_fieldname
# % description: Land use types
# % description: Field with the landuse type identifier
# % required: yes
# % guisection: Data preparation
# %end
# %option G_OPT_F_INPUT
# % key: rainfall_file
# % description: Rainfall file
# % guisection: Computation
# %end
# %option
# % key: maxdt
# % type: double
# % description: Max time step [sec]
# % answer: 30
# % required: yes
# % guisection: Settings
# %end
# %option
# % key: end_time
# % type: double
# % description: Total running time [min]
# % answer: 5
# % required: yes
# % guisection: Computation
# % guisection: Spatial data
# %end
# %option G_OPT_V_INPUT
# % key: points
# % label: Input points features
# % label: Input points feature layer
# % required: no
# % guisection: Data preparation
# % guidependency: points_fieldname
# % guisection: Spatial data
# %end
# %option G_OPT_DB_COLUMN
# % key: points_fieldname
# % description: Field with the input points idenfifier
# % required: no
# % guisection: Settings
# % guisection: Spatial data
# %end
# %option G_OPT_V_INPUT
# % key: streams
# % label: Stream network feature layer
# % required: no
# % guisection: Spatial data
# %end
# %option G_OPT_F_INPUT
# % key: rainfall_file
# % description: Definition of the rainfall event
# % guisection: Spatial data
# %end
# %option G_OPT_DB_TABLE
# % key: table_soil_vegetation
# % description: Table of soil and land use information
# % guisection: Settings
# % description: Soils and landuse parameters table
# % guidependency: table_soil_vegetation_fieldname
# % guisection: Model parameters
# %end
# %option G_OPT_DB_COLUMN
# % key: table_soil_vegetation_fieldname
# % description: Soil land use code
# % guisection: Settings
# %end
# %option G_OPT_V_INPUT
# % key: streams
# % label: Reach feature
# % required: no
# % guisection: Data preparation
# % description: Field with the connection between landuse and soil
# % guisection: Model parameters
# %end
# %option G_OPT_DB_TABLE
# % key: channel_properties_table
# % description: Reach shapes table
# % guisection: Settings
# % description: Channel properties table
# % guidependency: streams_channel_type_fieldname
# % guisection: Model parameters
# %end
# %option G_OPT_DB_COLUMN
# % key: streams_channel_type_fieldname
# % description: Reach shape table code
# % guisection: Settings
# % description: Field with the channel type identifier
# % guisection: Model parameters
# %end
# %option G_OPT_M_DIR
# % key: output
# % description: Output directory
# % required: yes
# % guisection: Computation options
# %end
# %option
# % key: maxdt
# % type: double
# % description: Maximum time step [s]
# % answer: 30
# % required: yes
# % guisection: Computation options
# %end
# %option
# % key: end_time
# % type: double
# % description: Total running time [min]
# % answer: 5
# % required: yes
# % guisection: Computation options
# %end
# %option
# % key: flow_direction
# % description: Flow direction
# % guisection: Settings
# % guisection: Advanced
# % options: single,multiple
# % answer: single
# %end
# %option
# % key: wave
# % description: Wave type
# % guisection: Settings
# % guisection: Advanced
# % options: kinematic,diffusion
# % answer: kinematic
# %end
# %option G_OPT_M_DIR
# % key: output
# % description: Name for output directory where to store results
# % required: yes
# %end

import os
import sys
import grass.script as gs

from smoderp2d.runners.grass import GrassGisRunner
from smoderp2d.providers.base import WorkflowMode
from smoderp2d.exceptions import ProviderError, MaxIterationExceeded

if __name__ == "__main__":
options, flags = gs.parser()
options['generate_temporary'] = flags['t']

from smoderp2d.runners.grass import GrassGisRunner
from smoderp2d.providers.base import WorkflowMode
from smoderp2d.exceptions import ProviderError, MaxIterationExceeded

try:
runner = GrassGisRunner()
runner.set_options(options)
Expand Down
2 changes: 1 addition & 1 deletion bin/qgis/smoderp2d-plugin/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name=SMODERP2D
qgisMinimumVersion=3.28.10
description=This plugin calculates hydrological and erosion processes on individual plots or small catchments.
version=2.0.0rc2
version=2.1.dev
author=CTU
email=petr.kavka@fsv.cvut.cz

Expand Down
11 changes: 5 additions & 6 deletions bin/qgis/smoderp2d-plugin/patches/smoderp_2D_dockwidget.patch
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
diff --git a/bin/qgis/smoderp2d-plugin/smoderp_2D_dockwidget.py b/bin/qgis/smoderp2d-plugin/smoderp_2D_dockwidget.py
index e751fcf3..92fed2c4 100644
index 4cef0a8f..be86b6eb 100644
--- a/bin/qgis/smoderp2d-plugin/smoderp_2D_dockwidget.py
+++ b/bin/qgis/smoderp2d-plugin/smoderp_2D_dockwidget.py
@@ -26,6 +26,7 @@ import os
@@ -27,6 +27,7 @@ import sys
import glob
import datetime
import tempfile
+import sys
from pathlib import Path

from PyQt5 import QtWidgets
@@ -41,11 +42,12 @@ from qgis.core import (
@@ -43,10 +44,11 @@ from qgis.core import (
from qgis.utils import iface
from qgis.gui import QgsMapLayerComboBox, QgsFieldComboBox

+sys.path.insert(0, os.path.dirname(__file__))
from smoderp2d.runners.qgis import QGISRunner
from smoderp2d.core.general import Globals, GridGlobals
from smoderp2d.providers import Logger
from smoderp2d.exceptions import ProviderError, ComputationAborted
from smoderp2d.exceptions import ProviderError, ComputationAborted, MaxIterationExceeded
-from bin.base import arguments, sections
+from base import arguments, sections

from .connect_grass import find_grass_bin
from .custom_widgets import HistoryWidget

2 changes: 1 addition & 1 deletion bin/qgis/smoderp2d-plugin/pb_tool.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ plugin_path:

[files]
# Python files that should be deployed with the plugin
python_files: __init__.py smoderp_2D.py smoderp_2D_dockwidget.py connect_grass.py custom_widgets.py
python_files: __init__.py smoderp_2D.py smoderp_2D_dockwidget.py custom_widgets.py

# The main dialog file that is loaded (not compiled)
main_dialog:
Expand Down
3 changes: 3 additions & 0 deletions bin/qgis/smoderp2d-plugin/scripts/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ source $VENV/bin/activate

script_dir=$(realpath $(dirname $0))
echo $script_dir
### install released SMODERP2D version
pip3 install smoderp2d
### or from git
# (cd ../../.. ;pip3 install .)

pv=$(python3 -V | cut -d' ' -f 2 | cut -d'.' -f 1,2)
LIB=$VENV/lib/python$pv/site-packages
Expand Down
3 changes: 2 additions & 1 deletion bin/qgis/smoderp2d-plugin/smoderp_2D_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def run(self):
for line in islice(fin, 1, 2):
if 'SMODERP2D patch applied' not in line:
raise ImportError(
'Your GRASS GIS installation needs to be fixed. Check the '
'There is a bug affecting the plugin functionality. Update QGIS to '
'version 3.34.10/3.38.2 or higher, or apply the fix manually. Check the '
'<a href="https://storm-fsv-cvut.github.io/smoderp2d-manual/providers.html#known-issue">documentation</a>.'
)
self.runner.create_location(QgsProject.instance().crs().authid())
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Author(s): Petr Kavka, Karel Vrana
# Copyright (C) TODO
# Author(s): Petr Kavka and SMODERP2D Development Team
# Copyright (C) SMODERP2D Development Team
#
# This file is part of smoderp2d.
#
Expand All @@ -21,7 +21,7 @@ build-backend = "setuptools.build_meta"

[metadata]
name = 'smoderp2d'
version = '2.0.0rc2'
version = '2.1.dev'

[tool.setuptools.packages.find]
where = [""]
Expand All @@ -32,7 +32,7 @@ exclude = ["bin*", "utils*", "tests*"]

[project]
name = 'smoderp2d'
version = '2.0.0rc2'
version = '2.1.dev'
description = 'Distributed event-based model for surface and subsurface runoff and erosion.'
readme = 'README.md'
authors = [
Expand Down
2 changes: 1 addition & 1 deletion smoderp2d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
- no
"""

__version__ = "2.0.0rc2"
__version__ = "2.1.dev"
2 changes: 2 additions & 0 deletions smoderp2d/providers/grass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def __init__(self, log_handler=GrassGisLogHandler):
os.environ['GRASS_OVERWRITE'] = '1'
# be quiet
os.environ['GRASS_VERBOSE'] = '0'
# allow to run r.hydrodem also when compatibility test fails
os.environ['GRASS_COMPATIBILITY_TEST'] = '0'

# define storage writer
self.storage = GrassGisWriter()
Expand Down
Loading

0 comments on commit 7776b58

Please sign in to comment.