Skip to content

Commit 69c9f58

Browse files
authoredJan 7, 2025··
Merge pull request #59 from ecmwf/162-datashader-does-not-handle-well-nans-in-ocean-plots
fix(training, plots) Exclude nans from error colorbars
2 parents f8e5b39 + 8dd3b11 commit 69c9f58

File tree

1 file changed

+3
-2
lines changed
  • training/src/anemoi/training/diagnostics

1 file changed

+3
-2
lines changed
 

‎training/src/anemoi/training/diagnostics/plots.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ def error_plot_in_degrees(array1: np.ndarray, array2: np.ndarray) -> np.ndarray:
584584
# For 'errors', only persistence and increments need identical colorbar-limits
585585
combined_error = np.concatenate(((pred - input_), (truth - input_)))
586586
norm = Normalize(vmin=np.nanmin(combined_data), vmax=np.nanmax(combined_data))
587+
norm_error = TwoSlopeNorm(vmin=np.nanmin(combined_error), vcenter=0.0, vmax=np.nanmax(combined_error))
587588
single_plot(fig, ax[1], lon, lat, truth, norm=norm, title=f"{vname} target", datashader=datashader)
588589
single_plot(fig, ax[2], lon, lat, pred, norm=norm, title=f"{vname} pred", datashader=datashader)
589590
single_plot(
@@ -688,7 +689,7 @@ def error_plot_in_degrees(array1: np.ndarray, array2: np.ndarray) -> np.ndarray:
688689
lat,
689690
pred - input_,
690691
cmap="bwr",
691-
norm=TwoSlopeNorm(vmin=combined_error.min(), vcenter=0.0, vmax=combined_error.max()),
692+
norm=norm_error,
692693
title=f"{vname} increment [pred - input]",
693694
datashader=datashader,
694695
)
@@ -699,7 +700,7 @@ def error_plot_in_degrees(array1: np.ndarray, array2: np.ndarray) -> np.ndarray:
699700
lat,
700701
truth - input_,
701702
cmap="bwr",
702-
norm=TwoSlopeNorm(vmin=combined_error.min(), vcenter=0.0, vmax=combined_error.max()),
703+
norm=norm_error,
703704
title=f"{vname} persist err",
704705
datashader=datashader,
705706
)

0 commit comments

Comments
 (0)
Please sign in to comment.