Ejemplo n.º 1
0
    def _loadAlgorithms(self):
        self.algs = []
        basePath = TauDEMUtils.taudemDescriptionPath()

        if ProcessingConfig.getSetting(TauDEMUtils.TAUDEM_USE_SINGLEFILE):
            folder = os.path.join(basePath, 'single')

            for descriptionFile in os.listdir(folder):
                if descriptionFile.endswith('txt'):
                    descriptionFile = os.path.join(folder, descriptionFile)
                    self._algFromDescription(descriptionFile)

            self.algs.append(PeukerDouglas())
            self.algs.append(SlopeArea())
            self.algs.append(LengthArea())
            self.algs.append(DropAnalysis())
            self.algs.append(DinfDistDown())
            self.algs.append(DinfDistUp())
            self.algs.append(GridNet())
            self.algs.append(DinfTransLimAccum())
            self.algs.append(DinfTransLimAccum2())

        if ProcessingConfig.getSetting(TauDEMUtils.TAUDEM_USE_MULTIFILE):
            folder = os.path.join(basePath, 'multi')

            for descriptionFile in os.listdir(folder):
                if descriptionFile.endswith('txt'):
                    descriptionFile = os.path.join(folder, descriptionFile)
                    self._algFromDescription(descriptionFile, True)

            self.algs.append(PeukerDouglasMulti())
            self.algs.append(SlopeAreaMulti())
            self.algs.append(LengthAreaMulti())
            self.algs.append(DropAnalysisMulti())
            self.algs.append(DinfDistDownMulti())
            self.algs.append(DinfDistUpMulti())
            self.algs.append(GridNetMulti())
            self.algs.append(DinfTransLimAccumMulti())
            self.algs.append(DinfTransLimAccum2Multi())
Ejemplo n.º 2
0
class TauDEMAlgorithmProvider(AlgorithmProvider):
    def __init__(self):
        AlgorithmProvider.__init__(self)
        self.activate = False
        self.createAlgsList()

    def getDescription(self):
        return 'TauDEM (hydrologic analysis)'

    def getName(self):
        return 'taudem'

    def getIcon(self):
        return QIcon(os.path.dirname(__file__) + '/../../images/taudem.png')

    def initializeSettings(self):
        AlgorithmProvider.initializeSettings(self)
        ProcessingConfig.addSetting(
            Setting(self.getDescription(), TauDEMUtils.TAUDEM_FOLDER,
                    self.tr('TauDEM command line tools folder'),
                    TauDEMUtils.taudemPath()))
        ProcessingConfig.addSetting(
            Setting(self.getDescription(), TauDEMUtils.MPIEXEC_FOLDER,
                    self.tr('MPICH2/OpenMPI bin directory'),
                    TauDEMUtils.mpiexecPath()))
        ProcessingConfig.addSetting(
            Setting(self.getDescription(), TauDEMUtils.MPI_PROCESSES,
                    self.tr('Number of MPI parallel processes to use'), 2))

    def unload(self):
        AlgorithmProvider.unload(self)
        ProcessingConfig.removeSetting(TauDEMUtils.TAUDEM_FOLDER)
        ProcessingConfig.removeSetting(TauDEMUtils.MPIEXEC_FOLDER)
        ProcessingConfig.removeSetting(TauDEMUtils.MPI_PROCESSES)

    def _loadAlgorithms(self):
        self.algs = self.preloadedAlgs

    def createAlgsList(self):
        self.preloadedAlgs = []
        folder = TauDEMUtils.taudemDescriptionPath()
        for descriptionFile in os.listdir(folder):
            if descriptionFile.endswith('txt'):
                try:
                    alg = TauDEMAlgorithm(os.path.join(folder,
                                                       descriptionFile))
                    if alg.name.strip() != '':
                        self.preloadedAlgs.append(alg)
                    else:
                        ProcessingLog.addToLog(
                            ProcessingLog.LOG_ERROR,
                            self.tr('Could not open TauDEM algorithm: %s' %
                                    descriptionFile))
                except Exception, e:
                    ProcessingLog.addToLog(
                        ProcessingLog.LOG_ERROR,
                        self.tr('Could not open TauDEM algorithm: %s' %
                                descriptionFile))

        self.preloadedAlgs.append(PeukerDouglas())
        self.preloadedAlgs.append(SlopeArea())
        self.preloadedAlgs.append(LengthArea())
        self.preloadedAlgs.append(DropAnalysis())
        self.preloadedAlgs.append(DinfDistDown())
        self.preloadedAlgs.append(DinfDistUp())
        self.preloadedAlgs.append(GridNet())
        self.preloadedAlgs.append(DinfTransLimAccum())
        self.preloadedAlgs.append(DinfTransLimAccum2())