Skip to content

Speed up landice gridded_flood_fill with scipy.ndimage#948

Open
trhille wants to merge 2 commits intoMPAS-Dev:mainfrom
trhille:landice/speed_up_gridded_flood_fill
Open

Speed up landice gridded_flood_fill with scipy.ndimage#948
trhille wants to merge 2 commits intoMPAS-Dev:mainfrom
trhille:landice/speed_up_gridded_flood_fill

Conversation

@trhille
Copy link
Copy Markdown
Collaborator

@trhille trhille commented Mar 26, 2026

Speed up gridded_flood_fill with scipy.ndimage instead of nested loops. For the antarctica_8km_2024_01_29.nc, this reduced the time from about 7s to 0.005s. This could make it much more manageable to use high-resolution gridded data sets to determine cell spacing for large meshes.

Checklist

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

@trhille
Copy link
Copy Markdown
Collaborator Author

trhille commented Mar 26, 2026

Testing

When using the antarctica_1km_2024_01_29.nc source file, the current implementation of landice.mesh.gridded_flood_fill in main takes 495.47 seconds. With these changes, it takes 0.32 seconds.
@xylar @matthewhoffman, I think you'll like this :)

I still need to confirm that these result in similar masks.

@matthewhoffman matthewhoffman added land ice in progress This PR is not ready for review or merging labels Mar 29, 2026
@matthewhoffman matthewhoffman marked this pull request as draft March 29, 2026 16:45
trhille added 2 commits April 20, 2026 09:20
Speed up gridded_flood_fill with scipy.ndimage instead of nested
loops. For the antarctica_8km_2024_01_29.nc, this reduced the time from
about 7s to 0.005s. This could make it much more manageable to use
high-resolution gridded data sets to determine cell spacing for
large meshes.
@trhille trhille force-pushed the landice/speed_up_gridded_flood_fill branch from 20fa45e to bfdd243 Compare April 20, 2026 16:20
@trhille
Copy link
Copy Markdown
Collaborator Author

trhille commented Apr 20, 2026

Here are results for the 3–30km GIS mesh, using the head of main (left) and the head of this branch (right). Results Both meshes have nCells = 54173 and areaCell fields are identical between the two. Using this branch, gridded_flood_fill took 0.0086 seconds; using main it took 7.55 s.

image

@trhille trhille requested a review from matthewhoffman April 20, 2026 16:55
@trhille trhille removed in progress This PR is not ready for review or merging labels Apr 20, 2026
@trhille trhille marked this pull request as ready for review April 20, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants