From 2b15022a7b670f1fc97b679ddbce4e0e247e3ade Mon Sep 17 00:00:00 2001 From: RolandFischbacher Date: Tue, 29 Apr 2025 13:29:21 +0200 Subject: [PATCH 1/4] Add morris sampling methode and change regex to handle white space and special characters runAna4ProbAna.py with com8MoTPSA module (runAna4ProbAnaCom8MoTPSA.py), add sections to com8MoTPSA.ini and probAnaCfg.ini, and introduce modname Pass module instead of modName and add hepler functions to simplify functions: `checkParameterInConfig` and `fetchParameterSection` Change handling of friction index to volume index for com8MoTPSA Add `renameDuplicates` to handle duplicate column names in DataFrame and Simplify configuration-appending by generalizing section (add all sections) --- avaframe/ana3AIMEC/aimecTools.py | 17 ++++++++++++++--- avaframe/com8MoTPSA/com8MoTPSA.py | 5 ++++- avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/avaframe/ana3AIMEC/aimecTools.py b/avaframe/ana3AIMEC/aimecTools.py index 4a3e0ef60..663e7abf8 100644 --- a/avaframe/ana3AIMEC/aimecTools.py +++ b/avaframe/ana3AIMEC/aimecTools.py @@ -157,7 +157,6 @@ def fetchReferenceSimNo(avaDir, inputsDF, comModule, cfg, inputDir=''): valRef: str value of vapParList[0] used to define reference sim """ - cfgSetup = cfg['AIMECSETUP'] if inputDir != '': inputDir = pathlib.Path(inputDir) @@ -172,12 +171,24 @@ def fetchReferenceSimNo(avaDir, inputsDF, comModule, cfg, inputDir=''): referenceSimName = cfgSetup['referenceSimName'] colorVariation = False # look for a configuration + # ToDo change filename of com8MoTPSA files try: # load dataFrame for all configurations configurationDF = cfgUtils.createConfigurationInfo(avaDir, comModule=comModule) - # 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') + + if comModule == 'com8MoTPSA': + # Reset the index of configurationDF so that the index (simHash) becomes a column and rename simName that it doesn't appear twice + configurationDF = configurationDF.reset_index().rename(columns={'index': 'simHash'}) + configurationDF = configurationDF.rename(columns={'simName': 'simName_renamed'}) + + # Merge inputsDF with the configurationDF. Make sure to keep the indexing from inputs and to merge on 'simHash' + inputsDF = inputsDF.reset_index().merge(configurationDF, on=['simHash', 'modelType']).set_index('index') + else: + # 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') + configFound = True + except (NotADirectoryError, FileNotFoundError) as e: if cfgSetup['varParList'] != '' and (any(item in inputsDF.columns.tolist() for item in cfgSetup['varParList'].split('|')) == False): message = ('No configuration directory found. This is needed for sorting simulation according to ' diff --git a/avaframe/com8MoTPSA/com8MoTPSA.py b/avaframe/com8MoTPSA/com8MoTPSA.py index 713b6d204..292b55404 100644 --- a/avaframe/com8MoTPSA/com8MoTPSA.py +++ b/avaframe/com8MoTPSA/com8MoTPSA.py @@ -70,7 +70,10 @@ def _runAndCheck(command): printCounter = printCounter + 1 if printCounter > 100: # print('\r' + line, flush=True, end='') - msg = "Process is running. Reported time steps: " + str(counter) + msg = ( + "Process is running. Reported time steps: " + + str(counter) + ) log.info(msg) printCounter = 0 diff --git a/avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py b/avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py index 78eb15ac8..e4b111ee5 100644 --- a/avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py +++ b/avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py @@ -130,4 +130,4 @@ def runProbAna(avalancheDir=''): help='the avalanche directory') args = parser.parse_args() - runProbAna(str(args.avadir)) + runProbAna(str(args.avadir)) \ No newline at end of file From e3e69f5b1bbbc9d7939f35460412dedb5d46bb55 Mon Sep 17 00:00:00 2001 From: RolandFischbacher Date: Fri, 13 Jun 2025 14:49:41 +0200 Subject: [PATCH 2/4] Change naming of outputlayer (dfa/psa), revert merging to original version (merge on simName) --- avaframe/ana3AIMEC/aimecTools.py | 17 +++-------------- avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py | 2 +- avaframe/out3Plot/plotUtilsCfg.ini | 2 +- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/avaframe/ana3AIMEC/aimecTools.py b/avaframe/ana3AIMEC/aimecTools.py index 663e7abf8..4140bc90d 100644 --- a/avaframe/ana3AIMEC/aimecTools.py +++ b/avaframe/ana3AIMEC/aimecTools.py @@ -171,24 +171,13 @@ def fetchReferenceSimNo(avaDir, inputsDF, comModule, cfg, inputDir=''): referenceSimName = cfgSetup['referenceSimName'] colorVariation = False # look for a configuration - # ToDo change filename of com8MoTPSA files try: # load dataFrame for all configurations configurationDF = cfgUtils.createConfigurationInfo(avaDir, comModule=comModule) - - if comModule == 'com8MoTPSA': - # Reset the index of configurationDF so that the index (simHash) becomes a column and rename simName that it doesn't appear twice - configurationDF = configurationDF.reset_index().rename(columns={'index': 'simHash'}) - configurationDF = configurationDF.rename(columns={'simName': 'simName_renamed'}) - - # Merge inputsDF with the configurationDF. Make sure to keep the indexing from inputs and to merge on 'simHash' - inputsDF = inputsDF.reset_index().merge(configurationDF, on=['simHash', 'modelType']).set_index('index') - else: - # 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') - + # 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') configFound = True - + except (NotADirectoryError, FileNotFoundError) as e: if cfgSetup['varParList'] != '' and (any(item in inputsDF.columns.tolist() for item in cfgSetup['varParList'].split('|')) == False): message = ('No configuration directory found. This is needed for sorting simulation according to ' diff --git a/avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py b/avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py index e4b111ee5..78eb15ac8 100644 --- a/avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py +++ b/avaframe/com8MoTPSA/runAna4ProbAnaCom8MoTPSA.py @@ -130,4 +130,4 @@ def runProbAna(avalancheDir=''): help='the avalanche directory') args = parser.parse_args() - runProbAna(str(args.avadir)) \ No newline at end of file + runProbAna(str(args.avadir)) diff --git a/avaframe/out3Plot/plotUtilsCfg.ini b/avaframe/out3Plot/plotUtilsCfg.ini index 6cc8cd51b..2371f80d9 100644 --- a/avaframe/out3Plot/plotUtilsCfg.ini +++ b/avaframe/out3Plot/plotUtilsCfg.ini @@ -140,4 +140,4 @@ nameVy = y velocity nameVz = z velocity nameTA = travel angle namezdelta = energy line height -namedmDet = detrained mass \ No newline at end of file +namedmDet = detrained mass From 8ee62639206e45c3d81f9dfdc4605c57b9496d4f Mon Sep 17 00:00:00 2001 From: Felix Oesterle Date: Tue, 24 Jun 2025 11:25:15 +0200 Subject: [PATCH 3/4] refactor(core): improve code readability and fix minor issues - Remove unused parameters in `probAna.py` and update method names for clarity. - Fix a conditional statement in `com1DFA.py` for better compatibility. - Add a missing newline and correct whitespace formatting in `aimecTools.py`. - Maintain consistent casing in `plotUtilsCfg.ini`. --- avaframe/ana3AIMEC/aimecTools.py | 2 +- avaframe/out3Plot/plotUtilsCfg.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/avaframe/ana3AIMEC/aimecTools.py b/avaframe/ana3AIMEC/aimecTools.py index 4140bc90d..4a3e0ef60 100644 --- a/avaframe/ana3AIMEC/aimecTools.py +++ b/avaframe/ana3AIMEC/aimecTools.py @@ -157,6 +157,7 @@ def fetchReferenceSimNo(avaDir, inputsDF, comModule, cfg, inputDir=''): valRef: str value of vapParList[0] used to define reference sim """ + cfgSetup = cfg['AIMECSETUP'] if inputDir != '': inputDir = pathlib.Path(inputDir) @@ -177,7 +178,6 @@ def fetchReferenceSimNo(avaDir, inputsDF, comModule, cfg, inputDir=''): # 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') configFound = True - except (NotADirectoryError, FileNotFoundError) as e: if cfgSetup['varParList'] != '' and (any(item in inputsDF.columns.tolist() for item in cfgSetup['varParList'].split('|')) == False): message = ('No configuration directory found. This is needed for sorting simulation according to ' diff --git a/avaframe/out3Plot/plotUtilsCfg.ini b/avaframe/out3Plot/plotUtilsCfg.ini index 2371f80d9..6cc8cd51b 100644 --- a/avaframe/out3Plot/plotUtilsCfg.ini +++ b/avaframe/out3Plot/plotUtilsCfg.ini @@ -140,4 +140,4 @@ nameVy = y velocity nameVz = z velocity nameTA = travel angle namezdelta = energy line height -namedmDet = detrained mass +namedmDet = detrained mass \ No newline at end of file From 3ac438d522090e46b13926555a0473936540c9e2 Mon Sep 17 00:00:00 2001 From: Felix Oesterle Date: Tue, 24 Jun 2025 12:21:37 +0200 Subject: [PATCH 4/4] refactor(com8MoTPSA): improve code formatting and readability - --- avaframe/com8MoTPSA/com8MoTPSA.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/avaframe/com8MoTPSA/com8MoTPSA.py b/avaframe/com8MoTPSA/com8MoTPSA.py index 292b55404..713b6d204 100644 --- a/avaframe/com8MoTPSA/com8MoTPSA.py +++ b/avaframe/com8MoTPSA/com8MoTPSA.py @@ -70,10 +70,7 @@ def _runAndCheck(command): printCounter = printCounter + 1 if printCounter > 100: # print('\r' + line, flush=True, end='') - msg = ( - "Process is running. Reported time steps: " - + str(counter) - ) + msg = "Process is running. Reported time steps: " + str(counter) log.info(msg) printCounter = 0