# SUMMARY:      createstreamnetwork.py
# USAGE:        Main code for python version createstreamnetwork
# ORG:          Pacific Northwest National Laboratory
# AUTHOR:       Zhuoran Duan
# E-MAIL:       zhuoran.duan@pnnl.gov
# ORIG-DATE:    Apr-2017
# DESCRIPTION:  Python version of original createstreamnetwork aml
# DESCRIP-END.
# COMMENTS:     This python script is created based on original 
#		AML scripts createstreamnetwork.aml as part of DHSVM
#
# Last Change: 2017-08-10 

# -------------------------------------------------------------
#	Import system modules
# -------------------------------------------------------------

import arcpy
from arcpy import env
from arcpy.sa import *
import arcgisscripting
import sys
import os
import math
import numpy as np
import csv 


#-------------------------------------------------------------------#
#--------------------------- WorkSpace  ----------------------------#    
#-------------------------------------------------------------------#
env.workspace = "C:/Users/jwon/Desktop/kitsap_clean/arcpy/kitsap8/"
path          = "C:/Users/jwon/Desktop/kitsap_clean/arcpy/kitsap8/"

#-------------------------------------------------------------------#
###########           Setup Input          
#-------------------------------------------------------------------#
elev = "dem40"                  # name of DEM GRID, unclipped DEM recommended
wshed = "mask"                # name of MASK file
soildepth = "soild"                   # name of soil depth file
streamfile = "streamfile"             # name of stream arc file
key = 'MASK'                          # Enter 'MASK' or 'MOUTH'
source = 220000000                       # Min source area to initiate stream (sq. meter)
mindepth = .5                       # Minimum Soil Depth (meter)                    
maxdepth =  2                     # Maximum Soil Depth (meter)

elev = path + elev
wshed = path + wshed

arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True

if arcpy.Exists(soildepth):
    print('Soil depth file already exists, delete and create new')
    arcpy.Delete_management(soildepth)
else:
    print('soil depth file not provided, creating map')

from soildepthscript import soildepthfun
soildepthfun("flow_acc", elev, mindepth, maxdepth, soildepth)

print('done')






