Skip to content
Snippets Groups Projects
Commit 27d7bbbd authored by David Verelst's avatar David Verelst
Browse files

prepost: run checklogs after HAWC2 on the node

parent 25aa3a58
No related branches found
No related tags found
No related merge requests found
......@@ -2541,6 +2541,8 @@ class PBS(object):
self.pbs += ' echo "POST-PROCESSING"\n'
self.pbs += ' source activate %s\n' % self.pyenv
self.pbs += " "
self.checklogs()
self.pbs += " "
self.postprocessing()
self.pbs += ' source deactivate\n'
self.pbs += "else\n"
......@@ -2549,6 +2551,8 @@ class PBS(object):
self.pbs += " %s %s ./%s %s \n" % param
self.pbs += ' echo "POST-PROCESSING"\n'
self.pbs += " "
self.checklogs()
self.pbs += " "
self.postprocessing()
self.pbs += "fi\n"
......@@ -2880,6 +2884,13 @@ class PBS(object):
self.pbs += ' find .\n'
self.pbs += '# ' + '-'*78 + '\n'
def checklogs(self):
"""
"""
self.pbs += 'python -c "from wetb.prepost import statsdel; '
rpl = (os.path.join(self.logs_dir, self.case+'.log'))
self.pbs += 'statsdel.logcheck(\'%s\')"\n' % rpl
def postprocessing(self):
"""Run post-processing just after HAWC2 has ran
"""
......@@ -2968,11 +2979,12 @@ class ErrorLogs(windIO.LogFile):
def __init__(self, silent=False, cases=None, resultfile='ErrorLog.csv'):
# call init from base class
super(ErrorLogs, self).__init__(silent=silent)
super(ErrorLogs, self).__init__()
self.PathToLogs = ''
self.ResultFile = resultfile
self.cases = cases
self.silent = silent
# TODO: save this not a csv text string but a df_dict, and save as excel
# and DataFrame!
......
......@@ -23,6 +23,20 @@ import os
from wetb.prepost import windIO
def logcheck(fname, fsave=None, mode='w'):
"""Check the log file of a single HAWC2 simulation and save results to
textfile.
"""
logf = windIO.LogFile()
logf.readlog(fname)
contents = logf._msglistlog2csv('')
if fsave is None:
fsave = fname.replace('.log', '.csv')
with open(fsave, mode) as f:
f.write(contents)
def calc(fpath, no_bins=46, m=[3, 4, 6, 8, 10, 12], neq=None, i0=0, i1=None,
ftype=False, fsave=False):
"""
......
......@@ -45,9 +45,8 @@ class LogFile(object):
"""Check a HAWC2 log file for errors.
"""
def __init__(self, silent=False):
def __init__(self):
self.silent = silent
# the total message list log:
self.MsgListLog = []
# a smaller version, just indication if there are errors:
......@@ -324,7 +323,7 @@ class LogFile(object):
# save the iterations in the results folder
if save_iter:
fiter = fname.replace('.log', '.iter')
fiter = os.path.basename(fname).replace('.log', '.iter')
fmt = ['%12.06f', '%4i', '%4i']
if case is not None:
fpath = os.path.join(case['[run_dir]'], case['[iter_dir]'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment