COSIMA / cosima-recipes

Example recipes for analyzing model output using the cosima-cookbook infrastructure
https://cosima-recipes.readthedocs.io
Apache License 2.0
43 stars 65 forks source link

xarray's `.mean()` function is simply an arithmetic mean #87

Open navidcy opened 4 years ago

navidcy commented 4 years ago

xarray's .mean(dim='dimension') is simply an arithmetic mean over that dimension. It does not take into account that, e.g., dimensions's coordinates could be on a non-uniform grid.

Remark(s) on the use of .mean() should be included in the notebooks.

Probably I'm duplicating old news here? This #12, #40, and #85 are related.

[While this may seem like triviality or common knowledge to pythonistas, newbies in xarray (like myself) may miss on reading the fine print in xarray's docs and work under the assumption that .mean() takes car of non-uniform grids.]

adele-morrison commented 2 months ago

Is this still relevant, or have we fixed this now?

navidcy commented 2 months ago

I think the issue is relevant. We have an example that shows the right way to take a zonal mean but I don't think this is how it's been implemented in all other examples that use zonal means. We should modify the example to actually do a zonal mean when they claim to do a zonal mean.