Last active
February 17, 2017 07:27
-
-
Save shoyer/26986d85cae05f5b5211eb3f3ebc0851 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@xr.register_dataset_accessor('crs') | |
@xr.register_dataarray_accessor('crs') | |
def make_crs(xarray_obj): | |
return xarray_obj.coords['crs'].item() | |
In [24]: ds = xr.Dataset({'x': 1}, coords={'foo': 'bar', 'crs': 'hello, my lovely unwrapped object'}) | |
In [25]: ds | |
Out[25]: | |
<xarray.Dataset> | |
Dimensions: () | |
Coordinates: | |
foo <U3 'bar' | |
crs <U33 'hello, my lovely unwrapped object' | |
Data variables: | |
x int64 1 | |
In [26]: ds.crs | |
Out[26]: 'hello, my lovely unwrapped object' | |
In [27]: ds.foo.crs | |
Out[27]: 'hello, my lovely unwrapped object' | |
In [28]: (ds + 10).crs | |
Out[28]: 'hello, my lovely unwrapped object' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment