Skip to content

Fix grounding line mask definition when creating landice meshes#935

Open
trhille wants to merge 1 commit intoMPAS-Dev:mainfrom
trhille:fix_grounding_line_mask
Open

Fix grounding line mask definition when creating landice meshes#935
trhille wants to merge 1 commit intoMPAS-Dev:mainfrom
trhille:fix_grounding_line_mask

Conversation

@trhille
Copy link
Collaborator

@trhille trhille commented Feb 26, 2026

This merge fixes grounding line mask definition, which previously marked the entire ocean as the grounding line used for setting cell widths. It also saves maps of the margin and grounding-line masks, which will be helpful for debugging purposes when new maps are added or mask definitions are changed.

Checklist

  • Document (in a comment titled Testing in this PR) any testing that was used to verify the changes

Fix grounding line mask definition, which previously marked the entire
ocean as the grounding line used for setting cell widths.
@trhille
Copy link
Collaborator Author

trhille commented Feb 26, 2026

Testing

I tested this on the Greenland mesh with 4–40km resolution. Using thee previous definition of the grounding-line mask, we get a mask that is really a union of open ocean and floating ice masks:
Screenshot 2026-02-26 at 11 37 28 AM
Using this update, we get:
Screenshot 2026-02-26 at 12 22 50 PM

These maps are now saved as pngs in the mesh_gen case directory.

Note that this doesn't make much practical difference for the Greenland mesh, since we take the minimum of the distances to the grounding line and ice margin. The cell area using the previous grounding line mask is shown on the left (nCells = 29953), with the changes in this merge shown on the right (nCells = 29748 ):

image


not_grounded_mask = np.logical_not(np.roll(grounded_mask,
n, axis=[0, 1]))
not_grounded_mask = np.logical_and(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the most straightforward way to define this. I have trouble thinking through the logic with these rolled arrays. If @matthewhoffman or @xylar has ideas about making this simpler, I'd be happy to hear them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also find these things confusing. ChatGPT suggested this as an alternative:

shifted_grounded = np.roll(grounded_mask, n, axis=[0, 1])
shifted_float = np.roll(float_mask, n, axis=[0, 1])

not_grounded_mask = (~shifted_grounded) & shifted_float

Side question: would it be more accurate to rename not_grounded_mask to neighbor_not_grounded_mask?

@matthewhoffman
Copy link
Member

@trhille , the maps look great and I like that you are now saving them out. I am happy to approve & merge once we're happy with that question about the logic for the masks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants