Ejemplo n.º 1
0
 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
                       })
Ejemplo n.º 2
0
def pitremove_example():
    """run function of TauDEM, take pitremove as an example.
    Compare the max, min, and average of rawdem and filled DEM.
    The result will be::

        RawDEM: Max: 284.07, Min: 139.11, Mean: 203.92
        FilledDEM: Max: 284.07, Min: 139.11, Mean: 203.93

    """
    dem = '../tests/data/Jamaica_dem.tif'
    wp = '../tests/data/tmp_results'
    fel = 'dem_pitremoved.tif'
    taudem_bin = None
    mpi_bin = None
    num_proc = 2

    TauDEM.pitremove(num_proc,
                     dem,
                     fel,
                     wp,
                     mpiexedir=mpi_bin,
                     exedir=taudem_bin)

    rawdem = RasterUtilClass.read_raster(dem)
    feldem = RasterUtilClass.read_raster(wp + os.sep + fel)

    print('RawDEM: Max: %.2f, Min: %.2f, Mean: %.2f' %
          (rawdem.get_max(), rawdem.get_min(), rawdem.get_average()))
    print('FilledDEM: Max: %.2f, Min: %.2f, Mean: %.2f' %
          (feldem.get_max(), feldem.get_min(), feldem.get_average()))
Ejemplo n.º 3
0
 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
                       })
Ejemplo n.º 4
0
    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
                          })
Ejemplo n.º 5
0
 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
                       })
Ejemplo n.º 6
0
def pitremove_simple_usage():
    """Simple usage of pitremove.
    Workspace will be set as the base directory of input file.
    """
    dem = '../tests/data/Jamaica_dem.tif'
    fel = 'dem_pitremoved.tif'
    num_proc = 2

    TauDEM.pitremove(num_proc, dem, fel)
Ejemplo n.º 7
0
def pitremove_simple_usage():
    """Simple usage of pitremove.
    Workspace will be set as the base directory of input file.
    """
    dem = '../tests/data/Jamaica_dem.tif'
    fel = '../tests/data/tmp_results/dem_pitremoved.tif'
    num_proc = 2

    TauDEM.pitremove(num_proc, dem, fel)
Ejemplo n.º 8
0
 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})
Ejemplo n.º 9
0
 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})
Ejemplo n.º 10
0
 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
                       })
Ejemplo n.º 11
0
 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})
Ejemplo n.º 12
0
 def hardenslppos(np,
                  simifiles,
                  tags,
                  hard,
                  maxsimi,
                  sechard=None,
                  secsimi=None,
                  spsim=None,
                  spsi=None,
                  workingdir=None,
                  mpiexedir=None,
                  exedir=None,
                  log_file=None,
                  runtime_file=None,
                  hostfile=None):
     """Select typical locations."""
     fname = TauDEM.func_name('hardenslppos')
     if len(simifiles) != len(tags):
         raise RuntimeError(
             "hardenslppos: simifiles and tags must have the same size!")
     tag_path = ''
     for i, tag in enumerate(tags):
         tag_path += ' %d %s ' % (tag, simifiles[i])
     in_params = dict()
     if spsim is not None and spsi is not None:
         in_params['-m'] = '%d %s' % (spsim, spsi)
     return TauDEM.run(
         FileClass.get_executable_fullpath(fname, exedir),
         in_files={'-inf': '%d %s' % (len(simifiles), tag_path)},
         wp=workingdir,
         in_params=in_params,
         out_files={
             '-maxS': [hard, maxsimi],
             '-secS': [sechard, secsimi]
         },
         mpi_params={
             'mpipath': mpiexedir,
             'hostfile': hostfile,
             'n': np
         },
         log_params={
             'logfile': log_file,
             'runtimefile': runtime_file
         })
Ejemplo n.º 13
0
 def __init__(self):
     """Initialize TauDEM."""
     TauDEM.__init__(self)