En raison du déménagement des baies serveurs, les services gitlab.irstea.fr et mattermost.irstea.fr seront interrompus le samedi 2 octobre 2021 au matin. Ils devraient revenir à la normale dans la journée.

Commit 6239144d authored by Rabotin Michael's avatar Rabotin Michael
Browse files

Corrected error for windows

parent fc6be731
......@@ -265,6 +265,7 @@ def main(parms_file):
cutting_raster(layer, layer_cut, xmin_slect, ymax_slect, xmax_slect, ymin_slect)
dem_wk = 'dem_wk'
grass_run_command('g.proj', flags='c', georef=dem_cut, stdout=DEVNULL, stderr=DEVNULL)
grass_run_command('r.in.gdal', flags='o', input=dem_cut, output=dem_wk, overwrite='True', stdout=DEVNULL, stderr=DEVNULL)
grass_run_command('g.region', flags='sp', raster=dem_wk, stdout=DEVNULL, stderr=DEVNULL)
......
......@@ -37,7 +37,7 @@ import struct, math, csv, shutil
from osgeo import gdal
from osgeo.gdalnumeric import *
from gdalconst import *
from osgeo.gdalconst import *
from osgeo import ogr
import multiprocessing
......@@ -108,6 +108,7 @@ def snapping_gauges_to_reaches(parms, directory_out):
dist_ok_2 = int(parms.get('auto_relocation', 'distance_tolerance_2' ))
col_area = parms.get('auto_relocation', 'gauge_area_col_name')
if col_area == '':
print(' =========> ERROR ')
sys.exit(' =========> CHECK gauge_area_col_name PARAMETER')
......@@ -160,7 +161,7 @@ def snapping_gauges_to_reaches(parms, directory_out):
Yreste = gauge_y % abs(vres)
new_gauge_x = (gauge_x - Xreste) + 1
new_gauge_y = (gauge_y - Yreste) - 1
print("end********")
for gauge in reloc_lyr:
if not gauge.IsFieldSet(col_name):
......@@ -168,7 +169,7 @@ def snapping_gauges_to_reaches(parms, directory_out):
gauge_code = gauge.GetField(col_name)
# Get the drained surface of the gauge
gauge_area = gauge.GetField(col_area)
# ------------------------------------------------------------
# if gauge_area < 0:
# nb_pixel_area = basin_min_size + 1
......@@ -191,7 +192,7 @@ def snapping_gauges_to_reaches(parms, directory_out):
Yreste = gauge_y % abs(vres)
new_gauge_x = (gauge_x - Xreste) + 1
new_gauge_y = (gauge_y - Yreste) - 1
# Read the currents of accum raster around the gauge
# (new_gauge_x - georef[0]) / hres)
# ==> this gives the column in raster file where the station has been relocated
......@@ -244,7 +245,7 @@ def snapping_gauges_to_reaches(parms, directory_out):
best_x = 0
best_y = 0
better_place_found = False
for y in range(start, row_max):
for x in range(start, col_max):
# ------------------------------------------------------------
......@@ -530,7 +531,7 @@ def main(parms_file, nbProc, generator=False):
driver.DeleteDataSource(gauges_reloc_file)
reloc_shp = driver.CreateDataSource(gauges_reloc_file)
reloc_lyr = reloc_shp.CopyLayer(gauges_lyr, gauges_reloc_name)
# Relocation of the gauges
if (parms.get('auto_relocation', 'to_do')) == 'yes':
print('---------- HRU-delin Step 2 : Relocation of the gauges')
......
......@@ -39,7 +39,7 @@ from grass.script.utils import decode, encode
import numpy as np
from osgeo import gdal
from gdalconst import *
from osgeo.gdalconst import *
from osgeo import ogr
import pandas as pd
......@@ -226,7 +226,7 @@ def main(parms_file, nbProc, generator=False):
directory_out = parms.get('dir_out', 'files')
if not os.path.isdir(directory_out):
sys.exit('------------> ERROR : In Directoy is not valid')
sys.exit('------------> ERROR : Out Directoy is not valid')
## if hgeon, landuse and soil provided, test if exist
......@@ -662,6 +662,7 @@ def main(parms_file, nbProc, generator=False):
p.wait()
pReclass.stdin.close()
pReclass.wait()
p.close()
grass_run_command('r.statistics', flags='c',base=hrus, cover=slope_labeled, method='average', output=slope_avg, overwrite='True')
grass_run_command('r.mapcalc', expression='slope_avg_cval=int(@slope_avg*1000)/1000.0', overwrite='True')
......@@ -702,7 +703,7 @@ def main(parms_file, nbProc, generator=False):
grass_run_command('db.execute', sql='ALTER TABLE hrus_c_pnt ADD x DOUBLE PRECISION')
grass_run_command('db.execute', sql='ALTER TABLE hrus_c_pnt ADD y DOUBLE PRECISION')
grass_run_command('v.to.db', map='hrus_c_pnt', option='coor', columns='x,y')
grass_run_command('v.to.db', map='hrus_c_pnt', option='coor', columns='x,y', overwrite='True')
header += '\tx\ty'
ranges['centroid'] = [0, 9999999, 'm']
header_min_val += '\t' + str(ranges['centroid'][0]) + '\t' + str(ranges['centroid'][0])
......@@ -844,7 +845,7 @@ def main(parms_file, nbProc, generator=False):
for l in vals:
p.write(l)
p.write(footer)
par.close()
save_config = os.path.join(directory_out, 'hrudelin_config_save.cfg')
#os.system('cp "%s" "%s" ' % (parms_file, save_config))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment