html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/358#issuecomment-291611335,https://api.github.com/repos/pydata/xarray/issues/358,291611335,MDEyOklzc3VlQ29tbWVudDI5MTYxMTMzNQ==,1217238,2017-04-04T19:46:39Z,2017-04-04T20:37:12Z,MEMBER,"Yes, looks pretty good. It would be nice to consolidate this with xarray's current logic for getting virtual datetime variables (they should probably delegate to the accessor): https://github.com/pydata/xarray/blob/94790388c273c0c1ce2c203940a706d331deb14f/xarray/core/dataset.py#L41 > I wonder, is there any way to register such an accessor with DataArrays that have a specific dtype? The simplest option is to raise `AttributeError` or `TypeError` in the constructor, e.g., ```python @xarray.register_dataarray_accessor('float_only') class FloatOnlyAccessor(object): def __init__(self, parent): if parent.dtype.kind != 'f': raise TypeError('wrong dtype') self.parent = parent ``` ``` >>> xarray.DataArray(1.5).float_only <__main__.FloatOnlyAccessor at 0x8d51350> >>> xarray.DataArray(1).float_only TypeError: wrong dtype ```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,59720901 https://github.com/pydata/xarray/issues/358#issuecomment-291232960,https://api.github.com/repos/pydata/xarray/issues/358,291232960,MDEyOklzc3VlQ29tbWVudDI5MTIzMjk2MA==,1217238,2017-04-03T18:34:47Z,2017-04-03T18:34:47Z,MEMBER,"Yes, I think this would be quite straightforward. I think the easiest way to do it would simply be to reuse xarray's accessor interface (i.e., `register_dataarray_accessor`) and then implement all the desired methods/properties.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,59720901