argopy.extensions.register_argo_accessor#
- register_argo_accessor(name)[source]#
A decorator to register an accessor as a custom property on
xarray.Dataset.argoobjects.- Parameters:
name (str) β Name under which the accessor should be registered. A warning is issued if this name conflicts with a preexisting attribute.
Examples
Somewhere in your code, you can register a class inheriting from
argopy.extensions.ArgoAccessorExtensionwith this decorator:@register_argo_accessor('floats') class WorkWithWMO(ArgoAccessorExtension): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._uid = argopy.utils.to_list(np.unique(self._obj["PLATFORM_NUMBER"].values)) @property def wmo(self): return self._uid @property def N(self): return len(self.wmo)
It will be available to an Argo dataset, like this:
ds.argo.floats.N ds.argo.floats.wmo