[GRASS-SVN] r67963 - in grass/trunk: lib/python/temporal temporal/t.rast.import temporal/t.rast.import/testsuite temporal/t.rast.import/testsuite/data

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Feb 26 06:36:10 PST 2016


Author: lucadelu
Date: 2016-02-26 06:36:10 -0800 (Fri, 26 Feb 2016)
New Revision: 67963

Added:
   grass/trunk/temporal/t.rast.import/testsuite/
   grass/trunk/temporal/t.rast.import/testsuite/data/
   grass/trunk/temporal/t.rast.import/testsuite/data/precip_2000.tar.bzip2
   grass/trunk/temporal/t.rast.import/testsuite/test_temporal_rast_import.py
Modified:
   grass/trunk/lib/python/temporal/stds_import.py
   grass/trunk/temporal/t.rast.import/t.rast.import.py
Log:
t.rast.import: added memory option #2375, added answer /tmp to directory option, added test

Modified: grass/trunk/lib/python/temporal/stds_import.py
===================================================================
--- grass/trunk/lib/python/temporal/stds_import.py	2016-02-26 14:17:36 UTC (rev 67962)
+++ grass/trunk/lib/python/temporal/stds_import.py	2016-02-26 14:36:10 UTC (rev 67963)
@@ -53,7 +53,7 @@
 
 
 def _import_raster_maps_from_gdal(maplist, overr, exp, location, link, format_,
-                                  set_current_region=False):
+                                  set_current_region=False, memory=300):
     impflags = ""
     if overr:
         impflags += "o"
@@ -76,7 +76,7 @@
                                     overwrite=gscript.overwrite())
             else:
                 gscript.run_command("r.in.gdal", input=filename,
-                                    output=name,
+                                    output=name, memory=memory,
                                     flags=impflags,
                                     overwrite=gscript.overwrite())
 
@@ -173,7 +173,8 @@
 
 def import_stds(input, output, directory, title=None, descr=None, location=None,
                 link=False, exp=False, overr=False, create=False,
-                stds_type="strds", base=None, set_current_region=False):
+                stds_type="strds", base=None, set_current_region=False,
+                memory=300):
     """Import space time datasets of type raster and vector
 
         :param input: Name of the input archive file
@@ -194,6 +195,7 @@
                          should be imported
         :param base: The base name of the new imported maps, it will be
                      extended using a numerical index.
+        :param memory: Cache size for raster rows, used in r.in.gdal
     """
 
     global raise_on_error
@@ -437,7 +439,8 @@
         if type_ == "strds":
             if format_ == "GTiff" or format_ == "AAIGrid":
                 _import_raster_maps_from_gdal(maplist, overr, exp, location,
-                                              link, format_, set_current_region)
+                                              link, format_, set_current_region,
+                                              memory)
             if format_ == "pack":
                 _import_raster_maps(maplist, set_current_region)
         elif type_ == "stvds":

Modified: grass/trunk/temporal/t.rast.import/t.rast.import.py
===================================================================
--- grass/trunk/temporal/t.rast.import/t.rast.import.py	2016-02-26 14:17:36 UTC (rev 67962)
+++ grass/trunk/temporal/t.rast.import/t.rast.import.py	2016-02-26 14:36:10 UTC (rev 67963)
@@ -41,6 +41,7 @@
 #%option G_OPT_M_DIR
 #% key: directory
 #% description: Path to the extraction directory
+#% answer: /tmp
 #%end
 
 #%option
@@ -67,6 +68,16 @@
 #% multiple: no
 #%end
 
+#%option
+#% key: memory
+#% type: integer
+#% description: Cache size for raster rows
+#% label: Maximum memory to be used (in MB)
+#% options: 0-2047
+#% answer: 300
+#% multiple: no
+#%end
+
 #%flag
 #% key: r
 #% description: Set the current region from the last map that was imported
@@ -107,6 +118,7 @@
     descr = options["description"]
     location = options["location"]
     base = options["basename"]
+    memory = options["memory"]
     set_current_region = flags["r"]
     link = flags["l"]
     exp = flags["e"]
@@ -117,7 +129,7 @@
 
     tgis.import_stds(input, output, directory, title, descr, location,
                      link, exp, overr, create, "strds", base, 
-                     set_current_region)
+                     set_current_region, memory)
 
 if __name__ == "__main__":
     options, flags = grass.parser()

Added: grass/trunk/temporal/t.rast.import/testsuite/data/precip_2000.tar.bzip2
===================================================================
(Binary files differ)


Property changes on: grass/trunk/temporal/t.rast.import/testsuite/data/precip_2000.tar.bzip2
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: grass/trunk/temporal/t.rast.import/testsuite/test_temporal_rast_import.py
===================================================================
--- grass/trunk/temporal/t.rast.import/testsuite/test_temporal_rast_import.py	                        (rev 0)
+++ grass/trunk/temporal/t.rast.import/testsuite/test_temporal_rast_import.py	2016-02-26 14:36:10 UTC (rev 67963)
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Fri Feb 26 14:46:06 2016
+
+ at author: lucadelu
+"""
+
+"""
+Test t.rast.import
+
+(C) 2014 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+ at author: lucadelu
+"""
+
+from grass.gunittest.case import TestCase
+import os
+
+class TestRasterImport(TestCase):
+    
+    input_ = os.path.join("data", "precip_2000.tar.bzip2")
+    @classmethod
+    def tearDownClass(cls):
+        """Remove the temporary region
+        """
+        cls.del_temp_region()
+        cls.runModule("t.remove", flags="rf", inputs="A")
+        
+    def test_import(self):
+        self.assertModule("t.rast.import", input=self.input_, output="A", 
+                          basename="a", overwrite=True)
+        tinfo = """start_time=2000-01-01 00:00:00
+                   end_time=2001-01-01 00:00:00
+                   granularity=1 month
+                   map_time=interval
+                   north=320000.0
+                   south=10000.0
+                   east=935000.0
+                   west=120000.0
+                """
+                
+        info = SimpleModule("t.info", flags="g", input="A")
+        self.assertModuleKeyValue(module=info, reference=tinfo,
+                                  precision=2, sep="=")
\ No newline at end of file



More information about the grass-commit mailing list