Skip to content

Commit

Permalink
Handle reportDictList and write warning; fixes #872
Browse files Browse the repository at this point in the history
  • Loading branch information
fso42 committed Sep 16, 2024
1 parent 0aaf7b0 commit 3730dc8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions avaframe/com1DFA/com1DFA.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ def com1DFAPostprocess(simDF, tCPUDF, simDFExisting, cfgMain, dem, reportDictLis

if cfgMain["FLAGS"].getboolean("createReport"):
# write report
reportDictList = gR.checkAndCleanReportDictOnWinIssue872(reportDictList)

gR.writeReport(reportDir, reportDictList, cfgMain["FLAGS"].getboolean("reportOneFile"), plotDict)

return dem, plotDict, reportDictList, simDFNew
Expand Down
36 changes: 36 additions & 0 deletions avaframe/log2Report/generateReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,39 @@ def writeReport(outDir, reportDictList, reportOneFile, plotDict='', standaloneRe

# Write report file
writeReportFile(reportD, pfile)


def checkAndCleanReportDictOnWinIssue872(reportDictList):
""" Check report dict for inconsistencies in simName. Sometimes the simName is not
properly set in the dict report. This is a dirty fix!! (see issue 872). S
Parameters
----------
reportDictList : list
of report dictionaries from simulations
Returns
-------
reportDictList : list
checked and cleaned reportDict
"""

for k, listItem in enumerate(reportDictList):
simName = listItem['simName']['name']
if '_AF_' in simName:
nameParts = simName.split('_AF_')
else:
nameParts = simName.split('_')

# This is the proper simName
simNameClean = nameParts[0]

if listItem['Simulation Parameters']['Release Area Scenario'] != simNameClean:
reportDictList[k]['Simulation Parameters']['Release Area Scenario'] = simNameClean
log.warning("Ran into windows QGis simName report problem, set release area scenario to simName.")

if listItem['Release Area']['Release area scenario'] != simNameClean:
reportDictList[k]['Release Area']['Release area scenario'] = simNameClean
log.warning("Ran into windows QGis simName report problem, set release area scenario to simName.")

return reportDictList

0 comments on commit 3730dc8

Please sign in to comment.