Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for overplotting a ocean/land mask with GeoMakie #72

Merged
merged 2 commits into from
Sep 1, 2024

Conversation

Sbozzolo
Copy link
Member

@Sbozzolo Sbozzolo commented Aug 31, 2024

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.

image

If `attributes["units"]` is not a string, we cannot `uparse` it. This happens
all the times we return a new `OutputVar` from one we have already processed.

This commit adds a check that accounts for this case too. In this case, we just
have to return the value.
Copy link

codecov bot commented Aug 31, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Project coverage is 16.84%. Comparing base (0a024c7) to head (b2da5d8).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
ext/ClimaAnalysisGeoMakieExt.jl 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #72       +/-   ##
===========================================
- Coverage   96.35%   16.84%   -79.51%     
===========================================
  Files           9        9               
  Lines         548      558       +10     
===========================================
- Hits          528       94      -434     
- Misses         20      464      +444     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Sbozzolo Sbozzolo force-pushed the gb/oceanmask branch 3 times, most recently from 8a15bd8 to 036fc41 Compare September 1, 2024 00:03
@AlexisRenchon
Copy link
Member

oooh that's cool!!

@AlexisRenchon
Copy link
Member

"Applying the mask directly to the data is left for future work"

we could make it a clear outlier and use lowclip or highclip in the heatmaps, then build the colorbar without outlier (by building it independently), e.g.

ax, hm = heatmap(fig[1, 1], xs, ys, zs, colormap = :something,
    colorrange = (-x, y), lowclip = :blue)
Colorbar(fig[1, 4], limits = (-x, y), colormap=:something)

https://docs.makie.org/stable/reference/blocks/colorbar#colorbar

@Sbozzolo
Copy link
Member Author

Sbozzolo commented Sep 1, 2024

"Applying the mask directly to the data is left for future work"

we could make it a clear outlier and use lowclip or highclip in the heatmaps, then build the colorbar without outlier (by building it independently), e.g.

ax, hm = heatmap(fig[1, 1], xs, ys, zs, colormap = :something,
    colorrange = (-x, y), lowclip = :blue)
Colorbar(fig[1, 4], limits = (-x, y), colormap=:something)

https://docs.makie.org/stable/reference/blocks/colorbar#colorbar

My plan is to create an OutputVar from a land/sea mask so that it can be used beyond plotting.

@Sbozzolo Sbozzolo force-pushed the gb/oceanmask branch 2 times, most recently from 1df83f3 to 7d42770 Compare September 1, 2024 20:34
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.
@Sbozzolo Sbozzolo merged commit d15e6ba into main Sep 1, 2024
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants