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

3-d conservative regridding #814

Open
brogalla opened this issue Sep 12, 2024 · 3 comments
Open

3-d conservative regridding #814

brogalla opened this issue Sep 12, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@brogalla
Copy link

Follow up from issue #715 : maybe this is already planned, but it would be very nice if there was an option for 3-d conservative regridding in addition to the recently added 3-d bilinear spherical regridding (ESMPy seems to have this as an option).

@brogalla brogalla added the enhancement New feature or request label Sep 12, 2024
@sadielbartholomew
Copy link
Member

sadielbartholomew commented Sep 13, 2024

Thanks Birgit, firstly sorry it seems David and myself missed your comment on the issue you link - we get a lot of traffic on GitHub so sometimes comments can get lost in the noise.

As far as I can tell from the code and according to our test suite, conservative is supported already as a regridding method with the 3D, vertical coordinate inclusive, case, for both of the spherical (regrids) or Cartesian (regridc) cases. So, unless I am missing something, you should be able to just specify it as the method, like so (and equivalently with regrids):

regridded_f = src_f.regridc(dst_f, axes='Z', method='conservative', z='Z', <plus any other keyword arguments you want>)

where you have to identify the specific z coordinate with e.g. here 'Z' as the identifier, and often you will want to include ln_z=True to the other argument inputs for 3D regridding.

For conservative regridding to work you will need bounds defined for all of the coordinates involved including the 'z'/vertical ones, though, and note 3D regridding won't work for certain cases such as DSG fields.

I am wondering about the background here - did you run into a specific error or issue when you tried to do conservative 3D regridding with cf? If so please let us know and we can guide. (There may be some other limitations I am not aware of.)

@brogalla
Copy link
Author

Hi Sadie, no problem at all -- and sorry for my delayed response.

I see! I tested the 'linear' 3D regridding and it worked fine, but I ran into errors when I tried conservative 3D regridding (2D conservative regridding worked fine). Then, while reading the documentation, I misinterpreted the comment that the vertical regridding can be done with linear weights to mean that the 3D regridding was only set up for the "linear" method, so I figured that was the cause of my issues. But, I think I just setup the conservative regridding incorrectly (probably something about the vertical coordinate bounds). I will try a simplified test case and let you know if I still run into issues. Again thanks for the help!

@sadielbartholomew
Copy link
Member

Thanks @brogalla. I hope it all works and we will assume so if we don' hear back, but yes, please do let us know in the case it doesn't work like you wish it to or if the documentation isn't clear enough about how to specify what you want in this respect (a separate but related issue which is just as important in my view), for example if we could add more examples to showcase how it can be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants