[GRASS-SVN] r69319 - grass-addons/grass7/vector/v.strds.stats

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 31 04:45:57 PDT 2016


Author: lucadelu
Date: 2016-08-31 04:45:57 -0700 (Wed, 31 Aug 2016)
New Revision: 69319

Modified:
   grass-addons/grass7/vector/v.strds.stats/v.strds.stats.py
Log:
v.strds.stats: fixed small bugs

Modified: grass-addons/grass7/vector/v.strds.stats/v.strds.stats.py
===================================================================
--- grass-addons/grass7/vector/v.strds.stats/v.strds.stats.py	2016-08-31 09:25:48 UTC (rev 69318)
+++ grass-addons/grass7/vector/v.strds.stats/v.strds.stats.py	2016-08-31 11:45:57 UTC (rev 69319)
@@ -70,7 +70,7 @@
 class Sample(object):
 
     def __init__(self, start=None, end=None, raster_names=None,
-                 strds_name=None):
+                 strds_name=None, granularity=None):
         self.start = start
         self.end = end
         if raster_names is not None:
@@ -78,6 +78,7 @@
         else:
             self.raster_names = []
         self.strds_name = strds_name
+        self.granu = granularity
 
     def __str__(self):
         return "Start: %s\nEnd: %s\nNames: %s\n" % (str(self.start),
@@ -86,12 +87,16 @@
 
     def printDay(self, date='start'):
         if date == 'start':
-            return str(self.start).split(' ')[0].replace('-', '_')
+            output = str(self.start).split(' ')[0].replace('-', '_')
         elif date == 'end':
-            return str(self.end).split(' ')[0].replace('-', '_')
+            output = str(self.end).split(' ')[0].replace('-', '_')
         else:
             grass.fatal("The values accepted by printDay in Sample are:"
                         " 'start', 'end'")
+        if self.granu:
+            if self.granu.find('minute') != -1 or self.granu.find('second') != -1:
+                output += '_' + str(self.start).split(' ')[1].replace(':', '_')
+        return output
 
 def main():
     # Get the options
@@ -99,6 +104,7 @@
     output = options["output"]
     strds = options["strds"]
     tempwhere = options["t_where"]
+    where = options["where"]
     methods = options["method"]
     percentile = options["percentile"]
 
@@ -126,6 +132,7 @@
     first_strds = tgis.open_old_stds(strds_names[0], "strds", dbif)
     # Single space time raster dataset
     if len(strds_names) == 1:
+        granu = first_strds.get_granularity()
         rows = first_strds.get_registered_maps("name,mapset,start_time,end_time",
                                                tempwhere, "start_time",
                                                dbif)
@@ -139,7 +146,7 @@
             end = row["end_time"]
             raster_maps = [row["name"] + "@" + row["mapset"], ]
 
-            s = Sample(start, end, raster_maps, first_strds.get_name())
+            s = Sample(start, end, raster_maps, first_strds.get_name(), granu)
             samples.append(s)
     else:
         # Multiple space time raster datasets
@@ -160,7 +167,7 @@
                                                         False, None,
                                                         "equal", False,
                                                         False)
-
+        #TODO check granularity for multiple STRDS
         for i in range(len(mapmatrizes[0])):
             isvalid = True
             mapname_list = []



More information about the grass-commit mailing list