Skip to content

[out3Plot]: add functionality for assets#1277

Open
awirb wants to merge 15 commits into
masterfrom
addInfra
Open

[out3Plot]: add functionality for assets#1277
awirb wants to merge 15 commits into
masterfrom
addInfra

Conversation

@awirb

@awirb awirb commented May 20, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@awirb awirb requested review from ahuber-bfw and fso42 May 20, 2026 12:47
@awirb awirb self-assigned this May 20, 2026
@qltysh

qltysh Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Analysis for project AvaFrame

❌ 1 blocking issue (1 total)

Tool Category Rule Count
black Style Incorrect formatting, autoformat by running qlty fmt. 1

@qltysh one-click actions:

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

Comment thread avaframe/com1DFA/particleTools.py
Comment thread avaframe/com1DFA/particleTools.py Outdated
Comment thread avaframe/com1DFA/particleTools.py Outdated
Comment thread avaframe/in1Data/getInput.py Outdated
Comment thread avaframe/in1Data/getInput.py
Comment thread avaframe/tests/test_particleTools.py
@qltysh

qltysh Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Qlty


Coverage Impact

⬆️ Merging this pull request will increase total coverage on master by 0.81%.

Modified Components (1)

RatingComponent% Diff
Coverage rating: C Coverage rating: C
com1DFA50.0%

Modified Files with Diff Coverage (5)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
avaframe/in1Data/getInput.py76.0%1300-1302, 1304-1306
Coverage rating: B Coverage rating: B
avaframe/com1DFA/com1DFA.py100.0%
Coverage rating: F Coverage rating: F
avaframe/com1DFA/particleTools.py33.9%1058, 1099-1151
Coverage rating: C Coverage rating: B
avaframe/com1DFA/deriveParameterSet.py86.4%1086-1091
Coverage rating: A Coverage rating: A
avaframe/in3Utils/geoTrans.py89.3%262, 266, 382
Total62.8%
🤖 Increase coverage with AI coding...
In the `addInfra` branch, add test coverage for this new code:

- `avaframe/com1DFA/deriveParameterSet.py` -- Line 1086-1091
- `avaframe/com1DFA/particleTools.py` -- Lines 1058 and 1099-1151
- `avaframe/in1Data/getInput.py` -- Lines 1300-1302 and 1304-1306
- `avaframe/in3Utils/geoTrans.py` -- Lines 262, 266, and 382

🚦 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.

@fso42 fso42 left a comment

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.

Wrong PR, sorry

@fso42 fso42 left a comment

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.

  def createAssetsRasterFromParticleLocations(particlesTimeArrays, dem, uniqueAssets,   
assetsValues):                                                                          
      """create a raster indicating particle trajectories colorcoded with assets        
classes,                                                                                
      highest overrides lower classes"""                                                
                                                                                        
      nTime, nPart = particlesTimeArrays["ID"].shape                                    
      particlesTimeArrays["assetsValue"] = np.full((nTime, nPart), np.nan)              
      particleAssets = np.full((dem["header"]["nrows"], dem["header"]["ncols"]),        
np.nan)                                                                                 
                                                                                        
      # Process classes from low to high so higher classes naturally override lower     
ones                                                                                    
      for l in uniqueAssets:                                                            
          assetCells = np.asarray(assetsValues["value_%d" % l])                         
          inAsset = np.isin(particlesTimeArrays["inCellDEM"], assetCells)               
                                                                                        
          for pId in range(nPart):                                                      
              hitTimes = np.where(inAsset[:, pId])[0]                                   
              if len(hitTimes) == 0:                                                    
                  continue                                                              
                                                                                        
              # Mark particle trajectory up to the last time it hit this asset class    
              mMax = hitTimes[-1]                                                       
              particlesTimeArrays["assetsValue"][:mMax, pId] = l                        
                                                                                        
              indX = particlesTimeArrays["indXDEM"][: mMax + 1, pId].astype(int)        
              indY = particlesTimeArrays["indYDEM"][: mMax + 1, pId].astype(int)        
              # Only overwrite cells not already set to a higher class                  
              particleAssets[indY, indX] = np.where(                                    
                  particleAssets[indY, indX] >= l, particleAssets[indY, indX], l        
              )                                                                         
                                                                                        
      return particleAssets, particlesTimeArrays                                        

