Skip to content

Commit

Permalink
version 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
celray committed Aug 25, 2018
1 parent b4b253b commit 99017de
Show file tree
Hide file tree
Showing 38 changed files with 164 additions and 172 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file removed Data/shapes/drawoutlets.dbf
Binary file not shown.
Binary file removed Data/shapes/drawoutlets.shp
Binary file not shown.
Binary file removed Data/shapes/drawoutlets.shx
Binary file not shown.
Binary file modified Data/shapes/riv1.dbf
Binary file not shown.
2 changes: 1 addition & 1 deletion Data/shapes/riv1.prj
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PROJCS["WGS 84 / UTM zone 37N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",39],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32637"]]
PROJCS["WGS 84 / UTM zone 37N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",39],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32637"]]
Binary file modified Data/shapes/riv1.shp
Binary file not shown.
Binary file modified Data/shapes/riv1.shx
Binary file not shown.
Binary file removed Data/shapes/subs1.dbf
Binary file not shown.
Binary file removed Data/shapes/subs1.shp
Binary file not shown.
Binary file removed Data/shapes/subs1.shx
Binary file not shown.
24 changes: 0 additions & 24 deletions Data/tables/Robit_usersoil.csv

This file was deleted.

Binary file removed Data/tables/WGEN_Robit.xlsx
Binary file not shown.
Binary file removed Data/tables/usersoil.xlsx
Binary file not shown.
5 changes: 0 additions & 5 deletions Data/weather/Schema.ini

This file was deleted.

5 changes: 0 additions & 5 deletions Data/weather/schemaBackup.ini

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install pyodbc via `pip install pyodbc`
## For users
This repository includes the code for the wrapper presented in this paper. The wrapper runs in 32 bit version of python 2.7.

### 1. [runQGISWorkflow.py](./runQGISWorkflow.py)
### 1. [runQSWAT.py](./runQSWAT.py)
This is the file used to launch the model set up process

### 2. [settings.py](./settings.py)
Expand All @@ -25,7 +25,7 @@ This directory contains all the modules for the workflow
This directory has an example dataset for testing

## Versions
Version 0.1.0 - June 2018
Version 1.5.0 - August 2018

## Authors
Celray James CHAWANDA
Expand Down
Binary file removed blue_nile_data_&_namelist/Data.zip
Binary file not shown.
66 changes: 0 additions & 66 deletions blue_nile_data_&_namelist/settings.py

This file was deleted.

18 changes: 4 additions & 14 deletions runQGISWorkflow.py → runQSWAT.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
"""
Author : Celray James CHAWANDA
Author : Celray James CHAWANDA ([email protected])
Institution : Vrije Universiteit Brussel (VUB)
This is the main script for launching the SWAT model setup process
"""


import sys, os, shutil, shlex
from settings import *
from datetime import datetime
Expand All @@ -19,7 +16,6 @@ def run_and_log(command, log_, save_dir, mode):
os.system(command + ">" + save_dir + '2>&1')
elif mode == "a":
os.system(command + ">>" + save_dir + '2>&1')

else:
os.system(command)

Expand All @@ -29,21 +25,15 @@ def copy_file(original_file_path, destination):
shutil.copy(original_file_path, destination)

time_begin = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

home_dir = os.getcwd()

copy_file("settings.py", "workflow_lib/settings.py")

os.chdir(home_dir + "/workflow_lib/")

run_and_log('python "' + os.path.join(home_dir, 'workflow_lib', 'prepare_project.py') + '"', log, '"' + os.path.join(home_dir, 'log.txt') + '"', "w")
run_and_log('python "' + os.path.join(home_dir, 'workflow_lib', 'main.py') + '"', log, '"' + os.path.join(home_dir, 'log.txt') + '"', "a")


time_end = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

print("\n\nFrom : " + time_begin)
print("To : " + time_end)
print("Run Time:\n From : " + time_begin)
print(" To : " + time_end)

