Index: wflow-py/wflow/wflow_extract.py =================================================================== diff -u -r11f8d5cb169091c08cc5b7210e35f2ce7aed5fb3 -r679be96f270311b53a1c4acd28f8226c34276e31 --- wflow-py/wflow/wflow_extract.py (.../wflow_extract.py) (revision 11f8d5cb169091c08cc5b7210e35f2ce7aed5fb3) +++ wflow-py/wflow/wflow_extract.py (.../wflow_extract.py) (revision 679be96f270311b53a1c4acd28f8226c34276e31) @@ -1,7 +1,7 @@ #!/usr/bin/python # Wflow is Free software, see below: -# +# # Copyright (c) J. Schellekens 2005-2011 # # This program is free software: you can redistribute it and/or modify @@ -29,14 +29,15 @@ -I skip input mapstacks if specified -f force overwrite an existing model -The script uses the pcraster resample program to reduce the maps. +The script uses the pcraster resample program to reduce the maps. """ from wflow.wflow_lib import * import wflow.pcrut as pcrut +import sys import os import os.path import glob @@ -48,17 +49,17 @@ for msg in args: print msg print __doc__ sys.exit(0) - + def main(argv=None): if argv is None: argv = sys.argv[1:] if len(argv) == 0: usage() - return + return opts, args = getopt.getopt(argv, 'fhC:N:Ir:c:') @@ -69,10 +70,10 @@ force = False caseName = "rhineNew" caseNameNew = "rhineNew_resampaa" - cloneMap = "clone.map" - + cloneMap = "clone.map" + for o, a in opts: if o == '-C': caseName = a if o == '-c': cloneMap = a @@ -81,20 +82,20 @@ if o == '-I': inmaps = False if o == '-h': usage() if o == '-f': force = True - + dirs = ['/intbl/', '/inmaps/', '/staticmaps/', '/intss/', '/instate/', '/outstate/'] if os.path.isdir(caseNameNew) and not force: print "Refusing to write into an existing directory:" + caseNameNew - exit() + sys.exit() if not os.path.isdir(caseNameNew): for ddir in dirs: os.makedirs(caseNameNew + ddir) for inifile in glob.glob(caseName + "/*.ini"): shutil.copy(inifile, inifile.replace(caseName,caseNameNew)) - + for ddir in dirs: for mfile in glob.glob(caseName + ddir + '/*.map'): mstr = "resample --clone " + cloneMap + ' ' + mfile + " " + mfile.replace(caseName,caseNameNew) @@ -111,10 +112,10 @@ for mfile in glob.glob(caseName + ddir + '*.tbl'): shutil.copy(mfile, mfile.replace(caseName,caseNameNew)) for mfile in glob.glob(caseName + ddir + '*.col'): - shutil.copy(mfile, mfile.replace(caseName,caseNameNew)) + shutil.copy(mfile, mfile.replace(caseName,caseNameNew)) for mfile in glob.glob(caseName + ddir + '*.tss'): - shutil.copy(mfile, mfile.replace(caseName,caseNameNew)) - + shutil.copy(mfile, mfile.replace(caseName,caseNameNew)) + print "recreating static maps ..." # Create new ldd using old river network dem = readmap(caseNameNew + "/staticmaps/wflow_dem.map")