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] Non-intuitive behavior if periodic not set as list #624

Open
dhruvbalwada opened this issue Mar 27, 2024 · 0 comments
Open

[BUG] Non-intuitive behavior if periodic not set as list #624

dhruvbalwada opened this issue Mar 27, 2024 · 0 comments
Labels

Comments

@dhruvbalwada
Copy link
Contributor

If the periodic argument to Grid is not passed as a list then the resultant grid object has non-intuitive result.

In example below user may expect both object to have only X dim as periodic. However, in case where list is given X dim is periodic and Z is non-periodic, while when the dimension is specified as string the option True is likely being used.

import xarray as xr
import numpy as np
from xgcm import Grid

ds = xr.Dataset(
    coords={
        "zl": (["zl"], np.arange(1,15)),
        "zi": (["zi"], np.arange(0.5, 15.5)),
        "xl": (["xl"], np.arange(1,15)),
        "xi": (["xi"], np.arange(0.5, 15.5)),
    }
)

grid_list = Grid(ds, 
            coords={"Z": {"center": 'zl', 'outer': 'zi'},
                    "X": {"center": 'xl', 'outer': 'xi'}},
           periodic=['X'])

grid_non_list = Grid(ds, 
            coords={"Z": {"center": 'zl', 'outer': 'zi'},
                    "X": {"center": 'xl', 'outer': 'xi'}},
           periodic='X')

The solution would be to raise an error to the user and force them to use a list, or automatically convert string to a list of a single value.

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

1 participant