@@ -16,7 +16,7 @@ Plot with `Makie.poly`.
16
16
"""
17
17
function Visualize. oceanmask ()
18
18
elevation = 0
19
- return GeoMakie. NaturalEarth. bathymetry (elevation)
19
+ return GeoMakie. NaturalEarth. bathymetry (elevation). geometry
20
20
end
21
21
22
22
"""
@@ -48,6 +48,9 @@ function _geomakie_plot_on_globe!(
48
48
)
49
49
length (var. dims) == 2 || error (" Can only plot 2D variables" )
50
50
51
+ apply_mask = _find_mask_to_apply (mask)
52
+ ! isnothing (apply_mask) && (var = apply_mask (var))
53
+
51
54
lon_name = " "
52
55
lat_name = " "
53
56
@@ -130,9 +133,6 @@ The dimensions have to be longitude and latitude.
130
133
mask. `ClimaAnalysis` comes with predefined masks, check out [`Visualize.oceanmask`](@ref) and
131
134
[`Visualize.landmask`](@ref).
132
135
133
- !!! note Masking does not affect the colorbar. If you have values defined beneath the map,
134
- they can still affect the colorbar.
135
-
136
136
Additional arguments to the plotting and axis functions
137
137
=======================================================
138
138
@@ -209,9 +209,6 @@ The dimensions have to be longitude and latitude.
209
209
mask. `ClimaAnalysis` comes with predefined masks, check out [`Visualize.oceanmask`](@ref) and
210
210
[`Visualize.landmask`](@ref).
211
211
212
- !!! note Masking does not affect the colorbar. If you have values defined beneath the map,
213
- they can still affect the colorbar.
214
-
215
212
Additional arguments to the plotting and axis functions
216
213
=======================================================
217
214
@@ -287,10 +284,9 @@ The dimensions have to be longitude and latitude.
287
284
288
285
`mask` has to be an object that can be plotted by `Makie.poly`. `ClimaAnalysis` comes with
289
286
predefined masks, check out [`Visualize.oceanmask`](@ref) and [`Visualize.landmask`](@ref).
290
-
291
- !!! note
292
- Masking does not affect the colorbar. If you have values defined beneath the map, they
293
- can still affect the colorbar.
287
+ Also, the corresponding mask is applied to the `OutputVar`s. For instance, using
288
+ `Visualize.landmask` means `ClimaAnalysis.apply_landmask` is applied to the `OutputVar`s
289
+ when computing the bias.
294
290
295
291
Additional arguments to the plotting and axis functions
296
292
=======================================================
@@ -324,9 +320,14 @@ function Visualize.plot_bias_on_globe!(
324
320
:mask => Dict (),
325
321
),
326
322
)
327
- bias_var = ClimaAnalysis. bias (sim, obs)
323
+ apply_mask = _find_mask_to_apply (mask)
324
+
325
+ bias_var = ClimaAnalysis. bias (sim, obs, mask = apply_mask)
328
326
global_bias = round (bias_var. attributes[" global_bias" ], sigdigits = 3 )
329
- rmse = round (ClimaAnalysis. global_rmse (sim, obs), sigdigits = 3 )
327
+ rmse = round (
328
+ ClimaAnalysis. global_rmse (sim, obs, mask = apply_mask),
329
+ sigdigits = 3 ,
330
+ )
330
331
units = ClimaAnalysis. units (bias_var)
331
332
332
333
bias_var. attributes[" long_name" ] *= " (RMSE: $rmse $units , Global bias: $global_bias $units )"
@@ -375,4 +376,24 @@ function Visualize.plot_bias_on_globe!(
375
376
)
376
377
end
377
378
379
+ """
380
+ Return the appropriate mask to apply to a `OutputVar` from the plotting `mask`.
381
+
382
+ If `mask` is `Visualize.landmask()`, return `ClimaAnalysis.apply_landmask`. If `mask` is
383
+ `Visualize.oceanmask()`, return `ClimaAnalysis.apply_oceanmask`. In all other cases, return
384
+ nothing.
385
+ """
386
+ function _find_mask_to_apply (mask)
387
+ if isnothing (mask)
388
+ return nothing
389
+ elseif mask == Visualize. landmask ()
390
+ return ClimaAnalysis. apply_landmask
391
+ elseif mask == Visualize. oceanmask ()
392
+ return ClimaAnalysis. apply_oceanmask
393
+ else
394
+ @warn " Mask not recognized, overplotting it. The colorbar will not be correct"
395
+ return nothing
396
+ end
397
+ end
398
+
378
399
end
0 commit comments