-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds support for applying land/sea masks to GeoMakie plots. The masks are obtained directly from GeoMakie as a collection of polygons. For the ocean mask, we use bathymetry data at 0 elevation. Data is provided by `NaturalEarth.jl`. (I had to bump the minimum compat for GeoMakie to 0.7 because support `NaturalEarth.jl` was introduced in that release.) This new option is only aesthetics: it does change the underlying data (we simply overplot something else). This also means that the colorbar will include values under the mask. Applying the mask directly to the data is left for future work. Thanks @haakon-e for help with this feature.
- Loading branch information
Showing
11 changed files
with
163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Visualizing `OutputVar`s | ||
|
||
This page is under construction, in the meantime, consult [`Visualize`](@ref). | ||
|
||
### Masking part of the output in `GeoMakie` | ||
|
||
When performing ocean or land simulations, it is often convenient to hide the | ||
other component (e.g., hide the ocean and focus on the continents). For | ||
`GeoMakie` plots, there is a direct way to accomplish this. In this section, we | ||
discuss this feature. | ||
|
||
The main `GeoMakie` plots are [`Visualize.contour2D_on_globe!`](@ref) and | ||
[`Visualize.heatmap2D_on_globe!`](@ref). Both these functions take a `mask` argument. By | ||
default, `mask` is `nothing`, meaning that the entire output is displayed on the | ||
globe. Alternatively, `mask` can be a collection of polygons that can be plotted | ||
with [`Makie.poly`](https://docs.makie.org/v0.21/reference/plots/poly). | ||
`ClimaAnalysis` comes with the most important ones [`Visualize.oceanmask`](@ref) and | ||
[`Visualize.landmask`](@ref), to hide ocean and continents respectively. | ||
|
||
For example, suppose `var` it the variable we want to plot with a ocean mask | ||
```julia | ||
import ClimaAnalysis.Visualize: contour2D_on_globe!, oceanmask | ||
import ClimaAnalysis.Utils: kwargs as ca_kwargs | ||
import GeoMakie | ||
import CairoMakie | ||
|
||
fig = CairoMakie.Figure() | ||
|
||
contour2D_on_globe!(fig, | ||
var, | ||
mask = oceanmask(), | ||
more_kwargs = Dict(:mask => ca_kwargs(color = :blue)), | ||
) | ||
|
||
CairoMakie.save("myfigure.pdf", fig) | ||
``` | ||
|
||
In this example, we plotted `var` on the globe and overplotted a blue ocean. | ||
`ca_kwargs` (`Utils.kwargs`) is a convenience function to pass keyword arguments | ||
more easily. | ||
|
||
!!! note Masking does not affect the colorbar. If you have values defined | ||
beneath the map, they can still affect the colorbar. | ||
|
||
The output might look something like: | ||
|
||
![oceanmask](./assets/oceanmask.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters