Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
15f5438
[com8MoTPSA] Squashed branch: MoT-PSA workflow, optimisation, and ana6
fso42 Feb 24, 2026
e41ff1c
refactor(runScripts): `runPlotAreaRefDiffs`,removing unused condition…
fso42 Feb 26, 2026
a7f0a5e
fix(probAna): restore missing bounds and config writing after merge
RolandFischbacher Feb 26, 2026
3f4d1e5
Merge remote-tracking branch 'origin/RF_com8MoTPSA' into RF_com8MoTPSA
RolandFischbacher Feb 26, 2026
97fd380
fix: handle new _L1/_L2 naming in merging logic and rename some varia…
RolandFischbacher Feb 26, 2026
7c32be0
change function name, move parameter to ini file, change values of in…
RolandFischbacher Feb 27, 2026
81b2d68
Add: if __name__ == '__main__'
RolandFischbacher Feb 27, 2026
76b0dc8
Fix: remove duplicate in com8MoTPSAMain and read chunkSize from avafr…
RolandFischbacher Feb 27, 2026
3d831a7
Implement a direct call of com8MoTPSAMain with updated cfgs (writeCfg…
RolandFischbacher Feb 27, 2026
8843c22
Use logging instead of print in optimisationUtils.py
RolandFischbacher Feb 27, 2026
51ac8a1
Add sklearn (scikit-learn) to the requirements in pyproject.toml and …
RolandFischbacher Feb 28, 2026
0f4e968
Initialize index and sampleMethod with np.nan to avoid UnboundLocalEr…
RolandFischbacher Feb 28, 2026
4d36ca4
Add a check if 'VISUALISATION' exists in cfgStart, if not, it will be…
RolandFischbacher Feb 28, 2026
0e7b446
Make optimisationType case-insensitive, add raise ValueErrors, update…
RolandFischbacher Mar 2, 2026
67a5886
Add description of Loss function to README_ana6.md.
RolandFischbacher Mar 9, 2026
da3f6db
Add description of Loss function to README_ana6.md and add parameter …
RolandFischbacher Mar 9, 2026
20b8cd0
Merge remote-tracking branch 'origin/RF_com8MoTPSA' into RF_com8MoTPSA
RolandFischbacher Mar 9, 2026
9c1940a
Add more info and layer handling in Cfg.ini files,swap scenario 1 and…
RolandFischbacher Mar 10, 2026
e0c0307
Revise README_ana6.md
RolandFischbacher Mar 12, 2026
9c6432c
Use cfg.getint(...) instead of int(cfg(...)), swap scenario 1 and 2 (…
RolandFischbacher Mar 12, 2026
39b8dbe
Improve documentation, construct the filename of AIMEC results from A…
RolandFischbacher Mar 12, 2026
4085755
Add definition of chunkSize to probAnaCfg.ini, if left empty 10 is us…
RolandFischbacher Mar 12, 2026
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
71 changes: 40 additions & 31 deletions avaframe/ana4Stats/probAna.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from avaframe.out3Plot import statsPlots as sP
from avaframe.in1Data import getInput as gI


# create local logger
# change log level in calling module to DEBUG to see log messages
log = logging.getLogger(__name__)
Expand Down Expand Up @@ -203,17 +202,17 @@ def updateCfgRange(cfg, cfgProb, varName, varDict):
if valVariation == "":
valVariation = "-"
parValue = (
variationType
+ "$"
+ valSteps
+ "$"
+ valVariation
+ "$"
+ cfgDist["GENERAL"]["minMaxInterval"]
+ "$"
+ cfgDist["GENERAL"]["buildType"]
+ "$"
+ cfgDist["GENERAL"]["support"]
variationType
+ "$"
+ valSteps
+ "$"
+ valVariation
+ "$"
+ cfgDist["GENERAL"]["minMaxInterval"]
+ "$"
+ cfgDist["GENERAL"]["buildType"]
+ "$"
+ cfgDist["GENERAL"]["support"]
)
# if variation using percent
elif variationType.lower() == "percent":
Expand All @@ -225,9 +224,9 @@ def updateCfgRange(cfg, cfgProb, varName, varDict):
parValue = valVariation + "$" + valSteps
if "ci" in valVariation:
message = (
"Variation Type: range - variationValue is %s not a valid option - only \
scalar value allowed or consider variationType rangefromci"
% valVariation
"Variation Type: range - variationValue is %s not a valid option - only \
scalar value allowed or consider variationType rangefromci"
% valVariation
)
log.error(message)
raise AssertionError(message)
Expand All @@ -236,9 +235,9 @@ def updateCfgRange(cfg, cfgProb, varName, varDict):
parValue = valVariation + "$" + valSteps
else:
message = (
"Variation Type: %s - not a valid option, options are: percent, range, \
normaldistribution, rangefromci"
% variationType
"Variation Type: %s - not a valid option, options are: percent, range, \
normaldistribution, rangefromci"
% variationType
)
log.error(message)
raise AssertionError(message)
Expand Down Expand Up @@ -272,9 +271,9 @@ def updateCfgRange(cfg, cfgProb, varName, varDict):
valValues = np.linspace(float(valStart), float(valStop), int(valSteps))
else:
message = (
"Variation Type: %s - not a valid option, options are: percent, range, \
normaldistribution, rangefromci"
% variationType
"Variation Type: %s - not a valid option, options are: percent, range, \
normaldistribution, rangefromci"
% variationType
)
log.error(message)
raise AssertionError(message)
Expand Down Expand Up @@ -616,8 +615,8 @@ def makeDictFromVars(cfg):

if (len(varParList) == len(varValues) == len(cfg[lengthsPar].split("|")) == len(varTypes)) is False:
message = (
"For every parameter in varParList a variationValue, %s and variationType needs to be provided"
% lengthsPar
"For every parameter in varParList a variationValue, %s and variationType needs to be provided"
% lengthsPar
)
log.error(message)
raise AssertionError(message)
Expand Down Expand Up @@ -801,13 +800,14 @@ def createSampleWithVariationStandardParameters(cfgProb, cfgStart, varParList, v
"values": sampleWBounds,
"typeList": cfgProb["PROBRUN"]["varParType"].split("|"),
"thFromIni": "",
"bounds": np.column_stack((lowerBounds, upperBounds)).tolist()
}

return paramValuesD


def createSampleWithVariationForThParameters(
avaDir, cfgProb, cfgStart, varParList, valVariationValue, varType, thReadFromShp
avaDir, cfgProb, cfgStart, varParList, valVariationValue, varType, thReadFromShp
):
"""Create a sample of parameters for a desired parameter variation,
and fetch thickness values from shp file and perform variation for each feature within
Expand Down Expand Up @@ -907,23 +907,23 @@ def createSampleWithVariationForThParameters(
# set lower and upper bounds depending on varType (percent, range, rangefromci)
lowerBounds[fullVarType == "percent"] = varValList[fullVarType == "percent"] - varValList[
fullVarType == "percent"
] * (fullValVar[fullVarType == "percent"] / 100.0)
] * (fullValVar[fullVarType == "percent"] / 100.0)
upperBounds[fullVarType == "percent"] = varValList[fullVarType == "percent"] + varValList[
fullVarType == "percent"
] * (fullValVar[fullVarType == "percent"] / 100.0)
] * (fullValVar[fullVarType == "percent"] / 100.0)

lowerBounds[fullVarType == "range"] = (
varValList[fullVarType == "range"] - fullValVar[fullVarType == "range"]
varValList[fullVarType == "range"] - fullValVar[fullVarType == "range"]
)
upperBounds[fullVarType == "range"] = (
varValList[fullVarType == "range"] + fullValVar[fullVarType == "range"]
varValList[fullVarType == "range"] + fullValVar[fullVarType == "range"]
)

lowerBounds[fullVarType == "rangefromci"] = (
varValList[fullVarType == "rangefromci"] - ciValues[fullVarType == "rangefromci"]
varValList[fullVarType == "rangefromci"] - ciValues[fullVarType == "rangefromci"]
)
upperBounds[fullVarType == "rangefromci"] = (
varValList[fullVarType == "rangefromci"] + ciValues[fullVarType == "rangefromci"]
varValList[fullVarType == "rangefromci"] + ciValues[fullVarType == "rangefromci"]
)

# create a sample of parameter values using scipy latin hypercube or morris sampling
Expand Down Expand Up @@ -1102,9 +1102,18 @@ def createCfgFiles(paramValuesDList, comMod, cfg, cfgPath=""):
cfgStart[section][par] = str(pVal[index])
else:
cfgStart["GENERAL"][par] = str(pVal[index])
if modName.lower() in ["com1dfa", "com5snowslide", "com6rockavalanche"]:
if modName.lower() in ["com1dfa", "com5snowslide", "com6rockavalanche", 'com8motpsa']:
# Check if visualisation exists in cfgStart, if not add the section
if not cfgStart.has_section("VISUALISATION"):
cfgStart.add_section("VISUALISATION")

cfgStart["VISUALISATION"]["scenario"] = str(count1)
cfgStart["INPUT"]["thFromIni"] = paramValuesD["thFromIni"]

# Safe read with fallback (no KeyError if PROBRUN or sampleMethod is missing)
sample_method = cfg.get("PROBRUN", "sampleMethod", fallback="")
cfgStart["VISUALISATION"]["sampleMethod"] = sample_method

if "releaseScenario" in paramValuesD.keys():
cfgStart["INPUT"]["releaseScenario"] = paramValuesD["releaseScenario"]
cfgF = pathlib.Path(cfgPath, ("%d_%sCfg.ini" % (countS, modName)))
Expand Down
10 changes: 7 additions & 3 deletions avaframe/ana4Stats/probAnaCfg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ unit = kPa
peakLim = 1.0
# if only probability analysis is performed check for modName to locate peakFiles avaDir/Outputs/modName/peakFiles
modName = com1DFA
# If modName = com8MoTPSA, simulations can be executed in chunks.
# chunkSize defines how many simulations are processed per chunk (running simulations, postprocessing and cleaning the working directory incrementally).
# If left empty, the default chunk size used in the script is 10.
chunkSize =


[PROBRUN]
Expand All @@ -40,7 +44,7 @@ samplingStrategy = 1
# #++++++VARIATION INFO FOR DRAW SAMPLES FROM FULL SET OF VARIATIONS
# type of parameters that shall be varied -separated by | (options: float)
varParType = float|float
# factor used to create the number of samples, if morris number of samples depends on number of varied variables and number of trajectories, for now use nSample as number of trajectories
# factor used to create the number of samples, if morris: number of samples depends on number of varied variables and number of trajectories, for now use nSample as number of trajectories, n >=2 for morris
nSample = 40
# sample method used to create sample (options: latin, morris)
sampleMethod = latin
Expand Down Expand Up @@ -71,13 +75,13 @@ frictModel = samosAT


[com4FlowPy_com4FlowPy_override]
# use default com1DFA config as base configuration (True) and override following parameters
# use default com4FlowPy config as base configuration (True) and override following parameters
# if False and local is available use local
defaultConfig = True


[com8MoTPSA_com8MoTPSA_override]
# use default com1DFA config as base configuration (True) and override following parameters
# use default com8MoTPSA config as base configuration (True) and override following parameters
# if False and local is available use local
defaultConfig = True

Expand Down
Loading
Loading