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

Add option to allow degenerated grid cells #61

Merged
merged 1 commit into from
Oct 18, 2019
Merged

Conversation

JiaweiZhuang
Copy link
Owner

@JiaweiZhuang JiaweiZhuang commented Aug 14, 2019

Addresses #60

By using xe.Regridder(grid_in, grid_out, 'conservative', ignore_degenerate=True), ESMF won't throw an error when seeing degenerated cells like triangles. But it might give nan for such cells. Should probably still throw an error by default, as this helps detecting bad/illegal grid coordinates. Ref: #22 (comment).

@bradyrx could you see whether this works properly for your problem?

TODO:

  • Add a test

Welcome to contribute test cases.

@codecov-io
Copy link

codecov-io commented Aug 14, 2019

Codecov Report

Merging #61 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #61      +/-   ##
==========================================
+ Coverage   95.75%   95.76%   +0.01%     
==========================================
  Files           6        6              
  Lines         259      260       +1     
==========================================
+ Hits          248      249       +1     
  Misses         11       11
Impacted Files Coverage Δ
xesmf/backend.py 96% <ø> (ø) ⬆️
xesmf/frontend.py 93.98% <100%> (+0.04%) ⬆️

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 b811764...bf6075b. Read the comment docs.

@JiaweiZhuang
Copy link
Owner Author

JiaweiZhuang commented Aug 14, 2019

Weirdly, setting ignore_degenerate=False also seems to suppress the error. Only ignore_degenerate=None behaves as default / throws error. Not 100% sure what's happening under ESMPy...

I can add something like

if not ignore_degenerate:
    ignore_degenerate = None

so that both False and None will behave as default. Not sure worth fixing this in xesmf level. Maybe @bekozi can comment more.

@bradyrx
Copy link

bradyrx commented Aug 15, 2019

Thanks @JiaweiZhuang for the quick turnaround on this. I will give this a try over the weekend.

@bradyrx
Copy link

bradyrx commented Oct 16, 2019

Hi @JiaweiZhuang, this method works. Here is an updated gist: https://nbviewer.jupyter.org/gist/bradyrx/421627385666eefdb0a20567c2da9976. Note that this broke prior to using this keyword.

@JiaweiZhuang JiaweiZhuang merged commit 7479110 into master Oct 18, 2019
raphaeldussin added a commit to raphaeldussin/xESMF that referenced this pull request Jan 12, 2021
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.

3 participants