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

Automatically generate a masking function using a OutputVar #141

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

ph-kev
Copy link
Member

@ph-kev ph-kev commented Oct 22, 2024

closes #137 - This PR adds the function Var.make_lonlat_mask which automatically generate a mask from a OutputVar. Additionally, one can specify the masking function when plotting the bias. See the plots below where a custom masking function (for computing the bias) is specified with an ocean mask (for visual purposes) for the plot.
plot_bias_with_custom_mask

The mask parameter now takes in a masking function or the predefined masks Visualize.oceanmask() and Visualize.landmask(). If Visualize.oceanmask() and Visualize.landmask() are used, then the corresponding masking function for the OutputVar is chosen. If a masking function is used, then no mask for visual is used. In all other cases, it is assumed that the mask being used is for visuals and a warning is displayed that it will be overplotted and the colorbar might be wrong.

Copy link

codecov bot commented Oct 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.25%. Comparing base (0202156) to head (54daa37).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #141      +/-   ##
==========================================
+ Coverage   98.22%   98.25%   +0.03%     
==========================================
  Files          11       11              
  Lines        1125     1149      +24     
==========================================
+ Hits         1105     1129      +24     
  Misses         20       20              

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

@ph-kev ph-kev requested a review from Sbozzolo October 22, 2024 23:05
@ph-kev ph-kev force-pushed the kp/auto-generate-masks branch 4 times, most recently from a418913 to 2640c42 Compare October 25, 2024 20:08
Refactor `_apply_lonlat_mask` to call `make_lonlat_mask`.
@ph-kev ph-kev marked this pull request as draft October 25, 2024 22:16
@ph-kev ph-kev marked this pull request as ready for review October 25, 2024 22:16
@ph-kev ph-kev force-pushed the kp/auto-generate-masks branch 2 times, most recently from dec436f to 4db1f19 Compare October 25, 2024 22:24
docs/src/var.md Outdated
Comment on lines 287 to 288
`set_to_zero` returns `True`, then the value will be `0` in the mask and if `set_to_zero`
returns `False`, then the value will be `1` in the mask. See the example below of this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`set_to_zero` returns `True`, then the value will be `0` in the mask and if `set_to_zero`
returns `False`, then the value will be `1` in the mask. See the example below of this
`set_to_zero` returns `true`, then the value will be `0` in the mask and if `set_to_zero`
returns `false`, then the value will be `1` in the mask. See the example below of this

@ph-kev ph-kev force-pushed the kp/auto-generate-masks branch from 4db1f19 to f3fe7af Compare October 25, 2024 23:24
The parameter `mask` for `plot_bias_on_globe!` now takes in either a
mask used for visualizing (e.g. `Visualize.landmask`,
`Visualize.oceanmask` or a vector of polygons) or a mask function (e.g.
`Var.apply_landmask`, `Var.apply_oceanmask`, or a custom masking
function).
@ph-kev ph-kev force-pushed the kp/auto-generate-masks branch from f3fe7af to 54daa37 Compare October 25, 2024 23:38
@ph-kev ph-kev merged commit 1b6fdea into CliMA:main Oct 25, 2024
9 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.

Automatically generate masks from OutputVar
2 participants