-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add open_datatree to xarray #8697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
0266b63
3899b06
d5b80f9
0c62960
a523d50
1e5e433
e687e4a
4e05d5c
77405d9
81b425f
3c5bcda
9f89256
a4bad61
e4f0374
3b1224c
e447900
352222d
9745864
20d8691
221bc8c
b74764e
6498acc
4280d30
8c54465
afba7ba
aab1744
5b48973
c6bb18a
4d306c0
d386ed3
e291587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -69,6 +69,7 @@ | |||||
T_NetcdfTypes = Literal[ | ||||||
"NETCDF4", "NETCDF4_CLASSIC", "NETCDF3_64BIT", "NETCDF3_CLASSIC" | ||||||
] | ||||||
from xarray.datatree_.datatree import DataTree | ||||||
|
||||||
DATAARRAY_NAME = "__xarray_dataarray_name__" | ||||||
DATAARRAY_VARIABLE = "__xarray_dataarray_variable__" | ||||||
|
@@ -788,6 +789,33 @@ def open_dataarray( | |||||
return data_array | ||||||
|
||||||
|
||||||
def open_datatree( | ||||||
filename_or_obj: str | os.PathLike[Any] | BufferedIOBase | AbstractDataStore, | ||||||
engine: T_Engine = None, | ||||||
**kwargs, | ||||||
) -> DataTree: | ||||||
""" | ||||||
Open and decode a dataset from a file or file-like object, creating one Tree node for each group in the file. | ||||||
Parameters | ||||||
---------- | ||||||
filename_or_obj : str, Path, file-like, or DataStore | ||||||
Strings and Path objects are interpreted as a path to a netCDF file or Zarr store. | ||||||
engine : str, optional | ||||||
Xarray backend engine to us. Valid options include `{"netcdf4", "h5netcdf", "zarr"}`. | ||||||
flamingbear marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
kwargs : | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
Additional keyword arguments passed to :py:meth:`~xarray.open_dataset` for each group. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method doesn't exist yet. at that location. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you explain why? This should exist, if you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it doesn't exist at the top level because we wanted to migrate over the code before allowing a direct import. from xarray import open_datatree Until all of the code was merged, we said it would be imported from xarray.core.datatree. From #8572 First comment So I had thought xarray.core.datatree.DataTree made more sense for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the second part of your comment, makes me think I might not understand what you were asking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess what I'm asking is:
Suggested change
Also, once that's fixed, does this cause the docs build to fail? If not I believe it would be fine to leave as-is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On reflection, I think this should still be |
||||||
Returns | ||||||
------- | ||||||
xarray.core.datatree.DataTree | ||||||
flamingbear marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
""" | ||||||
if engine is None: | ||||||
engine = plugins.guess_engine(filename_or_obj) | ||||||
|
||||||
backend = plugins.get_backend(engine) | ||||||
|
||||||
return backend.open_datatree(filename_or_obj, **kwargs) | ||||||
|
||||||
|
||||||
def open_mfdataset( | ||||||
paths: str | NestedSequence[str | os.PathLike], | ||||||
chunks: T_Chunks | None = None, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,15 @@ | ||
# import public API | ||
from .datatree import DataTree | ||
from .extensions import register_datatree_accessor | ||
from .io import open_datatree | ||
from .mapping import TreeIsomorphismError, map_over_subtree | ||
from .treenode import InvalidTreeError, NotFoundInTreeError | ||
|
||
try: | ||
# NOTE: the `_version.py` file must not be present in the git repository | ||
# as it is generated by setuptools at install time | ||
from ._version import __version__ | ||
except ImportError: # pragma: no cover | ||
# Local copy or not installed with setuptools | ||
__version__ = "999" | ||
|
||
__all__ = ( | ||
"DataTree", | ||
"open_datatree", | ||
"TreeIsomorphismError", | ||
"InvalidTreeError", | ||
"NotFoundInTreeError", | ||
"map_over_subtree", | ||
"register_datatree_accessor", | ||
"__version__", | ||
) |
Uh oh!
There was an error while loading. Please reload this page.