From dfc44ea6ff11d6a8f89eaf3fc9ab337dce85c5e3 Mon Sep 17 00:00:00 2001 From: Anna Wirbel Date: Thu, 18 Dec 2025 14:26:38 +0100 Subject: [PATCH] add writing of ref DF in aimec --- avaframe/ana3AIMEC/aimecTools.py | 4 +++- avaframe/ana3AIMEC/ana3AIMEC.py | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/avaframe/ana3AIMEC/aimecTools.py b/avaframe/ana3AIMEC/aimecTools.py index 8499fc7a7..501b43d0d 100644 --- a/avaframe/ana3AIMEC/aimecTools.py +++ b/avaframe/ana3AIMEC/aimecTools.py @@ -99,6 +99,7 @@ def readAIMECinputs(avalancheDir, pathDict, defineRunoutArea, dirName='com1DFA') # check for reference data referenceDir= pathlib.Path(avalancheDir, 'Inputs') + # file names need to contain: _LINE, _POLY, _POINT referenceTypes = {"referenceLine": "LINE", "referencePolygon": "POLY",'referencePoint': 'POINT'} for refType in referenceTypes: referenceFile, availableFile, _ = gI.getAndCheckInputFiles( @@ -106,7 +107,7 @@ def readAIMECinputs(avalancheDir, pathDict, defineRunoutArea, dirName='com1DFA') "REFDATA", referenceTypes[refType], fileExt="shp", - fileSuffix=referenceTypes[refType], + fileSuffix=("_" + referenceTypes[refType]), ) if availableFile == 'Yes': # add file paths to pathDict @@ -1643,6 +1644,7 @@ def createReferenceDF(pathDict): newLine = newLine.set_index(hashRef) referenceDF = pd.concat([referenceDF, newLine], ignore_index=False) referenceDF.loc[hashRef, 'dataType'] = 'reference' + referenceDF.loc[hashRef, "reference_Type"] = refFile.stem.split("_")[1] # TODO add here if additional info read from shp or a textfile? diff --git a/avaframe/ana3AIMEC/ana3AIMEC.py b/avaframe/ana3AIMEC/ana3AIMEC.py index 2fcad2f1d..383dd9bc3 100644 --- a/avaframe/ana3AIMEC/ana3AIMEC.py +++ b/avaframe/ana3AIMEC/ana3AIMEC.py @@ -152,6 +152,9 @@ def mainAIMEC(pathDict, inputsDF, cfg): if cfgSetup.getboolean('includeReference'): referenceDF = aimecTools.createReferenceDF(pathDict) refDataTransformed, referenceDF = postProcessReference(cfg, rasterTransfo, pathDict, referenceDF, newRasters) + # save resultsDF to file + referenceDFPath = pathlib.Path(pathDict["pathResult"], "referenceDF.csv") + referenceDF.to_csv(referenceDFPath) else: refDataTransformed = {} @@ -178,7 +181,7 @@ def mainAIMEC(pathDict, inputsDF, cfg): if sorted(pathDict['resTypeList']) == sorted(['ppr', 'pft', 'pfv']) and cfgPlots.getboolean('extraPlots'): outAimec.visuSimple(cfgSetup, rasterTransfo, resAnalysisDF, newRasters, pathDict) if len(resAnalysisDF.index) == 2 and sorted(pathDict['resTypeList']) == sorted(['ppr', 'pft', 'pfv']): - plotName = outAimec.visuRunoutComp(rasterTransfo, resAnalysisDF, cfgSetup, pathDict) + plotName = outAimec.visuRunoutComp(rasterTransfo, resAnalysisDF, cfgSetup, pathDict) plotName = outAimec.visuRunoutStat(rasterTransfo, inputsDF, resAnalysisDF, newRasters, cfgSetup, pathDict) @@ -415,9 +418,9 @@ def postProcessAIMEC(cfg, rasterTransfo, pathDict, resAnalysisDF, newRasters, ti def postProcessReference(cfg, rasterTransfo, pathDict, referenceDF, newRasters): - """ Apply domain transformation and analyse reference data, e.g. compute runout point + """Apply domain transformation and analyse reference data, e.g. compute runout point - Apply the domain tranformation to reference data sets + Apply the domain transformation to reference data sets Analyse them. Calculate runout