Repository navigation
[in2TopoHyd]: Module for computing hydraulic inital conditions #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,062 changes: 756 additions & 306 deletions
1,062
debrisframe/data/debrisParabolaChanneled/Inputs/DEM_ParabolaChanneled.asc
Large diffs are not rendered by default.
Oops, something went wrong.
92 changes: 92 additions & 0 deletions
92
debrisframe/data/debrisParabolaChanneled/Inputs/HYDR/hydrograph.csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| timestep,discharge | ||
| 0,0.0 | ||
| 1,2.83 | ||
| 2,5.67 | ||
| 3,8.5 | ||
| 4,11.33 | ||
| 5,14.17 | ||
| 6,17.0 | ||
| 7,19.83 | ||
| 8,22.67 | ||
| 9,25.5 | ||
| 10,28.33 | ||
| 11,31.17 | ||
| 12,34.0 | ||
| 13,36.83 | ||
| 14,39.67 | ||
| 15,42.5 | ||
| 16,45.33 | ||
| 17,48.17 | ||
| 18,51.0 | ||
| 19,53.83 | ||
| 20,56.67 | ||
| 21,59.5 | ||
| 22,62.33 | ||
| 23,65.17 | ||
| 24,68.0 | ||
| 25,70.83 | ||
| 26,73.67 | ||
| 27,76.5 | ||
| 28,79.33 | ||
| 29,82.17 | ||
| 30,85.0 | ||
| 31,83.58 | ||
| 32,82.17 | ||
| 33,80.75 | ||
| 34,79.33 | ||
| 35,77.92 | ||
| 36,76.5 | ||
| 37,75.08 | ||
| 38,73.67 | ||
| 39,72.25 | ||
| 40,70.83 | ||
| 41,69.42 | ||
| 42,68.0 | ||
| 43,66.58 | ||
| 44,65.17 | ||
| 45,63.75 | ||
| 46,62.33 | ||
| 47,60.92 | ||
| 48,59.5 | ||
| 49,58.08 | ||
| 50,56.67 | ||
| 51,55.25 | ||
| 52,53.83 | ||
| 53,52.42 | ||
| 54,51.0 | ||
| 55,49.58 | ||
| 56,48.17 | ||
| 57,46.75 | ||
| 58,45.33 | ||
| 59,43.92 | ||
| 60,42.5 | ||
| 61,41.08 | ||
| 62,39.67 | ||
| 63,38.25 | ||
| 64,36.83 | ||
| 65,35.42 | ||
| 66,34.0 | ||
| 67,32.58 | ||
| 68,31.17 | ||
| 69,29.75 | ||
| 70,28.33 | ||
| 71,26.92 | ||
| 72,25.5 | ||
| 73,24.08 | ||
| 74,22.67 | ||
| 75,21.25 | ||
| 76,19.83 | ||
| 77,18.42 | ||
| 78,17.0 | ||
| 79,15.58 | ||
| 80,14.17 | ||
| 81,12.75 | ||
| 82,11.33 | ||
| 83,9.92 | ||
| 84,8.5 | ||
| 85,7.08 | ||
| 86,5.67 | ||
| 87,4.25 | ||
| 88,2.83 | ||
| 89,1.42 | ||
| 90,0.0 |
1 change: 1 addition & 0 deletions
1
debrisframe/data/debrisParabolaChanneled/Inputs/LEVEE/crossSectionLevee.cpg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| UTF-8 |
Binary file added
BIN
+88 Bytes
debrisframe/data/debrisParabolaChanneled/Inputs/LEVEE/crossSectionLevee.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions
1
debrisframe/data/debrisParabolaChanneled/Inputs/LEVEE/crossSectionLevee.prj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| PROJCS["ETRS_1989_Austria_Lambert",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",400000.0],PARAMETER["False_Northing",400000.0],PARAMETER["Central_Meridian",13.3333333333333],PARAMETER["Standard_Parallel_1",49.0],PARAMETER["Standard_Parallel_2",46.0],PARAMETER["Latitude_Of_Origin",47.5],UNIT["Meter",1.0]] |
Binary file added
BIN
+156 Bytes
debrisframe/data/debrisParabolaChanneled/Inputs/LEVEE/crossSectionLevee.shp
|
JuLa96 marked this conversation as resolved.
|
Binary file not shown.
Binary file added
BIN
+116 Bytes
debrisframe/data/debrisParabolaChanneled/Inputs/LEVEE/crossSectionLevee.shx
Binary file not shown.
13 changes: 0 additions & 13 deletions
13
debrisframe/data/debrisParabolaChanneled/Inputs/REL/releaseParabolaChanneledTimeDep.csv
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
debrisframe/data/debrisParabolaChanneled/Inputs/XSECT/crossSection.cpg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| UTF-8 |
Binary file added
BIN
+77 Bytes
debrisframe/data/debrisParabolaChanneled/Inputs/XSECT/crossSection.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions
1
debrisframe/data/debrisParabolaChanneled/Inputs/XSECT/crossSection.prj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| PROJCS["ETRS_1989_Austria_Lambert",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",400000.0],PARAMETER["False_Northing",400000.0],PARAMETER["Central_Meridian",13.3333333333333],PARAMETER["Standard_Parallel_1",49.0],PARAMETER["Standard_Parallel_2",46.0],PARAMETER["Latitude_Of_Origin",47.5],UNIT["Meter",1.0]] |
Binary file added
BIN
+188 Bytes
debrisframe/data/debrisParabolaChanneled/Inputs/XSECT/crossSection.shp
Binary file not shown.
Binary file added
BIN
+108 Bytes
debrisframe/data/debrisParabolaChanneled/Inputs/XSECT/crossSection.shx
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| """ | ||
|
JuLa96 marked this conversation as resolved.
JuLa96 marked this conversation as resolved.
|
||
| Directory and file handling helper functions | ||
| """ | ||
|
|
||
| import pathlib | ||
| import shutil | ||
| import logging | ||
| import pandas as pd | ||
|
|
||
| log = logging.getLogger("avaframe.debrisframe.in1Utils.fileUtils") | ||
|
|
||
|
|
||
| def copyHydrToInput(debrisDir): | ||
| """ | ||
| copy the output file from in2TopoHyd into Inputs/REL | ||
| to serve as input data for c1TIF | ||
|
|
||
| Parameters | ||
| ----------- | ||
| debrisDir: str or pathlib path | ||
| path to debris-flow directory | ||
| """ | ||
|
|
||
| debrisDir = pathlib.Path(debrisDir) | ||
|
|
||
| outputFile = debrisDir / "Outputs" / "in2TopoHyd" / "initCondHyd.csv" | ||
| inputsDir = debrisDir / "Inputs" / "REL" | ||
| inputsDir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| inputsHydFile = inputsDir / outputFile.name | ||
|
|
||
| if not inputsHydFile.exists(): | ||
| shutil.copy2(outputFile, inputsHydFile) | ||
| else: | ||
| outputFileDF = pd.read_csv(outputFile) | ||
| inputsHydFileDF = pd.read_csv(inputsHydFile) | ||
|
|
||
| if not outputFileDF.equals(inputsHydFileDF): | ||
| log.info(f"{inputsHydFile} already exists and is inconsistent with {outputFile}.") | ||
| log.info(f"{inputsHydFile} is overwritten by {outputFile}!") | ||
| shutil.copy2(outputFile, inputsHydFile) | ||
| else: | ||
| log.info(f"{inputsHydFile} already exists and is consistent with {outputFile}") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| """ | ||
|
JuLa96 marked this conversation as resolved.
|
||
| Plotting helper functions | ||
| """ | ||
|
|
||
| # load modules | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| # local imports | ||
| import avaframe.in3Utils.fileHandlerUtils as fU | ||
|
|
||
|
|
||
| def plotCrossSection(crossSection, outputDir): | ||
| """ | ||
| This function plots the terrain cross section | ||
|
|
||
| Parameters | ||
| ----------- | ||
| crossSection: dict | ||
| dictionary containing | ||
| the elevation of the cross-section cells and levee points, | ||
| the path along (distance) along the cross-section cells | ||
| outputDir: str or Path | ||
| path to output directory of in2TopoHyd module | ||
|
|
||
| Returns | ||
| -------- | ||
| Plot: .png | ||
| saves plot in debris-flow directory | ||
| """ | ||
|
|
||
| # plot cross section | ||
| fig, ax = plt.subplots(figsize=(10, 8)) | ||
|
|
||
| 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]") | ||
| ax.grid(color="gray", linestyle="--", linewidth=0.5, alpha=0.6) | ||
| ax.set_title("Cross Section") | ||
|
|
||
| plt.legend() | ||
| plt.tight_layout() | ||
|
|
||
| # check if directory already exists | ||
| path = outputDir / "Plots" | ||
| fU.makeADir(path) | ||
|
|
||
| fig.savefig(path / "crossSection.png") | ||
|
|
||
|
|
||
| def plotRatingCurve(ratingCurve, crossSection, outputDir): | ||
| """ | ||
| This function plots the terrain cross section | ||
| and the corresponding rating curve | ||
|
|
||
| Parameters | ||
| ----------- | ||
| ratingCurve: dict | ||
| dictionary containing | ||
| thickness values/surface elevations and corresponding flow area | ||
| min and max values of horizontal distance of flow area | ||
| crossSection: dict | ||
| dictionary containing | ||
| the elevation of the cross-section cells, | ||
| the path along (distance) along the cross-section cells | ||
| outputDir: str or Path | ||
| path to output directory of in2TopoHyd module | ||
|
|
||
| Returns | ||
| -------- | ||
| Plot: .png | ||
| saves plot in debris-flow directory | ||
| """ | ||
|
|
||
| thickness = ratingCurve["thickness"] | ||
| flowArea = ratingCurve["flowArea"] | ||
| surfElev = ratingCurve["surfElev"] | ||
| xmin = ratingCurve["xmin"] | ||
| xmax = ratingCurve["xmax"] | ||
|
|
||
| # plot cross section | ||
| fig, ax = plt.subplots(ncols=1, nrows=2, figsize=(10, 8)) | ||
|
|
||
| ax[0].plot(crossSection["s"], crossSection["elevation"]) | ||
| ax[0].scatter(crossSection["sLevee"], crossSection["elevLevee"], color="red", label="Levee points") | ||
| for i, (elev, minimum, maximum) in enumerate(zip(surfElev, xmin, xmax)): | ||
| elev = [elev] * len(minimum) | ||
| ax[0].hlines( | ||
| elev, | ||
| xmin=minimum, | ||
| xmax=maximum, | ||
| linestyles="--", | ||
| colors="black", | ||
| lw=0.5, | ||
| label="elevation increments" if i == 0 else "_nolegend_", | ||
| ) | ||
| ax[0].set_xlabel("distance [m]"), ax[0].set_ylabel("elevation [m]") | ||
| ax[0].grid(color="gray", linestyle="--", linewidth=0.5, alpha=0.6) | ||
| ax[0].set_title("Cross Section") | ||
| ax[0].legend() | ||
|
|
||
| ax[1].plot(flowArea, thickness) | ||
| ax[1].set_xlabel("flow area [m²]") | ||
| ax[1].set_ylabel("flow thickness [m]") | ||
| ax[1].grid(color="gray", linestyle="--", linewidth=0.5, alpha=0.6) | ||
| ax[1].set_title("Rating Curve") | ||
|
|
||
| plt.tight_layout() | ||
|
|
||
| path = outputDir / "Plots" | ||
| fU.makeADir(path) | ||
| fig.savefig(path / "ratingCurve.png") | ||
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.