-
Notifications
You must be signed in to change notification settings - Fork 0
[c2]: Add module c2TopRunDF #52
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
base: master
Are you sure you want to change the base?
Conversation
❌ 1 blocking issue (3 total)
|
| area += 1 | ||
| else: | ||
| mcs += 1 | ||
| position = [row, col] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| plotter = HillshadePlotter() | ||
|
|
||
| # Generate the plot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (1)
🛟 Help
|
| import configparser | ||
| import pathlib | ||
| import shutil | ||
| import pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fso42
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an init.py in c2
|
|
||
| artificial_height = cfgDebris["GENERAL"]["energyHeight"] | ||
| if artificial_height == "elevation": | ||
| artificial_raster_height = rasterio.open(output_dir / "elevation.asc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is never closed. Either use with or explicitly close it
| # Open the DEM file | ||
| # Preprocess the DEM file if necessary | ||
| processed_dem_file = preprocess_raster(dem_file) | ||
| dataset = rasterio.open(processed_dem_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
| # Clean up the temporary file if preprocessing was done | ||
| if processed_dem_file != dem_file: | ||
| processed_dem_file.unlink() # Deletes the temporary file | ||
| fin = "finished" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the if seen to be dead code? fin is alway finished?
| max_val = np.amax(band3) | ||
| band3 = band3 / max_val | ||
| meanh = volume / perimeter | ||
| band4 = band3 * meanh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is overwritten 5 lines down without ever being used. Is this intentional?
| position = [row, col] | ||
| band2.fill(0) | ||
|
|
||
| band3[0, 0] = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
| mcsmax = 500 | ||
|
|
||
| # Flowpath simulation | ||
| for x in range(0, 100000): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this value go to ini?
| band3 = np.copy(band) | ||
| band3.fill(0) | ||
| area = 0 | ||
| mcsmax = 500 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Value for ini?
| # significant over longer distances. A smaller denominator causes faster decay, meaning | ||
| # the decay factor approaches zero more quickly. | ||
| distance = np.sqrt((position[0] - row) ** 2 + (position[1] - col) ** 2) | ||
| decay_factor = np.exp(-distance / 100) # Example decay factor with denominantor=100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, controlable via ini?
| # and distribute them more evenly. It simulates the physical process of diffusion, | ||
| # in which material or energy moves from areas of high concentration to areas of low | ||
| # concentration. | ||
| kernel = np.array([[0.05, 0.1, 0.05], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Values for ini?
| and edit ``local_debrisframeCfg.ini`` with your favorite text editor and adjust the variable | ||
| ``avalancheDir`` for example to ``data/debrisTopRun``, then run:: | ||
|
|
||
| python runC2ToprunDF.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: TopRun instead of Toprun

runC2TopRunDF.pyexecutes pyTopRunDF for one scenario.The file
TopRunDF.pyis modified,batch_select_process.pyis not used here (since a run of multiple scenarios is not enabled yet), the other files are directly used from the pyTopRunDF repository. The pyTopRunDF repository is integrated via a submodule intoc2TopRunDF/pyTopRunDF, from where the original scripts are executed.The modification of
TopRunDF.pyenables more consistency with the AvaFrame/DebrisFrame configuration and input handling:c2TopRunDFCfg.inifile instead of a.jsonfile (including a different location!)avalanchedir/Inputs, theavalanchediris defined indebrisframe.ini(orlocal_debrisframe.ini) instead ofScenarios/Scenario_{num}avalanchedir/Outputsinstead ofOutputs/Scenario_{num}Adding a global seed to the random functions yields the same result as that computed with the original code (with the same seed) for
Scenario_1(in pyTopRunDF repository.Documentation ends up here:
https://docs.debrisframe.org/en/ps_toprundf/installation.html