hdf_loader.py¶
bytes2str(value)
¶
hdf_compare(hdf_filename1, hdf_filename2, all_links=False)
¶
Compare hdf tree structure between two files
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf_filename1
|
str
|
filename of hdf file |
required |
hdf_filename2
|
str
|
filename of hdf file |
required |
all_links
|
bool, if True, also show soft links |
False
|
Returns:
Type | Description |
---|---|
str
|
str |
Source code in src/hdfmap/hdf_loader.py
hdf_dataset_list(hdf_filename, all_links=True, group='/')
¶
Generate list of all datasets in the hdf file structure
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf_filename
|
str
|
filename of hdf file |
required |
all_links
|
bool, if True, also include soft links |
True
|
|
group
|
str
|
only display tree structure of this group (default root) |
'/'
|
Returns:
Type | Description |
---|---|
list[str]
|
list of str addresses |
Source code in src/hdfmap/hdf_loader.py
hdf_find(hdf_filename, *names_or_classes, attributes=('NX_class', 'local_name'))
¶
find groups and datasets within hdf file matching a set of names or class names
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf_filename
|
str
|
filename of hdf file |
required |
names_or_classes
|
str
|
object names or NXclass names to search for |
()
|
attributes
|
tuple[str]
|
list of attr fields to check against names |
('NX_class', 'local_name')
|
Returns:
Type | Description |
---|---|
tuple[list[str], list[str]]
|
groups[], datasets[] |
Source code in src/hdfmap/hdf_loader.py
hdf_find_first(hdf_filename, *names_or_classes, attributes=('NX_class', 'local_name'))
¶
return the first path of object matching a set of names or class names
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf_filename
|
str
|
filename of hdf file |
required |
names_or_classes
|
str
|
object names or NXclass names to search for |
()
|
attributes
|
tuple[str]
|
list of attr fields to check against names |
('NX_class', 'local_name')
|
Returns:
Type | Description |
---|---|
str | None
|
hdf_path or None if no match |
Source code in src/hdfmap/hdf_loader.py
hdf_linked_files(hdf_filename, group='/')
¶
Return a list of files linked to the current file, looking for all external links.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf_filename
|
str
|
filename of hdf file |
required |
group
|
str
|
only look at links within this group (default root) |
'/'
|
Returns:
Type | Description |
---|---|
list[str]
|
list of str filenames (usually relative file paths) |
Source code in src/hdfmap/hdf_loader.py
hdf_tree_dict(hdf_filename)
¶
Generate summary dict of the hdf tree structure The structure is: {'group': {'@attrs': str, 'sub-group': {}, 'dataset': str}, ...}
Group attributes are stored with names pre-fixed with '@'
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf_filename
|
str
|
filename of hdf file |
required |
Returns:
Type | Description |
---|---|
dict
|
{'entry': {'dataset': value}...} |
Source code in src/hdfmap/hdf_loader.py
hdf_tree_string(hdf_filename, all_links=True, group='/', attributes=True)
¶
Generate string of the hdf file structure, similar to h5ls. Uses h5py.visititems
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf_filename
|
str
|
filename of hdf file |
required |
all_links
|
bool
|
bool, if True, also show links |
True
|
group
|
str
|
only display tree structure of this group (default root) |
'/'
|
attributes
|
bool
|
if True, display the attributes of groups and datasets |
True
|
Returns:
Type | Description |
---|---|
str
|
str |