Skip to content

[com4]: output for release area information#1213

Open
PaulaSp3 wants to merge 4 commits into
masterfrom
PS_FP_outputRelInfo
Open

[com4]: output for release area information#1213
PaulaSp3 wants to merge 4 commits into
masterfrom
PS_FP_outputRelInfo

Conversation

@PaulaSp3
Copy link
Copy Markdown
Contributor

@PaulaSp3 PaulaSp3 commented Nov 20, 2025

  • rasters are only merged if they are written as output.

  • computation time (for my example): +25%

  • new outputs:

    • mimimum volume of release area (raster)
    • maximum volume of release area (raster)
    • affected area for a segmented release area (that is marked by a release ID) (polygon)
    • Rel Id count (how many release areas - marked with a release ID) hit a cell (raster)
  • required input data (for these outputs):

    • the volume is given as raster value in release file (in REL folder)
    • the release ID is given as a raster (the release ID is the raster value). Cells with the same release ID belong the same release area. The raster is provided in Inputs/RELID.

@PaulaSp3 PaulaSp3 self-assigned this Nov 20, 2025
@PaulaSp3 PaulaSp3 added enhancement New feature or request flowPyDev Ideas for future development labels Nov 20, 2025
@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented Nov 20, 2025

Analysis for project AvaFrame

8 new issues

Tool Category Rule Count
qlty Structure Deeply nested control flow (level = 4) 5
qlty Structure Function with many parameters (count = 16): __init__ 1
qlty Structure High total complexity (count = 66) 1
qlty Structure Function with high complexity (count = 16): mergeDict 1

Comment thread avaframe/com4FlowPy/flowClass.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py Outdated
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py Outdated
Comment thread avaframe/com4FlowPy/flowClass.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
@PaulaSp3 PaulaSp3 requested a review from ahuber-bfw November 25, 2025 10:18
Comment thread avaframe/com4FlowPy/splitAndMerge.py Outdated
Comment thread avaframe/com4FlowPy/flowClass.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py Outdated
Comment thread avaframe/com4FlowPy/flowClass.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented Nov 25, 2025

Qlty


Coverage Impact

⬇️ Merging this pull request will decrease total coverage on master by 0.82%.

Modified Files with Diff Coverage (4)

RatingFile% DiffUncovered Line #s
Coverage rating: F Coverage rating: F
avaframe/com4FlowPy/flowCore.py26.6%147-409, 592, 596...
Coverage rating: F Coverage rating: F
avaframe/com4FlowPy/splitAndMerge.py0.0%14-352
Coverage rating: F Coverage rating: F
avaframe/com4FlowPy/flowClass.py50.0%195-467
Coverage rating: F Coverage rating: F
avaframe/com4FlowPy/com4FlowPy.py0.0%161-886
Total9.2%
🤖 Increase coverage with AI coding...
In the `PS_FP_outputRelInfo` branch, add test coverage for this new code:

- `avaframe/com4FlowPy/com4FlowPy.py` -- Line 161-886
- `avaframe/com4FlowPy/flowClass.py` -- Line 195-467
- `avaframe/com4FlowPy/flowCore.py` -- Lines 147-409, 592, 596, 631-660, 767, and 771-776
- `avaframe/com4FlowPy/splitAndMerge.py` -- Line 14-352

🚦 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 avaframe/com4FlowPy/flowClass.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/flowClass.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
@PaulaSp3 PaulaSp3 force-pushed the PS_FP_outputRelInfo branch from 9d893b8 to e75f10d Compare January 9, 2026 14:04
Comment thread avaframe/com4FlowPy/flowClass.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/flowCore.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
Comment thread avaframe/com4FlowPy/splitAndMerge.py
fluxDistOldVersionBool=False,
FSI=None,
forestParams=None,
startcellVol=None,
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 many parameters (count = 16): __init__ [qlty:function-parameters]

if key in processedStartCellIdDict:
ids = np.append(processedStartCellIdList[i][key], processedStartCellIdDict[key])
processedStartCellIdDict[key] = np.unique(ids)
else:
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]

