-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update 2 coastal-alteration tools to be functions
The functions are in mpas_tools.ocean.coastline_alteration. The scripts in ocean/coastline_alteration still work the same as before by calling the functions.
- Loading branch information
Showing
5 changed files
with
130 additions
and
89 deletions.
There are no files selected for viewing
Empty file.
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,69 @@ | ||
from __future__ import absolute_import, division, print_function, \ | ||
unicode_literals | ||
|
||
import numpy | ||
|
||
|
||
def add_critical_land_blockages(dsMask, dsBlockages): | ||
''' | ||
Parameters | ||
---------- | ||
dsMask : `xarray.Dataset` | ||
The mask to which critical blockages should be added | ||
dsBlockage : `xarray.Dataset` | ||
The transect masks defining critical land regions that should block | ||
ocean flow (e.g. the Antarctic Peninsula) | ||
Returns | ||
------- | ||
dsMask : `xarray.Dataset` | ||
The mask with critical blockages included | ||
''' | ||
|
||
dsMask = dsMask.copy() | ||
|
||
nTransects = dsBlockages.sizes['nTransects'] | ||
for transectIndex in range(nTransects): | ||
dsMask.regionCellMasks[:, 0] = numpy.maximum( | ||
dsBlockages.transectCellMasks[:, transectIndex], | ||
dsMask.regionCellMasks[:, 0]) | ||
|
||
return dsMask | ||
|
||
|
||
def widen_transect_edge_masks(dsMask, dsMesh, latitude_threshold=43.0): | ||
''' | ||
Parameters | ||
---------- | ||
dsMask : `xarray.Dataset` | ||
The mask to which critical blockages should be added | ||
dsMesh : `xarray.Dataset` | ||
The transect masks defining critical land regions that should block | ||
ocean flow (e.g. the Antarctic Peninsula) | ||
latitude_threshold : float | ||
Minimum latitude, degrees, for transect widening | ||
Returns | ||
------- | ||
dsMask : `xarray.Dataset` | ||
The mask with critical blockages included | ||
''' | ||
latitude_threshold_radians = numpy.deg2rad(latitude_threshold) | ||
|
||
dsMask = dsMask.copy() | ||
|
||
maxEdges = dsMesh.sizes['maxEdges'] | ||
|
||
latMask = numpy.abs(dsMesh.latEdge) > latitude_threshold_radians | ||
|
||
edgeMask = numpy.logical_and( | ||
latMask, dsMask.transectEdgeMasks == 1) | ||
for iEdge in range(maxEdges): | ||
eoc = dsMesh.edgesOnCell[:, iEdge]-1 | ||
mask = numpy.logical_and(eoc >= 0, | ||
edgeMask[eoc]) | ||
# cells with a neighboring transect edge should be masked to 1 | ||
dsMask['transectCellMasks'] = dsMask.transectCellMasks.where( | ||
numpy.logical_not(mask), 1.) | ||
|
||
return dsMask |
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 @@ | ||
../../mpas_tools/ |
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