-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
42 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
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 |
---|---|---|
|
@@ -13,3 +13,5 @@ | |
from ._timestamp import * | ||
from ._unicode import * | ||
from ._utilities import * | ||
from ._glob import * | ||
|
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,37 @@ | ||
import pathlib | ||
import os | ||
from typing import Union | ||
from ..data import Data | ||
from ..collection import Collection | ||
from .._open import open | ||
|
||
|
||
__all__ = ["describe_wt5", "find_wt5s"] | ||
|
||
|
||
def describe_wt5(path: Union[str, os.PathLike]): | ||
"""report useful general information about a wt5 file""" | ||
wt5 = open(path) | ||
desc = dict() | ||
desc["name"] = wt5.natural_name | ||
try: | ||
desc["created"] = wt5.created.human | ||
except: # likely an old timestamp that cannot be parsed | ||
desc["created"] = wt5.attrs["created"] | ||
|
||
if isinstance(wt5, Data): | ||
desc["shape"] = wt5.shape | ||
desc["axes"] = wt5.axis_expressions | ||
desc["nvars"] = len(wt5.variables) | ||
desc["nchan"] = len(wt5.channels) | ||
elif isinstance(wt5, Collection): | ||
for k in ["shape", "axes", "nvars", "nchan"]: | ||
desc[k] = "---" | ||
wt5.close() | ||
return desc | ||
|
||
|
||
def glob_wt5s(directory: Union[str,os.PathLike]): | ||
"""find all wt5 files in a directory""" | ||
return pathlib.Path(directory).glob("**/*.wt5") | ||
|
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