-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to
mosaic
for planar plotting.
- Interface to the `plot_horiz_field` has been simplified slightly. - The mask array now must be the same shape as the input field array. - Added a framework function to convert a cell mask to and edge mask.
- Loading branch information
1 parent
d6bc3a1
commit 260b8cf
Showing
10 changed files
with
148 additions
and
268 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
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_2_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_2_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 | ||
cellsOnEdge = (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 = ~cellsOnEdge.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
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
Oops, something went wrong.