Skip to content

Commit d04d7ff

Browse files
committed
Fix grounding line mask definition when creating landice meshes
Fix grounding line mask definition, which previously marked the entire ocean as the grounding line used for setting cell widths.
1 parent fc31e1c commit d04d7ff

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

compass/landice/mesh.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from shutil import copyfile
66

77
import jigsawpy
8+
import matplotlib.pyplot as plt
89
import mpas_tools.io
910
import numpy as np
1011
import xarray
@@ -457,23 +458,37 @@ def get_dist_to_edge_and_gl(self, thk, topg, x, y,
457458
[1, 1], [-1, 1], [1, -1], [-1, -1]])
458459

459460
ice_mask = thk > 0.0
460-
grounded_mask = thk > (-1028.0 / 910.0 * topg)
461+
grounded_mask = np.logical_and(thk > (-1028.0 / 910.0 * topg),
462+
ice_mask)
463+
float_mask = np.logical_and(thk < (-1028.0 / 910.0 * topg),
464+
ice_mask)
461465
margin_mask = np.zeros(sz, dtype='i')
462466
grounding_line_mask = np.zeros(sz, dtype='i')
463467

464468
for n in neighbors:
465469
not_ice_mask = np.logical_not(np.roll(ice_mask, n, axis=[0, 1]))
466470
margin_mask = np.logical_or(margin_mask, not_ice_mask)
467471

468-
not_grounded_mask = np.logical_not(np.roll(grounded_mask,
469-
n, axis=[0, 1]))
472+
not_grounded_mask = np.logical_and(
473+
np.logical_not(np.roll(grounded_mask,
474+
n, axis=[0, 1])),
475+
np.roll(float_mask, n, axis=[0, 1]))
470476
grounding_line_mask = np.logical_or(grounding_line_mask,
471477
not_grounded_mask)
472478

473479
# where ice exists and neighbors non-ice locations
474480
margin_mask = np.logical_and(margin_mask, ice_mask)
475-
# optional - plot mask
476-
# plt.pcolor(margin_mask); plt.show()
481+
# where grounded ice exists and neighbors floating ice
482+
grounding_line_mask = np.logical_and(grounding_line_mask, grounded_mask)
483+
484+
fig, ax = plt.subplots(1, 2, sharex=True, sharey=True, figsize=(6, 3))
485+
margin_plot = ax[0].pcolor(margin_mask)
486+
gl_plot = ax[1].pcolor(grounding_line_mask) # noqa F841
487+
ax[0].set_title("margin mask")
488+
ax[1].set_title("grounding line mask")
489+
plt.colorbar(margin_plot, ax=[ax[0], ax[1]], shrink=0.7)
490+
[ax.set_aspect('equal') for ax in ax]
491+
fig.savefig("masks.png", dpi=400)
477492

478493
# Calculate dist to margin and grounding line
479494
[XPOS, YPOS] = np.meshgrid(x, y)

0 commit comments

Comments
 (0)