startCellIdDict[(cell.rowindex, cell.colindex)], startcellId)
startCellIdDict[(cell.rowindex, cell.colindex)] = np.unique(
startcellIdList)
else:
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]

)
else:
relVolMinArray[cell.rowindex, cell.colindex] = max(
relVolMinArray[cell.rowindex, cell.colindex], cell.startcellVolMin
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]

else:
mergedDict[cellind] = smallDict[cellindSmall]
mergedDict[cellind] = np.unique(mergedDict[cellind])
log.info("appended result %s_%i_%i", fName, i, j)
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 = 16): mergeDict [qlty:function-complexity]

if cellind in mergedDict:
mergedDict[cellind] = np.append(smallDict[cellindSmall], mergedDict[cellind])
else:
mergedDict[cellind] = smallDict[cellindSmall]
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]

@PaulaSp3 PaulaSp3 force-pushed the PS_FP_outputRelInfo branch from e75f10d to e5091f8 Compare February 19, 2026 09:19
crs=demHeader["crs"],
)
del pathPolygons
return gdfPathPolygons
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.

High total complexity (count = 66) [qlty:file-complexity]

@PaulaSp3 PaulaSp3 force-pushed the PS_FP_outputRelInfo branch from e5091f8 to ae29065 Compare February 19, 2026 09:22
@PaulaSp3 PaulaSp3 force-pushed the PS_FP_outputRelInfo branch from ae29065 to c1ae153 Compare April 15, 2026 09:51
Copy link
Copy Markdown
Contributor

@ahuber-bfw ahuber-bfw left a comment

Choose a reason for hiding this comment

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

Hey @PaulaSp3,

Cool features (esp. the releaseID to Polygon feature :) )

only some questions/remarks:

  • maybe you can add some tests for the new functions in splitAndMerge.py in the test_com4FlowPy.py file
  • handling of additional output arrays in flowCore.py --> to be consistent with the method used for other optional outupts (e.g. infra, forestInteraction) maybe we could only initiate the required arrays, if the option is set in the .ini - else just assign None?
  • regarding the option to have a relVolMin and relVolMax output
    • are there use-cases, where this is interesting and you don't also use the relID option at the same time?
    • if this is only used togehter with the relID option, then this could probably be implemented at a higher level or in a post-processing step without need for modification in flowCore.py and flowClass.py

Comment thread docs/moduleCom4FlowPy.rst
- ``depFluxSum``: deposited flux summed up over all paths
- ``travelLengthMin``: the travel length along the flow path (the minimum value of all paths for every raster cell)
- ``fpTravelAngleMin``: the gamma angle along the flow path (the minimum value of all paths for every raster cell)
- ``relVolMin``: the minimum of the tracked release volume that route through the raster cell (the volume is provided in the release file in the REL folder)
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.

generell die Frage, wie man mit den extra input-files umgehen sollte, damit die Vorgehensweise konsistent bleibt (auch im Hinblick darauf, wie man es macht, falls in Zukunft noch zusätzliche inputs dazu kommen):

akutell:

  • releaseId --> aktuell eigener releaseIDPath oder .tif in RELID\ ABER
  • releaseVolume --> implizit in \REL bzw. releasePath

konsistent(er)?:

  • releaseID und releaseVolume als extra layer in \REL mit fixer Vorgabe für fileName bzw. jeweils mit eigenem releaseIdPath und releaseVolumePath ODER
  • \REL \RELID \RELVOLUME als eigene folder in inputs bzw. releasePath, releaseIdPath und releaseVolumePath

Comment thread avaframe/runCom4FlowPy.py
forestPath = ""
cfgPath["forestPath"] = forestPath

# read release ID raster
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.

Gleicher kommentar, wie in der Doku:

  • Macht's Sinn auch den releaseVolume input in ein extra file zu geben anstatt implizit im release file?
  • Wenn ja, dann würd hier auch noch ein entsprechender Input-Check sinnvoll sein

return mergedRas


def mergeDict(inDirPath, fName):
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.

