[GRASS-SVN] r69917 - in grass-addons/grass7/raster/r.green/r.green.hydro: r.green.hydro.delplants r.green.hydro.discharge r.green.hydro.financial r.green.hydro.optimal r.green.hydro.recommended r.green.hydro.structure r.green.hydro.technical r.green.hydro.theoretical

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Nov 25 14:37:49 PST 2016


Author: Giulia
Date: 2016-11-25 14:37:49 -0800 (Fri, 25 Nov 2016)
New Revision: 69917

Modified:
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.delplants/r.green.hydro.delplants.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.discharge/r.green.hydro.discharge.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.financial/r.green.hydro.financial.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.optimal/r.green.hydro.optimal.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.recommended/r.green.hydro.recommended.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.structure/r.green.hydro.structure.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py
   grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.theoretical/r.green.hydro.theoretical.py
Log:
r.green: path to the library

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.delplants/r.green.hydro.delplants.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.delplants/r.green.hydro.delplants.py	2016-11-25 22:19:42 UTC (rev 69916)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.delplants/r.green.hydro.delplants.py	2016-11-25 22:37:49 UTC (rev 69917)
@@ -100,25 +100,31 @@
 
 # import GRASS libraries
 from grass.exceptions import ParameterError
-from grass.script.core import parser, overwrite
+from grass.script.core import parser, overwrite, warning
 from grass.pygrass.vector import VectorTopo
 from grass.pygrass.raster import RasterRow
 from grass.pygrass.modules.shortcuts import vector as v
-from grass.pygrass.messages import get_msgr
 from grass.pygrass.utils import set_path
 
 
 try:
+    # set python path to the shared r.green libraries
     set_path('r.green', 'libhydro', '..')
     set_path('r.green', 'libgreen', os.path.join('..', '..'))
-
-    # finally import the module in the library
     from libgreen.utils import cleanup
     from libgreen.checkparameter import (check_required_columns,
                                          exception2error)
     from libhydro.plant import read_plants, write_plants
 except ImportError:
-    warning('libgreen and libhydro not in the python path!')
+    try:
+        set_path('r.green', 'libhydro', '../etc')
+        set_path('r.green', 'libgreen', '../etc')
+        from libgreen.utils import cleanup
+        from libgreen.checkparameter import (check_required_columns,
+                                             exception2error)
+        from libhydro.plant import read_plants, write_plants
+    except ImportError:
+        warning('libgreen and libhydro not in the python path!')
 
 
 def main(opts, flgs):

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.discharge/r.green.hydro.discharge.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.discharge/r.green.hydro.discharge.py	2016-11-25 22:19:42 UTC (rev 69916)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.discharge/r.green.hydro.discharge.py	2016-11-25 22:37:49 UTC (rev 69917)
@@ -172,17 +172,20 @@
 from grass.pygrass.utils import set_path
 from grass.script import mapcalc
 
-
 try:
     # set python path to the shared r.green libraries
     set_path('r.green', 'libhydro', '..')
     set_path('r.green', 'libgreen', os.path.join('..', '..'))
-
-    # finally import the module in the library
     from libgreen.utils import cleanup
     from libhydro.basin import dtm_corr
 except ImportError:
-    gcore.warning('libgreen and libhydro not in the python path!')
+    try:
+        set_path('r.green', 'libhydro', '../etc')
+        set_path('r.green', 'libgreen', '../etc')
+        from libgreen.utils import cleanup
+        from libhydro.basin import dtm_corr
+    except ImportError:
+        gcore.warning('libgreen and libhydro not in the python path!')
 
 
 if "GISBASE" not in os.environ:

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.financial/r.green.hydro.financial.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.financial/r.green.hydro.financial.py	2016-11-25 22:19:42 UTC (rev 69916)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.financial/r.green.hydro.financial.py	2016-11-25 22:37:49 UTC (rev 69917)
@@ -523,12 +523,14 @@
     # set python path to the shared r.green libraries
     set_path('r.green', 'libhydro', '..')
     set_path('r.green', 'libgreen', os.path.join('..', '..'))
