JiaweiZhuang / xESMF

Universal Regridder for Geospatial Data
http://xesmf.readthedocs.io/
MIT License
269 stars 49 forks source link

Implement ESMpy mask handling #23

Closed jhamman closed 1 year ago

jhamman commented 6 years ago

This comes from the discussion in #22. It is intended to help users specify masks for the valid cells in the source and/or destination grids. It does this in the following way:

I've been testing this and it seems to be headed in the right direction. There are certainly additional features/tests/docs that this will need but I'm putting up here to aid in our discussion.

codecov-io commented 6 years ago

Codecov Report

Merging #23 into master will decrease coverage by 0.21%. The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #23      +/-   ##
==========================================
- Coverage   95.19%   94.97%   -0.22%     
==========================================
  Files           6        6              
  Lines         229      239      +10     
==========================================
+ Hits          218      227       +9     
- Misses         11       12       +1
Impacted Files Coverage Δ
xesmf/frontend.py 93.75% <100%> (+0.23%) :arrow_up:
xesmf/backend.py 94.8% <85.71%> (-0.97%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 97ec30a...bf712c0. Read the comment docs.

jhamman commented 6 years ago

Here's the same example I showed in #22, but using a mask.

image

I haven't figured out yet how to mask the grid cells with nans where there were no valid weights. Perhaps @bekozi knows where to get that info from the ESMpy objects?

bekozi commented 6 years ago

I haven't figured out yet how to mask the grid cells with nans where there were no valid weights. Perhaps @bekozi knows where to get that info from the ESMpy objects?

We could potentially pull in the unmapped destination list to ESMPy, but I think it is easier to use fill values (or nans) during the sparse matrix multiplication. Basically, fill the destination matrix with nans before applying the sparse matrix. Afterwards, if the masks are set up correctly, only the mapped values will be non-nan. See filling and finding for mildly relevant examples.

JiaweiZhuang commented 6 years ago

Thanks for the PR (the first PR for xESMF)!

I still have some concerns: https://github.com/JiaweiZhuang/xESMF/issues/22#issuecomment-400175414. Let's continue the discussion in the main issue.

rabernat commented 4 years ago

@jhamman - this PR was discussed today at the xESMF dev meeting. There was a consensus that it's a very important feature.

Could you let us know whether you plan to keep working on the PR? Do you need any help from the dev team? If you don't have time to finish it, let us know so someone else can take it over.

jhamman commented 4 years ago

Thanks for the ping. I'm not likely to have time to pick this up in the near future so would welcome someone else stepping in if there is time/interest.

rabernat commented 4 years ago

What is the difference between this and #82? Does that supersede this?

If we want to move forward with this PR, I recommend it be moved to https://github.com/pangeo-data/xESMF? Unfortunately this has to be done manually.

raphaeldussin commented 4 years ago

Comparing across forks:

JiaweiZhuang:masking is up to date with all commits from jhamman:feature/masks.

so this PR can be closed