Comment thread avaframe/com1DFA/com1DFA.py Outdated
Comment thread avaframe/runScripts/runParticlesAssetsInfo.py Outdated
Comment thread avaframe/in1Data/getInput.py Outdated
@fso42 fso42 added the enhancement New feature or request label May 27, 2026
Comment thread avaframe/com1DFA/com1DFA.py
Comment thread avaframe/in3Utils/geoTrans.py
Comment thread avaframe/tests/test_deriveParameterSet.py Outdated
@fso42 fso42 self-requested a review June 10, 2026 14:03
Comment thread avaframe/tests/test_deriveParameterSet.py Outdated
Comment thread avaframe/tests/test_deriveParameterSet.py Outdated
Comment thread avaframe/com1DFA/particleTools.py Outdated
Comment thread avaframe/tests/test_particleTools.py Outdated
Comment thread docs/moduleOut3Plot.rst Outdated
@awirb awirb requested a review from fso42 June 11, 2026 14:11
Comment thread avaframe/com1DFA/com1DFA.py
Comment thread avaframe/in1Data/getInput.py Outdated
Comment thread avaframe/com1DFA/particleTools.py
Comment thread avaframe/out3Plot/outParticlesAnalysis.py Outdated
Comment thread avaframe/com1DFA/deriveParameterSet.py
Comment thread avaframe/com1DFA/deriveParameterSet.py
Comment thread avaframe/in3Utils/geoTrans.py
@awirb awirb requested a review from fso42 June 16, 2026 12:50

@ahuber-bfw ahuber-bfw left a comment

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.

Schaut gut aus und läuft für ein paar Testbeispiele bei mir.

Hier noch ein paar Kommentare zu Details, die aber auch noch in einem separaten, kleineren PR noch angepasst/angeschaut werden könnten.

Comment thread avaframe/in1Data/getInput.py Outdated
Comment thread avaframe/in1Data/getInput.py Outdated
Comment thread avaframe/in1Data/getInput.py Outdated
# remesh if extent matches computational DEM within resizeThreshold x meshCellSize
resizeThreshold = 3
# remeshing option for raster input data
remeshInterpMethod = default

@ahuber-bfw ahuber-bfw Jun 30, 2026

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.

Ist der Parameter hier im com1DFACfg.ini sinnvoll solange es nur die 2 optionen default (bilinear) und nearest gibt - oder schon als Platzhalter für mögliche Erweiterung der Interpolationsmethoden gedacht?

Weil aktuell macht 'nearest' eigentlich eh keinen Sinn für kontinuierliche Daten (z.B. DEMs) + über die API könnte man wo nötig trotzdem den Parameter für geoTrans.resizeData() auf "nearest" setzen?

Comment thread docs/moduleOut3Plot.rst



particle assets information

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 provide a link/reference on howto perform the analysis with runScripts/runParticlesAssetsInfo at the end of this documentation?

sth. like

after simulation with `com1dfa` and required settings is finished the asset-analysis can be run with

* run:
  ::

    pixi run python runScripts/runParticlesAssetsInfo.py


# check extent and cell size of assets raster - if not aligned with computational mesh - remesh
pathToAssets, pathToAssetsFull, remeshedAssets = dP.checkExtentAndCellSize(
cfg, assetsFile, dem, "DEM", nanInsideDEMCheck=False

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.

should "DEM" read "ASSETS" or "INFRA" here?

Comment thread avaframe/in1Data/getInput.py
elif interp == "nearest":
interpMethod = "nearest"
else:
message = 'Interpolation method "%s" not recognized' % (interp)

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 here we can hint to valid options:

message = 'Interpolation method "%s" not recognized - (valid options: "default" (bilinear), "nearest" (NN))' % (interp)

rasterRef : dict
reference raster dictionary
interp: str
default - refers to bilinear, other option is nearest

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.

in projectOnRaster projectOnGrid() und resizeData wird als "default" "bilinear" interpoliert.
in remeshData remeshDataRio und remeshRaster wird als "default" "cubic" verwendet.

"timePos": 0.0,
"timeNeigh": 0.0,
"timeField": 0.0,
"simTimestamp": 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.

runCom1DFA.py will crash with a KeyError if existing model runs without "simTimeStamp" are already present in the avaDir/Outputs --> starting with a clean avaDir works

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.

3 participants