From 15f07dcc78466a4789394cd5376c442a4307590e Mon Sep 17 00:00:00 2001 From: Paula Date: Wed, 11 Nov 2026 16:51:41 +0100 Subject: [PATCH 1/2] change brackets with units from [] to () --- avaframe/ana1Tests/FPtest.py | 4 +- avaframe/ana1Tests/energyLineTest.py | 16 +-- avaframe/com1DFA/debrisFunctions.py | 8 +- avaframe/com1DFA/testSPH.py | 12 +-- avaframe/out1Peak/outPlotAllPeak.py | 10 +- avaframe/out1Peak/outPlotAllPeakDiffs.py | 12 +-- avaframe/out3Plot/amaPlots.py | 12 +-- avaframe/out3Plot/outAB.py | 4 +- avaframe/out3Plot/outAIMEC.py | 102 +++++++++---------- avaframe/out3Plot/outAna1Plots.py | 30 +++--- avaframe/out3Plot/outCom1DFA.py | 50 ++++----- avaframe/out3Plot/outCom3Plots.py | 20 ++-- avaframe/out3Plot/outCom7Regional.py | 2 +- avaframe/out3Plot/outContours.py | 2 +- avaframe/out3Plot/outDebugPlots.py | 8 +- avaframe/out3Plot/outDistanceTimeAnalysis.py | 46 ++++----- avaframe/out3Plot/outParticlesAnalysis.py | 46 ++++----- avaframe/out3Plot/outProfilePlots.py | 24 ++--- avaframe/out3Plot/outQuickPlot.py | 30 +++--- avaframe/out3Plot/outTopo.py | 12 +-- avaframe/out3Plot/outTransformPlots.py | 4 +- avaframe/out3Plot/plotUtils.py | 4 +- avaframe/out3Plot/statsPlots.py | 16 +-- avaframe/runScripts/runPlotProfile.py | 2 +- 24 files changed, 238 insertions(+), 238 deletions(-) diff --git a/avaframe/ana1Tests/FPtest.py b/avaframe/ana1Tests/FPtest.py index 80129e389..22420674f 100644 --- a/avaframe/ana1Tests/FPtest.py +++ b/avaframe/ana1Tests/FPtest.py @@ -155,11 +155,11 @@ def plotProfilesFPtest(cfg, ind_time, relDict, comSol): ax1.plot(np.linspace(xllc, xllc+(ncols-1)*csz, ncols), relTh[100, :], '--k') ax1.plot(r, H0-mu*(r-deltaX), '-k', label='initial expected flow thickness') - ax1.set_xlabel('r in [m]') + ax1.set_xlabel('r in (m)') ax1.set_title('flow thickness, t=%.2f s' % (Tsave)) ax2.plot(r, mu*np.ones(np.shape(r)), '-k', label='friction threashold') - ax2.set_xlabel('r in [m]') + ax2.set_xlabel('r in (m)') ax2.set_title('Gradient of the flow thickness') ax1.legend() ax2.legend() diff --git a/avaframe/ana1Tests/energyLineTest.py b/avaframe/ana1Tests/energyLineTest.py index 4a3b7da5f..2bf7371ab 100644 --- a/avaframe/ana1Tests/energyLineTest.py +++ b/avaframe/ana1Tests/energyLineTest.py @@ -98,8 +98,8 @@ def generateCom1DFAEnergyPlot(avalancheDir, energyLineTestCfg, com1DFACfg, avaPr ax1 = outCom1DFA.addDem2Plot(ax1, dem, what='hillshade', extent=extent) ax1.plot(avaProfileMass['x'], avaProfileMass['y'], '-y.', zorder=20, label='Center of mass path', lw=1, path_effects=[pe.Stroke(linewidth=2, foreground='k'), pe.Normal()]) - ax1.set_xlabel('x [m]') - ax1.set_ylabel('y [m]') + ax1.set_xlabel('x (m)') + ax1.set_ylabel('y (m)') ax1.axis('equal') ax1.set_ylim([rowsMin, rowsMax]) ax1.set_xlim([colsMin, colsMax]) @@ -124,7 +124,7 @@ def generateCom1DFAEnergyPlot(avalancheDir, energyLineTestCfg, com1DFACfg, avaPr scat = ax2.scatter(avaProfileMass['s'], zEne, marker='s', cmap=cmap, s=8*pU.ms, c=u2Path/(2*g), label='Center of mass velocity altitude') cbar2 = ax2.figure.colorbar(scat, ax=ax2, use_gridspec=True) - cbar2.ax.set_title('[' + pU.cfgPlotUtils['unitFT'] + ']', pad=10) + cbar2.ax.set_title('(' + pU.cfgPlotUtils['unitFT'] + ')', pad=10) cbar2.ax.set_ylabel('Center of mass velocity altitude') # add alpha line @@ -143,8 +143,8 @@ def generateCom1DFAEnergyPlot(avalancheDir, energyLineTestCfg, com1DFACfg, avaPr color='r', linestyle='--') ax2.hlines(y=zIntersection, color='b', xmin=0, xmax=sIntersection, linestyle='--') - ax2.set_xlabel('s [m]') - ax2.set_ylabel('z [m]') + ax2.set_xlabel('s (m)') + ax2.set_ylabel('z (m)') ax2.set_xlim(sLim) ax2.set_ylim(zLim) ax2.legend(loc='upper right') @@ -168,7 +168,7 @@ def generateCom1DFAEnergyPlot(avalancheDir, energyLineTestCfg, com1DFACfg, avaPr scat = ax3.scatter(avaProfileMass['s'], zEne-z0, marker='s', cmap=cmap, s=8*pU.ms, c=u2Path/(2*g), label='Center of mass velocity altitude extrapolation') cbar3 = ax3.figure.colorbar(scat, ax=ax3, use_gridspec=True) - cbar3.ax.set_title('[' + pU.cfgPlotUtils['unitFT'] + ']', pad=10) + cbar3.ax.set_title('(' + pU.cfgPlotUtils['unitFT'] + ')', pad=10) cbar3.ax.set_ylabel('Center of mass velocity altitude') # add alpha line @@ -201,8 +201,8 @@ def generateCom1DFAEnergyPlot(avalancheDir, energyLineTestCfg, com1DFACfg, avaPr color='r', linestyle='--') ax3.hlines(y=zIntersection-z0, color='b', xmin=sMin, xmax=sIntersection, linestyle='--') - ax3.set_xlabel('s [m]') - ax3.set_ylabel('$\Delta z$ [m]') + ax3.set_xlabel('s (m)') + ax3.set_ylabel('$\Delta z$ (m)') ax3.yaxis.set_label_coords(0, 0.9) ax3.set_xlim([sMin, sMax]) ax3.set_ylim([zMin, zMax]) diff --git a/avaframe/com1DFA/debrisFunctions.py b/avaframe/com1DFA/debrisFunctions.py index 1367f5890..1871f5eac 100644 --- a/avaframe/com1DFA/debrisFunctions.py +++ b/avaframe/com1DFA/debrisFunctions.py @@ -422,10 +422,10 @@ def outputHydrographPlot(outputHydrographDF, cfgGen, simHash=""): ax[0].plot(t, discharge, color="brown") ax[1].plot(t[1:], volume, color="brown") - ax[0].set_xlabel("time [s]") - ax[0].set_ylabel("discharge [m³/s]") - ax[1].set_xlabel("time [s]") - ax[1].set_ylabel("cumulative volume [m³]") + ax[0].set_xlabel("time (s)") + ax[0].set_ylabel("discharge (m³/s)") + ax[1].set_xlabel("time (s)") + ax[1].set_ylabel("cumulative volume (m³)") ax[1].set_title(f"total cumulative volume = {np.max(volume):.02f} m³") plt.suptitle(f"Output hydrograph - {station}") diff --git a/avaframe/com1DFA/testSPH.py b/avaframe/com1DFA/testSPH.py index 27c5b1803..1424de61c 100644 --- a/avaframe/com1DFA/testSPH.py +++ b/avaframe/com1DFA/testSPH.py @@ -188,21 +188,21 @@ def plotGrad(ax, x, xx, particles, ind, mark, count): fig1, ax1 = plt.subplots(figsize=(figW, figH)) ax1.set_title('h(x)') -ax1.set_xlabel('x [m]') -ax1.set_ylabel('h [m]') +ax1.set_xlabel('x (m)') +ax1.set_ylabel('h (m)') fig2, ax2 = plt.subplots(figsize=(figW, figH)) ax2.set_title('h(y)') -ax2.set_xlabel('y [m]') -ax2.set_ylabel('h [m]') +ax2.set_xlabel('y (m)') +ax2.set_ylabel('h (m)') fig3, ax3 = plt.subplots(figsize=(figW, figH)) ax3.set_title('Gradh(x)') -ax3.set_xlabel('x [m]') +ax3.set_xlabel('x (m)') ax3.set_ylabel('Gradh []') ax3.set_ylim([-0.02, 0.02]) # ax3.set_ylim([-0.016, 0.016]) fig4, ax4 = plt.subplots(figsize=(figW, figH)) ax4.set_title('Gradh(y)') -ax4.set_xlabel('y [m]') +ax4.set_xlabel('y (m)') ax4.set_ylabel('Gradh []') # ax4.set_ylim([-0.02, 0.02]) ax4.set_ylim([-0.016, 0.016]) diff --git a/avaframe/out1Peak/outPlotAllPeak.py b/avaframe/out1Peak/outPlotAllPeak.py index 045511e37..28afd96ab 100644 --- a/avaframe/out1Peak/outPlotAllPeak.py +++ b/avaframe/out1Peak/outPlotAllPeak.py @@ -204,8 +204,8 @@ def plotAllPeakFields(avaDir, cfgFLAGS, modName, demData=""): # add title, labels and ava Info title = str("%s" % name) ax.set_title(title) - ax.set_xlabel("x [m]") - ax.set_ylabel("y [m]") + ax.set_xlabel("x (m)") + ax.set_ylabel("y (m)") pU.putAvaNameOnPlot(ax, avaDir) # save and or show figure @@ -320,7 +320,7 @@ def addConstrainedDataField(fileName, resType, demField, ax, cellSize, alpha=1.0 plt.text( 0.5, 0.5, - ("[%s]" % unit), + ("(%s)" % unit), horizontalalignment="left", verticalalignment="center", transform=cax2.transAxes, @@ -414,8 +414,8 @@ def plotAllFields(avaDir, inputDir, outDir, unit="", constrainData=True): title = str("%s" % name) ax.set_title(title) - ax.set_xlabel("x [m]") - ax.set_ylabel("y [m]") + ax.set_xlabel("x (m)") + ax.set_ylabel("y (m)") plotName = "%s" % (name) diff --git a/avaframe/out1Peak/outPlotAllPeakDiffs.py b/avaframe/out1Peak/outPlotAllPeakDiffs.py index 12e7258d7..d2ac1acab 100644 --- a/avaframe/out1Peak/outPlotAllPeakDiffs.py +++ b/avaframe/out1Peak/outPlotAllPeakDiffs.py @@ -272,14 +272,14 @@ def plotAreaDiff( cbar.set_label(resType) # add labels - ax[0].set_xlabel("x [m]") - ax[0].set_ylabel("y [m]") + ax[0].set_xlabel("x (m)") + ax[0].set_ylabel("y (m)") ax[0].set_title(title) - ax[1].set_xlabel("x [m]") - ax[1].set_ylabel("y [m]") + ax[1].set_xlabel("x (m)") + ax[1].set_ylabel("y (m)") ax[1].set_title("Simulation %s" % resType) - ax[2].set_xlabel("x [m]") - ax[2].set_ylabel("y [m]") + ax[2].set_xlabel("x (m)") + ax[2].set_ylabel("y (m)") ax[2].set_title("Reference mask") pU.saveAndOrPlot({"pathResult": outDir}, "areaIndicatorAnalysis_%s" % simName, fig) diff --git a/avaframe/out3Plot/amaPlots.py b/avaframe/out3Plot/amaPlots.py index ff1180c96..a21861145 100644 --- a/avaframe/out3Plot/amaPlots.py +++ b/avaframe/out3Plot/amaPlots.py @@ -68,14 +68,14 @@ def plotPathAngle(dbData, cfgMain, nameEvent, tickOrigin='orig-transit'): 'r+', markersize=20, label='runout pt') ax1.plot(row['geom_event_pt3d_%s_snapped' % projstr].x, row['geom_event_pt3d_%s_snapped' % projstr].y, 'r*', markersize=14, label='snapped') - ax1.set_xlabel('x [m]') - ax1.set_ylabel('y [m]') + ax1.set_xlabel('x (m)') + ax1.set_ylabel('y (m)') ax1.legend(loc='center left', bbox_to_anchor=(1, 0.5)) ax1.set_aspect('equal') # panel 2 plot xy distance and elevation drop and add angle info ax21 = fig.add_subplot(122) - ax21.set_title('runout length in $S_{xy}$: %.1f [m], altitude drop: %.1f [m]' % (row['%s_Distance' % nameEvent], row['%s_LineAltDrop' % nameEvent])) + ax21.set_title('runout length in $S_{xy}$: %.1f (m), altitude drop: %.1f (m)' % (row['%s_Distance' % nameEvent], row['%s_LineAltDrop' % nameEvent])) z2coor = np.asarray([coord[2] for coord in row['geom_path_ln3d_%s' % projstr].coords]) ax21.plot(row['%s_PathDist' % nameEvent], z2coor, '--', color='lightgray', label='thalweg') @@ -132,8 +132,8 @@ def plotPathAngle(dbData, cfgMain, nameEvent, tickOrigin='orig-transit'): ax21.set_xticks(xTicks[1:-1]) ax21.set_xticklabels(ticksFromOrigStr[1:-1]) - ax21.set_xlabel('$S_{xy}$ [m]') - ax21.set_ylabel('altitude [m]') + ax21.set_xlabel('$S_{xy}$ (m)') + ax21.set_ylabel('altitude (m)') ax21.set_aspect('equal') ax21.legend(loc='center left', bbox_to_anchor=(1, 0.5)) @@ -177,7 +177,7 @@ def plotHist(dbData, name, cfgMain, colorcode=''): transform=ax3.transAxes, fontsize=12, horizontalalignment='left', verticalalignment='bottom', alpha=0.8, bbox=dict(boxstyle="round", ec=(1., 1., 1.), fc=(1., 1., 1.), alpha=0.5)) - ax3.set_xlabel('angle [°]') + ax3.set_xlabel('angle (°)') # save figure outFile = ('histogram_%s_angle' % (nameAngle)) diff --git a/avaframe/out3Plot/outAB.py b/avaframe/out3Plot/outAB.py index 6a3d70399..24708f9b8 100644 --- a/avaframe/out3Plot/outAB.py +++ b/avaframe/out3Plot/outAB.py @@ -220,10 +220,10 @@ def plotProfile(avaProfile, eqParams, saveOutPath): fig = plt.figure(figsize=(1.5*pU.figW, 1*pU.figH)) titleText = avaProfile['name'] plt.title(titleText) - xlabelText = 'Distance [m]\nBeta: ' + str(round(beta, 1)) + \ + xlabelText = 'Distance (m)\nBeta: ' + str(round(beta, 1)) + \ '°' + ' Alpha: ' + str(round(alpha, 1)) + '°' plt.xlabel(xlabelText, multialignment='center') - plt.ylabel('Height [m]') + plt.ylabel('Height (m)') plt.plot(s, z, '-', label='DEM') plt.plot(s, poly(s), ':', label='QuadFit') plt.axvline(x=s[indSplit], color='0.7', diff --git a/avaframe/out3Plot/outAIMEC.py b/avaframe/out3Plot/outAIMEC.py index 8c39f5570..4629d410f 100644 --- a/avaframe/out3Plot/outAIMEC.py +++ b/avaframe/out3Plot/outAIMEC.py @@ -106,7 +106,7 @@ def visuTransfo(rasterTransfo, inputData, cfgSetup, pathDict): gs = gridspec.GridSpec(1, 3) ax1 = fig.add_subplot(gs[0, 0]) - ref0, im = pU.NonUnifIm(ax1, x, y, maskedArray, 'x [m]', 'y [m]', + ref0, im = pU.NonUnifIm(ax1, x, y, maskedArray, 'x (m)', 'y (m)', extent=[x.min(), x.max(), y.min(), y.max()], cmap=cmap, norm=norm) plt.plot(xx, yy, 'r*', markersize=8, label=labelRunout, zorder=10) @@ -126,7 +126,7 @@ def visuTransfo(rasterTransfo, inputData, cfgSetup, pathDict): maskedArraySLTransposed = np.transpose(maskedArraySL) - ref0, im = pU.NonUnifIm(ax2, s, l, maskedArraySLTransposed, '$S_{XY}$ (thalweg) [m]', '$L_{XY}$ (thalweg) [m]', + ref0, im = pU.NonUnifIm(ax2, s, l, maskedArraySLTransposed, '$S_{XY}$ (thalweg) (m)', '$L_{XY}$ (thalweg) (m)', extent=[s.min(), s.max(), l.min(), l.max()], cmap=cmap, norm=norm) ax2.axvline(x=s[indStartOfRunout], color='k', linestyle='--', @@ -184,7 +184,7 @@ def visuRunoutComp(rasterTransfo, resAnalysisDF, cfgSetup, pathDict): ############################################ # prepare for plot title = ['Pressure ', 'Flow Thickness ', 'Flow Velocity '] - unit = ['$ppr_{CrossMax}$ [kPa]', '$pft_{CrossMax}$ [m]', '$pfv_{CrossMax}$ $[ms^{-1}]$'] + unit = ['$ppr_{CrossMax}$ (kPa)', '$pft_{CrossMax}$ (m)', '$pfv_{CrossMax}$ $(ms^{-1})$'] peakList = ['ppr', 'pft', 'pfv'] ############################################ @@ -201,7 +201,7 @@ def visuRunoutComp(rasterTransfo, resAnalysisDF, cfgSetup, pathDict): ax.set_title(titleVal + 'distribution along thalweg') ax.legend(loc='best') - ax.set_xlabel('$S_{XY}$ (thalweg) [m]') + ax.set_xlabel('$S_{XY}$ (thalweg) (m)') ax.set_xlim([s.min(), s.max()]) ax.set_ylim(auto=True) ax.set_ylabel(unitVal) @@ -379,8 +379,8 @@ def visuRunoutStat(rasterTransfo, inputsDF, resAnalysisDF, newRasters, cfgSetup, s, l, maskedArrayTransposed, - "$S_{XY}$ (thalweg) [m]", - "$L_{XY}$ (thalweg) [m]", + "$S_{XY}$ (thalweg) (m)", + "$L_{XY}$ (thalweg) (m)", extent=[xMin, xMax, yMin, yMax], cmap=cmap, norm=norm, @@ -452,10 +452,10 @@ def visuRunoutStat(rasterTransfo, inputsDF, resAnalysisDF, newRasters, cfgSetup, ax2.set_title("%s distribution along thalweg for all sims" % name) ax2.legend(loc="upper right") - ax2.set_xlabel("$S_{xy}$ (thalweg) [m]") + ax2.set_xlabel("$S_{xy}$ (thalweg) (m)") ax2.set_xlim([s.min(), s.max()]) ax2.set_ylim(auto=True) - ax2.set_ylabel("$%s_{%s}$ [%s]" % (displayRunoutResType, crossValue, unit)) + ax2.set_ylabel("$%s_{%s}$ (%s)" % (displayRunoutResType, crossValue, unit)) # add middle panel with cross max values along s # loop over all sims and compute colorbar value and add line plot @@ -494,17 +494,17 @@ def visuRunoutStat(rasterTransfo, inputsDF, resAnalysisDF, newRasters, cfgSetup, cbar = ax3.figure.colorbar(cmapSC2, ax=ax3) cbar.outline.set_visible(False) if cfgSetup["unit"] != "": - cbar.ax.set_title("[" + cfgSetup["unit"] + "]", pad=10) + cbar.ax.set_title("(" + cfgSetup["unit"] + ")", pad=10) cbar.set_label(paraVar) if isinstance(firstVar, str): cbar.set_ticks(ticks=np.linspace(0, 1, len(itemsList)), labels=itemsList) # add labels title ax3.set_title("%s along thalweg for all sims" % name) ax3.legend(loc="upper right") - ax3.set_xlabel("$S_{xy}$ (thalweg) [m]") + ax3.set_xlabel("$S_{xy}$ (thalweg) (m)") ax3.set_xlim([s.min(), s.max()]) ax3.set_ylim(auto=True) - ax3.set_ylabel("$%s_{%s}$ [%s]" % (displayRunoutResType, crossValue, unit)) + ax3.set_ylabel("$%s_{%s}$ (%s)" % (displayRunoutResType, crossValue, unit)) outFileName = "_".join( [projectName, runoutResType, str(thresholdValue).replace(".", "p"), "slComparisonStat"] @@ -544,7 +544,7 @@ def visuMass(resAnalysisDF, pathDict, simRowHash, refSimRowHash, timeMass): ############################################ # prepare for plot Title = ['Entrained Mass Flow', 'Total Mass'] - Unit = ['Entrained Mass Flow [$kg.s{^-1}$]', 'Total Mass [kg]'] + Unit = ['Entrained Mass Flow ($kg.s{^-1}$)', 'Total Mass (kg)'] fieldList = ['entMassFlowArray', 'totalMassArray'] fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(pU.figW*2, pU.figH)) fig.subplots_adjust(left=0.05, bottom=0.05, right=0.95, top=0.95, hspace=0.3) @@ -558,7 +558,7 @@ def visuMass(resAnalysisDF, pathDict, simRowHash, refSimRowHash, timeMass): ax.set_title(title + ' function of time') ax.legend(loc=1) - ax.set_xlabel('t [s]') + ax.set_xlabel('t (s)') ax.set_ylabel(unit) if refSimRowHash != simRowHash: @@ -575,7 +575,7 @@ def visuMass(resAnalysisDF, pathDict, simRowHash, refSimRowHash, timeMass): bbox=dict(boxstyle="square", ec='white', fc='white'), horizontalalignment='left', verticalalignment='bottom') - ax2.set_ylabel('Total Mass Difference [%]', color='r') + ax2.set_ylabel('Total Mass Difference (%)', color='r') outFileName = '_'.join([projectName, str(simName), 'massAnalysis']) pU.putAvaNameOnPlot(ax, pathDict['projectName']) @@ -644,7 +644,7 @@ def visuSimple(cfgSetup, rasterTransfo, resAnalysisDF, newRasters, pathDict): pU.cfgPlotUtils['unit' + runoutResType])) ax.axvline(x=s[indStartOfRunout], color='k', linestyle='--', label=rasterTransfo['labelRunout']) - ref3, im = pU.NonUnifIm(ax, s, l, maskedArrayTranspose, '$S_{XY}$ (thalweg) [m]', '$L_{XY}$ (thalweg) [m]', + ref3, im = pU.NonUnifIm(ax, s, l, maskedArrayTranspose, '$S_{XY}$ (thalweg) (m)', '$L_{XY}$ (thalweg) (m)', extent=[s.min(), s.max(), l.min(), l.max()], cmap=cmap, norm=norm) @@ -776,8 +776,8 @@ def visuComparison(rasterTransfo, inputs, pathDict): s[indStartOfRunout:], l, np.transpose(dataDiff), - "$S_{XY}$ (thalweg) [m]", - "$L_{XY}$ (thalweg) [m]", + "$S_{XY}$ (thalweg) (m)", + "$L_{XY}$ (thalweg) (m)", extent=[s[indStartOfRunout], xLim, l.min(), l.max()], cmap=cmap, ) @@ -795,7 +795,7 @@ def visuComparison(rasterTransfo, inputs, pathDict): # add legend associated to the contour plot handles, _ = contourRef.legend_elements() ax2.legend( - title=displayRunoutResType + " contour lines [" + unit + "]", + title=displayRunoutResType + " contour lines (" + unit + ")", handles=handles, labels=labels, ncol=ncolLegend, @@ -843,8 +843,8 @@ def visuComparison(rasterTransfo, inputs, pathDict): s, l, np.transpose(dataTF), - "$S_{XY}$ (thalweg) [m]", - "$L_{XY}$ (thalweg) [m]", + "$S_{XY}$ (thalweg) (m)", + "$L_{XY}$ (thalweg) (m)", extent=[s[indStartOfRunout], xLim, l.min(), l.max()], cmap=cmapTF, ) @@ -894,7 +894,7 @@ def visuComparison(rasterTransfo, inputs, pathDict): divider = make_axes_locatable(ax2) cax = divider.append_axes("right", size="5%", pad=0.1) pU.addColorBar( - im3, ax2, None, None, title=displayRunoutResType + (" [%s]" % unit), extend="both", cax=cax + im3, ax2, None, None, title=displayRunoutResType + (" (%s)" % unit), extend="both", cax=cax ) ax2.set_aspect("equal") ax1.set_aspect("equal") @@ -1204,8 +1204,8 @@ def plotContoursTransformed(contourDict, pathDict, rasterTransfo, cfgSetup, inpu ax1 = fig.add_subplot(gs[0, 0:2]) ax1.set_title('%s %s %s contour lines' % (displayRunoutResType, cfgSetup['thresholdValue'], unit)) - ax1.set_xlabel('$S_{XY}$ (thalweg) [m]') - ax1.set_ylabel('$L_{XY}$ (thalweg) [m]') + ax1.set_xlabel('$S_{XY}$ (thalweg) (m)') + ax1.set_ylabel('$L_{XY}$ (thalweg) (m)') pU.putAvaNameOnPlot(ax1, pathDict['projectName']) norm = mpl.colors.Normalize(vmin=minVal, vmax=maxVal) @@ -1231,7 +1231,7 @@ def plotContoursTransformed(contourDict, pathDict, rasterTransfo, cfgSetup, inpu cbar = ax1.figure.colorbar(cmap, ax=ax1) cbar.outline.set_visible(False) if cfgSetup['unit'] != '': - cbar.ax.set_title('[' + cfgSetup['unit'] + ']', pad=10) + cbar.ax.set_title('(' + cfgSetup['unit'] + ')', pad=10) cbar.set_label(paraVar) else: # TODO: remove? @@ -1247,8 +1247,8 @@ def plotContoursTransformed(contourDict, pathDict, rasterTransfo, cfgSetup, inpu # PANEL 2 zoom into runout area ax2 = fig.add_subplot(gs[0, 2]) ax2.set_title('zoom into runout area, equal axes') - ax2.set_xlabel('$S_{XY}$ (thalweg) [m]') - ax2.set_ylabel('$L_{XY}$ (thalweg) [m]') + ax2.set_xlabel('$S_{XY}$ (thalweg) (m)') + ax2.set_ylabel('$L_{XY}$ (thalweg) (m)') pU.putAvaNameOnPlot(ax1, pathDict['projectName']) for index, simName in enumerate(contourDict): if colorOrdering: @@ -1368,7 +1368,7 @@ def addThalwegAltitude(ax1, rasterTransfo, pfvCrossMax, velocityThreshold, zMaxM # add colorbar cbar2 = ax1.figure.colorbar(scat, ax=ax1, use_gridspec=True) - cbar2.ax.set_title('[m/s]', pad=10) + cbar2.ax.set_title('(m/s)', pad=10) cbar2.ax.set_ylabel('Max peak flow velocity (mpfv)') # draw the horizontal and vertical lines for angle computation @@ -1393,8 +1393,8 @@ def addThalwegAltitude(ax1, rasterTransfo, pfvCrossMax, velocityThreshold, zMaxM ax1.plot(X, Y, color='grey', linestyle='--', linewidth=0.8) # Labels - ax1.set_xlabel('$s_{xy}$ [m]', fontsize=20) - ax1.set_ylabel('$z + mpfv²/2g$ [m]', fontsize=20) + ax1.set_xlabel('$s_{xy}$ (m)', fontsize=20) + ax1.set_ylabel('$z + mpfv²/2g$ (m)', fontsize=20) # limit axes extent to where there is data with buffer sExt = rasterTransfo['s'][indVelZero] * 0.1 @@ -1511,8 +1511,8 @@ def plotMaxValuesComp(pathDict, resultsDF, name1, name2, hue=None): fig.ax_joint.legend() # add label names with units - fig.ax_joint.set_xlabel('%s [%s]' % (availableoptions[name1Index], units[name1Index])) - fig.ax_joint.set_ylabel('%s [%s]' % (availableoptions[name2Index], units[name2Index])) + fig.ax_joint.set_xlabel('%s (%s)' % (availableoptions[name1Index], units[name1Index])) + fig.ax_joint.set_ylabel('%s (%s)' % (availableoptions[name2Index], units[name2Index])) pU.putAvaNameOnPlot(fig.ax_joint, pathDict['avalancheDir']) outFileName = pathDict['projectName'] + ('_%svs%s' % (name1, name2)) @@ -1626,7 +1626,7 @@ def plotVelThAlongThalweg(pathDict, rasterTransfo, pftCrossMax, pfvCrossMax, cfg sm2.set_array([]) cax = ax1.inset_axes([1.04, 0.0, 0.025, 0.99]) cbar2 = plt.colorbar(sm2, shrink=0.5, ax=ax1, cax=cax) - cbar2.set_label(r'pfv [m/s]', rotation=270, labelpad=25) + cbar2.set_label(r'pfv (m/s)', rotation=270, labelpad=25) # add bar for scale reference if len(np.where(rasterTransfo['z'] > 0)[0]) > 1: @@ -1646,8 +1646,8 @@ def plotVelThAlongThalweg(pathDict, rasterTransfo, pftCrossMax, pfvCrossMax, cfg ax2.yaxis.tick_left() ax2.yaxis.set_label_position("left") ax2.xaxis.set_label_position("bottom") - ax2.set_ylabel('altitude [m] (pft x 10)') - ax1.set_xlabel('$S_{xy}$ [m]') + ax2.set_ylabel('altitude (m) (pft x 10)') + ax1.set_xlabel('$S_{xy}$ (m)') plt.title('Max peak flow thickness (bars) along thalweg colored with max peak flow velocity') leg = plt.legend() textLeg = leg.get_texts()[6] @@ -1744,13 +1744,13 @@ def referenceLinePlot(refLineRasterXY, dem, refLine, rasterTransfo, refRasterSL, ax1.plot(DBXl, DBYl, 'k-', label='SL domain') ax1.plot(DBXr, DBYr, 'k-') ax1.plot([DBXl, DBXr], [DBYl, DBYr], 'k-') - ax1.set_xlabel('x [m]') - ax2.set_ylabel(['y [m]']) + ax1.set_xlabel('x (m)') + ax2.set_ylabel(['y (m)']) ax1.legend() # second panel SL coordinates ax2.set_title('Raster SL reference %s' % refLineSL['type']) - pU.NonUnifIm(ax2, rasterTransfo['l'], rasterTransfo['s'], refRasterSL, '$L_{XY}$ (thalweg) [m]', '$S_{XY}$ (thalweg) [m]', + pU.NonUnifIm(ax2, rasterTransfo['l'], rasterTransfo['s'], refRasterSL, '$L_{XY}$ (thalweg) (m)', '$S_{XY}$ (thalweg) (m)', extent=[rasterTransfo['l'].min(), rasterTransfo['l'].max(), rasterTransfo['s'].min(), rasterTransfo['s'].max()], aspect='equal') if refLineSL['type'] == 'point': ax2.plot(refLineSL['l'], refLineSL['s'], 'b', linestyle='', marker='*', markersize=4, label='point in SL') @@ -1796,7 +1796,7 @@ def compareRunoutLines(cfgSetup, refDataTransformed, newRaster, runoutLine, rast ax1.set_title('Runout lines') pU.NonUnifIm(ax1, rasterTransfo['l'], rasterTransfo['s'], maskedArray, - '$L_{XY}$ (thalweg) [m]', '$S_{XY}$ (thalweg) [m]', + '$L_{XY}$ (thalweg) (m)', '$S_{XY}$ (thalweg) (m)', extent=[rasterTransfo['l'].min(), rasterTransfo['l'].max(), rasterTransfo['s'].min(), rasterTransfo['s'].max()], cmap=cmapTF, aspect='equal') @@ -1867,9 +1867,9 @@ def plotRunoutLineComparisonToReference(cfgSetup, refLine, runoutLine, pathDict, (runoutLineNoPoints, refLineNoPoints, RMSE)), horizontalalignment='left', verticalalignment='bottom', transform=ax2.transAxes) boxInfo.set_bbox({'facecolor':'white', 'alpha': 0.5}) - ax2.set_ylabel('S_xy along thalweg [m]') - ax1.set_ylabel('runout difference [m]') - ax1.set_xlabel('L_xy across thalweg [m]') + ax2.set_ylabel('S_xy along thalweg (m)') + ax1.set_ylabel('runout difference (m)') + ax1.set_xlabel('L_xy across thalweg (m)') ax2.legend() # add panels for hist and CDF @@ -1921,10 +1921,10 @@ def boxScalarMeasures(pathDict, resultsDF, name='', orderList=None): ax[1, 1].set_xlabel('') # add y labels - ax[1, 0].set_ylabel('max pfv [ms-1]', fontsize=14) - ax[1, 1].set_ylabel('max pft [m]', fontsize=14) - ax[0, 0].set_ylabel('sRunout [m]', fontsize=14) - ax[0, 1].set_ylabel('runout angle [°]', fontsize=14) + ax[1, 0].set_ylabel('max pfv (ms-1)', fontsize=14) + ax[1, 1].set_ylabel('max pft (m)', fontsize=14) + ax[0, 0].set_ylabel('sRunout (m)', fontsize=14) + ax[0, 1].set_ylabel('runout angle (°)', fontsize=14) # set tick size ax[1, 1].tick_params(axis='both', which='major', labelsize=14) @@ -2062,8 +2062,8 @@ def plotOverlap(rasterTransfo, newData, name, avaDir): s, l, np.transpose(np.where((newData > 0), newData, np.nan)), - "$S_{XY}$ (thalweg) [m]", - "$L_{XY}$ (thalweg) [m]", + "$S_{XY}$ (thalweg) (m)", + "$L_{XY}$ (thalweg) (m)", extent=[s.min(), s.max(), l.min(), l.max()], ) ax[1].set_title("Overlap in coordinate system") @@ -2072,8 +2072,8 @@ def plotOverlap(rasterTransfo, newData, name, avaDir): s, l, np.transpose(np.where(rasterTransfo["intersectionPoints"], 1, np.nan)), - "$S_{XY}$ (thalweg) [m]", - "$L_{XY}$ (thalweg) [m]", + "$S_{XY}$ (thalweg) (m)", + "$L_{XY}$ (thalweg) (m)", extent=[s.min(), s.max(), l.min(), l.max()], ) @@ -2084,8 +2084,8 @@ def plotOverlap(rasterTransfo, newData, name, avaDir): s, l, np.transpose(np.where(fieldOverlap > 0, newData, np.nan)), - "$S_{XY}$ (thalweg) [m]", - "$L_{XY}$ (thalweg) [m]", + "$S_{XY}$ (thalweg) (m)", + "$L_{XY}$ (thalweg) (m)", extent=[s.min(), s.max(), l.min(), l.max()], ) diff --git a/avaframe/out3Plot/outAna1Plots.py b/avaframe/out3Plot/outAna1Plots.py index 4a03438ad..99273f63c 100644 --- a/avaframe/out3Plot/outAna1Plots.py +++ b/avaframe/out3Plot/outAna1Plots.py @@ -191,7 +191,7 @@ def _plotVariable(ax1, cfg, simiDict, comSol, limits, axis, particles=False): ax2.plot(xArrayFields, hSimi * vxSimi[indFinal, :], "--m") ax2.plot(xArrayFields, hSimi * vySimi[indFinal, :], "--b") ax2.plot(xArrayFields, hSimi * vzSimi[indFinal, :], "--c") - ax1.set_xlabel("x in [m]") + ax1.set_xlabel("x in (m)") ax1.text(xCenter + 5, -0.05, "x = %.2f m" % (xCenter), color="b") ax1.set_xlim([xCenter - widthX, xCenter + widthX]) ax1.set_ylim([-0.05, maxFT]) @@ -219,17 +219,17 @@ def _plotVariable(ax1, cfg, simiDict, comSol, limits, axis, particles=False): ax2.plot(yArrayFields, hSimi * vxSimi[:, indFinal], "--m") ax2.plot(yArrayFields, hSimi * vySimi[:, indFinal], "--b") ax2.plot(yArrayFields, hSimi * vzSimi[:, indFinal], "--c") - ax1.set_xlabel("y in [m]") + ax1.set_xlabel("y in (m)") ax1.set_xlim([-widthY, widthY]) ax1.set_ylim([-0.05, maxFT]) ax2.set_ylim([minMz, maxFM]) - ax1.set_ylabel(pU.cfgPlotUtils["nameFT"] + " [" + pU.cfgPlotUtils["unitFT"] + "]") + ax1.set_ylabel(pU.cfgPlotUtils["nameFT"] + " (" + pU.cfgPlotUtils["unitFT"] + ")") ax1.grid(color="grey", linestyle="-", linewidth=0.25, alpha=0.5) color = "tab:green" ax2.tick_params(axis="y", labelcolor=color) ax2.grid(color="tab:green", linestyle="-", linewidth=0.25, alpha=0.5) - ax2.set_ylabel(getLabel("", "", dir="") + " [" + pU.cfgPlotUtils["unitFTV"] + "]", color=color) + ax2.set_ylabel(getLabel("", "", dir="") + " (" + pU.cfgPlotUtils["unitFTV"] + ")", color=color) props = dict(boxstyle="round", alpha=0) text = "analytical solution (dashed line) \n numerical solution (full line)" @@ -385,7 +385,7 @@ def _plotVariableDamBreak(var, x, xMiddle, dtInd, dtStep, label): plt.title("Dry-Bed") plt.plot(x, var[:, 0], "k--", label="t = 0s") plt.plot(x, var[:, dtInd], label="t = %.1fs" % dtStep) - plt.xlabel("x-coordinate [m]") + plt.xlabel("x-coordinate (m)") plt.ylabel(label) plt.legend() @@ -400,12 +400,12 @@ def plotDamAnaResults(t, x, xMiddle, h, u, tSave, cfg, outDirTest): # index of time steps dtInd = np.searchsorted(t, tSave) - name = pU.cfgPlotUtils["nameFT"] + "[" + pU.cfgPlotUtils["unitFT"] + "]" + name = pU.cfgPlotUtils["nameFT"] + "(" + pU.cfgPlotUtils["unitFT"] + ")" fig = _plotVariableDamBreak(h, x, xMiddle, dtInd, tSave, name) outputName = "damBreakFlowThickness" pU.saveAndOrPlot({"pathResult": outDirTest / "pics"}, outputName, fig) - name = pU.cfgPlotUtils["nameFV"] + "[" + pU.cfgPlotUtils["unitFV"] + "]" + name = pU.cfgPlotUtils["nameFV"] + "(" + pU.cfgPlotUtils["unitFV"] + ")" fig = _plotVariableDamBreak(u, x, xMiddle, dtInd, tSave, name) outputName = "damBreakFlowVelocity" pU.saveAndOrPlot({"pathResult": outDirTest / "pics"}, outputName, fig) @@ -556,8 +556,8 @@ def _plotDamProfile(ax, x, y, nx_loc, cfg, data1, data2, xAna, xMidAna, yAna, in ax.plot(x, data1[nx_loc, :], "k--", label="initial") ax.plot(x, data2[nx_loc, :], "b", label="numerical") ax.plot(xAna, yAna[:, indT], "r-", label="analytical") - ax.set_xlabel("x [m]") - ax.set_ylabel("%s [%s]" % (label, unit)) + ax.set_xlabel("x (m)") + ax.set_ylabel("%s (%s)" % (label, unit)) ax.set_xlim([cfg.getfloat("xStart"), cfg.getfloat("xEnd")]) ax.set_ylim([-0.05, max(yMax, scaleCoef * max(yAna[:, indT]))]) # ax.axvline(xMidAna[indT], color='grey', linestyle='--') @@ -777,8 +777,8 @@ def plotDamBreakSummary( ax6.add_patch(rect) ax6.set_ylim([rowsMin + yllc, rowsMax + yllc]) ax6.set_xlim([colsMin + xllc, colsMax + xllc]) - ax6.set_xlabel("x [m]") - ax6.set_ylabel("y [m]") + ax6.set_xlabel("x (m)") + ax6.set_ylabel("y (m)") leg = ax6.legend(loc="upper right") leg.set(zorder=200) # ax3.set_title(pU.cfgPlotUtils['nameFT']) @@ -855,7 +855,7 @@ def addErrorTime( ax2 = ax1.twinx() ax1.plot(time, hErrorL2Array, "k-", label="h L2 error") ax1.plot(time, hErrorLMaxArray, "k--", label="h LMax error") - ax1.set_xlabel("time in [s]") + ax1.set_xlabel("time in (s)") ax1.set_ylabel(getTitleError(relativ, " on h")) ax1.legend(loc="upper left") ax1.grid(color="grey", linestyle="-", linewidth=0.25, alpha=0.5) @@ -984,8 +984,8 @@ def addContour2Plot(ax1, fieldFT, simiDict, fieldHeader, limits, nLevels=9): ax1.legend([h1[-1], h2[-1]], ["simulation", "analytical"]) ax1.set_ylim([-widthY, widthY]) ax1.set_xlim([-widthX + xCenter, widthX + xCenter]) - ax1.set_xlabel("x [m]") - ax1.set_ylabel("y [m]") + ax1.set_xlabel("x (m)") + ax1.set_ylabel("y (m)") # add vertical and horizontal line showing the location of the profile plots cuts ax1.axvline(xCenter, color="b", linestyle=":") ax1.axhline(0, color="r", linestyle=":") @@ -1381,7 +1381,7 @@ def plotTimeCPULog(simDF, outDirTest, cfgSimi, xField, coloredBy, sizedBy, logSc ax1.set_xscale("log") ax1.set_title("CPU time") ax1.set_xlabel("number of particles") - ax1.set_ylabel("time [s]") + ax1.set_ylabel("time (s)") # Adding legend and titles legend = ax1.legend(handles=handles1, loc="upper left") ax1.add_artist(legend) diff --git a/avaframe/out3Plot/outCom1DFA.py b/avaframe/out3Plot/outCom1DFA.py index 7b4b9ffd6..4bcabecac 100644 --- a/avaframe/out3Plot/outCom1DFA.py +++ b/avaframe/out3Plot/outCom1DFA.py @@ -59,27 +59,27 @@ def plotTrackParticle(outDirData, particlesList, trackedPartProp, cfg, dem, cuSi circle1 = plt.Circle((center["x"], center["y"]), radius, color="r") ax1.plot(trackedPartProp["x"], trackedPartProp["y"]) ax1.add_patch(circle1) - ax1.set_xlabel("x [m]") - ax1.set_ylabel("y [m]") + ax1.set_xlabel("x (m)") + ax1.set_ylabel("y (m)") ax1.set_title("Trajectory") ax2 = plt.subplot(222) ax2.plot(time, trackedPartProp["m"]) - ax2.set_xlabel("t [s]") - ax2.set_ylabel("m [kg]") + ax2.set_xlabel("t (s)") + ax2.set_ylabel("m (kg)") ax2.set_title("Mass") ax3 = plt.subplot(223) velocity = DFAtls.norm(trackedPartProp["ux"], trackedPartProp["uy"], trackedPartProp["uz"]) ax3.plot(time, velocity) - ax3.set_xlabel("t [s]") - ax3.set_ylabel("v [m/s]") + ax3.set_xlabel("t (s)") + ax3.set_ylabel("v (m/s)") ax3.set_title("Velocity") ax4 = plt.subplot(224) ax4.plot(time, trackedPartProp["h"]) - ax4.set_xlabel("t [s]") - ax4.set_ylabel("h [m]") + ax4.set_xlabel("t (s)") + ax4.set_ylabel("h (m)") ax4.set_title("Flow thickness") pathDict = {} @@ -128,8 +128,8 @@ def plotTrackParticleAcceleration(outDirData, trackedPartProp, cfg, cuSimName): ax1 = plt.subplot(111) ax1.plot(trackedPartProp["t"], trackedPartProp["uAcc"]) - ax1.set_xlabel("time step [s]") - ax1.set_ylabel("acceleration [ms-2]") + ax1.set_xlabel("time step (s)") + ax1.set_ylabel("acceleration (ms-2)") pathDict = {} pathDict["pathResult"] = outDirData @@ -164,8 +164,8 @@ def plotAllPartAcc(outDirData, particlesList, cfg, Tsave, cuSimName): for idx in particlesList[0]["ID"]: uAcc[:, idx] = np.asarray([p["uAcc"][idx] for p in particlesList]) ax1.plot(Tsave, uAcc[:, idx]) - ax1.set_xlabel("time step [s]") - ax1.set_ylabel("acceleration [ms-2]") + ax1.set_xlabel("time step (s)") + ax1.set_ylabel("acceleration (ms-2)") pathDict = {} pathDict["pathResult"] = outDirData @@ -293,8 +293,8 @@ def addDem2Plot(ax, dem, what="slope", extent="", origHeader=False, cmap=None): xArray, yArray, value, - "x [m]", - "y [m]", + "x (m)", + "y (m)", # extent=[2400, 2700, YY.min(), YY.max()], extent=extent, cmap=cmap, @@ -317,7 +317,7 @@ def addDem2Plot(ax, dem, what="slope", extent="", origHeader=False, cmap=None): # add info box with indication of label meaning pU.putInfoBox( ax, - "- elevation [m]", + "- elevation (m)", location="upperLeft", color="gray", hAlignment="left", @@ -394,8 +394,8 @@ def addResult2Plot(ax, header, rasterData, resType, colorbar=True, contour=False xArray, yArray, rasterData, - "x [m]", - "y [m]", + "x (m)", + "y (m)", extent=extent, cmap=cmap, norm=norm, @@ -649,7 +649,7 @@ def plotReleaseScenarioView( ax.set_aspect("equal") cax = ax.inset_axes([1.04, 0.0, 0.05, 1.0]) - pU.addColorBar(im1, ax, ticks, None, title="release thickness [m]", cax=cax, fmt="{x:.2f}") + pU.addColorBar(im1, ax, ticks, None, title="release thickness (m)", cax=cax, fmt="{x:.2f}") plt.legend( handles=handles, fontsize=8, @@ -731,8 +731,8 @@ def plotResFields(fields, cfg, tPlot, dem, totalMass): im3 = ax[1, 0].imshow(fv, cmap=cmap1, vmin=vMin, vmax=vMax, extent=extentCellCenters, zorder=4) im4 = ax[1, 1].imshow(ft, cmap=cmap2, vmin=thMin, vmax=thMax, extent=extentCellCenters, zorder=4) # set title - ax[1, 0].set_title("FV [ms-1]") - ax[1, 1].set_title("FT [m]") + ax[1, 0].set_title("FV (ms-1)") + ax[1, 1].set_title("FT (m)") # add colorbar fig.colorbar(im3, ax=ax[1, 0]) fig.colorbar(im4, ax=ax[1, 1]) @@ -772,8 +772,8 @@ def plotResFields(fields, cfg, tPlot, dem, totalMass): zorder=4, ) # set title - ax[0, 2].set_title("dmDet [kg]") - ax[1, 2].set_title("FTDet [m]") + ax[0, 2].set_title("dmDet (kg)") + ax[1, 2].set_title("FTDet (m)") # add colorbar fig.colorbar(im5, ax=ax[0, 2]) fig.colorbar(im6, ax=ax[1, 2]) @@ -822,10 +822,10 @@ def massPlot(infoDict, massDetrainedTotal, t, avaDir, logName): ax3 = ax.twinx() ax3.plot(t, pfvTimeMax, color="lightgray", linestyle="-") - ax.set_xlabel("time [s]") + ax.set_xlabel("time (s)") ax.set_ylabel("total mass [% of initial mass]") ax2.set_ylabel("detrained mass [% of initial mass]", color="royalblue") - ax3.set_ylabel("max velocity [ms-1]", color="lightgray") + ax3.set_ylabel("max velocity (ms-1)", color="lightgray") ax2.spines["right"].set_color("royalblue") ax2.tick_params(axis="y", colors="royalblue") @@ -877,7 +877,7 @@ def massSourcePlot(infoDict, massDetrainedTotal, t, avaDir, logName): label="initialized mass", ) - ax.set_xlabel("time [s]") + ax.set_xlabel("time (s)") ax.set_ylabel("total/ initialized mass [% of initial mass]") ax2.set_ylabel("entrained mass [% of initial mass]", color="royalblue") diff --git a/avaframe/out3Plot/outCom3Plots.py b/avaframe/out3Plot/outCom3Plots.py index 37363222b..50a0599db 100644 --- a/avaframe/out3Plot/outCom3Plots.py +++ b/avaframe/out3Plot/outCom3Plots.py @@ -46,8 +46,8 @@ def hybridProfilePlot(avalancheDir, resultsHybrid): r"Profiles extracted from the DFA simulations with corresponding $\alpha-\beta$ model results" ) ax.set_title(titleText) - ax.set_xlabel("projectd length s [m]") - ax.set_ylabel("Height [m]") + ax.set_xlabel("projectd length s (m)") + ax.set_ylabel("Height (m)") ax.set_aspect("equal", adjustable="box") ax.grid(linestyle=":", color="0.9") ax.legend(frameon=False) @@ -94,8 +94,8 @@ def hybridPathPlot(avalancheDir, dem, resultsHybrid, fields, particles, muArray) i = i + 1 titleText = "Avalanche path for each iteration with peak travel angle field \n and particles flow thickness in final time step" ax.set_title(titleText) - ax.set_ylabel("x [m]") - ax.set_ylabel("y [m]") + ax.set_ylabel("x (m)") + ax.set_ylabel("y (m)") ax, extent, cb, CS = outCom1DFA.addResult2Plot(ax, dem["header"], fields["pta"], "pta") cb.ax.set_ylabel(pU.cfgPlotUtils["namepta"]) ax = outCom1DFA.addDem2Plot(ax, dem, what="slope", extent=extent) @@ -210,8 +210,8 @@ def generateCom1DFAPathPlot(avalancheDir, cfgPath, avaProfileMass, dem, paraboli ) ax2.axhline(y=10, color="0.8", linewidth=1, linestyle="-.", label="_Beta angle (10°)") ax2.text(minX, 10, "%.0f°" % (10), color="0.8", ha="left", va="bottom") - ax2.set_xlabel("$s_{xy}$ [m]") - ax2.set_ylabel("slope angle [°]") + ax2.set_xlabel("$s_{xy}$ (m)") + ax2.set_ylabel("slope angle (°)") ax2.set_title("Avalanche thalweg profile slope") # make profile plot, zoomed out @@ -249,8 +249,8 @@ def generateCom1DFAPathPlot(avalancheDir, cfgPath, avaProfileMass, dem, paraboli minX, _ = ax3.get_xlim() ax3.text(splitPoint["s"], minY, "%.2f m" % (splitPoint["s"]), color="r", ha="left", va="bottom") ax3.text(minX, splitPoint["z"], "%.2f m" % (splitPoint["z"]), color="r", ha="left", va="bottom") - ax3.set_xlabel("$s_{xy}$ [m]") - ax3.set_ylabel("z [m]") + ax3.set_xlabel("$s_{xy}$ (m)") + ax3.set_ylabel("z (m)") ax3.legend() ax3.set_title("Avalanche thalweg profile") @@ -329,8 +329,8 @@ def avalancheThalwegPlot(ax, fieldRaster, dem, avaProfileMass, splitPoint=None, if splitPoint is not None: if not splitPoint.get("isTopSplitPoint", False): # if not a top split point ax.plot(splitPoint["x"], splitPoint["y"], "P", color="r", label="_Split point", zorder=20) - ax.set_xlabel("x [m]") - ax.set_ylabel("y [m]") + ax.set_xlabel("x (m)") + ax.set_ylabel("y (m)") ax.axis("equal") ax.set_ylim([rowsMin, rowsMax]) ax.set_xlim([colsMin, colsMax]) diff --git a/avaframe/out3Plot/outCom7Regional.py b/avaframe/out3Plot/outCom7Regional.py index 92c84a9ec..2e472bd9f 100644 --- a/avaframe/out3Plot/outCom7Regional.py +++ b/avaframe/out3Plot/outCom7Regional.py @@ -153,7 +153,7 @@ def createReportPlot(dirListGrouped, inputDEM, outputDir, groupExtents, groupFea # Add DEM colorbar cax = ax.inset_axes([1.015, 0, 0.375, 0.02]) # [x, y, width, height] - plt.colorbar(im, cax=cax, orientation="horizontal", label="Elevation [m]") + plt.colorbar(im, cax=cax, orientation="horizontal", label="Elevation (m)") # Format plot; add title and labels ax.set_aspect("equal") diff --git a/avaframe/out3Plot/outContours.py b/avaframe/out3Plot/outContours.py index bfd28f0f5..06819cbae 100644 --- a/avaframe/out3Plot/outContours.py +++ b/avaframe/out3Plot/outContours.py @@ -158,7 +158,7 @@ def plotContoursFromDict(contourDictRef, contourDictSim, pathDict, levels, multi if multiplePlots is False: cbar = ax1.figure.colorbar(cmap) cbar.outline.set_visible(False) - cbar.ax.set_title('[' + pathDict['unit'] + ']', pad=10) + cbar.ax.set_title('(' + pathDict['unit'] + ')', pad=10) cbar.set_label(pathDict['parameter']) pU.putAvaNameOnPlot(ax1, pathDict['avaDir']) fU.makeADir(pathDict['pathResult']) diff --git a/avaframe/out3Plot/outDebugPlots.py b/avaframe/out3Plot/outDebugPlots.py index e9cc68b76..4d695f389 100644 --- a/avaframe/out3Plot/outDebugPlots.py +++ b/avaframe/out3Plot/outDebugPlots.py @@ -64,7 +64,7 @@ def plotPartIni(particles, dem): y = np.arange(header['nrows']) * header['cellsize'] fig, ax = plt.subplots(figsize=(pU.figW, pU.figH)) cmap = copy.copy(mpl.cm.get_cmap("Greys")) - ref0, im = pU.NonUnifIm(ax, x, y, dem['areaRaster'], 'x [m]', 'y [m]', + ref0, im = pU.NonUnifIm(ax, x, y, dem['areaRaster'], 'x (m)', 'y (m)', extent=[x.min(), x.max(), y.min(), y.max()], cmap=cmap, norm=None) @@ -82,7 +82,7 @@ def plotAreaDebug(header, avapath, Raster): fig, ax = plt.subplots(figsize=(pU.figW, pU.figH)) ax.set_title('Release area') cmap = copy.copy(mpl.cm.get_cmap("Greys")) - ref0, im = pU.NonUnifIm(ax, x, y, Raster, 'x [m]', 'y [m]', + ref0, im = pU.NonUnifIm(ax, x, y, Raster, 'x (m)', 'y (m)', extent=[x.min(), x.max(), y.min(), y.max()], cmap=cmap, norm=None) ax.plot(avapath['x'] * cellsize, avapath['y'] * cellsize, 'r', label='release polyline') @@ -99,7 +99,7 @@ def plotRemovePart(xCoord0, yCoord0, header, X, Y, Mask, mask): fig, ax = plt.subplots(figsize=(pU.figW, pU.figH)) ax.set_title('Release area') cmap = copy.copy(mpl.cm.get_cmap("Greys")) - ref0, im = pU.NonUnifIm(ax, x, y, Mask, 'x [m]', 'y [m]', + ref0, im = pU.NonUnifIm(ax, x, y, Mask, 'x (m)', 'y (m)', extent=[x.min(), x.max(), y.min(), y.max()], cmap=cmap, norm=None) ax.plot(xCoord0 * header['cellsize'], yCoord0 * header['cellsize'], 'r', label='release polyline') @@ -196,7 +196,7 @@ def plotPosition(fig, ax, particles, dem, data, Cmap, unit, plotPart=False, last ax.set_title('t=%.2f s' % particles['t']) cmap, _, ticks, norm = pU.makeColorMap(Cmap, np.nanmin(data), np.nanmax(data), continuous=True) cmap.set_under(color='w') - ref0, im = pU.NonUnifIm(ax, xx, yy, data, 'x [m]', 'y [m]', + ref0, im = pU.NonUnifIm(ax, xx, yy, data, 'x (m)', 'y (m)', extent=[x.min(), x.max(), y.min(), y.max()], cmap=cmap, norm=norm) diff --git a/avaframe/out3Plot/outDistanceTimeAnalysis.py b/avaframe/out3Plot/outDistanceTimeAnalysis.py index c51885f56..476f0e5f2 100644 --- a/avaframe/out3Plot/outDistanceTimeAnalysis.py +++ b/avaframe/out3Plot/outDistanceTimeAnalysis.py @@ -82,17 +82,17 @@ def addRangeTimePlotToAxes(mtiInfo, cfgRangeTime, ax): pc = ax.pcolormesh(timeListNew, rangeGates, mti, cmap=pU.cmapRangeTime) ax.plot(timeList, rangeList, ".", color="black", markersize=4, label="avalanche front") - ax.set_xlabel("Time [s]") + ax.set_xlabel("Time (s)") # add y label axis if mtiInfo["type"] == "thalwegTime": sTypeCapital = mtiInfo["sType"][0].upper() + mtiInfo["sType"][1:] if cfgRangeTime['GENERAL'].getboolean('originStart'): - ax.set_ylabel("$S_{XY}$ [m]") + ax.set_ylabel("$S_{XY}$ (m)") else: labelY = r'$\beta_{%.1f°}$' % mtiInfo['betaPointAngle'] - ax.set_ylabel("%s distance to %s [m]" % (sTypeCapital, labelY)) + ax.set_ylabel("%s distance to %s (m)" % (sTypeCapital, labelY)) else: - ax.set_ylabel("Distance to %s [m]" % mtiInfo["referencePointName"]) + ax.set_ylabel("Distance to %s (m)" % mtiInfo["referencePointName"]) # add colorbar and infobox unit = pU.cfgPlotUtils["unit" + rangeTimeResType] @@ -190,8 +190,8 @@ def radarFieldOfViewPlot(radarFov, radarRange, cfgRangeTime, rangeGates, dem): zorder=2, ) ax1.set_title("Radar range") - ax1.set_xlabel("x [m]") - ax1.set_ylabel("y [m]") + ax1.set_xlabel("x (m)") + ax1.set_ylabel("y (m)") plt.xticks(rotation=45) # add colorbar and infoboxes unit = "m" @@ -220,12 +220,12 @@ def radarFieldOfViewPlot(radarFov, radarRange, cfgRangeTime, rangeGates, dem): ax2.plot(xR[0], xR[1], marker="o", color="k") ax2.plot(xL[0], xL[1], marker="o", color="k") ax2.set_title("DEM with radar location") - ax2.set_xlabel("x [m]") - ax2.set_ylabel("y [m]") + ax2.set_xlabel("x (m)") + ax2.set_ylabel("y (m)") plt.xticks(rotation=45) # add infoboxes pU.putAvaNameOnPlot(ax2, cfgRangeTime["GENERAL"]["avalancheDir"]) - pU.putInfoBox(ax2, "- elevation [m]", location="lowerRight", color="brown") + pU.putInfoBox(ax2, "- elevation (m)", location="lowerRight", color="brown") ax2.clabel(CS, CS.levels, inline=True, fontsize=10) # set path for saving figure @@ -272,7 +272,7 @@ def plotRangeRaster(slRaster, rasterTransfo, cfgRangeTime, rangeRaster, cLower): ) # add imshow plot of range ref0, im1 = pU.NonUnifIm( - ax1, l, s, rangeRaster, "l [m]", "s [m]", extent=[l.min(), l.max(), s.min(), s.max()], cmap=cmapRange + ax1, l, s, rangeRaster, "l (m)", "s (m)", extent=[l.min(), l.max(), s.min(), s.max()], cmap=cmapRange ) # add horizontal line indicating location of start of runout area and avalanche front ax1.axhline( @@ -300,7 +300,7 @@ def plotRangeRaster(slRaster, rasterTransfo, cfgRangeTime, rangeRaster, cLower): ) cmapRes.set_bad(alpha=0.0) ref2, im2 = pU.NonUnifIm( - ax1, l, s, maskResType, "l [m]", "s [m]", extent=[l.min(), l.max(), s.min(), s.max()], cmap=cmapRes + ax1, l, s, maskResType, "l (m)", "s (m)", extent=[l.min(), l.max(), s.min(), s.max()], cmap=cmapRes ) # add legend and colorbar @@ -510,7 +510,7 @@ def addTitleBox(ax, width, height, lw, point, textsize, maxVel=True): ax.text( point[1][0], point[1][1], - "Approach \n velocity [m/s]", + "Approach \n velocity (m/s)", size=textsize, transform=ax.transAxes, va="top", @@ -762,7 +762,7 @@ def animationPlot(demData, data, cellSize, resType, cfgRangeTime, mtiInfo, timeS aspect="equal", zorder=4, ) - cName1 = "%s [%s]" % (pU.cfgPlotUtils["name" + resType], pU.cfgPlotUtils["unit" + resType]) + cName1 = "%s (%s)" % (pU.cfgPlotUtils["name" + resType], pU.cfgPlotUtils["unit" + resType]) pU.addColorBar(im1, ax1, ticksRes, None, title=cName1) # add domain transformation info @@ -799,11 +799,11 @@ def animationPlot(demData, data, cellSize, resType, cfgRangeTime, mtiInfo, timeS ax1.legend(loc="upper right") # label x, y axes if cfgRangeTime["ANIMATE"].getboolean("xyEastNorth"): - ax1.set_xlabel("East x [m]") - ax1.set_ylabel("North y [m]") + ax1.set_xlabel("East x (m)") + ax1.set_ylabel("North y (m)") else: - ax1.set_xlabel("x [m]") - ax1.set_ylabel("y [m]") + ax1.set_xlabel("x (m)") + ax1.set_ylabel("y (m)") # optional add title to panel if cfgRangeTime["ANIMATE"].getboolean("panelTitles"): ax1.set_title("simulation x,y extent at t=%.2fs" % timeStep) @@ -828,10 +828,10 @@ def animationPlot(demData, data, cellSize, resType, cfgRangeTime, mtiInfo, timeS # determine if sParallel or sProjected has been used if sType.lower() == "parallel": s = rasterTransfo["sParallel"] - rasterTransfo["sParallel"][indStartOfRunout] - sLabel = "Parallel distance to beta point [m]" + sLabel = "Parallel distance to beta point (m)" elif sType.lower() == "projected": s = rasterTransfo["s"] - rasterTransfo["s"][indStartOfRunout] - sLabel = "Projected distance to beta point [m]" + sLabel = "Projected distance to beta point (m)" # create figure # add line indicating location of start of runout area and avalanche front @@ -865,7 +865,7 @@ def animationPlot(demData, data, cellSize, resType, cfgRangeTime, mtiInfo, timeS l, s, maskResType, - "l [m]", + "l (m)", sLabel, extent=[l.min(), l.max(), s.min(), s.max()], cmap=cmapRes, @@ -914,12 +914,12 @@ def animationPlot(demData, data, cellSize, resType, cfgRangeTime, mtiInfo, timeS # create fig pc = ax3.pcolormesh(timeListNew, rangeGates, mti, vmin=resMin, vmax=resMax, cmap=pU.cmapRangeTime) ax3.plot(timeList, rangeList, ".", color="black", markersize=4, label="avalanche front") - ax3.set_xlabel("Time [s]") + ax3.set_xlabel("Time (s)") sTypeCapital = sType[0].upper() + sType[1:] - ax3.set_ylabel("%s distance to %s [m]" % (sTypeCapital, mtiInfo["referencePointName"])) + ax3.set_ylabel("%s distance to %s (m)" % (sTypeCapital, mtiInfo["referencePointName"])) # add colorbar and infobox - cName = "%s [%s]" % ( + cName = "%s (%s)" % ( cfgRangeTime["GENERAL"]["maxOrMean"] + " " + pU.cfgPlotUtils["name" + resType], pU.cfgPlotUtils["unit" + resType], ) diff --git a/avaframe/out3Plot/outParticlesAnalysis.py b/avaframe/out3Plot/outParticlesAnalysis.py index 4e106220d..8173e6564 100644 --- a/avaframe/out3Plot/outParticlesAnalysis.py +++ b/avaframe/out3Plot/outParticlesAnalysis.py @@ -79,8 +79,8 @@ def plotParticleThalwegAltitudeVelocity( label="thalweg", ) ax[0].legend(loc="upper right") - ax[0].set_xlabel("x [m]") - ax[0].set_ylabel("y [m]") + ax[0].set_xlabel("x (m)") + ax[0].set_ylabel("y (m)") # ax[1] # plot the thalweg diagram @@ -124,7 +124,7 @@ def plotParticleThalwegAltitudeVelocity( ) # y label - ax[1].set_ylabel("Velocity [m/s]", fontsize=22) + ax[1].set_ylabel("Velocity (m/s)", fontsize=22) ax[1].tick_params(axis="both", labelsize=15) # Second Y axis @@ -153,9 +153,9 @@ def plotParticleThalwegAltitudeVelocity( facecolor="black", ) # X and Y labels - ax[1].set_xlabel("$s_{xy}$[m]\n\n", fontsize=22) + ax[1].set_xlabel("$s_{xy}$(m)\n\n", fontsize=22) ax[1].xaxis.set_major_formatter(FormatStrFormatter("%.0f")) - ax2.set_ylabel("Altitude [m]", fontsize=22) + ax2.set_ylabel("Altitude (m)", fontsize=22) ax2.tick_params(axis="both", labelsize=15) # add legend @@ -261,8 +261,8 @@ def plotThalwegTimeAltitudes( addTrOrMe(ax2, measuredData, "xOrig", "yOrig", cmapData, label=True, zorder=22) # # add labels and legend - ax2.set_xlabel("x [m] \n\n", fontsize=20) - ax2.set_ylabel("y [m] \n\n", fontsize=20) + ax2.set_xlabel("x (m) \n\n", fontsize=20) + ax2.set_ylabel("y (m) \n\n", fontsize=20) ax2.tick_params(axis="both", labelsize=15) ax2.legend(loc="lower left") @@ -396,8 +396,8 @@ def plotParticleMotionTracking( handles, labels = ax1.get_legend_handles_labels() handles.append(bluePatch) # labels and ticks - ax1.set_xlabel("x [m] \n\n", fontsize=22) - ax1.set_ylabel("y [m]", fontsize=22) + ax1.set_xlabel("x (m) \n\n", fontsize=22) + ax1.set_ylabel("y (m)", fontsize=22) ax1.tick_params(axis="both", labelsize=13) ax1.legend(handles=handles, loc="upper left") @@ -429,8 +429,8 @@ def plotParticleMotionTracking( zorder=0, ) # labels and ticks - ax2.set_xlabel("Time [s] \n\n", fontsize=15) - ax2.set_ylabel("$trajectory_{XYZ}$ [m]", fontsize=15) + ax2.set_xlabel("Time (s) \n\n", fontsize=15) + ax2.set_ylabel("$trajectory_{XYZ}$ (m)", fontsize=15) ax2.tick_params(axis="both", labelsize=13) # ax3 @@ -455,8 +455,8 @@ def plotParticleMotionTracking( zorder=0, ) # labels and ticks - ax3.set_xlabel("Time [s] \n\n", fontsize=15) - ax3.set_ylabel("Velocity [m/s]", fontsize=15) + ax3.set_xlabel("Time (s) \n\n", fontsize=15) + ax3.set_ylabel("Velocity (m/s)", fontsize=15) ax3.tick_params(axis="both", labelsize=13) # ax4 @@ -482,8 +482,8 @@ def plotParticleMotionTracking( if mDataAvailable: addTrOrMe(ax4, measuredData, "t", "uAcc", cmapData, label=False) # labels and ticks - ax4.set_xlabel("Time [s] \n\n", fontsize=15) - ax4.set_ylabel("Acceleration [m/s²]", fontsize=15) + ax4.set_xlabel("Time (s) \n\n", fontsize=15) + ax4.set_ylabel("Acceleration (m/s²)", fontsize=15) ax4.tick_params(axis="both", labelsize=13) # ax5 @@ -500,8 +500,8 @@ def plotParticleMotionTracking( if mDataAvailable: addTrOrMe(ax5, measuredData, "sAimec", "trajectoryLengthXYZ", cmapData, label=False) # labels and ticks - ax5.set_xlabel("$S_{xy}$ (thalweg) [m]", fontsize=15) - ax5.set_ylabel("$trajectory_{XYZ}$ [m]", fontsize=15) + ax5.set_xlabel("$S_{xy}$ (thalweg) (m)", fontsize=15) + ax5.set_ylabel("$trajectory_{XYZ}$ (m)", fontsize=15) ax5.tick_params(axis="both", labelsize=13) # ax6 @@ -526,8 +526,8 @@ def plotParticleMotionTracking( if mDataAvailable: addTrOrMe(ax6, measuredData, "sAimec", "velocityMag", cmapData, label=True) # labels and ticks - ax6.set_xlabel("$S_{xy}$ [m]", fontsize=15) - ax6.set_ylabel("Velocity [m/s]", fontsize=15) + ax6.set_xlabel("$S_{xy}$ (m)", fontsize=15) + ax6.set_ylabel("Velocity (m/s)", fontsize=15) ax6.tick_params(axis="both", labelsize=13) # ax7 @@ -544,8 +544,8 @@ def plotParticleMotionTracking( if mDataAvailable: addTrOrMe(ax7, measuredData, "sAimec", "uAcc", cmapData, label=False) # labels and ticks - ax7.set_xlabel("$S_{xy}$ [m]", fontsize=15) - ax7.set_ylabel("Acceleration [m/s²]", fontsize=15) + ax7.set_xlabel("$S_{xy}$ (m)", fontsize=15) + ax7.set_ylabel("Acceleration (m/s²)", fontsize=15) ax7.tick_params(axis="both", labelsize=13) # save and or plot @@ -909,8 +909,8 @@ def plotParticlesAssets(dem, assets, particleAssets, outDir, plotName, title): vmin=vMin, vmax=vMax, ) - ax.set_xlabel("x [m]") - ax.set_ylabel("y [m]") + ax.set_xlabel("x (m)") + ax.set_ylabel("y (m)") fig.colorbar(im1, ax=ax) # save and or plot diff --git a/avaframe/out3Plot/outProfilePlots.py b/avaframe/out3Plot/outProfilePlots.py index edac885dc..89c4ca883 100644 --- a/avaframe/out3Plot/outProfilePlots.py +++ b/avaframe/out3Plot/outProfilePlots.py @@ -77,8 +77,8 @@ def plotAlongProfile(avaDir, peakFilesDF, resType='pft', cInd='names'): # add profile line ax1.plot(profileLine['x'], profileLine['y'], color='orange', linestyle='-', zorder=10, label='profile line') - ax1.set_xlabel('x [m]') - ax1.set_ylabel('y [m]') + ax1.set_xlabel('x (m)') + ax1.set_ylabel('y (m)') ax1.legend() # initialize profile figure @@ -118,18 +118,18 @@ def plotAlongProfile(avaDir, peakFilesDF, resType='pft', cInd='names'): label='dem elevation\nalong given profile') # add labels - ax[1,0].set_xlabel('distance along given profile [m]') - ax[1, 1].set_xlabel('distance along given profile [m]') - ax[0, 0].set_ylabel('peak flow depth (pfd) [m]') - ax[1, 0].set_ylabel('peak flow thickness (pft) [m]') - ax[1, 1].set_ylabel('DEM elevation (+ pft) [m]') - ax[0, 1].set_ylabel('DEM elevation (+ pfd) [m]') + ax[1,0].set_xlabel('distance along given profile (m)') + ax[1, 1].set_xlabel('distance along given profile (m)') + ax[0, 0].set_ylabel('peak flow depth (pfd) (m)') + ax[1, 0].set_ylabel('peak flow thickness (pft) (m)') + ax[1, 1].set_ylabel('DEM elevation (+ pft) (m)') + ax[0, 1].set_ylabel('DEM elevation (+ pfd) (m)') # add title to panels - ax[0, 0].set_title('pfd along given profile [m]', fontsize=11) - ax[1, 0].set_title('pft along given profile [m]', fontsize=11) - ax[0, 1].set_title('pfd on top of DEM for given profile [m]', fontsize=11) - ax[1, 1].set_title('pft on top of DEM for given profile [m]', fontsize=11) + ax[0, 0].set_title('pfd along given profile (m)', fontsize=11) + ax[1, 0].set_title('pft along given profile (m)', fontsize=11) + ax[0, 1].set_title('pfd on top of DEM for given profile (m)', fontsize=11) + ax[1, 1].set_title('pft on top of DEM for given profile (m)', fontsize=11) # add legend ax[0,0].legend() diff --git a/avaframe/out3Plot/outQuickPlot.py b/avaframe/out3Plot/outQuickPlot.py index 9bfa30925..85f037b85 100644 --- a/avaframe/out3Plot/outQuickPlot.py +++ b/avaframe/out3Plot/outQuickPlot.py @@ -131,8 +131,8 @@ def generatePlot(dataDict, avaName, outDir, cfg, plotDict, crossProfile=True): ax1.set_aspect('auto') title = str('%s - simulation' % name1) ax1.set_title(title) - ax1.set_xlabel('x [m]') - ax1.set_ylabel('y [m]') + ax1.set_xlabel('x (m)') + ax1.set_ylabel('y (m)') ax2 = fig.add_subplot(222) cmap, _, ticks, norm = pU.makeColorMap(cmapType, minVal, maxVal, continuous=pU.contCmap) @@ -145,7 +145,7 @@ def generatePlot(dataDict, avaName, outDir, cfg, plotDict, crossProfile=True): ax2.set_xlim([colsMinPlot, colsMaxPlot]) ax2.set_ylim([rowsMinPlot, rowsMaxPlot]) ax2.set_aspect('auto') - ax2.set_xlabel('x [m]') + ax2.set_xlabel('x (m)') title = str('%s - reference' % name2) ax2.set_title(title) @@ -162,7 +162,7 @@ def generatePlot(dataDict, avaName, outDir, cfg, plotDict, crossProfile=True): (diffMean, unit, diffMax, unit, diffMin, unit), horizontalalignment='left', verticalalignment='bottom', transform=ax3.transAxes) ax3.set_aspect('auto') - ax3.set_xlabel('x [m]') + ax3.set_xlabel('x (m)') ax3.set_title('Difference simulation-reference') # for difference histogramm - remove dataDiff == 0 values from array @@ -193,7 +193,7 @@ def generatePlot(dataDict, avaName, outDir, cfg, plotDict, crossProfile=True): ax4.set_ylim([rowsMinPlot, rowsMaxPlot]) pU.addColorBar(im4, ax4, None, unit, extend='both') ax4.set_aspect('auto') - ax4.set_xlabel('x [m]') + ax4.set_xlabel('x (m)') # if difference is zero dont insert CDF plots indDiff = dataDiffPlot > 0 @@ -220,12 +220,12 @@ def generatePlot(dataDict, avaName, outDir, cfg, plotDict, crossProfile=True): suptitle = fig1.suptitle(avaName, fontsize=14, color='0.5') ax[0, 0].plot(data1[:, ny_loc], 'k', label='Simulation') ax[0, 0].plot(data2[:, ny_loc], 'b--', label='Reference') - ax[0, 0].set_xlabel('Location across track [nrows]') + ax[0, 0].set_xlabel('Location across track (nrows)') ax[0, 0].set_ylabel('Result parameter') ax[0, 0].set_title('Cross profile at x = %d' % ny_loc) ax[0, 1].plot(data1[nx_loc, :], 'k', label='Simulation') ax[0, 1].plot(data2[nx_loc, :], 'b--', label='Reference') - ax[0, 1].set_xlabel('Location along track [ncols]') + ax[0, 1].set_xlabel('Location along track (ncols)') ax[0, 1].set_ylabel('Result parameter') ax[0, 1].set_title('Long profile at y = %d' % nx_loc) ax[0, 0].legend() @@ -521,8 +521,8 @@ def generateOnePlot(dataDict, outDir, cfg, plotDict): ax1.set_aspect('auto') title = str('%s' % name1) ax1.set_title(title) - ax1.set_xlabel('x [m]') - ax1.set_ylabel('y [m]') + ax1.set_xlabel('x (m)') + ax1.set_ylabel('y (m)') ax3 = fig.add_subplot(122) if axis == 'x': @@ -530,12 +530,12 @@ def generateOnePlot(dataDict, outDir, cfg, plotDict): else: ax3.plot(data1[ny_loc, :], 'k', label='Reference') - ax3.set_xlabel('Location across track [nrows]') - ax3.set_ylabel('%s [%s]' % (nameRes, unit)) + ax3.set_xlabel('Location across track (nrows)') + ax3.set_ylabel('%s (%s)' % (nameRes, unit)) if axis == 'x': - ax3.set_title('Profile at x ~ %d [%s] (%d)' % (location, unit, nx_loc)) + ax3.set_title('Profile at x ~ %d (%s) (%d)' % (location, unit, nx_loc)) else: - ax3.set_title('Profile at y ~ %d [%s] (%d)' % (location, unit, ny_loc)) + ax3.set_title('Profile at y ~ %d (%s) (%d)' % (location, unit, ny_loc)) saveNameProfile = outDir / ('Profiles_%s.%s' % (name1, pU.outputFormat)) # save and or show figure @@ -573,8 +573,8 @@ def plotContours(contourDict, resType, thresholdValue, pathDict, addLegend=True, # show flow path ax1 = fig.add_subplot(121) ax1.set_title('%s %s %s contour lines' % (resTypeLabel, thresholdValue, unit)) - ax1.set_ylabel('x [m]') - ax1.set_xlabel('y [m]') + ax1.set_ylabel('x (m)') + ax1.set_xlabel('y (m)') pU.putAvaNameOnPlot(ax1, pathDict['avaDir']) # create color map diff --git a/avaframe/out3Plot/outTopo.py b/avaframe/out3Plot/outTopo.py index 1da55536e..0e8f0538d 100644 --- a/avaframe/out3Plot/outTopo.py +++ b/avaframe/out3Plot/outTopo.py @@ -40,8 +40,8 @@ def _generateDEMPlot(X, Y, z, title): # linewidth=0, antialiased=False) ax.set_title('DEM: %s' % title) - ax.set_xlabel('x [m]') - ax.set_ylabel('y [m]') + ax.set_xlabel('x (m)') + ax.set_ylabel('y (m)') ax.set_zlabel('elevation (m)') return ax, fig @@ -130,12 +130,12 @@ def plotReleasePoints(xv, yv, xyPoints, demType): ax[0].plot(np.zeros(len(yv)) + xv[-1], yv, "k-") ax[0].plot(xyPoints[:, 0], xyPoints[:, 1], "r*") ax[0].set_title("Domain and release area of %s - projected" % demType) - ax[0].set_xlabel("along valley [m]") - ax[0].set_ylabel("across valley [m]") + ax[0].set_xlabel("along valley (m)") + ax[0].set_ylabel("across valley (m)") ax[1].plot(xyPoints[:, 0], xyPoints[:, 1], "r*") - ax[1].set_xlabel("along valley [m]") - ax[1].set_ylabel("across valley [m]") + ax[1].set_xlabel("along valley (m)") + ax[1].set_ylabel("across valley (m)") xLength = abs(xyPoints[0, 0] - xyPoints[3, 0]) yLength = abs(xyPoints[0, 1] - xyPoints[1, 1]) diff --git a/avaframe/out3Plot/outTransformPlots.py b/avaframe/out3Plot/outTransformPlots.py index bd18ed273..302ead98e 100644 --- a/avaframe/out3Plot/outTransformPlots.py +++ b/avaframe/out3Plot/outTransformPlots.py @@ -81,8 +81,8 @@ def plotDepthToThickness(depth, thickness, slopeAngleField, profileAxis, profile label="slope angle", ) ax[1, 1].set_xlabel("x") - ax3.set_ylabel("slope angle [°]") - ax[1, 1].set_ylabel("flow thickness [m]") + ax3.set_ylabel("slope angle (°)") + ax[1, 1].set_ylabel("flow thickness (m)") ax[1, 1].legend() # save and or show figure diff --git a/avaframe/out3Plot/plotUtils.py b/avaframe/out3Plot/plotUtils.py index 62f222811..6838737d7 100644 --- a/avaframe/out3Plot/plotUtils.py +++ b/avaframe/out3Plot/plotUtils.py @@ -606,7 +606,7 @@ def addColorBar( else: pad = 10 if myUnit != None and myUnit != "": - cbar.ax.set_title("[" + myUnit + "]", pad=pad) + cbar.ax.set_title("(" + myUnit + ")", pad=pad) if title != "": cbar.set_label(title) if len(tickLabelsList) > 0: @@ -941,7 +941,7 @@ def addHillShadeContours( # add info box with indication of label meaning putInfoBox( ax, - "- elevation [m]", + "- elevation (m)", location="upperLeft", color="gray", hAlignment="left", diff --git a/avaframe/out3Plot/statsPlots.py b/avaframe/out3Plot/statsPlots.py index 87cbf46e6..858645702 100644 --- a/avaframe/out3Plot/statsPlots.py +++ b/avaframe/out3Plot/statsPlots.py @@ -96,8 +96,8 @@ def plotValuesScatter( # set range and steps of colormap cc = varValV sc = ax.scatter(values1, values2, c=cc, cmap=cmap) - ax.set_xlabel('%s %s [%s]' % (statsMeasure, name1, unit1)) - ax.set_ylabel('%s %s [%s]' % (statsMeasure, name2, unit2)) + ax.set_xlabel('%s %s (%s)' % (statsMeasure, name1, unit1)) + ax.set_ylabel('%s %s (%s)' % (statsMeasure, name2, unit2)) pU.addColorBar(sc, ax, ticks, unitVar, nameVar, tickLabelsList=itemsList) pU.putAvaNameOnPlot(ax, avalancheDir) @@ -170,8 +170,8 @@ def plotValuesScatterHist( nameVar = cfg['varParName'] unitVar = cfg['varParUnit'] varValV = np.array(varVal) - title1 = statsMeasure + ' ' + name1+' [' + unit1 + ']' - title2 = statsMeasure + ' ' + name2+' [' + unit2 + ']' + title1 = statsMeasure + ' ' + name1+' (' + unit1 + ')' + title2 = statsMeasure + ' ' + name2+' (' + unit2 + ')' if flagHue: # create pandas data frame reqiured for seaborn jointplot @@ -387,8 +387,8 @@ def plotProbMap(avaDir, inDir, cfgFull, demPlot=False): pU.addColorBar(im1, ax1, ticks, unit) title = str('%s' % cfg['name']) - ax1.set_xlabel('x [m]') - ax1.set_ylabel('y [m]') + ax1.set_xlabel('x (m)') + ax1.set_ylabel('y (m)') # add zoom plot of runout area ax2 = fig.add_subplot(122) @@ -436,8 +436,8 @@ def plotProbMap(avaDir, inDir, cfgFull, demPlot=False): # Get the handles for the legend elements handles, _ = CS2.legend_elements() - ax2.set_xlabel('x [m]') - ax2.set_ylabel('y [m]') + ax2.set_xlabel('x (m)') + ax2.set_ylabel('y (m)') plt.legend(handles, labels, facecolor='black', framealpha=0.04) pU.addColorBar(im2, ax2, ticks, unit) diff --git a/avaframe/runScripts/runPlotProfile.py b/avaframe/runScripts/runPlotProfile.py index c09642ab0..0c7a8c382 100644 --- a/avaframe/runScripts/runPlotProfile.py +++ b/avaframe/runScripts/runPlotProfile.py @@ -92,7 +92,7 @@ cmapSC2 = ScalarMappable(norm=Normalize(minVal, maxVal), cmap=cmapSC) cbar = ax1.figure.colorbar(cmapSC2, ax=ax1) cbar.outline.set_visible(False) -cbar.ax.set_title('[' + unit + ']', pad=10) +cbar.ax.set_title('(' + unit + ')', pad=10) cbar.set_label(varPar) ax2.imshow(testField['rasterData']) ax2.hlines(nrowsHalf, 0, testField['rasterData'].shape[1], "white", label="profile location") From 606160ebcb93fd189ea0f15b26c81f51537f97d4 Mon Sep 17 00:00:00 2001 From: Paula Date: Wed, 11 Nov 2026 16:59:28 +0100 Subject: [PATCH 2/2] fix bug --- avaframe/out3Plot/outQuickPlot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/avaframe/out3Plot/outQuickPlot.py b/avaframe/out3Plot/outQuickPlot.py index 85f037b85..fe635a532 100644 --- a/avaframe/out3Plot/outQuickPlot.py +++ b/avaframe/out3Plot/outQuickPlot.py @@ -220,12 +220,12 @@ def generatePlot(dataDict, avaName, outDir, cfg, plotDict, crossProfile=True): suptitle = fig1.suptitle(avaName, fontsize=14, color='0.5') ax[0, 0].plot(data1[:, ny_loc], 'k', label='Simulation') ax[0, 0].plot(data2[:, ny_loc], 'b--', label='Reference') - ax[0, 0].set_xlabel('Location across track (nrows)') + ax[0, 0].set_xlabel("Location across track [nrows]") ax[0, 0].set_ylabel('Result parameter') ax[0, 0].set_title('Cross profile at x = %d' % ny_loc) ax[0, 1].plot(data1[nx_loc, :], 'k', label='Simulation') ax[0, 1].plot(data2[nx_loc, :], 'b--', label='Reference') - ax[0, 1].set_xlabel('Location along track (ncols)') + ax[0, 1].set_xlabel("Location along track [ncols]") ax[0, 1].set_ylabel('Result parameter') ax[0, 1].set_title('Long profile at y = %d' % nx_loc) ax[0, 0].legend() @@ -530,7 +530,7 @@ def generateOnePlot(dataDict, outDir, cfg, plotDict): else: ax3.plot(data1[ny_loc, :], 'k', label='Reference') - ax3.set_xlabel('Location across track (nrows)') + ax3.set_xlabel("Location across track [nrows]") ax3.set_ylabel('%s (%s)' % (nameRes, unit)) if axis == 'x': ax3.set_title('Profile at x ~ %d (%s) (%d)' % (location, unit, nx_loc))