-
     from libgreen.utils import cleanup
-    from libgreen.checkparameter import check_required_columns, exception2error
-    from libhydro.plant import read_plants, write_structures
 except ImportError:
-    warning('libgreen and libhydro not in the python path!')
+    try:
+        set_path('r.green', 'libhydro', '../etc')
+        set_path('r.green', 'libgreen', '../etc')
+        from libgreen.utils import cleanup
+    except ImportError:
+        warning('libgreen and libhydro not in the python path!')
 
 
 def rname(base):
@@ -706,7 +708,7 @@
         # open vector map with the existing electroline
         ename = opts['electro']
         ename, emapset = ename.split('@') if '@' in ename else (ename, '')
-        ltemp=[]
+        ltemp = []
         with VectorTopo(ename, mapset=emapset,
                         layer=int(opts['electro_layer']),
                         mode='r') as electro:

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.optimal/r.green.hydro.optimal.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.optimal/r.green.hydro.optimal.py	2016-11-25 22:19:42 UTC (rev 69916)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.optimal/r.green.hydro.optimal.py	2016-11-25 22:37:49 UTC (rev 69917)
@@ -107,19 +107,28 @@
 #from grass.pygrass.raster.buffer import Buffer
 from grass.pygrass.utils import set_path
 
-
 try:
+    # set python path to the shared r.green libraries
     set_path('r.green', 'libhydro', '..')
     set_path('r.green', 'libgreen', os.path.join('..', '..'))
-
     from libgreen.utils import cleanup
     from libgreen.utils import dissolve_lines
     from libhydro.optimal import find_segments
     from libhydro.optimal import write_plants
     from libhydro.optimal import write_points
 except ImportError:
-    gcore.warning('libgreen and libhydro not in the python path!')
+    try:
+        set_path('r.green', 'libhydro', '../etc')
+        set_path('r.green', 'libgreen', '../etc')
+        from libgreen.utils import cleanup
+        from libgreen.utils import dissolve_lines
+        from libhydro.optimal import find_segments
+        from libhydro.optimal import write_plants
+        from libhydro.optimal import write_points
+    except ImportError:
+        gcore.warning('libgreen and libhydro not in the python path!')
 
+
 ##################################################
 # optimization problem
 # the coordinate along the river is s

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.recommended/r.green.hydro.recommended.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.recommended/r.green.hydro.recommended.py	2016-11-25 22:19:42 UTC (rev 69916)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.recommended/r.green.hydro.recommended.py	2016-11-25 22:37:49 UTC (rev 69917)
@@ -209,12 +209,18 @@
     # set python path to the shared r.green libraries
     set_path('r.green', 'libhydro', '..')
     set_path('r.green', 'libgreen', os.path.join('..', '..'))
-    # finally import the module in the library
     from libgreen.utils import cleanup
     from libhydro.plant import power2energy
 except ImportError:
-    gcore.warning('libgreen and libhydro not in the python path!')
+    try:
+        set_path('r.green', 'libhydro', '../etc')
+        set_path('r.green', 'libgreen', '../etc')
+        from libgreen.utils import cleanup
+        from libhydro.plant import power2energy
+    except ImportError:
+        gcore.warning('libgreen and libhydro not in the python path!')
 
+
 if "GISBASE" not in os.environ:
     print("You must be in GRASS GIS to run this program.")
     sys.exit(1)

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.structure/r.green.hydro.structure.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.structure/r.green.hydro.structure.py	2016-11-25 22:19:42 UTC (rev 69916)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.structure/r.green.hydro.structure.py	2016-11-25 22:37:49 UTC (rev 69917)
@@ -142,15 +142,20 @@
     # set python path to the shared r.green libraries
     set_path('r.green', 'libhydro', '..')
     set_path('r.green', 'libgreen', os.path.join('..', '..'))
-
     from libgreen.utils import cleanup
