-
Notifications
You must be signed in to change notification settings - Fork 14
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
Switch to mosaic
for all plotting functionality
#256
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f3c5f5a
Switch to `mosaic` for planar plotting.
andrewdnolan ebbb966
Swith to `mosaic` for spherical mesh plotting.
andrewdnolan b46ec7e
Update dependencies for `mosaic` and bump alpha version.
andrewdnolan 049035f
Use mosaic for vertex plotting instead of tricontourf.
andrewdnolan 19c6c59
Add title to spherical plots if provided.
andrewdnolan 65c0354
Apply suggestions from code review
andrewdnolan 49f414f
More suggestions from code review.
andrewdnolan d9382af
Update documentation for mosaic based visualization.
andrewdnolan 11c9a5d
Use discrete colorbar for plotting barotropic stream function
andrewdnolan 394fa42
Bump mosaic version and let mosaic set axis limits for periodic axes
andrewdnolan f4ffbb7
Bump alpha version following rebase
andrewdnolan 9684bea
Undo tight axis limits for periodic plots (for now).
andrewdnolan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,6 +297,7 @@ seaice/api | |
:toctree: generated/ | ||
|
||
area_for_field | ||
cell_mask_to_edge_mask | ||
time_index_from_xtime | ||
``` | ||
|
||
|
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from polaris.mpas.area import area_for_field | ||
from polaris.mpas.mask import cell_mask_to_edge_mask | ||
from polaris.mpas.time import time_index_from_xtime, time_since_start |
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,35 @@ | ||
|
||
def cell_mask_to_edge_mask(ds_mesh, cell_mask): | ||
"""Convert a cell mask to edge mask using mesh connectivity information | ||
|
||
True corresponds to valid cells and False are invalid cells | ||
|
||
Parameters | ||
---------- | ||
ds_mesh : xarray.Dataset | ||
The MPAS mesh | ||
|
||
cell_mask : xarray.DataArray | ||
The cell mask we want to convert to an edge mask | ||
|
||
|
||
Returns | ||
------- | ||
edge_mask : xarray.DataArray | ||
The edge mask corresponding to the input cell mask | ||
""" | ||
|
||
# test if any are False | ||
if ~cell_mask.any(): | ||
return ds_mesh.nEdges > -1 | ||
|
||
# zero index the connectivity array | ||
cells_on_edge = (ds_mesh.cellsOnEdge - 1) | ||
|
||
# using nCells (dim) instead of indexToCellID since it's already 0 indexed | ||
masked_cells = ds_mesh.nCells.where(~cell_mask, drop=True).astype(int) | ||
|
||
# use inverse so True/False convention matches input cell_mask | ||
edge_mask = ~cells_on_edge.isin(masked_cells).any("TWO") | ||
|
||
return edge_mask |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that there has to be unmasked cells on either side of an edge for it to be valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there does have to be unmasked cells on either side of an edge, but not both, for it to be valid.
With the
cells_on_edge
array being zero based, boundary edges will have one entry that's>= 0
and one-1
entry. The int arraymasked_cells
is zero based as well, so a value of-1
can never be in it. So, theisin
condition will never be true for the missing cell along boundary edges. Therefore, theedge_mask
will only ever be true for a boundary edge if the one valid cell on the edge isTrue
in thecell_mask
that's passed to the function.