Skip to content

Commit

Permalink
Clear c_grid_axis_shift from attrs when destaggering (#106)
Browse files Browse the repository at this point in the history
Co-authored-by: Anderson Banihirwe <[email protected]>
  • Loading branch information
jthielen and andersy005 authored Sep 20, 2022
1 parent 65172e5 commit 04473a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tests/test_accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ def test_dataarray_destagger_with_postprocess(test_grid):
# Check staggered to unstaggered dimension coordinate handling
xr.testing.assert_allclose(destaggered['x'], postprocessed['x'])

# Check attributes are preserved
# Check attributes are preserved, other than those made invalid by destaggering
assert set(destaggered.attrs.keys()) == set(data.attrs.keys()) - {
'stagger',
}
assert 'c_grid_axis_shift' not in destaggered['x'].attrs


@pytest.mark.parametrize('test_grid', ['lambert_conformal', 'mercator'], indirect=True)
Expand Down
2 changes: 1 addition & 1 deletion xwrf/destagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _destag_variable(datavar, stagger_dim=None, unstag_dim_name=None):
return xr.Variable(
dims=tuple(str(unstag_dim_name) if dim == stagger_dim else dim for dim in center_mean.dims),
data=center_mean.data,
attrs=_drop_attrs(datavar.attrs, ('stagger',)),
attrs=_drop_attrs(datavar.attrs, ('stagger', 'c_grid_axis_shift')),
encoding=datavar.encoding,
fastpath=True,
)
Expand Down

0 comments on commit 04473a7

Please sign in to comment.