-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experiment with accessors and links in attributes
- Loading branch information
Showing
3 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import xarray_ms.accessors # noqa: F401 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from xarray.core.datatree import DataTree | ||
from xarray.core.extensions import ( | ||
register_datatree_accessor, | ||
) | ||
|
||
|
||
@register_datatree_accessor("subtable") | ||
class SubTableAccessor: | ||
def __init__(self, node: DataTree): | ||
self.node = node | ||
|
||
@property | ||
def antenna(self) -> DataTree: | ||
"""Returns the antenna dataset""" | ||
|
||
try: | ||
link = self.node.attrs["antenna_xds_link"] | ||
except KeyError: | ||
raise ValueError("antenna_xds_link not found") | ||
else: | ||
return self.node.root[link] |
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