-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
249 changed files
with
17,016 additions
and
12,695 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pytest | ||
numpy==1.23.5 | ||
matplotlib==3.6.3 | ||
scipy==1.11.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pytest==8.2.0 | ||
numpy==1.26.4 | ||
matplotlib==3.6.3 | ||
scipy==1.11.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pytest==7.2.2 | ||
numpy==1.26.4 | ||
matplotlib==3.5.3 | ||
scipy==1.7.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<metadata xml:lang="cs"><Esri><CreaDate>20230116</CreaDate><CreaTime>10441900</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><ModDate>20240410</ModDate><ModTime>132913</ModTime></Esri><toolbox name="SMODERP2D" alias=""><arcToolboxHelpPath>e:\arcgis pro\Resources\Help\gp</arcToolboxHelpPath><toolsets/></toolbox><dataIdInfo><idCitation><resTitle>SMODERP2D</resTitle></idCitation></dataIdInfo><distInfo><distributor><distorFormat><formatName>ArcToolbox Toolbox</formatName></distorFormat></distributor></distInfo></metadata> | ||
<metadata xml:lang="cs"><Esri><CreaDate>20230116</CreaDate><CreaTime>10441900</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><ModDate>20240605</ModDate><ModTime>111141</ModTime></Esri><toolbox name="SMODERP2D" alias=""><arcToolboxHelpPath>c:\program files\arcgis\pro\Resources\Help\gp</arcToolboxHelpPath><toolsets/></toolbox><dataIdInfo><idCitation><resTitle>SMODERP2D</resTitle></idCitation></dataIdInfo><distInfo><distributor><distorFormat><formatName>ArcToolbox Toolbox</formatName></distorFormat></distributor></distInfo></metadata> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
import argparse | ||
|
||
from smoderp2d.runners.grass import GrassGisRunner | ||
from smoderp2d.exceptions import ProviderError, MaxIterationExceeded | ||
|
||
def run_process(params, epsg): | ||
retcode = 0 | ||
runner = None | ||
try: | ||
runner = GrassGisRunner() | ||
runner.create_location(f'EPSG:{epsg}') | ||
runner.set_options(params) | ||
runner.import_data() | ||
runner.run() | ||
except (ProviderError, MaxIterationExceeded) as e: | ||
print(f'ERORR: {e}', file=sys.stderr) | ||
retcode = 1 | ||
|
||
if runner is not None: | ||
runner.finish() | ||
|
||
return retcode | ||
|
||
def main(params, epsg): | ||
sys.exit(run_process(params, epsg)) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
prog='batch_process', | ||
description='Run SMODERP2D as batch process' | ||
) | ||
parser.add_argument('--elevation', required=True) | ||
parser.add_argument('--soil', required=True) | ||
parser.add_argument('--soil_type_fieldname', required=True) | ||
parser.add_argument('--vegetation', required=True) | ||
parser.add_argument('--vegetation_type_fieldname', required=True) | ||
parser.add_argument('--rainfall_file', required=True) | ||
parser.add_argument('--end_time', required=True) | ||
parser.add_argument('--maxdt', required=True) | ||
parser.add_argument('--table_soil_vegetation', required=True) | ||
parser.add_argument('--table_soil_vegetation_fieldname', required=True) | ||
parser.add_argument('--output', required=True) | ||
parser.add_argument('--points') | ||
parser.add_argument('--points_fieldname') | ||
parser.add_argument('--streams') | ||
parser.add_argument('--channel_properties_table') | ||
parser.add_argument('--streams_channel_type_fieldname') | ||
parser.add_argument('--flow_direction', default='single') | ||
parser.add_argument('--wave', default='kinematic') | ||
parser.add_argument('--generate_temporary', action='store_true') | ||
parser.add_argument('--epsg', default=5514) | ||
|
||
args = parser.parse_args() | ||
|
||
main({ | ||
'elevation': args.elevation, | ||
'soil': args.soil, | ||
'soil_type_fieldname': args.soil_type_fieldname, | ||
'vegetation': args.vegetation, | ||
'vegetation_type_fieldname': args.vegetation_type_fieldname, | ||
'rainfall_file': args.rainfall_file, | ||
'end_time': args.end_time, | ||
'maxdt': args.maxdt, | ||
'output': args.output, | ||
'points': args.points, | ||
'points_fieldname': args.points_fieldname, | ||
'streams': args.streams, | ||
'table_soil_vegetation': args.table_soil_vegetation, | ||
'table_soil_vegetation_fieldname': args.table_soil_vegetation_fieldname, | ||
'channel_properties_table': args.channel_properties_table, | ||
'streams_channel_type_fieldname': args.streams_channel_type_fieldname, | ||
'flow_direction': args.flow_direction, | ||
'wave': args.wave, | ||
'generate_temporary': bool(args.generate_temporary) | ||
}, epsg=args.epsg | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys | ||
import argparse | ||
import csv | ||
|
||
from smoderp2d.exceptions import ProviderError, MaxIterationExceeded | ||
|
||
from batch_process import run_process | ||
|
||
def get_params_epsg(params): | ||
epsg = params.pop('epsg') | ||
|
||
return params, int(epsg) | ||
|
||
def run_process_single(params, epsg): | ||
# run single process | ||
print('-' * 80) | ||
print(f'Run process with {params}...') | ||
print('-' * 80) | ||
|
||
return run_process(params, epsg) | ||
|
||
def main(csv_file, workers): | ||
# collect params | ||
params = [] | ||
with open(csv_file, newline='') as fd: | ||
reader = csv.DictReader(fd, delimiter=';') | ||
for row in reader: | ||
if row['epsg'].startswith('#'): | ||
# skip commented rows | ||
continue | ||
for k, v in row.items(): | ||
if v in ('true', 'false'): | ||
row[k] = True if v.lower() == 'true' else False | ||
params.append(row) | ||
|
||
# check for duplicated output paths | ||
output_paths = set(p['output'] for p in params) | ||
if len(params) != len(output_paths): | ||
sys.exit("ERROR: Duplicated output paths detected") | ||
|
||
# run processes | ||
if workers > 1: | ||
from joblib import Parallel, delayed | ||
|
||
Parallel(n_jobs=workers, backend="multiprocessing", verbose=10)( | ||
delayed(run_process_single)(*get_params_epsg(p)) for p in params | ||
) | ||
else: | ||
for p in params: | ||
run_process_single(*get_params_epsg(p)) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
prog='batch_process_csv', | ||
description='Run SMODERP2D as batch processes from CSV', | ||
epilog=r'Usage: PYTHONPATH=`pwd` python3 bin/grass/batch_process_csv.py --csv \ bin/grass/batch_process.csv' | ||
) | ||
|
||
parser.add_argument('--csv', required=True) | ||
parser.add_argument('--workers', default=1) | ||
|
||
args = parser.parse_args() | ||
|
||
main(args.csv, int(args.workers)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.