Skip to content

[com4FlowPy] faster backTracking, previewMode and minor improvs#1138

Merged
fso42 merged 2 commits into
masterfrom
AH_com4FlowPy_backCalcNxGraph
Jun 2, 2025
Merged

[com4FlowPy] faster backTracking, previewMode and minor improvs#1138
fso42 merged 2 commits into
masterfrom
AH_com4FlowPy_backCalcNxGraph

Conversation

@ahuber-bfw
Copy link
Copy Markdown
Contributor

main features:

  • re-implemented "back-tracking" - now it is running at around +5% to +10% computational time, instead of ++100%
  • introduction of a "preview-mode" flag --> if this is set, release pixels that are already "included"/"touched"/"hit" by a previous process path are not calculated separately (might be interesting for preliminary parameterisation runs, etc.)

A jupyter notebook on how the "back-tracking" works in principle can be found in:
https://github.com/OpenNHM/DevTestNotebooks/tree/AH_com4FlowPyBacktracking/com4FlowPyBacktracking

minor changes:

  • some cleanup of model code and in-line documentation
  • minor modifications to .gitignore (adding *.py[cod] and *.aux.xml files)
  • updated Input data in /data/avaFlowPy
    • renamed dem file
    • included forest layer
    • updated release layer and infrastructure layer

fixes issue #1076

@ahuber-bfw ahuber-bfw requested review from PaulaSp3 and fso42 May 27, 2025 15:52
@ahuber-bfw ahuber-bfw self-assigned this May 27, 2025
@ahuber-bfw ahuber-bfw added enhancement New feature or request flowPyDev Ideas for future development labels May 27, 2025
@ahuber-bfw ahuber-bfw changed the title faster backTracking, previewMode and minor improvs [com4FlowPy] faster backTracking, previewMode and minor improvs May 27, 2025
@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented May 27, 2025

❌ 4 blocking issues (8 total)

Tool Category Rule Count
ruff Style Incorrect formatting, autoformat by running qlty fmt. 3
ripgrep Lint # TODO: check if this can be simplified 1
qlty Structure Function with high complexity (count = 10): startLogging 2
qlty Structure Deeply nested control flow (level = 4) 2

@qltysh one-click actions:

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

@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented May 27, 2025

Diff Coverage: The code coverage on the diff in this pull request is 35.2%.

Total Coverage: Unable to calculate total coverage change because base branch coverage was not found.

File Coverage Changes
Path File Coverage Δ Indirect
avaframe/com4FlowPy/flowCore.py 12.5
avaframe/com4FlowPy/rasterIo.py 0.0
🛟 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.

Copy link
Copy Markdown
Contributor

@PaulaSp3 PaulaSp3 left a comment

Choose a reason for hiding this comment

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

Very cool features! :) I have a few suggestions. IMO the code would be easier to understand when variables like 'values' and 'node' are renamed to e.g., 'infraValues' and 'parentNode'/ 'childNode'.

Comment thread avaframe/com4FlowPy/flowCore.py Outdated
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py Outdated
Comment thread avaframe/com4FlowPy/flowCore.py Outdated
Comment thread avaframe/com4FlowPy/flowCore.py Outdated
Comment thread avaframe/com4FlowPy/flowCore.py Outdated
Comment thread avaframe/com4FlowPy/flowCore.py Outdated
Comment thread avaframe/com4FlowPy/flowCore.py Outdated
Comment thread avaframe/com4FlowPy/flowCore.py Outdated
Comment thread docs/moduleCom4FlowPy.rst Outdated
@fso42 fso42 added this to the Version 1.13 milestone Jun 2, 2025
PaulaSp3 and others added 2 commits June 2, 2025 17:16
'preview-mode'

prototype for sped-up version of back-tracking functionality and implementation of previewMode (previously implicitly used in back-tracking)

fixed runtime Bug if infraBool=False, that was introduced with prior commit

previewMode log Message added

fixed minor log BUG in runCom4.. + replaces nSkipForestCells with skipForestDist [m]

creation of custom WorkDir - fixed Bug with logfile if workDir doesn't exit a priori

minor re-write of forestFriction part of calc_z_delta()

minor code clean-up

code style

fixed minor log BUG in runCom4.. + replaces nSkipForestCells with skipForestDist [m]

creation of custom WorkDir - fixed Bug with logfile if workDir doesn't exit a priori

minor code clean-up

Update docs/moduleCom4FlowPy.rst

Co-authored-by: Paula Spannring <95042192+PaulaSp3@users.noreply.github.com>

Update avaframe/com4FlowPy/flowClass.py

Co-authored-by: Paula Spannring <95042192+PaulaSp3@users.noreply.github.com>

deleted note in moduleCom4FlowPy.rst documentation finle

review suggestion

New implementation of back-tracking routine and indtroduction of
'preview-mode'

prototype for sped-up version of back-tracking functionality and implementation of previewMode (previously implicitly used in back-tracking)

fixed runtime Bug if infraBool=False, that was introduced with prior commit

previewMode log Message added

prototype for sped-up version of back-tracking functionality and implementation of previewMode (previously implicitly used in back-tracking)

fixed runtime Bug if infraBool=False, that was introduced with prior commit

previewMode log Message added

added doc-strings to back-tracking functions

added documentation for back-tracking in flowCore.py

updated code comments in flowCore

added tests, deleted deprecated backCalculation function

added *.py[cod] and *.aux.xml to .gitignore

updated data/avaFlowPy

renamed dem in avaFlowPy

updated doc and minor changes to flowCore.py

changed one occurence of 'not in'
incorporated review suggestions P.S.

minor change to nested funciton in calculation()

removed unused imports in tests/tests_com4FlowPy
@fso42 fso42 force-pushed the AH_com4FlowPy_backCalcNxGraph branch from 44c34d1 to f36e793 Compare June 2, 2025 15:16
@fso42 fso42 merged commit 78af900 into master Jun 2, 2025
4 of 5 checks passed
@fso42 fso42 deleted the AH_com4FlowPy_backCalcNxGraph branch June 2, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request flowPyDev Ideas for future development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[com4FlowPy] Implement "Back-Tracking"/"Back-Calculation" feature more efficiently

3 participants