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

Xarray arguments for mean : skipna and keep_attrs #28

Closed
agstephens opened this issue Jul 17, 2020 · 0 comments · Fixed by #39
Closed

Xarray arguments for mean : skipna and keep_attrs #28

agstephens opened this issue Jul 17, 2020 · 0 comments · Fixed by #39
Assignees

Comments

@agstephens
Copy link
Collaborator

The Xarray mean method is:
http://xarray.pydata.org/en/stable/generated/xarray.DataArray.mean.html

It includes two optional arguments:

  • skipna - skip missing values (or not)
  • keep_attrs - keep variable attributes (or not)

Create some unit tests to help us understand the behaviour of each argument:

def test_xarray_da_mean_skipna_true():
  - create a simple 1D xarray.DataArray with 10 values of [10., 10., 10., 10., 10., nan, nan, nan, nan, nan]
  - test that the average is 2 if you use `skipna=True`

def test_xarray_da_mean_skipna_false():
  - create a simple 1D xarray.DataArray with 10 values of [10., 10., 10., 10., 10., nan, nan, nan, nan, nan]
  - test that the average is 1 if you use `skipna=False`

If the results are not as above, we need to investigate more.

def test_xarray_da_mean_keep_attrs_true():
  - read a variable from our mini-esgf-cache
  - average it with `mean` method across the time axis, with `keep_attrs=True`
  - assert the original attributes match the new attributes

def test_xarray_da_mean_keep_attrs_false():
  - read a variable from our mini-esgf-cache
  - average it with `mean` method across the time axis, with `keep_attrs=False`
  - examine the attributes of the resulting average DataArray
  - assert those values when you know them

Discuss with team whether we want to:
  1. Keep attrs
  2. Lose attrs
  3. Modify attrs (which might be: keep some then remove/edit/add others).

Keep these unit tests in our codebase anyway.

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

Successfully merging a pull request may close this issue.

2 participants