-    from libhydro.optimal import conv_segpoints
-    from libgreen.checkparameter import check_required_columns, exception2error
-    from libhydro.plant import read_plants, write_structures
 except ImportError:
-    warning('libgreen and libhydro not in the python path!')
+    try:
+        set_path('r.green', 'libhydro', '../etc')
+        set_path('r.green', 'libgreen', '../etc')
+        from libgreen.utils import cleanup
+    except ImportError:
+        warning('libgreen and libhydro not in the python path!')
 
+from libhydro.optimal import conv_segpoints
+from libgreen.checkparameter import check_required_columns, exception2error
+from libhydro.plant import read_plants, write_structures
 
+
 def main(opts, flgs):
     TMPVECT = []
     DEBUG = True if flgs['d'] else False

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py	2016-11-25 22:19:42 UTC (rev 69916)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.technical/r.green.hydro.technical.py	2016-11-25 22:37:49 UTC (rev 69917)
@@ -231,7 +231,7 @@
 from grass.pygrass.messages import get_msgr
 from grass.pygrass.vector import VectorTopo
 
-from math import pi, log10, sin, acos, asin, sqrt, atan
+from math import pi, log10, sin, acos, asin, sqrt
 
 try:
     from scipy.optimize import fsolve
@@ -241,18 +241,24 @@
 
 import numpy as np
 
-
 try:
     # set python path to the shared r.green libraries
     set_path('r.green', 'libhydro', '..')
     set_path('r.green', 'libgreen', os.path.join('..', '..'))
-    # finally import the module in the library
     from libgreen.utils import cleanup
+    from libhydro.plant import power2energy
     from libhydro.optimal import conv_segpoints
-    from libhydro.plant import power2energy
 except ImportError:
-    gcore.warning('libgreen and libhydro not in the python path!')
+    try:
+        set_path('r.green', 'libhydro', '../etc')
+        set_path('r.green', 'libgreen', '../etc')
+        from libgreen.utils import cleanup
+        from libhydro.plant import power2energy
+        from libhydro.optimal import conv_segpoints
+    except ImportError:
+        gcore.warning('libgreen and libhydro not in the python path!')
 
+
 DEBUG = False
 TMPRAST = []
 

Modified: grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.theoretical/r.green.hydro.theoretical.py
===================================================================
--- grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.theoretical/r.green.hydro.theoretical.py	2016-11-25 22:19:42 UTC (rev 69916)
+++ grass-addons/grass7/raster/r.green/r.green.hydro/r.green.hydro.theoretical/r.green.hydro.theoretical.py	2016-11-25 22:37:49 UTC (rev 69917)
@@ -100,12 +100,10 @@
 from grass.pygrass.messages import get_msgr
 from grass.pygrass.utils import set_path
 
-
 try:
     # set python path to the shared r.green libraries
     set_path('r.green', 'libhydro', '..')
     set_path('r.green', 'libgreen', os.path.join('..', '..'))
-    # finally import the module in the library
     from libgreen.utils import cleanup
     from libhydro.basin import dtm_corr
     from libhydro.plant import power2energy
@@ -115,7 +113,19 @@
     from libgreen.utils import raster2numpy
     from libgreen.utils import remove_pixel_from_raster
 except ImportError:
-    gcore.warning('libgreen and libhydro not in the python path!')
+    try:
+        set_path('r.green', 'libhydro', '../etc')
+        set_path('r.green', 'libgreen', '../etc')
+        from libgreen.utils import cleanup
+        from libhydro.basin import dtm_corr
+        from libhydro.plant import power2energy
+        from libhydro import basin
+        from libgreen.utils import check_overlay_rr
+        #from libgreen.utils import check_overlay_rv
+        from libgreen.utils import raster2numpy
+        from libgreen.utils import remove_pixel_from_raster
+    except ImportError:
+        gcore.warning('libgreen and libhydro not in the python path!')
 
 
 if "GISBASE" not in os.environ:



More information about the grass-commit mailing list