Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions avaframeConnector_commonFunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ def copyDEM(dem, targetDir):
pass


def copyRaster(raster, targetDir, suffix):
"""copies raster file to targetDir with suffix added to filename

Parameters
-----------
raster:
qgis raster layer
targetDir: pathlib.Path
target directory
suffix: string
suffix to add to filename (e.g., "_mu", "_k")
"""
sourceRasterPath = pathlib.Path(raster.source())

# Add suffix before file extension
newFileName = sourceRasterPath.stem + suffix + sourceRasterPath.suffix
Copy link

Choose a reason for hiding this comment

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

Rename this local variable "newFileName" to match the regular expression ^[_a-z][a-z0-9_]*$. [radarlint-python:python:S117]

targetRasterPath = targetDir / newFileName
Copy link

Choose a reason for hiding this comment

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

Rename this local variable "targetRasterPath" to match the regular expression ^[_a-z][a-z0-9_]*$. [radarlint-python:python:S117]


try:
shutil.copy(sourceRasterPath, targetRasterPath)
except shutil.SameFileError:
pass


def copyMultipleShp(sourceDict, targetPath, addToName=""):
"""copies multiple shapefile parts to targetPath

Expand Down Expand Up @@ -87,6 +111,43 @@ def getSHPParts(base):
return globbed


# TODO: maybe combine this with getLatestPeak
Copy link

Choose a reason for hiding this comment

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

Found 2 issues:

1. Complete the task associated to this "TODO" comment. [radarlint-python:python:S1135]


2. # TODO: maybe combine this with getLatestPeak [ripgrep:TODO]

def getLatestPeakCom8(targetDir):
"""Get latest peakFiles of com8MoTPSA results

Parameters
-----------
targetDir: pathlib path
to avalanche directory
Returns
-------
rasterResults: dataframe
dataframe with info about simulations, including path
"""
avaDir = pathlib.Path(str(targetDir))
inputDirPeak = avaDir / "Outputs" / "com8MoTPSA" / "peakFiles"
allRasterResults = fU.makeSimDF(inputDirPeak, avaDir=avaDir)

return allRasterResults

def getLatestPeakCom9(targetDir):
"""Get latest peakFiles of com9MoTVoellmy results

Parameters
-----------
targetDir: pathlib path
to avalanche directory
Returns
-------
rasterResults: dataframe
dataframe with info about simulations, including path
"""
avaDir = pathlib.Path(str(targetDir))
inputDirPeak = avaDir / "Outputs" / "com9MoTVoellmy" / "peakFiles"
allRasterResults = fU.makeSimDF(inputDirPeak, avaDir=avaDir)

return allRasterResults

def getLatestPeak(targetDir):
"""Get latest peakFiles of com1DFA results

Expand Down Expand Up @@ -259,6 +320,7 @@ def addStyleToCom1DFAResults(rasterResults):
qmls = dict()
qmls["ppr"] = str(scriptDir / "QGisStyles" / "ppr.qml")
qmls["pft"] = str(scriptDir / "QGisStyles" / "pft.qml")
qmls["pfd"] = str(scriptDir / "QGisStyles" / "pft.qml")
qmls["pfv"] = str(scriptDir / "QGisStyles" / "pfv.qml")
qmls["PR"] = str(scriptDir / "QGisStyles" / "ppr.qml")
qmls["FV"] = str(scriptDir / "QGisStyles" / "pfv.qml")
Expand Down
7 changes: 3 additions & 4 deletions avaframeConnector_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
from qgis.core import QgsProcessingProvider
from qgis.PyQt.QtGui import QIcon

from qgis.core import (
QgsMessageLog,
QgsGeometry,
)

from qgis.PyQt.QtWidgets import (
QMessageBox,
Expand Down Expand Up @@ -91,6 +87,7 @@ def find_python():
from .getVersion_algorithm import getVersionAlgorithm
from .runCom1DFA_algorithm import runCom1DFAAlgorithm
from .runCom2AB_algorithm import runCom2ABAlgorithm
from .runCom9MoTVoellmy_algorithm import runCom9MoTVoellmyAlgorithm
from .runAna4ProbAna_algorithm import runAna4ProbAnaAlgorithm
from .runAna4ProbDirOnly_algorithm import runAna4ProbDirOnlyAlgorithm
from .runAna5DFAPathGeneration_algorithm import runAna5DFAPathGenerationAlgorithm
Expand Down Expand Up @@ -132,6 +129,8 @@ def loadAlgorithms(self):
self.addAlgorithm(runCom5SnowSlideAlgorithm())
self.addAlgorithm(runCom6RockAvalancheAlgorithm())
self.addAlgorithm(runCom6ScarpAlgorithm())
# self.addAlgorithm(runCom8MoTPSAAlgorithm())
self.addAlgorithm(runCom9MoTVoellmyAlgorithm())
self.addAlgorithm(runCom7RegionalSplittingAlgorithm())
self.addAlgorithm(runCom7RegionalComputationAlgorithm())
self.addAlgorithm(runAna4ProbAnaAlgorithm())
Expand Down
5 changes: 3 additions & 2 deletions metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name=AvaFrameConnector
qgisMinimumVersion=3.22
description=Connects to AvaFrame
version=1.13
version=1.14
author=AvaFrame Team
email=felix@avaframe.org

Expand All @@ -24,7 +24,8 @@ repository=https://github.com/OpenNHM/QGisAF

hasProcessingProvider=yes
# Uncomment the following line and add your changelog:
changelog= 1.13 Add Scarp (com6) analysis tool
changelog= 1.14 Add experimental MoT Voellmy (com9); com7 Regional
1.13 Add Scarp (com6) analysis tool
1.12.1 Remove numpy update on installation
1.12 On Release area statics run, open parent folder on completion
1.10 Add path generation tool, accept geotiff as raster input
Expand Down
2 changes: 2 additions & 0 deletions pb_tool.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ python_files: __init__.py avaframeConnector.py avaframeConnector_provider.py
runCom2AB_algorithm.py
runCom5SnowSlide_algorithm.py
runCom6RockAvalanche_algorithm.py
runCom8MoTPSA_algorithm.py
runCom9MoTVoellmy_algorithm.py
runCom6Scarp_algorithm.py
runAna4ProbAna_algorithm.py
runAna4ProbDirOnly_algorithm.py
Expand Down
Loading