-
Notifications
You must be signed in to change notification settings - Fork 10
[out3Plot]: add functionality for assets #1277
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
Open
awirb
wants to merge
9
commits into
master
Choose a base branch
from
addInfra
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b5439ac
add functionality for assets
awirb 25d2aea
change naming
awirb 8802c50
rename2
awirb b764b16
chore(github-actions): bump `setup-pixi` to v0.9.6 in test workflow
fso42 7f6c2b1
fix comments
awirb 193c987
new name for variable
awirb 8f6ca15
discard nan values in assets raster
awirb 609f76e
change title of plot
awirb 4224304
nan values not accounted for
awirb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| """ | ||
| Run creating a raster with numerical particle trajectories colorcoded with assets classes, highest overrides lower classes | ||
| """ | ||
|
|
||
| import pathlib | ||
|
|
||
| # Local imports | ||
| import avaframe.in1Data.getInput as gI | ||
| from avaframe.in3Utils import cfgUtils | ||
| import avaframe.out3Plot.outParticlesAnalysis as oP | ||
| import avaframe.com1DFA.particleTools as pT | ||
| import avaframe.in2Trans.rasterUtils as rU | ||
| import avaframe.in3Utils.fileHandlerUtils as fU | ||
| from avaframe.in3Utils import logUtils | ||
|
|
||
| # load avalanche directory | ||
| cfgMain = cfgUtils.getGeneralConfig() | ||
| avalancheDir = cfgMain["MAIN"]["avalancheDir"] | ||
| outDir = pathlib.Path(avalancheDir, "Outputs", "out3Plot", "particleAnalysis") | ||
| fU.makeADir(outDir) | ||
|
|
||
| # log file name; leave empty to use default runLog.log | ||
| logName = "runParticlesAssetsInfo" | ||
| # Start logging | ||
| log = logUtils.initiateLogger(avalancheDir, logName) | ||
| log.info("MAIN SCRIPT") | ||
| log.info("Current avalanche: %s", avalancheDir) | ||
|
|
||
| # create data frame that lists all available simulations | ||
| inputsDF, resTypeList = fU.makeSimFromResDF(avalancheDir, "com1DFA") | ||
| # load dataFrame for all configurations | ||
| configurationDF = cfgUtils.createConfigurationInfo(avalancheDir, comModule="com1DFA") | ||
| # Merge inputsDF with the configurationDF. Make sure to keep the indexing from inputs and to merge on 'simName' | ||
| inputsDF = inputsDF.reset_index().merge(configurationDF, on=["simName", "modelType"]).set_index("index") | ||
|
|
||
| # loop over all sims found | ||
| for index, row in inputsDF.iterrows(): | ||
| # fetch simName | ||
| simName = row["simName"] | ||
| dem = rU.readRaster(pathlib.Path(avalancheDir, "Inputs", row["DEM"])) | ||
| log.info("Find particle trajectories for simulation: %s" % (simName)) | ||
|
|
||
| # fetch info on infrastructure | ||
| uniqueAssets, assets, assetsValues = gI.preprocessAssets(avalancheDir, dem, sizeThreshold=1.0e-10) | ||
|
|
||
| # read particles saved from com1DFA simulation | ||
| Particles, timeStepInfo = pT.readPartFromPickle( | ||
| pathlib.Path(avalancheDir), simName=simName, flagAvaDir=True, comModule="com1DFA" | ||
| ) | ||
| # create time series of particles arrays | ||
| particlesTimeArrays = pT.reshapeParticlesDicts( | ||
| Particles, ["ID", "indXDEM", "indYDEM", "x", "y", "inCellDEM"] | ||
| ) | ||
|
|
||
| # derive info on which particles interacted with infrastructure | ||
| particleAssets, particlesTimeArrays = pT.createAssetsRasterFromParticleLocations( | ||
| particlesTimeArrays, dem, uniqueAssets, assetsValues | ||
| ) | ||
| # export raster | ||
| rU.writeResultToRaster( | ||
| dem["header"], particleAssets, (outDir / ("particleAssetsInfo_%s" % simName)), flip=True | ||
| ) | ||
|
|
||
| # create plot | ||
| plotName = "particleAssetsInfo_%s" % simName | ||
| _ = oP.plotParticlesInfra(dem, assets, particleAssets, outDir, plotName) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.