Skip to content

Commit

Permalink
Fixed the plots codes to prevent potential failure. (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamiraArdani-NOAA authored Jan 7, 2025
1 parent 2288922 commit 76641bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ush/nfcens/lead_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ def plot_lead_average(df: pd.DataFrame, logger: logging.Logger,
else:
handles = []
labels = []
n_mods = 0
for m in range(len(mod_setting_dicts)):
if model_list[m] in model_colors.model_alias:
model_plot_name = (
Expand Down Expand Up @@ -581,9 +582,10 @@ def plot_lead_average(df: pd.DataFrame, logger: logging.Logger,
else:
y_vals_metric_min = np.nanmin(y_vals_metric1)
y_vals_metric_max = np.nanmax(y_vals_metric1)
if m == 0:
if n_mods == 0:
y_mod_min = y_vals_metric_min
y_mod_max = y_vals_metric_max
n_mods+=1
else:
if math.isinf(y_mod_min):
y_mod_min = y_vals_metric_min
Expand Down
4 changes: 3 additions & 1 deletion ush/nfcens/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ def plot_time_series(df: pd.DataFrame, logger: logging.Logger,
labels = [model_list[0].upper()]
handles = []
labels = []
n_mods = 0
for m in range(len(mod_setting_dicts)):
if model_list[m] in model_colors.model_alias:
model_plot_name = (
Expand Down Expand Up @@ -615,10 +616,11 @@ def plot_time_series(df: pd.DataFrame, logger: logging.Logger,
else:
y_vals_metric_min = np.nanmin(y_vals_metric1)
y_vals_metric_max = np.nanmax(y_vals_metric1)
if m == 0:
if n_mods == 0:
y_mod_min = y_vals_metric_min
y_mod_max = y_vals_metric_max
counts = pivot_counts[str(model_list[m])].values
n_mods+=1
else:
y_mod_min = np.nanmin([y_mod_min, y_vals_metric_min])
y_mod_max = np.nanmax([y_mod_max, y_vals_metric_max])
Expand Down

0 comments on commit 76641bc

Please sign in to comment.