-
-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added facade functions `to_zarr` and `from_zarr` * black * added to changelog * update PR with review comments * fix rebase issues with changelog * black --------- Co-authored-by: Oriol (ZBook) <[email protected]>
- Loading branch information
1 parent
7fb2257
commit 8632186
Showing
5 changed files
with
91 additions
and
1 deletion.
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
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
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,46 @@ | ||
"""Input and output support for zarr data.""" | ||
|
||
from .converters import convert_to_inference_data | ||
from .inference_data import InferenceData | ||
|
||
|
||
def from_zarr(store): | ||
return InferenceData.from_zarr(store) | ||
|
||
|
||
from_zarr.__doc__ = InferenceData.from_zarr.__doc__ | ||
|
||
|
||
def to_zarr(data, store=None, **kwargs): | ||
""" | ||
Convert data to zarr, optionally saving to disk if ``store`` is provided. | ||
The zarr storage is using the same group names as the InferenceData. | ||
Parameters | ||
---------- | ||
store : zarr.storage, MutableMapping or str, optional | ||
Zarr storage class or path to desired DirectoryStore. | ||
Default (None) a store is created in a temporary directory. | ||
**kwargs : dict, optional | ||
Passed to :py:func:`convert_to_inference_data`. | ||
Returns | ||
------- | ||
zarr.hierarchy.group | ||
A zarr hierarchy group containing the InferenceData. | ||
Raises | ||
------ | ||
TypeError | ||
If no valid store is found. | ||
References | ||
---------- | ||
https://zarr.readthedocs.io/ | ||
""" | ||
inference_data = convert_to_inference_data(data, **kwargs) | ||
zarr_group = inference_data.to_zarr(store=store) | ||
return zarr_group |
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
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 |
---|---|---|
|
@@ -37,6 +37,8 @@ IO / General conversion | |
to_datatree | ||
to_json | ||
to_netcdf | ||
from_zarr | ||
to_zarr | ||
|
||
|
||
General functions | ||
|