From 69b05ae10941617f6c395728553c16b00f0aeb08 Mon Sep 17 00:00:00 2001 From: Guido Riembauer <62383722+griembauer@users.noreply.github.com> Date: Tue, 19 Jul 2022 04:23:05 +0200 Subject: [PATCH] t.rast.series: pass n_procs and memory parameters to r.series (#2470) --- temporal/t.rast.series/t.rast.series.html | 17 +++++++++++++---- temporal/t.rast.series/t.rast.series.py | 10 ++++++++++ 2 files changed, 23 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..f8dfdce412a 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 be 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..5651d3b7a58 100755
--- a/temporal/t.rast.series/t.rast.series.py
+++ b/temporal/t.rast.series/t.rast.series.py
@@ -62,6 +62,12 @@
 # % answer: start_time
 # %end
 
+# %option G_OPT_M_NPROCS
+# %end
+
+# %option G_OPT_MEMORYMB
+# %end
+
 # %option G_OPT_T_WHERE
 # %end
 
@@ -95,6 +101,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 +156,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")