maybe consider writing a test for the new functions in tests/test_com4FlowPy.py

if parent.forestIntCount < (self.forestIntCount - self.isForest):
self.forestIntCount = parent.forestIntCount + self.isForest

def calc_startCellVol(self, startcellVolNew):
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.

generally - what is the use-case of tracking volMin and volMax?

  • is it size-classification on the merged model results?
  • is there a use-case, where volMin and volMax are interesting and you don't use the relID option at the same time?

overall the naming von volMin and volMax could be a bit misleading/confusing - mainly, because it is physiclly improbable, that the whole release Volume is routed through each cell of a modeled process zone (which maybe could be represented be some combination with the routing flux?).

If this functionality is always/only interesting in conjunction with also using relIDs for contiguous release areas, could you simply add the information about min and max volumes at the final merging step in com4FlowPy.py?

if relVolBool:
relVolArray = release.copy()
else:
relVolArray = None
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.

also here:

  • does it make sense to provide release volume in a separate file and not implicitly in the release file?

forestIntArray = np.ones_like(dem, dtype=np.float32) * -9999
relVolMinArray = np.ones_like(dem, dtype=np.float32) * -9999
relVolMaxArray = np.zeros_like(dem, dtype=np.float32)
processedStartCellIdDict = {}
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.

only initialize these if the corresponding options in relOutputParams are set to True?

travelLengthMaxList = []
travelLengthMinList = []
processedStartCellIdList = []
relVolMinList = []
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.

same here

if forestInteraction:
forestIntList.append(res[12])
forestIntList.append(res[15])
relVolMinList.append(res[13])
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.

and here

travelLengthMinArray = np.ones_like(dem, dtype=np.float32) * -9999
travelLengthMaxArray = np.ones_like(dem, dtype=np.float32) * -9999

relVolMinArray = np.ones_like(dem, dtype=np.float32) * -9999
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.

only initialize if option is set, else initialize with None?
in this way we do not reserve any memory if the array is not used in the next steps + also the return statement (lines 813 - 830) at the end of the function could stay like it is (all possible results are returned, but the ones which are not calculated are set to None - higher level functions can then also easily check, if a give result is available ....

fluxDistOldVersionBool=fluxDistOldVersionBool,
FSI=forestArray[row_idx, col_idx] if isinstance(forestArray, np.ndarray) else None,
forestParams=forestParams,
startcellVol=startcellVol,
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.

see comments in flowClass.py

--> is it really necessary to implement this at the level of single cells (since it only passes one particular information from release cell to all the cells in the process area, if I understand correctly?)

  • maybe this can be accomplished at a higher level or in a quick post-processing step?

Comment thread avaframe/runCom4FlowPy.py
cfgPath["tempDir"] = pathlib.Path(temp_dir)
cfgPath["demPath"] = pathlib.Path(cfgCustomPaths["demPath"])
cfgPath["releasePath"] = pathlib.Path(cfgCustomPaths["releasePath"])
cfgPath["relIdPath"] = pathlib.Path(cfgCustomPaths["relIdPath"])
Copy link
Copy Markdown
Contributor

@ahuber-bfw ahuber-bfw May 4, 2026

Choose a reason for hiding this comment

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

im com4FlowPyCfg.ini heißt die variable releaseIdPath --> wird deshalb hier so nicht gefunden

workDir =
demPath =
releasePath =
releaseIdPath =
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.

im runCom4FlowPy.py wird nach relIdPath gesucht --> hier oder dort anpassen damits funktioniert

PaulaSp3 and others added 2 commits May 13, 2026 15:10
still in progress

relVolMin and relVolMax as output

correct position for relId

delete print

small change

fix bug

pathPolygons as output

rename function

tidy up

try to keep RAM as small as possible

print a warning if the output in cfg is not completly valid

small corrections

correct bugs and doc

update docu

adapt pytest

delete unused package
@PaulaSp3 PaulaSp3 force-pushed the PS_FP_outputRelInfo branch from 4f4a576 to 8b69944 Compare May 13, 2026 13:10
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.

2 participants