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

[BUG] Default boundary condition is periodic even when specified otherwise #604

Open
dhruvbalwada opened this issue May 3, 2023 · 4 comments
Labels

Comments

@dhruvbalwada
Copy link
Contributor

dhruvbalwada commented May 3, 2023

The issue: Even when xgcm has been told that a coordinate is not periodic, it still chooses that as the default behavior if no explicit boundary information is passed - instead of throwing an error or warning.

import xarray as xr 
import xgcm
import numpy as np

dx = 0.5
L = 20
x_left = np.arange(0,L-dx, dx)
x = np.arange(dx, L, dx)

slope = 2.
y = slope*x

da_y = xr.DataArray(y, dims=['xc'], coords={'xc':x})
ds_y = xr.Dataset(coords={'xc':x, 'xg':x_left})
ds_y['y'] = da_y

grid = xgcm.Grid(ds_y, 
                 coords={"X": {"center": "xc", "left": "xg"}},
                periodic=None)

dy_default = grid.diff(ds_y.y, 'X')
dy = grid.diff(ds_y.y, 'X', boundary='extend')

In this example we told grid that X is not a periodic direction. When we print grid, it says that X is not periodic. However, the dy_default (where we did not pass a boundary condition) still assumes X is periodic without alerting the user.

@dhruvbalwada
Copy link
Contributor Author

Might be related to #509

@hdrake
Copy link

hdrake commented Sep 1, 2023

Confirming I'm running into this same issue.

@jbusecke
Copy link
Contributor

Is this fixed by using the boundary= input syntax? In that case deprecation of periodic might be the solution here.

@hdrake
Copy link

hdrake commented Apr 11, 2024

Is this fixed by using the boundary= input syntax? In that case deprecation of periodic might be the solution here.

Yep–see #606 (comment).

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

No branches or pull requests

3 participants