with open(home_dir + "/run_time.txt", "w") as f:
f.write("Begin: " + time_begin + "\nEnd : " + time_end)
Expand Down
28 changes: 15 additions & 13 deletions settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""------------------ QSWAT Workflow 1.5 Settings File---------------"""
"""------------------ QSWAT Workflow v1.5 Settings File---------------"""
# Project Identification
Project_Name = "working_example"

Expand All @@ -7,17 +7,16 @@
Topography = "dem.tif"
Soils = "rob_soils.tif"
Land_Use = "roblanduse.tif"
#Irrigation = ""

# LookUp Files
soil_lookup = "soil_lookup.csv"
landuse_lookup = "landuse_lookup.csv"
#
# Database table files
Usersoil = "usersoil.csv"
WGEN_user = "WGEN_Robit.csv"

# Shape Files
Outlet = "drawoutlets.shp" # it should have same format as in the example
Outlet = "MainOutlet.shp" # it should have same format as in the example

# Weather stationinformation files
Precipitation = "pcpRobStation.txt"
Expand All @@ -30,11 +29,11 @@
# Watershed Deliniation (1 = Cells)
WS_thresholds_type = 1
WS_threshold = 792
OUT_Snap_threshold = 300 # metres
Burn_in_shape = "" # leave as "" if none
OUT_Snap_threshold = 300 # metres
Burn_in_shape = "" # leave as "" if none (option under development as of v1.5)

# ------------- HRU Definition -------------
Slope_classes = "0, 10, 50, 9999"
Slope_classes = "0, 10, 42, 9999"

# HRU creation method (1 = Dominant landuse, soil, slope , 2 = Dominant HRU,
# 3 = Filter by Area, 4 = Target Number of HRUs,
Expand All @@ -45,17 +44,20 @@
# Thresholds (1 = Total Area , 2 = Percent)
HRU_thresholds_type = 2

HRU_thres_Soil = 10 # Only used if HRU_creation_method 5 is selected
HRU_thres_LandUse = 12 # can be set to "" if 5 is not selected
HRU_thres_LandUse = 12 # Only used if HRU_creation_method 5 is selected
HRU_thres_Soil = 10 # can be set to "" if 5 is not selected
HRU_thres_Slope = 7

Target_Value = 20 # used if HRU_creation_method 3 and 4 are selected

# model run settings file
cal_file = "" # a model.in file (format of swatcup) with parameters for the callibrated model
# leave as "" if there is no file to be used.
Model_Run_period = "" # e.g. "1975 - 1980". period to run the simulation from file.cio,
# leave as "" to run whole period where weather data is available
Warm_up_period = 1 # the number of years for running the model without printing output

# Log progress or not? If yes, you will not see updates
log = False # True or False
"""--------------------------- Settings End -----------------------"""





Binary file modified workflow_lib/QSWATRef2012.mdb
Binary file not shown.
Binary file added workflow_lib/cal_holders.zip
Binary file not shown.
17 changes: 12 additions & 5 deletions workflow_lib/cio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import cj_function_lib as cj
import init_file as variables
import settings
import mdbtools as mdt

#print variables.ProjMDB
Expand Down Expand Up @@ -120,8 +121,13 @@


# Parameters
NBYR = cio_table[0].split(",")[1]
IYR = cio_table[0].split(",")[2]
if settings.Model_Run_period.replace(" ","") != "":
NBYR = int(settings.Model_Run_period.replace(" ","").split("-")[1]) - int(settings.Model_Run_period.replace(" ","").split("-")[0])
IYR = int(settings.Model_Run_period.replace(" ","").split("-")[0])
else:
NBYR = cio_table[0].split(",")[1]
IYR = cio_table[0].split(",")[2]

IDAF = cio_table[0].split(",")[3]
IDAL = cio_table[0].split(",")[4]
IGEN = cio_table[0].split(",")[5]
Expand Down Expand Up @@ -152,7 +158,10 @@
ICLB = cio_table[0].split(",")[30]
#IPRINT = cio_table[0].split(",")[31]
IPRINT = '0'
NYSKIP = cio_table[0].split(",")[32]
if settings.Warm_up_period == "":
NYSKIP = cio_table[0].split(",")[32]
else:
NYSKIP = settings.Warm_up_period
ILOG = cio_table[0].split(",")[33]
IPRP = cio_table[0].split(",")[34]
IPRS = cio_table[0].split(",")[35]
Expand All @@ -169,8 +178,6 @@
IWTR = cio_table[0].split(",")[46]
ICALEN = cio_table[0].split(",")[47]



# Building String
cio_file = "Master Watershed File: file.cio" + \
"\n" + "Project Description:" + \
Expand Down
Loading

0 comments on commit 99017de

Please sign in to comment.