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
19 changes: 15 additions & 4 deletions avaframe/ana3AIMEC/aimecTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,16 +1001,18 @@ def computeRunOut(cfgSetup, rasterTransfo, resAnalysisDF, transformedRasters, si
resAnalysisDF.loc[simRowHash, "lRunout"] = lcoord[index]
resAnalysisDF.loc[simRowHash, "xRunout"] = gridx[cLower, index]
resAnalysisDF.loc[simRowHash, "yRunout"] = gridy[cLower, index]
resAnalysisDF.loc[simRowHash, "runoutAngle"] = np.rad2deg(
np.arctan((zThalweg[cUpper] - zThalweg[cLower]) / (scoord[cLower] - scoord[cUpper]))
)
else:
resAnalysisDF.loc[simRowHash, "sRunout"] = np.nan
resAnalysisDF.loc[simRowHash, "lRunout"] = np.nan
resAnalysisDF.loc[simRowHash, "xRunout"] = np.nan
resAnalysisDF.loc[simRowHash, "yRunout"] = np.nan
resAnalysisDF.loc[simRowHash, "runoutAngle"] = np.nan

resAnalysisDF.loc[simRowHash, 'deltaSXY'] = scoord[cLower] - scoord[cUpper]
resAnalysisDF.loc[simRowHash, "runoutAngle"] = np.rad2deg(
np.arctan((zThalweg[cUpper] - zThalweg[cLower]) / (scoord[cLower] - scoord[cUpper]))
)

if flagMeanFound:
resAnalysisDF.loc[simRowHash, "zRunout"] = zThalweg[cLower]
resAnalysisDF.loc[simRowHash, "sMeanRunout"] = scoord[cLowerm]
Expand Down Expand Up @@ -1296,6 +1298,11 @@ def analyzeArea(rasterTransfo, resAnalysisDF, simRowHash, newRasters, cfg, pathD
):
# only plot comparisons of simulations to reference
compPlotPath = outAimec.visuComparison(rasterTransfo, inputs, pathDict)
elif not resAnalysisDF.loc[simRowHash, "runoutFound"] and cfgPlots.getboolean("extraPlots"):
log.warning(
"ContourComparisonToReference plot not generated as only 0 values for comparison simulation: %s"
% resAnalysisDF.loc[simRowHash, "simName"]
)
# add contourlines to contourDict
contourDict = outAimec.fetchContourLines(rasterTransfo, inputs, cfgSetup.getfloat('thresholdValue'), contourDict)

Expand Down Expand Up @@ -1798,7 +1805,11 @@ def analyzeDiffsRunoutLines(cfgSetup, runoutLine, refDataTransformed, resAnalysi
refLineStr = '%d/%d' % (refLineNoPoints, runoutLineAllPoints)

# compute RMSE between runout line and refLine
RMSE = np.sqrt(np.sum(diffNoNans**2)/len(diffNoNans))
# set RMSE to nan if no runout line found for sim to compare to reference
if np.all(np.isnan(runoutLine["s"])):
RMSE = np.nan
else:
RMSE = np.sqrt(np.sum(diffNoNans**2) / len(diffNoNans))

# plot differences in runout lines
if len(np.where((np.isnan(runoutLine["s"]) == False))[0]) > 0:
Expand Down
29 changes: 21 additions & 8 deletions avaframe/ana3AIMEC/ana3AIMEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,16 +352,29 @@ def postProcessAIMEC(cfg, rasterTransfo, pathDict, resAnalysisDF, newRasters, ti
resAnalysisDF['runoutLineDiff_poly'] = np.nan
resAnalysisDF['runoutLineDiff_poly'] = resAnalysisDF['runoutLineDiff_line'].astype(object)

# add max, min and std values of result fields
resAnalysisDF.at[simRowHash, resType + 'FieldMax'] = np.nanmax(rasterData['rasterData'])
# for mean and min values and std, only take peak field values != 0
maskedRaster = np.where(rasterData['rasterData'] < cfgSetup.getfloat('minValueField'), np.nan, rasterData['rasterData'])
resAnalysisDF.at[simRowHash, resType + 'FieldMin'] = np.nanmin(maskedRaster)
resAnalysisDF.at[simRowHash, resType + 'FieldMean'] = np.nanmean(maskedRaster)
resAnalysisDF.at[simRowHash, resType + 'FieldStd'] = np.nanstd(maskedRaster)
# only extract values if nonzero values found in rasterData; if only 0 values set to 0
if np.any(rasterData["rasterData"]):
# add max, min and std values of result fields
resAnalysisDF.at[simRowHash, resType + "FieldMax"] = np.nanmax(rasterData["rasterData"])
# for mean and min values and std, only take peak field values != 0
maskedRaster = np.where(
rasterData["rasterData"] < cfgSetup.getfloat("minValueField"),
np.nan,
rasterData["rasterData"],
)
resAnalysisDF.at[simRowHash, resType + "FieldMin"] = np.nanmin(maskedRaster)
resAnalysisDF.at[simRowHash, resType + "FieldMean"] = np.nanmean(maskedRaster)
resAnalysisDF.at[simRowHash, resType + "FieldStd"] = np.nanstd(maskedRaster)
else:
resAnalysisDF.at[simRowHash, resType + "FieldMax"] = 0.0
resAnalysisDF.at[simRowHash, resType + "FieldMin"] = 0.0
resAnalysisDF.at[simRowHash, resType + "FieldMean"] = 0.0
resAnalysisDF.at[simRowHash, resType + "FieldStd"] = 0.0

# analyze all fields
resAnalysisDF = aimecTools.analyzeField(simRowHash, rasterTransfo, newRaster, resType, resAnalysisDF)
resAnalysisDF = aimecTools.analyzeField(
simRowHash, rasterTransfo, newRaster, resType, resAnalysisDF
)

# compute runout based on runoutResType
resAnalysisDF = aimecTools.computeRunOut(cfgSetup, rasterTransfo, resAnalysisDF, newRasters, simRowHash)
Expand Down
Loading
Loading