[GRASS-SVN] r72204 - in grass-addons/grass7/temporal: . t.rast.null

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Feb 2 06:20:09 PST 2018


Author: lucadelu
Date: 2018-02-02 06:20:09 -0800 (Fri, 02 Feb 2018)
New Revision: 72204

Added:
   grass-addons/grass7/temporal/t.rast.null/
   grass-addons/grass7/temporal/t.rast.null/Makefile
   grass-addons/grass7/temporal/t.rast.null/t.rast.null.html
   grass-addons/grass7/temporal/t.rast.null/t.rast.null.py
Log:
t.rast.null: added new temporal modules to manage null values

Added: grass-addons/grass7/temporal/t.rast.null/Makefile
===================================================================
--- grass-addons/grass7/temporal/t.rast.null/Makefile	                        (rev 0)
+++ grass-addons/grass7/temporal/t.rast.null/Makefile	2018-02-02 14:20:09 UTC (rev 72204)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = t.rast.null
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script


Property changes on: grass-addons/grass7/temporal/t.rast.null/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-makefile
Added: svn:eol-style
   + native

Added: grass-addons/grass7/temporal/t.rast.null/t.rast.null.html
===================================================================
--- grass-addons/grass7/temporal/t.rast.null/t.rast.null.html	                        (rev 0)
+++ grass-addons/grass7/temporal/t.rast.null/t.rast.null.html	2018-02-02 14:20:09 UTC (rev 72204)
@@ -0,0 +1,29 @@
+<h2>DESCRIPTION</h2>
+<em><b>t.rast.null</b></em> manages NULL-values of the input space time raster
+dataset.
+<p>
+The setnull parameter is used to specify values in the ranges to be set to NULL.
+A range is either a single value (e.g., 5.3), or a pair of values (e.g., 4.76-34.56).
+Existing NULL-values are left NULL, unless the null argument is requested.
+<p>
+The null parameter eliminates the NULL value and replaces it with value.
+This argument is applied only to existing NULL values, and not to the NULLs created by the setnull argument.
+
+
+<h2>EXAMPLES</h2>
+Set specific values (0,-1 and -2) of a space time raster dataset to NULL:
+<div class="code"><pre>
+    t.rast.null input=MY_INPUT_DATASET setnull=0,-1,-2
+</pre></div>
+
+<h2>SEE ALSO</h2>
+<em>
+<a href="r.null.html">r.null</a>,
+</em>
+
+
+<h2>AUTHOR</h2>
+Luca Delucchi, Fondazione Edmund Mach
+
+<p>
+<i>Last changed: $Date$</i>


Property changes on: grass-addons/grass7/temporal/t.rast.null/t.rast.null.html
___________________________________________________________________
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass-addons/grass7/temporal/t.rast.null/t.rast.null.py
===================================================================
--- grass-addons/grass7/temporal/t.rast.null/t.rast.null.py	                        (rev 0)
+++ grass-addons/grass7/temporal/t.rast.null/t.rast.null.py	2018-02-02 14:20:09 UTC (rev 72204)
@@ -0,0 +1,109 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+################################################
+#
+# MODULE:       t.rast.null
+# AUTHOR(S):    Luca Delucchi
+# PURPOSE:      t.rast.null set null values in a space time raster dataset
+#
+# COPYRIGHT:    (C) 2018 by Luca Delucchi
+#
+#               This program is free software under the GNU General Public
+#               License (>=v2). Read the file COPYING that comes with GRASS
+#               for details.
+#
+################################################
+
+#%module
+#% description: Calculate kappa parameter in a space time raster dataset
+#% keyword: temporal
+#% keyword: raster
+#% keyword: null data
+#%end
+
+#%option G_OPT_STRDS_INPUT
+#% key: strds
+#%end
+
+#%option
+#% key: setnull
+#% type: string
+#% label: List of cell values to be set to NULL
+#% multiple: yes
+#% required: no
+#%end
+
+#%option
+#% key: null
+#% type: double
+#% label: The value to replace the null value by
+#% multiple: no
+#% required: no
+#%end
+
+#%option G_OPT_T_WHERE
+#%end
+
+#%option
+#% key: nprocs
+#% type: integer
+#% description: Number of r.to.vect processes to run in parallel, more than 1 process works only in conjunction with flag -t
+#% required: no
+#% multiple: no
+#% answer: 1
+#%end
+
+import copy
+import sys
+
+import grass.temporal as tgis
+import grass.script as gscript
+import grass.pygrass.modules as pymod
+
+def main():
+    strds = options["strds"]
+    where = options["where"]
+    nprocs = int(options["nprocs"])
+    
+    nullmod = pymod.Module('r.null')
+    nullmod.flags.quiet = True
+    if options["null"]:
+        nullmod.inputs.null = options["null"]
+    elif options["setnull"]:
+        nullmod.inputs.setnull = options["setnull"]
+    else:
+        gscript.fatal(_("Please set 'null' or 'setnull' option"))
+        
+    tgis.init()
+    # We need a database interface
+    dbif = tgis.SQLDatabaseInterfaceConnection()
+    dbif.connect()
+
+    sp = tgis.open_old_stds(strds, "strds", dbif)
+    maps = sp.get_registered_maps_as_objects(where, "start_time", None)
+    if maps is None:
+        gscript.fatal(_("Space time raster dataset {st} seems to be "
+                        "empty".format(st=strds)))
+        return 1
+    # module queue for parallel execution
+    process_queue = pymod.ParallelModuleQueue(int(nprocs))
+
+    count = 0
+    num_maps = len(maps)
+    
+    for mapp in maps:
+        count += 1
+        mod = copy.deepcopy(nullmod)
+        mod.inputs.map = mapp.get_id()
+        process_queue.put(mod)
+
+        if count%10 == 0:
+            gscript.percent(count, num_maps, 1)
+
+    # Wait for unfinished processes
+    process_queue.wait()
+    
+if __name__ == "__main__":
+    options, flags = gscript.parser()
+    sys.exit(main())


Property changes on: grass-addons/grass7/temporal/t.rast.null/t.rast.null.py
___________________________________________________________________
Added: svn:mime-type
   + text/x-python
Added: svn:eol-style
   + native



More information about the grass-commit mailing list