Skip to content

Commit

Permalink
Fix cmap_extrema when NaNs are in the data
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-kev committed Oct 26, 2024
1 parent 1b6fdea commit 412bf17
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ if duplicate dates are detected.
- Add support for automatically converting CFTime.AbstractCFDateTime dates to seconds.
- Treat `NaN`s as zeros when integrating (`integrate_lon, integrate_lat, integrate_lonlat`).
- Fix duplicate values on colorbar for plotting bias.
- Fix `NaN`s for colorbar when plotting bias.

v0.5.10
-------
Expand Down
8 changes: 5 additions & 3 deletions ext/ClimaAnalysisGeoMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import GeoMakie: Makie
import ClimaAnalysis
import ClimaAnalysis: Visualize

import NaNStatistics: nanextrema

MakiePlace = Union{Makie.Figure, Makie.GridLayout}

"""
Expand Down Expand Up @@ -278,7 +280,7 @@ end
plot_bias_on_globe!(fig::Makie.Figure,
sim::ClimaAnalysis.OutputVar,
obs::ClimaAnalysis.OutputVar;
cmap_extrema = extrema(ClimaAnalysis.bias(sim, obs).data),
cmap_extrema = nanextrema(ClimaAnalysis.bias(sim, obs).data),
p_loc = (1, 1),
plot_coastline = true,
plot_colorbar = true,
Expand All @@ -287,7 +289,7 @@ end
plot_bias_on_globe!(grid_layout::Makie.GridLayout,
sim::ClimaAnalysis.OutputVar,
obs::ClimaAnalysis.OutputVar;
cmap_extrema = extrema(ClimaAnalysis.bias(sim, obs).data),
cmap_extrema = nanextrema(ClimaAnalysis.bias(sim, obs).data),
p_loc = (1, 1),
plot_coastline = true,
plot_colorbar = true,
Expand Down Expand Up @@ -339,7 +341,7 @@ function Visualize.plot_bias_on_globe!(
place::MakiePlace,
sim::ClimaAnalysis.OutputVar,
obs::ClimaAnalysis.OutputVar;
cmap_extrema = extrema(ClimaAnalysis.bias(sim, obs).data),
cmap_extrema = nanextrema(ClimaAnalysis.bias(sim, obs).data),
p_loc = (1, 1),
plot_coastline = true,
plot_colorbar = true,
Expand Down
3 changes: 1 addition & 2 deletions test/test_GeoMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ using OrderedCollections
var,
var_zero,
mask = mask_fn,
cmap_extrema = (-5.0, 5.0),
# The keyword `nan_color` do not work right now for CairoMakie.
# The keyword `nan_color` does not work right now for CairoMakie.
# See https://github.com/MakieOrg/Makie.jl/issues/4524
more_kwargs = Dict(
:plot => ClimaAnalysis.Utils.kwargs(nan_color = :red),
Expand Down

0 comments on commit 412bf17

Please sign in to comment.