From e0c19bdee2eafbbd9548f651862dcd6290dd288d Mon Sep 17 00:00:00 2001 From: JuLa96 <206707905+JuLa96@users.noreply.github.com> Date: Tue, 10 Feb 2026 13:32:02 +0100 Subject: [PATCH 1/4] Update in3Utils/generateTopo.py --- avaframe/in3Utils/generateTopo.py | 82 +++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/avaframe/in3Utils/generateTopo.py b/avaframe/in3Utils/generateTopo.py index 4588c1384..61da3a845 100644 --- a/avaframe/in3Utils/generateTopo.py +++ b/avaframe/in3Utils/generateTopo.py @@ -285,6 +285,85 @@ def hockey(cfg): return x, y, zv +def debrisFlowTopoAvarage(cfg): + """ + Compute coordinates of an average parabolic-shaped slope as a generic topography for debris-flow simulations + defined by a 2nd-degree polynomial: ax**2 + bx + c + The parameters of the polynomial function are derived from real watershed profiles (Kessler 2019) + """ + # input parameters + C = float(cfg["TOPO"]["C"]) # C = 709 m + cff = float(cfg["CHANNELS"]["cff"]) + cRadius = float(cfg["CHANNELS"]["cRadius"]) + cInit = float(cfg["CHANNELS"]["cInit"]) + cMustart = float(cfg["CHANNELS"]["cMustart"]) + cMuend = float(cfg["CHANNELS"]["cMuend"]) + + # Get grid definitons + dx, xEnd, yEnd = getGridDefs(cfg) + + # Compute coordinate grid + xv, yv, zv, x, y, nRows, nCols = computeCoordGrid(dx, xEnd, yEnd) + + # If a channel shall be introduced + # Get parabola Parameters + [A, B, fLen] = getParabolaParams(cfg) # fLen = x0 = 1679 m + + # Set surface elevation + mask = np.zeros(np.shape(xv)) + mask[np.where(xv < fLen)] = 1 + zv = (A * xv ** 2 + B * xv + C) * mask + + # If a channel shall be introduced + if cfg["TOPO"].getboolean("channel"): + # Compute cumulative distribution function - c1 for upper part (start) + # of channel and c2 for lower part (end) of channel + c1 = norm.cdf(xv, cMustart * fLen, cff) + c2 = 1.0 - norm.cdf(xv, cMuend * fLen, cff) # cMuend = 0.62, cff = 120 + + # combine both into one function separated at the the middle of + # the channel longprofile location + mask_c1 = np.zeros(np.shape(xv)) + mask_c1[np.where(xv < (fLen * (0.5 * (cMustart + cMuend))))] = 1 + c0 = c1 * mask_c1 + + mask_c2 = np.zeros(np.shape(xv)) + mask_c2[np.where(xv >= (fLen * (0.5 * (cMustart + cMuend))))] = 1 + c0 = c0 + c2 * mask_c2 + + # Is the channel of constant width or narrowing + if cfg["TOPO"].getboolean("narrowing"): + # upper part of channel: constant width + mask_c1 = np.zeros(np.shape(xv)) + mask_c1[np.where(xv < (fLen * (0.5 * (cMustart + cMuend))))] = 1 + cExtent_c1 = np.zeros(np.shape(xv)) + cRadius + + # lower part of channel: narrowing + mask_c2 = np.zeros(np.shape(xv)) + mask_c2[np.where(xv >= (fLen * (0.5 * (cMustart + cMuend))))] = 1 + cExtent_c2 = cInit * (1 - c0[:]) + (c0[:] * cRadius) + + cExtent = cExtent_c1 * mask_c1 + cExtent_c2 * mask_c2 + else: + cExtent = np.zeros(np.shape(xv)) + cRadius + + # Set surface elevation + mask = np.zeros(np.shape(y)) + mask[np.where(abs(y) < cExtent)] = 1 + # Add surface elevation modification introduced by channel + if cfg["TOPO"].getboolean("topoAdd"): + zv = zv + cRadius * c0 * (1.0 - np.sqrt(np.abs(1.0 - (np.square(y) / (cExtent ** 2))))) * mask # changed from cExtent to cRadius + # outside of the channel, add layer of channel thickness + mask = np.zeros(np.shape(y)) + mask[np.where(abs(y) >= cExtent)] = 1 + mask_c2 = np.ones(np.shape(xv)) #added, smooth transition from upper to lower part of channel + c0 = c2 * mask_c2 #added to extend lower distribution to upper edge of topography + zv = zv + cRadius * mask * c0 # changed from cExtent to cRadius + else: + zv = zv - cExtent * c0 * np.sqrt(np.abs(1.0 - (np.square(y) / (cExtent ** 2)))) * mask + + # Log info here + log.info("Generic debris-flow topography is computed") def parabola(cfg): """ @@ -708,6 +787,9 @@ def generateTopo(cfg, avalancheDir): elif demType == "PY": [x, y, z] = pyramid(cfg) + elif demType == "DFTA": + [x, y, z] = debrisFlowTopoAvarage(cfg) + # If a drop shall be introduced if cfg["TOPO"].getboolean("drop"): z = addDrop(cfg, x, y, z) From 19091d682377906a2cc94d134664ff4b831255bd Mon Sep 17 00:00:00 2001 From: JuLa96 <206707905+JuLa96@users.noreply.github.com> Date: Tue, 10 Feb 2026 13:32:43 +0100 Subject: [PATCH 2/4] Update out3Plot/outTopo.py --- avaframe/out3Plot/outTopo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avaframe/out3Plot/outTopo.py b/avaframe/out3Plot/outTopo.py index ab1f72ef0..f7ab1302f 100644 --- a/avaframe/out3Plot/outTopo.py +++ b/avaframe/out3Plot/outTopo.py @@ -111,7 +111,7 @@ def plotGeneratedDEM(z, nameExt, cfg, outDir, cfgMain): X, Y = geoTrans.makeCoordinateGrid(xl, yl, dx, ncols, nrows) topoNames = {'IP': 'inclined Plane', 'FP': 'flat plane', 'PF': 'parabola flat', 'TPF': 'triple parabola flat', - 'HS': 'Hockeystick smoothed', 'BL': 'bowl', 'HX': 'Helix', 'PY': 'Pyramid'} + 'HS': 'Hockeystick smoothed', 'BL': 'bowl', 'HX': 'Helix', 'PY': 'Pyramid', 'DFTA': 'generic debris-flow topography'} ax, fig = _generateDEMPlot(X, Y, z, topoNames[nameExt]) From 54892bd67eee11d313662e3bc14b6f5e129ab7f9 Mon Sep 17 00:00:00 2001 From: JuLa96 <206707905+JuLa96@users.noreply.github.com> Date: Tue, 10 Feb 2026 13:37:31 +0100 Subject: [PATCH 3/4] Update in3Utils/generateTopo.py --- avaframe/in3Utils/generateTopo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avaframe/in3Utils/generateTopo.py b/avaframe/in3Utils/generateTopo.py index 61da3a845..e14cc7f04 100644 --- a/avaframe/in3Utils/generateTopo.py +++ b/avaframe/in3Utils/generateTopo.py @@ -365,6 +365,8 @@ def debrisFlowTopoAvarage(cfg): # Log info here log.info("Generic debris-flow topography is computed") + return x, y, zv + def parabola(cfg): """ Compute coordinates of a parabolically-shaped slope with a flat foreland From 4cd8089cd21d82dd5edf982f3bc8154f1dddca46 Mon Sep 17 00:00:00 2001 From: JuLa96 <206707905+JuLa96@users.noreply.github.com> Date: Tue, 10 Feb 2026 13:41:37 +0100 Subject: [PATCH 4/4] Update in3Utils/generateTopo.py --- avaframe/in3Utils/generateTopo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/avaframe/in3Utils/generateTopo.py b/avaframe/in3Utils/generateTopo.py index e14cc7f04..f90ebd1f7 100644 --- a/avaframe/in3Utils/generateTopo.py +++ b/avaframe/in3Utils/generateTopo.py @@ -285,7 +285,7 @@ def hockey(cfg): return x, y, zv -def debrisFlowTopoAvarage(cfg): +def debrisFlowTopoAverage(cfg): """ Compute coordinates of an average parabolic-shaped slope as a generic topography for debris-flow simulations defined by a 2nd-degree polynomial: ax**2 + bx + c @@ -790,7 +790,7 @@ def generateTopo(cfg, avalancheDir): [x, y, z] = pyramid(cfg) elif demType == "DFTA": - [x, y, z] = debrisFlowTopoAvarage(cfg) + [x, y, z] = debrisFlowTopoAverage(cfg) # If a drop shall be introduced if cfg["TOPO"].getboolean("drop"):