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.

Unverified Commit 0d49c72c authored by Julien Veyssier's avatar Julien Veyssier
Browse files

windows-friendly final touch, fix pandas file writing, fix a few remaining...


windows-friendly final touch, fix pandas file writing, fix a few remaining grass commands...running on windows
Signed-off-by: default avatarJulien Veyssier <eneiluj@posteo.net>
parent 4e627862
......@@ -3,7 +3,7 @@
# this file contains the converted old awk scripts which were not portable (to windows)
from collections import defaultdict
import time
import os, time
# Format table N:M
# it was the uggliest code ever
......@@ -30,12 +30,12 @@ def formatNm(bas, topoToHruTmpPath, topoBflTmpPath, stats):
ttohru.write('%s\t%s\t%s\t' % (sec[:-1], size, bas))
ttohru.write(','.join(ids))
ttohru.write('\n')
ttohru.write(os.linesep)
tbfl.write('%s\t%s\t' % (sec[:-1], size))
ws = ['%.4f' % (w / acc_sum) for w in weight]
tbfl.write(','.join(ws))
tbfl.write('\n')
tbfl.write(os.linesep)
# Find max rate in N:M (+ associated id)
......
......@@ -48,7 +48,7 @@ def grass_pipe_command(*args, **kwargs):
def exportRasters(rMap):
for name in rMap:
grass.run_command('r.out.gdal',
grass_run_command('r.out.gdal',
input=name,
output=rMap[name],
overwrite='True', stdout=DEVNULL, stderr=DEVNULL)
......@@ -56,7 +56,7 @@ def exportRasters(rMap):
def exportRastersFromEnv(rMap, grassDbPath, location):
os.environ['GISRC'] = os.path.join(grassDbPath, 'grassdata', location, '.grassrc')
for name in rMap:
grass.run_command('r.out.gdal',
grass_run_command('r.out.gdal',
input='result',
output=rMap[name],
overwrite='True', stdout=DEVNULL, stderr=DEVNULL)
......@@ -64,7 +64,7 @@ def exportRastersFromEnv(rMap, grassDbPath, location):
def importRastersInEnv(rMap, grassDbPath, location):
os.environ['GISRC'] = os.path.join(grassDbPath, 'grassdata', location, '.grassrc')
for name in rMap:
grass.run_command('r.in.gdal',
grass_run_command('r.in.gdal',
flags='o',
input=rMap[name],
output=name,
......
......@@ -427,14 +427,14 @@ def main(parms_file, nbProc, generator=False):
strTime = time.strftime('%a, %d %b %Y, %H:%M:%S', time.localtime())
dfTth = pd.concat(tthFrames)
dfTth.sort_values('a', inplace=True)
with open(os.path.join(tmpPath, 'topologie_to_hru.par'), 'w') as f:
with open(os.path.join(tmpPath, 'topologie_to_hru.par'), 'w', newline='\n') as f:
f.write('# topology_to_hru.par created %s by hru-delin-nextgen\n' % strTime)
f.write('# ID\tMAXACC\tSUBBASIN\tTO_HRU\n')
dfTth.to_csv(f, header=False, index=False, sep='\t')
dfTbfl = pd.concat(tbflFrames)
dfTbfl.sort_values('a', inplace=True)
with open(os.path.join(tmpPath, 'topologie_bfl.par'), 'w') as f:
with open(os.path.join(tmpPath, 'topologie_bfl.par'), 'w', newline='\n') as f:
f.write('# topology_rates.par created %s by hru-delin-nextgen\n' % strTime)
f.write('# ID\tMAXACC\tWEIGHTS\n')
dfTbfl.to_csv(f, header=False, index=False, sep='\t')
......
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