xgcm
xgcm copied to clipboard
validation of input dimensions sizes
It is currently possible to create Grid and Axis objects whose sizes are not compatible with xgcm's data model.
This should not be allowed
>>> ds = xr.Dataset(coords={'x_c': (['x_c',], np.arange(1,10)),
'x_g': (['x_g',], np.arange(0.5,9))})
>>> ds
<xarray.Dataset>
Dimensions: (x_c: 9, x_g: 9)
Coordinates:
* x_c (x_c) int64 1 2 3 4 5 6 7 8 9
* x_g (x_g) float64 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5
Data variables:
*empty*
>>> grid = Grid(ds, coords={'X': {'center': 'x_c', 'outer': 'x_g'}})
>>> grid
<xgcm.Grid>
X Axis (periodic):
* center x_c (9) --> outer
* outer x_g (9) --> center
According to our own docs, the outer position should have a length of 10. So this (and all similarly erroneous Grid / Axis creation operations) should raise errors.
I think this is relevant to #208. We should fix both with one PR.
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
This definitely needs fixing.