Skip to content

Commit

Permalink
add mass plot also if only one sim and adjust y2 label
Browse files Browse the repository at this point in the history
  • Loading branch information
awirb committed Aug 17, 2023
1 parent 0b42412 commit 8a7f008
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
5 changes: 2 additions & 3 deletions avaframe/ana3AIMEC/ana3AIMEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,8 @@ def postProcessAIMEC(cfg, rasterTransfo, pathDict, resAnalysisDF, newRasters, ti
fnameMass = resAnalysisDF.loc[simRowHash, 'massBal']
resAnalysisDF, timeMass = aimecTools.analyzeMass(fnameMass, simRowHash, refSimRowHash, resAnalysisDF, time=timeMass)

if simRowHash != refSimRowHash:
massPlotName = outAimec.visuMass(resAnalysisDF, pathDict, simRowHash, refSimRowHash, timeMass)
resAnalysisDF.loc[simRowHash, 'massPlotName'] = massPlotName
massPlotName = outAimec.visuMass(resAnalysisDF, pathDict, simRowHash, refSimRowHash, timeMass)
resAnalysisDF.loc[simRowHash, 'massPlotName'] = massPlotName
else:
timeMass = None

Expand Down
29 changes: 16 additions & 13 deletions avaframe/out3Plot/outAIMEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,30 +353,33 @@ def visuMass(resAnalysisDF, pathDict, simRowHash, refSimRowHash, timeMass):
for ax, field, title, unit in zip(axes.flatten(), fieldList, Title, Unit):
refArray = resAnalysisDF.loc[refSimRowHash, field]
simArray = resAnalysisDF.loc[simRowHash, field]
if refSimRowHash != simRowHash:
ax.plot(timeMass, simArray, '-b', label='Simulation : %s ' % simName)
ax.plot(timeMass, refArray, '-k', label='Reference : %s ' % refSimName)
ax.plot(timeMass, simArray, '-b', label='Simulation : %s ' % simName)

ax.set_title(title + ' function of time')
ax.legend(loc=1)
ax.set_xlabel('t [s]')
ax.set_ylabel(unit)

ax2 = axes.flatten()[1].twinx()
ax2.spines['right'].set_color('r')
ax2.tick_params(axis='y', colors='r')
ax2.plot(timeMass, (simArray-refArray) / refArray*100, 'r', label='total mass')
if refSimRowHash != simRowHash:
ax2 = axes.flatten()[1].twinx()
ax2.spines['right'].set_color('r')
ax2.tick_params(axis='y', colors='r')
# after loop this refers o the totalMassArray field as final item in fieldList
ax2.plot(timeMass, (simArray-refArray) / refArray*100, 'r--', label='total mass')

if np.any(entMass):
axes.flatten()[1].text(timeMass[-1]/4, (np.nanmin(refArray) + np.nanmax(refArray))/2,
'Entrained Mass Difference : %.2f kg \n Relative to total mass : %.2f %% ' %
((entMassRef-entMass), (entMassRef-entMass)/finalMassRef*100),
bbox=dict(boxstyle="square", ec='white', fc='white'),
horizontalalignment='left', verticalalignment='bottom')
if np.any(entMass):
axes.flatten()[1].text(timeMass[-1]/4, (np.nanmin(refArray) + np.nanmax(refArray))/2,
'Entrained Mass Difference : %.2f kg \n Relative to total mass : %.2f %% ' %
((entMassRef-entMass), (entMassRef-entMass)/finalMassRef*100),
bbox=dict(boxstyle="square", ec='white', fc='white'),
horizontalalignment='left', verticalalignment='bottom')

ax2.set_ylabel('Entrained Mass Difference relative to total mass[%]', color='r')
ax2.set_ylabel('Total Mass Difference [%]', color='r')

outFileName = '_'.join([projectName, str(simName), 'massAnalysis'])
pU.putAvaNameOnPlot(ax2, pathDict['projectName'])
pU.putAvaNameOnPlot(ax, pathDict['projectName'])
outFilePath = pU.saveAndOrPlot(pathDict, outFileName, fig)

return outFilePath
Expand Down

0 comments on commit 8a7f008

Please sign in to comment.