|
6 | 6 | from shutil import copyfile |
7 | 7 |
|
8 | 8 | import jigsawpy |
| 9 | +import matplotlib.pyplot as plt |
9 | 10 | import mpas_tools.io |
10 | 11 | import numpy as np |
11 | 12 | import xarray |
@@ -514,23 +515,36 @@ def get_dist_to_edge_and_gl(self, thk, topg, x, y, |
514 | 515 | [1, 1], [-1, 1], [1, -1], [-1, -1]]) |
515 | 516 |
|
516 | 517 | ice_mask = thk > 0.0 |
517 | | - grounded_mask = thk > (-1028.0 / 910.0 * topg) |
| 518 | + grounded_mask = np.logical_and(thk > (-1028.0 / 910.0 * topg), |
| 519 | + ice_mask) |
| 520 | + float_mask = np.logical_and(thk < (-1028.0 / 910.0 * topg), |
| 521 | + ice_mask) |
518 | 522 | margin_mask = np.zeros(sz, dtype='i') |
519 | 523 | grounding_line_mask = np.zeros(sz, dtype='i') |
520 | 524 |
|
521 | 525 | for n in neighbors: |
522 | | - not_ice_mask = np.logical_not(np.roll(ice_mask, n, axis=[0, 1])) |
523 | | - margin_mask = np.logical_or(margin_mask, not_ice_mask) |
| 526 | + shifted_ice = np.roll(ice_mask, n, axis=[0, 1]) |
| 527 | + margin_mask = np.logical_or(margin_mask, ~shifted_ice) |
524 | 528 |
|
525 | | - not_grounded_mask = np.logical_not(np.roll(grounded_mask, |
526 | | - n, axis=[0, 1])) |
| 529 | + shifted_grounded = np.roll(grounded_mask, n, axis=[0, 1]) |
| 530 | + shifted_float = np.roll(float_mask, n, axis=[0, 1]) |
| 531 | + not_grounded_mask = (~shifted_grounded) & shifted_float |
527 | 532 | grounding_line_mask = np.logical_or(grounding_line_mask, |
528 | 533 | not_grounded_mask) |
529 | 534 |
|
530 | 535 | # where ice exists and neighbors non-ice locations |
531 | 536 | margin_mask = np.logical_and(margin_mask, ice_mask) |
532 | | - # optional - plot mask |
533 | | - # plt.pcolor(margin_mask); plt.show() |
| 537 | + # where grounded ice exists and neighbors floating ice |
| 538 | + grounding_line_mask = np.logical_and(grounding_line_mask, grounded_mask) |
| 539 | + |
| 540 | + fig, ax = plt.subplots(1, 2, sharex=True, sharey=True, figsize=(6, 3)) |
| 541 | + margin_plot = ax[0].pcolor(margin_mask) |
| 542 | + gl_plot = ax[1].pcolor(grounding_line_mask) # noqa F841 |
| 543 | + ax[0].set_title("margin mask") |
| 544 | + ax[1].set_title("grounding line mask") |
| 545 | + plt.colorbar(margin_plot, ax=[ax[0], ax[1]], shrink=0.7) |
| 546 | + [ax.set_aspect('equal') for ax in ax] |
| 547 | + fig.savefig("masks.png", dpi=400) |
534 | 548 |
|
535 | 549 | # Calculate dist to margin and grounding line |
536 | 550 | [XPOS, YPOS] = np.meshgrid(x, y) |
|
0 commit comments