From 2a0d11451db37b7794687eed036c1b44d699445e Mon Sep 17 00:00:00 2001 From: Guido Riembauer Date: Thu, 30 Jun 2022 15:49:37 +0200 Subject: [PATCH 1/4] add n_procs and memory parameter --- temporal/t.rast.series/t.rast.series.html | 17 +++++++++++++---- temporal/t.rast.series/t.rast.series.py | 13 +++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/temporal/t.rast.series/t.rast.series.html b/temporal/t.rast.series/t.rast.series.html index 6be1d56445e..8f76e812902 100644 --- a/temporal/t.rast.series/t.rast.series.html +++ b/temporal/t.rast.series/t.rast.series.html @@ -12,6 +12,15 @@

DESCRIPTION

r.series. It supports a subset of the aggregation methods of r.series. +

Performance

+To enable parallel processing, the user can specify the number of threads to be +used with the nprocs parameter (default 1). The memory parameter +(default 300 MB) can also be provided to determine the size of the buffer in MB for +computation. Both parameters are passed to r.series. +To take advantage of the parallelization, GRASS GIS +needs to compiled with OpenMP enabled. + +

EXAMPLES

Estimate the average temperature for the whole time series

@@ -43,7 +52,7 @@

Climatology: single month in a multi-annual time series

method=average output=tempmean_january \ where="strftime('%m', start_time)='01'" -# equivalently, we can use +# equivalently, we can use t.rast.series input=tempmean_monthly \ output=tempmean_january method=average \ where="start_time = datetime(start_time, 'start of year', '0 month')" @@ -59,12 +68,12 @@

Climatology: single month in a multi-annual time series

where="start_time = datetime(start_time, 'start of year', '2 month')" -Generalizing a bit, we can estimate monthly climatologies for all months +Generalizing a bit, we can estimate monthly climatologies for all months by means of different methods
-for i in `seq -w 1 12` ; do 
-  for m in average stddev minimum maximum ; do 
+for i in `seq -w 1 12` ; do
+  for m in average stddev minimum maximum ; do
     t.rast.series input=tempmean_monthly method=${m} output=tempmean_${m}_${i} \
     where="strftime('%m', start_time)='${i}'"
   done
diff --git a/temporal/t.rast.series/t.rast.series.py b/temporal/t.rast.series/t.rast.series.py
index 09b3eb95344..faa13e1deb2 100755
--- a/temporal/t.rast.series/t.rast.series.py
+++ b/temporal/t.rast.series/t.rast.series.py
@@ -62,6 +62,15 @@
 # % answer: start_time
 # %end
 
+# %option G_OPT_M_NPROCS
+# % description: Number of cores for multiprocessing in r.series
+# % answer: 1
+# %end
+
+# %option G_OPT_MEMORYMB
+# % description: Maximum memory to be used (in MB) by r.series
+# %end
+
 # %option G_OPT_T_WHERE
 # %end
 
@@ -95,6 +104,8 @@ def main():
     method = options["method"]
     quantile = options["quantile"]
     order = options["order"]
+    memory = options["memory"]
+    nprocs = options["nprocs"]
     where = options["where"]
     add_time = flags["t"]
     nulls = flags["n"]
@@ -148,6 +159,8 @@ def main():
                 overwrite=grass.overwrite(),
                 method=method,
                 quantile=quantile,
+                memory=memory,
+                nprocs=nprocs
             )
         except CalledModuleError:
             grass.fatal(_("%s failed. Check above error messages.") % "r.series")

From 8446fe0a9f3841a04ab0e6db1aa110f74b987809 Mon Sep 17 00:00:00 2001
From: Guido Riembauer 
Date: Thu, 30 Jun 2022 16:05:00 +0200
Subject: [PATCH 2/4] add comma to last argument (black says so)

---
 temporal/t.rast.series/t.rast.series.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/temporal/t.rast.series/t.rast.series.py b/temporal/t.rast.series/t.rast.series.py
index faa13e1deb2..c30ab8a7c55 100755
--- a/temporal/t.rast.series/t.rast.series.py
+++ b/temporal/t.rast.series/t.rast.series.py
@@ -160,7 +160,7 @@ def main():
                 method=method,
                 quantile=quantile,
                 memory=memory,
-                nprocs=nprocs
+                nprocs=nprocs,
             )
         except CalledModuleError:
             grass.fatal(_("%s failed. Check above error messages.") % "r.series")

From a3734964040e39b5cfc74c19a07a23889d6e3840 Mon Sep 17 00:00:00 2001
From: Guido Riembauer <62383722+griembauer@users.noreply.github.com>
Date: Mon, 4 Jul 2022 09:34:13 +0200
Subject: [PATCH 3/4] Update temporal/t.rast.series/t.rast.series.html

review Vero

Co-authored-by: Veronica Andreo 
---
 temporal/t.rast.series/t.rast.series.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/temporal/t.rast.series/t.rast.series.html b/temporal/t.rast.series/t.rast.series.html
index 8f76e812902..f8dfdce412a 100644
--- a/temporal/t.rast.series/t.rast.series.html
+++ b/temporal/t.rast.series/t.rast.series.html
@@ -18,7 +18,7 @@ 

Performance

(default 300 MB) can also be provided to determine the size of the buffer in MB for computation. Both parameters are passed to r.series. To take advantage of the parallelization, GRASS GIS -needs to compiled with OpenMP enabled. +needs to be compiled with OpenMP enabled.

EXAMPLES

From 272559d21619cd43be29a5dea119dcc809ad1512 Mon Sep 17 00:00:00 2001 From: Guido Riembauer Date: Mon, 18 Jul 2022 08:34:29 +0200 Subject: [PATCH 4/4] remove unnecessary descriptions --- temporal/t.rast.series/t.rast.series.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/temporal/t.rast.series/t.rast.series.py b/temporal/t.rast.series/t.rast.series.py index c30ab8a7c55..5651d3b7a58 100755 --- a/temporal/t.rast.series/t.rast.series.py +++ b/temporal/t.rast.series/t.rast.series.py @@ -63,12 +63,9 @@ # %end # %option G_OPT_M_NPROCS -# % description: Number of cores for multiprocessing in r.series -# % answer: 1 # %end # %option G_OPT_MEMORYMB -# % description: Maximum memory to be used (in MB) by r.series # %end # %option G_OPT_T_WHERE