|
5 | 5 | from shutil import copyfile |
6 | 6 |
|
7 | 7 | import jigsawpy |
| 8 | +import matplotlib.pyplot as plt |
8 | 9 | import mpas_tools.io |
9 | 10 | import numpy as np |
10 | 11 | import xarray |
@@ -457,23 +458,37 @@ def get_dist_to_edge_and_gl(self, thk, topg, x, y, |
457 | 458 | [1, 1], [-1, 1], [1, -1], [-1, -1]]) |
458 | 459 |
|
459 | 460 | 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) |
461 | 465 | margin_mask = np.zeros(sz, dtype='i') |
462 | 466 | grounding_line_mask = np.zeros(sz, dtype='i') |
463 | 467 |
|
464 | 468 | for n in neighbors: |
465 | 469 | not_ice_mask = np.logical_not(np.roll(ice_mask, n, axis=[0, 1])) |
466 | 470 | margin_mask = np.logical_or(margin_mask, not_ice_mask) |
467 | 471 |
|
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])) |
470 | 476 | grounding_line_mask = np.logical_or(grounding_line_mask, |
471 | 477 | not_grounded_mask) |
472 | 478 |
|
473 | 479 | # where ice exists and neighbors non-ice locations |
474 | 480 | 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) |
477 | 492 |
|
478 | 493 | # Calculate dist to margin and grounding line |
479 | 494 | [XPOS, YPOS] = np.meshgrid(x, y) |
|
0 commit comments