Skip to content

[c2]: Add module c2TopRunDF#52

Open
PaulaSp3 wants to merge 24 commits into
masterfrom
PS_topRunDF
Open

[c2]: Add module c2TopRunDF#52
PaulaSp3 wants to merge 24 commits into
masterfrom
PS_topRunDF

Conversation

@PaulaSp3
Copy link
Copy Markdown
Contributor

@PaulaSp3 PaulaSp3 commented Jan 28, 2026

runC2TopRunDF.pyexecutes pyTopRunDF for one scenario.

The file TopRunDF.py is modified, batch_select_process.py is 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 into c2TopRunDF/pyTopRunDF, from where the original scripts are executed.

The modification of TopRunDF.py enables more consistency with the AvaFrame/DebrisFrame configuration and input handling:

  • a different handling with input parameters: we use an c2TopRunDFCfg.ini file instead of a .json file (including a different location!)
  • Input data (the DEM) is located in avalanchedir/Inputs, the avalanchedir is defined in debrisframe.ini (or local_debrisframe.ini) instead of Scenarios/Scenario_{num}
  • Output data are saved in avalanchedir/Outputs instead of Outputs/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

@PaulaSp3 PaulaSp3 self-assigned this Jan 28, 2026
@PaulaSp3 PaulaSp3 linked an issue Jan 28, 2026 that may be closed by this pull request
8 tasks
@PaulaSp3 PaulaSp3 added the enhancement New feature or request label Jan 28, 2026
@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented Jan 28, 2026

❌ 3 blocking issues (5 total)

Tool Category Rule Count
ripgrep Lint # TODO: only work with the open rasterio file or also read in raster data and header? 1
ruff Lint f-string without any placeholders 1
ruff Lint pytest imported but unused 1
qlty Structure Function with high complexity (count = 42): c2TopRunDFMain 1
qlty Structure Deeply nested control flow (level = 4) 1

Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py

plotter = HillshadePlotter()

# Generate the plot
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.

Function with high complexity (count = 40): c2TopRunDFMain [qlty:function-complexity]

Comment thread debrisframe/c2TopRunDF/testOutput.py Outdated
Comment thread debrisframe/c2TopRunDF/testOutput.py Outdated
Comment thread debrisframe/c2TopRunDF/testOutput.py Outdated
@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented Jan 28, 2026

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Files with Diff Coverage (1)

RatingFile% DiffUncovered Line #s
New Coverage rating: A
debrisframe/tests/test_c2TopRunDF.py100.0%
Total100.0%
🚦 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/c2TopRunDF/c2TopRunDF.py
@PaulaSp3 PaulaSp3 requested a review from fso42 January 29, 2026 08:12
Comment thread debrisframe/c2TopRunDF/testClass.py Outdated
Comment thread debrisframe/c2TopRunDF/testRasterio.py Outdated
import configparser
import pathlib
import shutil
import pytest
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.

pytest imported but unused [ruff:F401]

Copy link
Copy Markdown
Contributor

@fso42 fso42 left a 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

Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
position = [row, col]
band2.fill(0)

band3[0, 0] = 0
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 is this needed?

Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
Comment thread docs/source/installation.rst Outdated
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py
Comment thread debrisframe/c2TopRunDF/c2TopRunDF.py Outdated
area += 1
else:
mcs += 1
position = [row, col]
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.

Deeply nested control flow (level = 4) [qlty:nested-control-flow]

if processed_dem_file != dem_file:
processed_dem_file.unlink() # Deletes the temporary file

log.info(f"Simulation finished")
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.

f-string without any placeholders [ruff:F541]

Suggested change
log.info(f"Simulation finished")
log.info("Simulation finished")

# Preprocess the DEM file if necessary
processed_dem_file = preprocess_raster(dem_file)
demData = rasterUtils.readRaster(processed_dem_file, noDataToNan=False)
# TODO: only work with the open rasterio file or also read in raster data and header?
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.

# TODO: only work with the open rasterio file or also read in raster data and header? [ripgrep:TODO]

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.

2 participants