{"action":"created","issue":{"url":"https://api.github.com/repos/xray/xray/issues/442","labels_url":"https://api.github.com/repos/xray/xray/issues/442/labels{/name}","comments_url":"https://api.github.com/repos/xray/xray/issues/442/comments","events_url":"https://api.github.com/repos/xray/xray/issues/442/events","html_url":"https://github.com/xray/xray/issues/442","id":90658514,"number":442,"title":"NetCDF attributes like `long_name` and `units` lost on `.mean()`","user":{"login":"j08lue","id":3404817,"avatar_url":"https://avatars.githubusercontent.com/u/3404817?v=3","gravatar_id":"","url":"https://api.github.com/users/j08lue","html_url":"https://github.com/j08lue","followers_url":"https://api.github.com/users/j08lue/followers","following_url":"https://api.github.com/users/j08lue/following{/other_user}","gists_url":"https://api.github.com/users/j08lue/gists{/gist_id}","starred_url":"https://api.github.com/users/j08lue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j08lue/subscriptions","organizations_url":"https://api.github.com/users/j08lue/orgs","repos_url":"https://api.github.com/users/j08lue/repos","events_url":"https://api.github.com/users/j08lue/events{/privacy}","received_events_url":"https://api.github.com/users/j08lue/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-24T12:14:30Z","updated_at":"2015-06-25T18:30:45Z","closed_at":null,"body":"When reading in a variable from netCDF, the standard attributes like `long_name`, `standard_name`, and `units` are being propagated, but apparently lost when calling ~~`.load()`~~ `.mean()` on the `DataArray`.\r\n\r\nCouldn't these CF-[Highly Recommended Variable Attributes](http://wiki.esipfed.org/index.php/Attribute_Convention_for_Data_Discovery#Highly_Recommended_Variable_Attributes) be kept during this operation?\r\n\r\n(What to do with them afterwards, e.g. upon merge, is a different question, [unresolved also in the pandas community](https://github.com/pydata/pandas/issues/2485).)\r\n\r\nEDIT: the problem actually occurs when calling `.mean()` (not `.load()`, as originally posted)."},"comment":{"url":"https://api.github.com/repos/xray/xray/issues/comments/115356215","html_url":"https://github.com/xray/xray/issues/442#issuecomment-115356215","issue_url":"https://api.github.com/repos/xray/xray/issues/442","id":115356215,"user":{"login":"shoyer","id":1217238,"avatar_url":"https://avatars.githubusercontent.com/u/1217238?v=3","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"created_at":"2015-06-25T18:30:45Z","updated_at":"2015-06-25T18:30:45Z","body":"Ah. So this is intentional. `.mean()` does have an optional parameter that lets you control this -- try `.mean(keep_attrs=True)`.\r\n\r\nThe basic problem is that it's ambiguous how to handle attributes like units after doing computation. I don't want to inspect attributes and choose some to preserve and others to remove, so we have a choice of either preserving all attributes in an operation or removing all of them.\r\n\r\nObviously, for some aggregations (e.g., `sum` or `var`) it doesn't make sense to preserve attributes (which commonly include units). I suppose we could make an exception for aggregations like mean/median/std, but it's also weird to have some aggregations that preserve attributes and others that don't."}}