Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building regridders with masks #219

Merged
merged 30 commits into from
Mar 22, 2023

Conversation

stephenworsley
Copy link
Contributor

@stephenworsley stephenworsley commented Oct 20, 2022

Addresses #218 by having ESMF ignore masked points.

TODO

  • Handle the creation of "contiguous bounds" in a way which prioritises unmasked cells.
  • Consider a way to derive masks directly from cube masks.
  • Write a benchmark to demonstrate that ignoring discontiguities offers significant performance improvements.
  • extend support to unstructured regridders.
  • extend support to RefinedGridInfo.
  • Extend support to regridder load/save
  • Consider a way to derive masks directly from discontiguities in coordinates.
  • Consider a way to properly derive a mask from masked data (e.g. only using masks which are constant over all non-horizontal dimensions)

@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Merging #219 (b309b4a) into main (38f2b67) will increase coverage by 0.02%.
The diff coverage is 98.79%.

❗ Current head b309b4a differs from pull request most recent head e06c20e. Consider uploading reports for the commit e06c20e to get more accurate results

@@            Coverage Diff             @@
##             main     #219      +/-   ##
==========================================
+ Coverage   99.19%   99.22%   +0.02%     
==========================================
  Files          28       28              
  Lines        2871     3095     +224     
==========================================
+ Hits         2848     3071     +223     
- Misses         23       24       +1     
Impacted Files Coverage Δ
esmf_regrid/experimental/unstructured_regrid.py 97.36% <ø> (ø)
esmf_regrid/_esmf_sdo.py 96.51% <95.23%> (+1.02%) ⬆️
esmf_regrid/schemes.py 97.43% <97.26%> (-0.35%) ⬇️
esmf_regrid/esmf_regridder.py 95.45% <100.00%> (+0.06%) ⬆️
esmf_regrid/experimental/io.py 100.00% <100.00%> (ø)
esmf_regrid/experimental/unstructured_scheme.py 98.56% <100.00%> (+0.05%) ⬆️
.../tests/unit/experimental/io/test_round_tripping.py 100.00% <100.00%> (ø)
...nstructured_scheme/test_GridToMeshESMFRegridder.py 100.00% <100.00%> (ø)
...nstructured_scheme/test_MeshToGridESMFRegridder.py 100.00% <100.00%> (ø)
...sts/unit/schemes/test_ESMFAreaWeightedRegridder.py 100.00% <100.00%> (ø)
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link
Contributor

@SciTools-incubator/esmf-regrid-devs This pull-request is stale due to a lack of activity in the last 90 days. Remove stale label or comment, otherwise this pull-request will close automatically in 7 days time.

@github-actions github-actions bot added the Stale: Closure warning This stale issue or pull-request has been marked for closure label Jan 23, 2023
@github-actions
Copy link
Contributor

@Scit@SciTools-incubator/esmf-regrid-devs This stale pull-request has been automatically closed due to no community activity

@github-actions github-actions bot added the Stale: Closed This stale issue or pull-request has been closed due to no activity label Jan 30, 2023
@github-actions github-actions bot closed this Jan 30, 2023
@stephenworsley stephenworsley removed Stale: Closure warning This stale issue or pull-request has been marked for closure Stale: Closed This stale issue or pull-request has been closed due to no activity labels Feb 22, 2023
@stephenworsley stephenworsley linked an issue Feb 22, 2023 that may be closed by this pull request
@stephenworsley
Copy link
Contributor Author

The benchmarks run against a curvilinear grid with a row of degenerate cells which would cause the regridder to run slower. masking. Benchmarks are run with and without the mask being included. When the mask is included there are significant performance improvements (this may be even better when the cells are particularly bad). Note that this benchmarks with masks fails on main.
image

@trexfeathers trexfeathers self-requested a review March 7, 2023 10:10
@stephenworsley stephenworsley marked this pull request as ready for review March 9, 2023 13:47
Copy link
Contributor

@trexfeathers trexfeathers left a comment

Choose a reason for hiding this comment

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

I'm not quite done reviewing yet, but I wanted to give you some things to work on so you're not waiting on me.

Great idea!

