Skip to content

[in2TopoHyd]: Module for computing hydraulic inital conditions - #90

Open
JuLa96 wants to merge 8 commits into
masterfrom
JL_AddTopoHydModule
Open

[in2TopoHyd]: Module for computing hydraulic inital conditions#90
JuLa96 wants to merge 8 commits into
masterfrom
JL_AddTopoHydModule

Conversation

@JuLa96

@JuLa96 JuLa96 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

in2TopoHyd is an input module for deriving initial hydraulic conditions for the c1TIF computation module
for a debris-flow hydrograph at a prescribed release line. The module combines the topography of the release area with
a time-dependent discharge hydrograph (Topo-Hydrograph) to calculate the corresponding flow thickness and flow velocity at the release line.

The hydraulic conditions are derived from the terrain cross section along the release line.
A rating curve is calculated from the cross-sectional geometry, relating flow thickness to flow area.
For each discharge value of the input hydrograph, the module determines the corresponding mean flow velocity and flow thickness.
The flow thickness is then distributed over the wetted cells of the release cross section.

The resulting initial conditions contain the flow thickness as well as the velocity components in x, y and z direction for every wet cell and every hydrograph timestep.

closes #85

Compiled doc : https://docs.debrisframe.org/en/jl_addtopohydmodule/

initial conditions in time-dependent release mode

Add documentation

Add test case
@JuLa96 JuLa96 added the enhancement New feature or request label Aug 14, 2026
@JuLa96 JuLa96 self-assigned this Aug 14, 2026
@JuLa96
JuLa96 requested review from PaulaSp3 and fso42 August 14, 2026 08:46
@qltysh

qltysh Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

❌ 2 blocking issues (2 total)

Tool Category Rule Count
ruff Style Incorrect formatting, autoformat by running qlty fmt. 2

@qltysh one-click actions:

  • Auto-fix formatting (qlty fmt && git push)

Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
@qltysh

qltysh Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Qlty


Coverage Impact

This PR will not change total coverage.

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

Comment thread debrisframe/runIn2TopoHyd.py Outdated
Comment thread debrisframe/runIn2TopoHyd.py Outdated
Comment thread debrisframe/data/testIn2TopoHyd/Inputs/DEM_DFTA_Topo_5m.asc Outdated
Comment thread docs/source/moduleIn2TopoHyd.rst Outdated
Comment thread docs/source/moduleIn2TopoHyd.rst Outdated
Comment thread docs/source/moduleIn2TopoHyd.rst Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file ends with "Levee", below in the documentation it says, the file needs to end with "levee" (lower case).
When running the example, I get this error:

File not found or there are more than one levee files in POINTS-folder!
Ensure that there is exactly one point-shapefile including the ending *levee.shp!

Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/data/debrisParabolaChanneled/Inputs/HYDR/hydrograph.csv
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated

return crossSection

def assignRasterCoords(cellSize, releaseLine):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you use avaframe.in3Utils.geoTrans.getCellsAlongLine() instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, I used this function but then I realized that it returns more than one raster center point for a distance station along the release line and this is contradicts the concept of a cross section.
Setting addBuffer = False did not help.

Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py Outdated
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py
Comment thread debrisframe/in2TopoHyd/in2TopoHyd.py
Comment thread docs/source/_static/css/custom.css
Add test files to default debris-data folder

Create separate folders for input data in order to
avoid access conflicts

modify core functions of the module

adapt documentation and config file

format documentation
@JuLa96
JuLa96 force-pushed the JL_AddTopoHydModule branch from 0290d64 to 7107d3b Compare August 21, 2026 12:24
@JuLa96
JuLa96 requested review from PaulaSp3 and fso42 August 21, 2026 12:26
return ratingCurve


def computeSlope(dem, crossSection):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def computeSlope(dem, crossSection):
def computeSlopeAlongChannel(dem, crossSection):

Comment on lines +299 to +308
# compute two additional cross sections on both handsides of the release line, respectively,
# in distance d of original cross section
d = 2 * np.sqrt(csz**2 + csz**2)
# move starting and ending points of release line in direction of n1 and n2
xcoordStart1 = xcoordStart + d * nx1
ycoordStart1 = ycoordStart + d * ny1
xcoordEnd1 = xcoordEnd + d * nx1
ycoordEnd1 = ycoordEnd + d * ny1
xcoordStart2 = xcoordStart + d * nx2
ycoordStart2 = ycoordStart + d * ny2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this (and below) the same as in computeSlope() ?
Then I suggest moving that to a separate function.
You could also add d as a parameter to the config file?

return wetCells


def plotCrossSection(crossSection, outputDir):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to make another script for plotting functions?


ax.plot(crossSection["s"], crossSection["elevation"])
ax.scatter(crossSection["sLevee"], crossSection["elevLevee"], color="red", label="Levee points")
ax.set_xlabel("distance [m]"), ax.set_ylabel("elevation [m]")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ax.set_xlabel("distance [m]"), ax.set_ylabel("elevation [m]")
ax.set_xlabel("distance [m]")
ax.set_ylabel("elevation [m]")

ax[0].legend()

ax[1].plot(thickness, flowArea)
ax[1].set_xlabel("flow thickness [m]"), ax[1].set_ylabel("flow area [m²]")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ax[1].set_xlabel("flow thickness [m]"), ax[1].set_ylabel("flow area [m²]")
ax[1].set_xlabel("flow thickness [m]")
ax[1].set_ylabel("flow area [m²]")

default="",
help="the avalanche/ debris directory",
)
print(parser)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(parser)

Comment on lines +134 to +138
Inputs/
DEM raster file
CFGs/ - expert configuration files (optional)
REL/ - release line
LEVEE/ - levee points

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PLease update here the right directories.

Comment thread debrisframe/in1Utils/fileUtils.py
@PaulaSp3

Copy link
Copy Markdown
Contributor

@JuLa96 , @fso42 : I've added in runC1TIF the possibility to compute the c1TIF initial conditions from a hydrograph by executing in2HydTopoMain(). There are still some little open questions (commented as TODO in the code).
(b1c7b51)

There is a related issue (#91), we could/should consider, at least in a separate PR.

@fso42 fso42 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The deletion of the release csv is intentional?

Comment thread debrisframe/runC1TIF.py Outdated
Comment thread debrisframe/runC1TIF.py Outdated
Comment thread debrisframe/runC1TIF.py
Comment thread debrisframe/runC1TIF.py Outdated
@PaulaSp3

Copy link
Copy Markdown
Contributor

@fso42: If no timeDependentReleaseScenarios is selected, only one csv file is allowed to be in the REL folder. For the workflow, we want to use the csv file derived from in2TopoHyd.
That's why I've deleted it.
I could modify the timeDependentReleaseScenarios to the name of the derived csv file from in2TopoHyd. What do you mean?

@fso42

fso42 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

@fso42: If no timeDependentReleaseScenarios is selected, only one csv file is allowed to be in the REL folder. For the workflow, we want to use the csv file derived from in2TopoHyd. That's why I've deleted it. I could modify the timeDependentReleaseScenarios to the name of the derived csv file from in2TopoHyd. What do you mean?

Ah ok, I was just wondering. I would leave it then as it is now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a inTopoHyd module

3 participants