Skip to content

Commit

Permalink
Slopes do not used pitfilled DEM
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisWGeorge committed Jun 9, 2024
1 parent 303734d commit 05ff797
Show file tree
Hide file tree
Showing 17 changed files with 57,192 additions and 39,776 deletions.
23 changes: 15 additions & 8 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>






<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">






<path>/QSWAT3</path>






<path>/${PROJECT_DIR_NAME}</path>






</pydev_pathproperty>






<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>






<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>

<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python</pydev_property>





Expand Down
81 changes: 42 additions & 39 deletions QSWAT3/QSWAT/delineation.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,8 @@ def runTauDEM(self, outletFile: Optional[str], makeWshed: bool) -> None:
QSWATUtils.removeLayer(slpFile, root)
QSWATUtils.removeLayer(angFile, root)
self.progress('DinfFlowDir ...')
ok = TauDEMUtils.runDinfFlowDir(felFile, slpFile, angFile, numProcesses, self._dlg.taudemOutput)
# Dinf slopes based on non-pitfilled and non-burned-in DEM
ok = TauDEMUtils.runDinfFlowDir(demFile, slpFile, angFile, numProcesses, self._dlg.taudemOutput)
if not ok:
self.cleanUp(3)
return
Expand All @@ -684,13 +685,14 @@ def runTauDEM(self, outletFile: Optional[str], makeWshed: bool) -> None:
if not ok:
self.cleanUp(3)
return
scaFile = base + 'sca' + suffix
QSWATUtils.removeLayer(scaFile, root)
self.progress('AreaDinf ...')
ok = TauDEMUtils.runAreaDinf(angFile, scaFile, None, numProcesses, self._dlg.taudemOutput, mustRun=self.thresholdChanged)
if not ok:
self.cleanUp(3)
return
# Dinf area not used
# scaFile = base + 'sca' + suffix
# QSWATUtils.removeLayer(scaFile, root)
# self.progress('AreaDinf ...')
# ok = TauDEMUtils.runAreaDinf(angFile, scaFile, None, numProcesses, self._dlg.taudemOutput, mustRun=self.thresholdChanged)
# if not ok:
# self.cleanUp(3)
# return
gordFile = base + 'gord' + suffix
plenFile = base + 'plen' + suffix
tlenFile = base + 'tlen' + suffix
Expand Down Expand Up @@ -833,27 +835,28 @@ def runTauDEM(self, outletFile: Optional[str], makeWshed: bool) -> None:
self._dlg.taudemOutput.append('------------------- TauDEM finished -------------------\n')
self._gv.pFile = pFile
self._gv.basinFile = wFile
if self._dlg.checkBurn.isChecked():
# need to make slope file from original dem
felNoburn = base + 'felnoburn' + suffix
QSWATUtils.removeLayer(felNoburn, root)
self.progress('PitFill ...')
ok = TauDEMUtils.runPitFill(demFile, felNoburn, numProcesses, self._dlg.taudemOutput)
if not ok:
self.cleanUp(3)
return
slopeFile = base + 'slope' + suffix
angleFile = base + 'angle' + suffix
QSWATUtils.removeLayer(slopeFile, root)
QSWATUtils.removeLayer(angleFile, root)
self.progress('DinfFlowDir ...')
ok = TauDEMUtils.runDinfFlowDir(felNoburn, slopeFile, angleFile, numProcesses, self._dlg.taudemOutput)
if not ok:
self.cleanUp(3)
return
self._gv.slopeFile = slopeFile
else:
self._gv.slopeFile = slpFile
# already made Dinf slope file on non-pitfilled and anon-burned-in DEM
# if self._dlg.checkBurn.isChecked():
# # need to make slope file from original dem
# felNoburn = base + 'felnoburn' + suffix
# QSWATUtils.removeLayer(felNoburn, root)
# self.progress('PitFill ...')
# ok = TauDEMUtils.runPitFill(demFile, felNoburn, numProcesses, self._dlg.taudemOutput)
# if not ok:
# self.cleanUp(3)
# return
# slopeFile = base + 'slope' + suffix
# angleFile = base + 'angle' + suffix
# QSWATUtils.removeLayer(slopeFile, root)
# QSWATUtils.removeLayer(angleFile, root)
# self.progress('DinfFlowDir ...')
# ok = TauDEMUtils.runDinfFlowDir(felNoburn, slopeFile, angleFile, numProcesses, self._dlg.taudemOutput)
# if not ok:
# self.cleanUp(3)
# return
# self._gv.slopeFile = slopeFile
# else:
self._gv.slopeFile = slpFile
self._gv.streamFile = streamFile
if self._dlg.useOutlets.isChecked():
assert outletFile is not None
Expand Down Expand Up @@ -932,24 +935,24 @@ def runExisting(self) -> None:
self._dlg.setCursor(Qt.WaitCursor)
self._dlg.taudemOutput.clear()
# create Dinf slopes
felFile = base + 'fel' + suffix
# felFile = base + 'fel' + suffix # not used for Dinf slopes
slpFile = base + 'slp' + suffix
angFile = base + 'ang' + suffix
QSWATUtils.removeLayer(slpFile, root)
QSWATUtils.removeLayer(angFile, root)
willRun = not (QSWATUtils.isUpToDate(demFile, slpFile) and QSWATUtils.isUpToDate(demFile, angFile))
if willRun:
self.progress('DinfFlowDir ...')
if self._dlg.showTaudem.isChecked():
self._dlg.tabWidget.setCurrentIndex(3)
ok = TauDEMUtils.runPitFill(demFile, felFile, numProcesses, self._dlg.taudemOutput)
if not ok:
QSWATUtils.error('Cannot generate pitfilled file from dem {0}'.format(demFile), self._gv.isBatch)
self.cleanUp(3)
return
ok = TauDEMUtils.runDinfFlowDir(felFile, slpFile, angFile, numProcesses, self._dlg.taudemOutput)
# if self._dlg.showTaudem.isChecked():
# self._dlg.tabWidget.setCurrentIndex(3)
# ok = TauDEMUtils.runPitFill(demFile, felFile, numProcesses, self._dlg.taudemOutput)
# if not ok:
# QSWATUtils.error('Cannot generate pitfilled file from dem {0}'.format(demFile), self._gv.isBatch)
# self.cleanUp(3)
# return
ok = TauDEMUtils.runDinfFlowDir(demFile, slpFile, angFile, numProcesses, self._dlg.taudemOutput)
if not ok:
QSWATUtils.error('Cannot generate slope file from pitfilled dem {0}'.format(felFile), self._gv.isBatch)
QSWATUtils.error('Cannot generate slope file from dem {0}'.format(demFile), self._gv.isBatch)
self.cleanUp(3)
return
self.progress('DinfFlowDir done')
Expand Down
5 changes: 4 additions & 1 deletion QSWAT3/QSWAT/hrus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,10 @@ def generateBasins(self, progressBar: QProgressBar, progressLabel: QLabel, root:
# generate slope bands data and write it before reading next row
for i in range(slopeNumberCols):
slopeValue = cast(float, slopeData[0, i])
slopeData[0, i] = self._gv.db.slopeIndex(slopeValue * 100) if slopeValue != slopeNoData else slopeBandsNoData
# slopes will be nodata in pits
if slopeValue == slopeNoData:
slopeValue = Parameters._DEFAULTSLOPE
slopeData[0, i] = self._gv.db.slopeIndex(slopeValue * 100)
slopeBandsBand.WriteArray(slopeData, 0, slopeCurrentRow)
slopeCurrentRow = slopeRow
slopeData = slopeBand.ReadAsArray(0, slopeRow, slopeNumberCols, 1)
Expand Down
Loading

0 comments on commit 05ff797

Please sign in to comment.