def moveoutletstostrm(np, flowdir, streamRaster, outlet, modifiedOutlet, maxdist=50, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run move the given outlets to stream""" fname = TauDEM.func_name('moveoutletstostrm') legacy_names = [TauDEM.func_name('moveoutletstostreams') ] # name in old TauDEM version for lname in legacy_names: if FileClass.get_executable_fullpath( lname, exedir, raise_exception=False) is not None: fname = lname break return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), { '-p': flowdir, '-src': streamRaster, '-o': outlet }, workingdir, {'-md': maxdist}, {'-om': modifiedOutlet}, { 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, { 'logfile': log_file, 'runtimefile': runtime_file })
def gridnet(np, pfile, plenfile, tlenfile, gordfile, outlet=None, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run gridnet""" fname = TauDEM.func_name('gridnet') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), { '-p': pfile, '-o': outlet }, workingdir, None, { '-plen': plenfile, '-tlen': tlenfile, '-gord': gordfile }, { 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, { 'logfile': log_file, 'runtimefile': runtime_file })
def moveoutletstostrm(np, flowdir, streamRaster, outlet, modifiedOutlet, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run move the given outlets to stream""" fname = TauDEM.func_name('moveoutletstostrm') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), { '-p': flowdir, '-src': streamRaster, '-o': outlet }, workingdir, None, {'-om': modifiedOutlet}, { 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, { 'logfile': log_file, 'runtimefile': runtime_file })
def selecttyplocslppos(np, inputconf, outputconf=None, extlog=None, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Select typical locations.""" fname = TauDEM.func_name('selecttyplocslppos') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), in_files={'-in': inputconf}, wp=workingdir, in_params=None, out_files={ '-out': outputconf, '-extlog': extlog }, mpi_params={ 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, log_params={ 'logfile': log_file, 'runtimefile': runtime_file })
def read_required_section(self, _require): """read and check required section""" if _require in self.cf.sections(): if self.bin_dir is None: self.bin_dir = self.cf.get(_require, 'exedir') if self.root_dir is None and self.cf.has_option( _require, 'rootdir'): self.root_dir = self.cf.get(_require, 'rootdir') if self.root_dir is None: raise IOError("Workspace must be defined!") self.ws = CreateWorkspace(self.root_dir) self.log = LogNames(self.ws.log_dir) self.topoparam = TopoAttrNames(self.ws) self.slpposresult = FuzSlpPosFiles(self.ws) if self.dem is None: self.dem = self.cf.get(_require, 'rawdem') self.dem = AutoFuzSlpPosConfig.check_file_available(self.dem) if self.dem is None: raise ValueError("DEM can not be None!") else: raise ValueError( "[REQUIRED] section MUST be existed in *.ini file.") if not os.path.isdir(self.bin_dir): self.bin_dir = None if FileClass.get_executable_fullpath( 'fuzzyslpposinference') is None: raise RuntimeError( "exeDir is set to None, however the executable path are not " "set in environment path!")
def d8distuptoridge(np, p, fel, src, dist, distm, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run D8 distance to stream""" fname = TauDEM.func_name('d8distuptoridge') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), in_files={ '-fel': fel, '-p': p, '-src': src }, wp=workingdir, in_params={'-m': TauDEM.convertdistmethod(distm)}, out_files={'-du': dist}, mpi_params={ 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, log_params={ 'logfile': log_file, 'runtimefile': runtime_file })
def connectdown(np, p, acc, outlet, wtsd=None, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Reads an ad8 contributing area file, identifies the location of the largest ad8 value as the outlet of the largest watershed""" # If watershed is not specified, use acc to generate a mask layer. if wtsd is None or not os.path.isfile(wtsd): p, workingdir = TauDEM.check_infile_and_wp(p, workingdir) wtsd = workingdir + os.sep + 'wtsd_default.tif' RasterUtilClass.get_mask_from_raster(p, wtsd, True) fname = TauDEM.func_name('connectdown') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), { '-p': p, '-ad8': acc, '-w': wtsd }, workingdir, None, {'-o': outlet}, { 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, { 'logfile': log_file, 'runtimefile': runtime_file })
def simplecalculator(np, inputa, inputb, output, operator, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run simple calculator. operator = 0: add 1: minus 2: multiply 3: divide 4: a/(a+b) 5: mask """ fname = TauDEM.func_name('simplecalculator') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), in_files={'-in': [inputa, inputb]}, wp=workingdir, in_params={'-op': operator}, out_files={'-out': output}, mpi_params={ 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, log_params={ 'logfile': log_file, 'runtimefile': runtime_file })
def extractridge(np, angfile, elevfile, rdgsrc, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Extract ridge source.""" fname = TauDEM.func_name('ridgeextraction') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), in_files={ '-dir': angfile, '-fel': elevfile }, wp=workingdir, in_params=None, out_files={'-src': rdgsrc}, mpi_params={ 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, log_params={ 'logfile': log_file, 'runtimefile': runtime_file })
def read_optional_section(self, _opt): """read and check OPTIONAL inputs.""" if _opt not in self.cf.sections(): return self.mpi_dir = self.cf.get(_opt, 'mpiexedir') self.hostfile = self.cf.get(_opt, 'hostfile') self.outlet = self.cf.get(_opt, 'outlet') self.valley = self.cf.get(_opt, 'vlysrc') self.ridge = self.cf.get(_opt, 'rdgsrc') self.regional_attr = self.cf.get(_opt, 'regionalattr') if self.proc <= 0 or self.proc is None: if self.cf.has_option(_opt, 'inputproc'): self.proc = self.cf.getint(_opt, 'inputproc') else: self.proc = cpu_count() / 2 # if mpi directory is not set if self.mpi_dir is None or StringClass.string_match(self.mpi_dir, 'none') \ or not os.path.isdir(self.mpi_dir): mpipath = FileClass.get_executable_fullpath('mpiexec') self.mpi_dir = os.path.dirname(mpipath) if self.mpi_dir is None: raise RuntimeError('Can not find mpiexec!') self.hostfile = AutoFuzSlpPosConfig.check_file_available(self.hostfile) self.outlet = AutoFuzSlpPosConfig.check_file_available(self.outlet) self.valley = AutoFuzSlpPosConfig.check_file_available(self.valley) self.ridge = AutoFuzSlpPosConfig.check_file_available(self.ridge) self.regional_attr = AutoFuzSlpPosConfig.check_file_available( self.regional_attr) if self.topoparam is None: self.topoparam = TopoAttrNames(self.ws) if self.regional_attr is not None: self.topoparam.add_user_defined_attribute('rpi', self.regional_attr, True)
def areadinf(np, angfile, sca, outlet=None, wg=None, edgecontaimination=False, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run Accumulate area according to Dinf flow direction""" # -nc means do not consider edge contaimination if edgecontaimination: in_params = {'-nc': None} else: in_params = None fname = TauDEM.func_name('areadinf') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), { '-ang': angfile, '-o': outlet, '-wg': wg }, workingdir, in_params, {'-sca': sca}, { 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, { 'logfile': log_file, 'runtimefile': runtime_file })
def d8hdisttostrm(np, p, src, dist, thresh, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run D8 horizontal distance down to stream. """ fname = TauDEM.func_name('d8hdisttostrm') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), { '-p': p, '-src': src }, workingdir, {'-thresh': thresh}, {'-dist': dist}, { 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, { 'logfile': log_file, 'runtimefile': runtime_file })
def dinfflowdir(np, filleddem, flowangle, slope, workingdir=None, mpiexedir=None, exedir=None, log_file=None, hostfile=None): """Run Dinf flow direction""" return TauDEM.run(FileClass.get_executable_fullpath('dinfflowdir', exedir), {'-fel': filleddem}, workingdir, None, {'-ang': flowangle, '-slp': slope}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file})
def threshold(np, acc, stream_raster, threshold=100., workingdir=None, mpiexedir=None, exedir=None, log_file=None, hostfile=None): """Run threshold for stream raster""" return TauDEM.run(FileClass.get_executable_fullpath('threshold', exedir), {'-ssa': acc}, workingdir, {'-thresh': threshold}, {'-src': stream_raster}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file})
def peukerdouglas(np, fel, streamSkeleton, workingdir=None, mpiexedir=None, exedir=None, log_file=None, hostfile=None): """Run peuker-douglas function""" return TauDEM.run(FileClass.get_executable_fullpath('peukerdouglas', exedir), {'-fel': fel}, workingdir, None, {'-ss': streamSkeleton}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file})
def pitremove(np, dem, filleddem, workingdir=None, mpiexedir=None, exedir=None, log_file=None, hostfile=None): """Run pit remove using the flooding approach """ return TauDEM.run(FileClass.get_executable_fullpath('pitremove', exedir), {'-z': dem}, workingdir, None, {'-fel': filleddem}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file})
def threshold(np, acc, stream_raster, threshold=100., workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run threshold for stream raster""" fname = TauDEM.func_name('threshold') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-ssa': acc}, workingdir, {'-thresh': threshold}, {'-src': stream_raster}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def gridnet(np, pfile, plenfile, tlenfile, gordfile, outlet=None, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run gridnet""" fname = TauDEM.func_name('gridnet') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-p': pfile, '-o': outlet}, workingdir, None, {'-plen': plenfile, '-tlen': tlenfile, '-gord': gordfile}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def pitremove(np, dem, filleddem, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run pit remove using the flooding approach """ fname = TauDEM.func_name('pitremove') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-z': dem}, workingdir, None, {'-fel': filleddem}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def peukerdouglas(np, fel, streamSkeleton, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run peuker-douglas function""" fname = TauDEM.func_name('peukerdouglas') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-fel': fel}, workingdir, None, {'-ss': streamSkeleton}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def dinfflowdir(np, filleddem, flowangle, slope, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run Dinf flow direction""" fname = TauDEM.func_name('dinfflowdir') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-fel': filleddem}, workingdir, None, {'-ang': flowangle, '-slp': slope}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def d8flowdir(np, filleddem, flowdir, slope, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run D8 flow direction""" fname = TauDEM.func_name('d8flowdir') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-fel': filleddem}, workingdir, None, {'-p': flowdir, '-sd8': slope}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def fuzzyslpposinference(np, config, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run fuzzy inference.""" fname = TauDEM.func_name('fuzzyslpposinference') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), in_files={'-in': config}, wp=workingdir, in_params=None, out_files=None, mpi_params={'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, log_params={'logfile': log_file, 'runtimefile': runtime_file})
def raster2shp(rasterfile, vectorshp, layername=None, fieldname=None): """Convert raster to ESRI shapefile""" FileClass.remove_files(vectorshp) FileClass.check_file_exists(rasterfile) # raster to polygon vector exepath = FileClass.get_executable_fullpath("gdal_polygonize.py") str_cmd = 'python %s -f "ESRI Shapefile" %s %s' % (exepath, rasterfile, vectorshp) if layername is not None and fieldname is not None: str_cmd += ' %s %s' % (layername, fieldname) print (str_cmd) print (UtilClass.run_command(str_cmd))
def moveoutletstostrm(np, flowdir, streamRaster, outlet, modifiedOutlet, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run move the given outlets to stream""" fname = TauDEM.func_name('moveoutletstostrm') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-p': flowdir, '-src': streamRaster, '-o': outlet}, workingdir, None, {'-om': modifiedOutlet}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def d8hdisttostrm(np, p, src, dist, thresh, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run D8 horizontal distance down to stream. """ fname = TauDEM.func_name('d8hdisttostrm') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-p': p, '-src': src}, workingdir, {'-thresh': thresh}, {'-dist': dist}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def streamnet(np, filleddem, flowdir, acc, streamRaster, modifiedOutlet, streamOrder, chNetwork, chCoord, streamNet, subbasin, workingdir=None, mpiexedir=None, exedir=None, log_file=None, hostfile=None): """Run streamnet""" return TauDEM.run(FileClass.get_executable_fullpath('streamnet', exedir), {'-fel': filleddem, '-p': flowdir, '-ad8': acc, '-src': streamRaster, '-o': modifiedOutlet}, workingdir, None, {'-ord': streamOrder, '-tree': chNetwork, '-coord': chCoord, '-net': streamNet, '-w': subbasin}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file})
def convert2geojson(jsonfile, src_srs, dst_srs, src_file): """convert shapefile to geojson file""" if os.path.exists(jsonfile): os.remove(jsonfile) if sysstr == 'Windows': exepath = '"%s/Lib/site-packages/osgeo/ogr2ogr"' % sys.exec_prefix else: exepath = FileClass.get_executable_fullpath('ogr2ogr') # os.system(s) s = '%s -f GeoJSON -s_srs "%s" -t_srs %s %s %s' % ( exepath, src_srs, dst_srs, jsonfile, src_file) UtilClass.run_command(s)
def convert2geojson(jsonfile, src_srs, dst_srs, src_file): """convert shapefile to geojson file""" if os.path.exists(jsonfile): os.remove(jsonfile) if sysstr == 'Windows': exepath = '"%s/Lib/site-packages/osgeo/ogr2ogr"' % sys.exec_prefix else: exepath = FileClass.get_executable_fullpath('ogr2ogr') # os.system(s) s = '%s -f GeoJSON -s_srs "%s" -t_srs %s %s %s' % ( exepath, src_srs, dst_srs, jsonfile, src_file) UtilClass.run_command(s)
def streamnet(np, filleddem, flowdir, acc, streamRaster, modifiedOutlet, streamOrder, chNetwork, chCoord, streamNet, subbasin, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run streamnet""" fname = TauDEM.func_name('streamnet') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-fel': filleddem, '-p': flowdir, '-ad8': acc, '-src': streamRaster, '-o': modifiedOutlet}, workingdir, None, {'-ord': streamOrder, '-tree': chNetwork, '-coord': chCoord, '-net': streamNet, '-w': subbasin}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def aread8(np, flowdir, acc, outlet=None, streamskeleton=None, edgecontaimination=False, workingdir=None, mpiexedir=None, exedir=None, log_file=None, hostfile=None): """Run Accumulate area according to D8 flow direction""" # -nc means do not consider edge contaimination if not edgecontaimination: in_params = {'-nc': None} else: in_params = None return TauDEM.run(FileClass.get_executable_fullpath('aread8', exedir), {'-p': flowdir, '-o': outlet, '-wg': streamskeleton}, workingdir, in_params, {'-ad8': acc}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file})
def dinfdistdown(np, ang, fel, slp, src, statsm, distm, edgecontamination, wg, dist, workingdir=None, mpiexedir=None, exedir=None, log_file=None, hostfile=None): """Run D-inf distance down to stream""" in_params = {'-m': '%s %s' % (TauDEM.convertstatsmethod(statsm), TauDEM.convertdistmethod(distm))} if StringClass.string_match(edgecontamination, 'false') or edgecontamination is False: in_params['-nc'] = None return TauDEM.run(FileClass.get_executable_fullpath('dinfdistdown', exedir), {'-fel': fel, '-slp': slp, '-ang': ang, '-src': src, '-wg': wg}, workingdir, in_params, {'-dd': dist}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file})
def mfdmdflowdir(np, filleddem, flowdir, portion, min_portion=0.01, p0=1.1, rng=8.9, lb=0., ub=1., workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run MFD-md flow direction (Qin et al., 2007)""" fname = TauDEM.func_name('flowmfdmd') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-dem': filleddem}, workingdir, {'-min_portion': min_portion, '-p0': p0, '-range': rng, '-tanb_lb': lb, '-tanb_ub': ub}, {'-mfd': flowdir, '-portion': portion}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file}, ignore_err=True)
def curvature(np, fel, profc, horizc=None, planc=None, unspherc=None, avec=None, maxc=None, minc=None, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Calculate various curvature.""" fname = TauDEM.func_name('curvature') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), in_files={'-fel': fel}, wp=workingdir, in_params=None, out_files={'-prof': profc, '-plan': planc, '-horiz': horizc, '-unspher': unspherc, '-ave': avec, '-max': maxc, '-min': minc}, mpi_params={'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, log_params={'logfile': log_file, 'runtimefile': runtime_file})
def dropanalysis(np, fel, p, ad8, ssa, outlet, minthresh, maxthresh, numthresh, logspace, drp, workingdir=None, mpiexedir=None, exedir=None, log_file=None, hostfile=None): """Drop analysis for optimal threshold for extracting stream.""" parstr = '%f %f %f' % (minthresh, maxthresh, numthresh) if logspace == 'false': parstr += ' 1' else: parstr += ' 0' return TauDEM.run(FileClass.get_executable_fullpath('dropanalysis', exedir), {'-fel': fel, '-p': p, '-ad8': ad8, '-ssa': ssa, '-o': outlet}, workingdir, {'-par': parstr}, {'-drp': drp}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file})
def dinfdistdown(np, ang, fel, slp, src, statsm, distm, edgecontamination, wg, dist, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run D-inf distance down to stream""" in_params = {'-m': '%s %s' % (TauDEM.convertstatsmethod(statsm), TauDEM.convertdistmethod(distm))} if StringClass.string_match(edgecontamination, 'false') or edgecontamination is False: in_params['-nc'] = None fname = TauDEM.func_name('dinfdistdown') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-fel': fel, '-slp': slp, '-ang': ang, '-src': src, '-wg': wg}, workingdir, in_params, {'-dd': dist}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def areadinf(np, angfile, sca, outlet=None, wg=None, edgecontaimination=False, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run Accumulate area according to Dinf flow direction""" # -nc means do not consider edge contaimination if edgecontaimination: in_params = {'-nc': None} else: in_params = None fname = TauDEM.func_name('areadinf') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-ang': angfile, '-o': outlet, '-wg': wg}, workingdir, in_params, {'-sca': sca}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def dinfdistuptoridge(np, ang, fel, slp, propthresh, dist, statsm, distm, edgecontamination, rdg=None, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run Dinf distance to ridge.""" fname = TauDEM.func_name('dinfdistuptoridge') in_params = { '-thresh': str(propthresh), '-m': '%s %s' % (TauDEM.convertstatsmethod(statsm), TauDEM.convertdistmethod(distm)) } if StringClass.string_match(edgecontamination, 'false') or edgecontamination is False: in_params['-nc'] = None return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), in_files={ '-ang': ang, '-fel': fel, '-slp': slp, '-rdg': rdg }, wp=workingdir, in_params=in_params, out_files={'-du': dist}, mpi_params={ 'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np }, log_params={ 'logfile': log_file, 'runtimefile': runtime_file })
def dropanalysis(np, fel, p, ad8, ssa, outlet, minthresh, maxthresh, numthresh, logspace, drp, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Drop analysis for optimal threshold for extracting stream.""" parstr = '%f %f %f' % (minthresh, maxthresh, numthresh) if logspace == 'false': parstr += ' 1' else: parstr += ' 0' fname = TauDEM.func_name('dropanalysis') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-fel': fel, '-p': p, '-ad8': ad8, '-ssa': ssa, '-o': outlet}, workingdir, {'-par': parstr}, {'-drp': drp}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def dropanalysis(np, fel, p, ad8, ssa, outlet, minthresh, maxthresh, numthresh, logspace, drp, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Drop analysis for optimal threshold for extracting stream.""" parlist = [minthresh, maxthresh, numthresh] if logspace == 'false': parlist.append(1) else: parlist.append(0) fname = TauDEM.func_name('dropanalysis') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-fel': fel, '-p': p, '-ad8': ad8, '-ssa': ssa, '-o': outlet}, workingdir, {'-par': parlist}, {'-drp': drp}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def rpiskidmore(np, vlysrc, rdgsrc, rpi, vlytag=1, rdgtag=1, dist2vly=None, dist2rdg=None, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Calculate RPI according to Skidmore (1990).""" fname = TauDEM.func_name('rpiskidmore') in_params = dict() if vlytag > 0: in_params['-vlytag'] = vlytag if rdgtag > 0: in_params['-rdgtag'] = rdgtag return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), in_files={'-vly': vlysrc, '-rdg': rdgsrc}, wp=workingdir, in_params=in_params, out_files={'-rpi': rpi, '-dist2vly': dist2vly, '-dist2rdg': dist2rdg}, mpi_params={'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, log_params={'logfile': log_file, 'runtimefile': runtime_file})
def d8distdowntostream(np, p, fel, src, dist, distancemethod, thresh, workingdir=None, mpiexedir=None, exedir=None, log_file=None, hostfile=None): """Run D8 distance down to stream by different method for distance. This function is extended from d8hdisttostrm by Liangjun. Please clone `TauDEM by lreis2415`_ and compile for this program. .. _TauDEM by lreis2415: https://github.com/lreis2415/TauDEM """ return TauDEM.run(FileClass.get_executable_fullpath('d8distdowntostream', exedir), {'-fel': fel, '-p': p, '-src': src}, workingdir, {'-thresh': thresh, '-m': TauDEM.convertdistmethod(distancemethod)}, {'-dist': dist}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file})
def connectdown(np, p, acc, outlet, wtsd=None, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Reads an ad8 contributing area file, identifies the location of the largest ad8 value as the outlet of the largest watershed""" # If watershed is not specified, use acc to generate a mask layer. if wtsd is None or not os.path.isfile(wtsd): p, workingdir = TauDEM.check_infile_and_wp(p, workingdir) wtsd = workingdir + os.sep + 'wtsd_default.tif' RasterUtilClass.get_mask_from_raster(p, wtsd, True) fname = TauDEM.func_name('connectdown') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-p': p, '-ad8': acc, '-w': wtsd}, workingdir, None, {'-o': outlet}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})
def d8distdowntostream(np, p, fel, src, dist, distancemethod, thresh, workingdir=None, mpiexedir=None, exedir=None, log_file=None, runtime_file=None, hostfile=None): """Run D8 distance down to stream by different method for distance. This function is extended from d8hdisttostrm by Liangjun. Please clone `TauDEM by lreis2415`_ and compile for this program. .. _TauDEM by lreis2415: https://github.com/lreis2415/TauDEM """ fname = TauDEM.func_name('d8distdowntostream') return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir), {'-fel': fel, '-p': p, '-src': src}, workingdir, {'-thresh': thresh, '-m': TauDEM.convertdistmethod(distancemethod)}, {'-dist': dist}, {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np}, {'logfile': log_file, 'runtimefile': runtime_file})