esmf_regrid/_esmf_sdo.py Outdated Show resolved Hide resolved
esmf_regrid/esmf_regridder.py Outdated Show resolved Hide resolved
esmf_regrid/experimental/io.py Outdated Show resolved Hide resolved
esmf_regrid/experimental/io.py Outdated Show resolved Hide resolved
esmf_regrid/experimental/io.py Outdated Show resolved Hide resolved
esmf_regrid/experimental/unstructured_scheme.py Outdated Show resolved Hide resolved
benchmarks/benchmarks/esmf_regridder/__init__.py Outdated Show resolved Hide resolved
benchmarks/benchmarks/esmf_regridder/__init__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@trexfeathers trexfeathers left a comment

Choose a reason for hiding this comment

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

Here's the rest of my review.

Is there merit in replacing NumPy operations on the masks with Dask Array operations? Some Cube masks can be very large.

esmf_regrid/schemes.py Outdated Show resolved Hide resolved
esmf_regrid/schemes.py Outdated Show resolved Hide resolved
esmf_regrid/schemes.py Outdated Show resolved Hide resolved
esmf_regrid/schemes.py Show resolved Hide resolved
esmf_regrid/schemes.py Outdated Show resolved Hide resolved
esmf_regrid/schemes.py Show resolved Hide resolved
esmf_regrid/schemes.py Outdated Show resolved Hide resolved
esmf_regrid/schemes.py Show resolved Hide resolved
benchmarks/benchmarks/generate_data.py Outdated Show resolved Hide resolved
@trexfeathers
Copy link
Contributor

Apologies, I know I can get a bit evangelical about D.R.Y. code, but do I feel this PR makes a very strong case for more effort in this space.

I believe I have the second-most experience with this codebase, but all the layers and parallel changes made me get quite lost during review. I'm also going to find it difficult to confirm which of my suggestions have been actioned, as the action will need to be mirrored in an uncertain number of places. Also, if I wanted to make an enhancement like this, I doubt I would be successful in remembering all the different places a change needed to be made.

D.R.Y. takes longer to get working, and I appreciate that's work that could otherwise be spent on new features, but it makes future work quicker, easier and less error-prone. This is all doubly true when it comes to developers who are not the original author. I'm basically describing Technical Debt. I know there are already some ideas in the pipeline (#198); take this as my vote for expediting that as well as going further; let's pay off that debt sooner before we pay much more Interest 👍.

Cc @pp-mo as the buddy for iris-esmf-regrid.

@valeriupredoi
Copy link

just plopping myself here to say hi and good work on this, guys! Looking forward to see this and the other features, including the handling of the new esmpy in an upcoming release 🍻

Copy link
Contributor

@trexfeathers trexfeathers left a comment

Choose a reason for hiding this comment

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

Looking good... here are my new comments.

esmf_regrid/experimental/unstructured_scheme.py Outdated Show resolved Hide resolved
esmf_regrid/experimental/io.py Show resolved Hide resolved
esmf_regrid/experimental/unstructured_scheme.py Outdated Show resolved Hide resolved
esmf_regrid/experimental/unstructured_scheme.py Outdated Show resolved Hide resolved
esmf_regrid/experimental/unstructured_scheme.py Outdated Show resolved Hide resolved
esmf_regrid/schemes.py Outdated Show resolved Hide resolved
esmf_regrid/schemes.py Outdated Show resolved Hide resolved
esmf_regrid/experimental/unstructured_scheme.py Outdated Show resolved Hide resolved
esmf_regrid/tests/unit/schemes/test__cube_to_GridInfo.py Outdated Show resolved Hide resolved
esmf_regrid/schemes.py Outdated Show resolved Hide resolved
stephenworsley and others added 2 commits March 22, 2023 14:38
Co-authored-by: Martin Yeo <40734014+trexfeathers@users.noreply.github.com>
Copy link
Contributor

@trexfeathers trexfeathers left a comment

Choose a reason for hiding this comment

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

@stephenworsley
Copy link
Contributor Author

This should have a CHANGELOG entry:

I've decided to add an entry for #241 while I was there.

@trexfeathers trexfeathers merged commit b22062d into SciTools:main Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Handle discontiguities and "bad geometries" hiding under masks
3 participants