Skip to content

Commit

Permalink
Merge pull request #4 from hydroEng/ensemble-missing-tps-fix
Browse files Browse the repository at this point in the history
Ensemble missing tps fix
  • Loading branch information
hydroEng authored Feb 26, 2023
2 parents f8dd19b + cedd009 commit 3f81053
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ def _write_sr(msg: pandas.Series):
self.log_string += '\n' + msg.to_string() + '\n'

def _write_df(msg: pandas.DataFrame):
self.log_string += '\n' + msg.to_string() + '\n'

try:
name = str(msg.name) + "\n"
except AttributeError:
name = ""

self.log_string += '\n' + name + msg.to_string() + '\n'

def _write_none():
self.log_string += '\n' + "None" + '\n'
Expand Down Expand Up @@ -57,7 +63,7 @@ def print_log(self):
def write_to_txt(self, output_dir, filename):
""" Output log as a text file to specified folder. """

filepath= os.path.join(output_dir, filename)
filepath = os.path.join(output_dir, filename)

with open(filepath, 'w+') as f:
f.write(self.log_string)
5 changes: 4 additions & 1 deletion src/tuflow_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ def _get_crit_tp(row: pd.Series) -> str:
median = row['Median']

diffs = {}

# Skip nan values that occur because of missing results for a particular temporal pattern / duration csv.
row = row.dropna()

for cell in row:
col_name = _get_col_name(cell, row)
if 'tp' in col_name:
Expand Down Expand Up @@ -328,7 +332,6 @@ def _tp_vs_max_flow_df(df: pd.DataFrame) -> tuple:
po_line = str(column)

dur_tp_df = df.pivot(index='Duration', columns='Temporal Pattern', values=po_line)
dur_tp_df = dur_tp_df.fillna(0)
dur_tp_df = _drop_sort_duration(dur_tp_df)

tp_cols = [col for col in dur_tp_df.columns if 'tp' in col]
Expand Down

0 comments on commit 3f81053

Please sign in to comment.