### Install kglab Source: https://h5rdmtoolbox.readthedocs.io/en/latest/practical_examples/knowledge_graph.html Install the kglab package using pip. This is the first step before using kglab in the knowledge graph example. ```python #!pip install kglab ``` -------------------------------- ### Create an example HDF5 file with coordinates Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/wrapper/DatasetSlicing.ipynb Creates an example HDF5 file using h5rdmtoolbox. The make_scale and attach_scale arguments set up coordinates and associate them with the dataset 'data'. ```python with h5tbx.File('example.h5', 'w') as h5: h5.create_dataset('data', data=np.random.rand(10, 10)) h5['data'].make_scale('x') h5['data'].attach_scale('x', 'x') ``` -------------------------------- ### Start the linked-data web viewer with h5tbx serve Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/ld/web_viewer.rst Use h5tbx serve to start the web viewer. Provide a file or directory, optionally filter by extensions, and set a file URI and local IRI pattern for DOI resolution. ```bash h5tbx serve example.h5 h5tbx serve data/ --h5ext=.h5 --h5ext=.hdf5 h5tbx serve example.h5 --file-uri https://doi.org/10.5281/zenodo.17572275# --local-iri-pattern "https://doi.org/10.5281/zenodo.*" ``` -------------------------------- ### Example convention YAML file Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/convention/creating_a_new_convention.ipynb A complete example of a convention file named example_convention.yaml, including header metadata, standard attribute definitions, and custom type validators. ```yaml # filename: example_convention.yaml # 1. General information at the header #------------------------------------- __name__: h5rdmtoolbox-tuturial-convention __institution__: https://orcid.org/members/001G000001e5aUTIAY __contact__: https://orcid.org/0000-0001-8729-0482 # 2. Definition of standard attributes #------------------------------------- units: target_method: create_dataset validator: $units description: The physical unit of the dataset. If dimensionless, the unit is ''. default_value: $EMPTY contact_id: description: ID of a person to contact for questions. target_method: __init__ validator: $str default_value: $EMPTY comment: description: Comment to a dataset target_method: create_dataset validator: $regex(^[A-Z].*) default_value: $NONE data_type: description: 'Type of data in file. Can be numerical or experimental' target_method: __init__ validator: $dataSourceTypes # 3. Special type definitions #---------------------------- $dataSourceTypes: - numerical - experimental ``` -------------------------------- ### Download example Photon-HDF5 file Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/practical_examples/photon_hdf5.ipynb Downloads the example Photon-HDF5 file from figshare if it is not already present locally. The file is saved as 'test_photon_file.hdf5' in the current directory. ```python import requests import pathlib if not pathlib.Path('test_photon_file.hdf5').exists(): r = requests.get('https://figshare.com/ndownloader/files/2182602') with open('test_photon_file.hdf5', 'wb') as f: f.write(r.content) ``` -------------------------------- ### Create example data with h5rdmtoolbox Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/layout/getting_started.html Creates example data for layout validation: two datasets with different compression types and a group with an attribute. The output includes a deprecation warning about creating a dataset without data or dtype. ```python import h5rdmtoolbox as h5tbx with h5tbx.File() as h5: h5.create_dataset('u', shape=(3, 5), compression='lzf') h5.create_dataset('v', shape=(3, 5), compression='gzip') h5.create_group('instruments', attrs={'description': 'Instrument data'}) h5.dump() ``` -------------------------------- ### Download NeXus example file Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/practical_examples/nexus.ipynb Downloads a sample NeXus file from the nexusformat exampledata repository if it does not already exist locally. ```python import requests import pathlib if not pathlib.Path('file.nxs').exists(): r = requests.get('https://github.com/nexusformat/exampledata/raw/master/Soleil/hdf5/file_1.nxs') with open('file.nxs', 'wb') as f: f.write(r.content) ``` -------------------------------- ### Install kglab Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/practical_examples/knowledge_graph.ipynb Install the kglab package, which is required for building and visualizing knowledge graphs from HDF5 data. ```python #!pip install kglab ``` -------------------------------- ### Install h5RDMtoolbox optional dependencies Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/gettingstarted/installation.rst Installs optional dependencies for h5RDMtoolbox. The database extra requires a separately installed MongoDB server. The complete extra installs all the above dependencies. ```sh # install dependencies to use the database (MongoDB) pip install h5RDMtoolbox[database] # Note: MongoDB server must be installed separately # install dependencies for testing pip install h5RDMtoolbox[test] # install dependencies needed to build this documentation pip install h5RDMtoolbox[docs] # install all above dependencies pip install h5RDMtoolbox[complete] # install dependencies for CSV support pip install h5RDMtoolbox[csv] # install dependencies for standard name tables pip install h5RDMtoolbox[snt] # install dependencies for catalog/SPARQL queries pip install h5RDMtoolbox[catalog] ``` -------------------------------- ### Create database and collection Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/database/mongoDB.ipynb Creates a database named 'h5database_notebook_tutorial' and a collection named 'digits', then drops all content to start fresh. ```python db = client['h5database_notebook_tutorial'] collection = db['digits'] # drop all content in order to start from scratch: collection.drop() ``` -------------------------------- ### Import h5rdmtoolbox and tutorial modules Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/faq/faq004.ipynb Imports the h5rdmtoolbox library and its tutorial module, which provides access to example convention files. ```python import h5rdmtoolbox as h5tbx from h5rdmtoolbox import tutorial ``` -------------------------------- ### Import Zenodo and h5rdmtoolbox Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/repository/zenodo.ipynb Imports the Zenodo repository module and the h5rdmtoolbox package for the example workflow. ```python from h5rdmtoolbox.repository import zenodo import h5rdmtoolbox as h5tbx ``` -------------------------------- ### Set h5rdmtoolbox backend to h5py Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/wrapper/GroupCreation.ipynb Initializes the h5rdmtoolbox library and sets the backend to h5py. This is a prerequisite for the subsequent examples. ```python import h5rdmtoolbox as h5tbx h5tbx.use(None) ``` -------------------------------- ### Import download_file and pprint Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/wrapper/FAIRAttributes.ipynb Imports `download_file` from h5rdmtoolbox.utils and `pprint` for pretty printing. Used in the example to download a file. ```python from h5rdmtoolbox.utils import download_file from pprint import pprint ``` -------------------------------- ### Import required libraries Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/ld/getting_started.ipynb Imports numpy, rdflib, h5rdmtoolbox, and Path for the linked data example. ```python import numpy as np import rdflib import h5rdmtoolbox as h5tbx from pathlib import Path ``` -------------------------------- ### Import h5rdmtoolbox and select h5py backend Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/wrapper/CreateFile.html Sets up the h5rdmtoolbox environment by importing the package and selecting the h5py backend. The first block initializes the toolbox, and the second block activates the h5py backend for subsequent file operations. ```python import h5rdmtoolbox as h5tbx h5tbx.use(None) ``` ```python using("h5py") ``` -------------------------------- ### Configure h5rdmtoolbox to disable auto version Source: https://h5rdmtoolbox.readthedocs.io/en/latest/practical_examples/metadata4ing.html Configures h5rdmtoolbox to disable automatic creation of the h5tbx version attribute. This setup is required before using the library in the examples. ```python import h5rdmtoolbox as h5tbx _ = h5tbx.set_config(auto_create_h5tbx_version=False) ``` -------------------------------- ### Get first match with h5.find_one Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/database/hdfDB.html Use h5.find_one to retrieve only the first matching dataset. The example searches for standard_name 'velocity' and units 'm', returning a single lazy dataset object. ```python with h5tbx.File(filename) as h5: res = h5.find_one(flt={'standard_name': 'velocity', 'units': 'm'}) res ``` ```text ``` -------------------------------- ### Get call and failure counts for compression specification Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/layout/getting_started.ipynb Returns a tuple with the number of calls and the number of failures for the compression specification. In this example, it returns (2, 1), indicating two calls and one failure. ```python spec_compression.n_calls, spec_compression.n_fails ``` -------------------------------- ### Using a database interface Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/database/firstSteps.ipynb Example showing how to use a database interface to insert datasets and groups into a database and perform find operations. ```python import h5rdmtoolbox as h5tbx mydb = MyDBInterface() with h5tbx.File() as h5: h5.create_group('a group') h5.create_dataset('my_dataset', shape=(4, 2)) # ... mydb.insert_dataset(h5['my_dataset']) mydb.insert_group(h5['a group']) many_res = mydb.find(...) single_res = mydb.find_one(...) ``` -------------------------------- ### Layout.__init__ Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/generated/h5rdmtoolbox.layout.Layout.rst Initializes a new Layout instance. ```APIDOC ## Layout.__init__ ### Description Initializes a new Layout instance. ### Method __init__ ### Signature `__init__(self, ...)` ### Parameters No parameters documented. ### Returns None ``` -------------------------------- ### Pint-xarray unit conversion example Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/wrapper/DatasetSlicing.html Example of using pint-xarray to quantify and convert units, which is what to_units does under the hood. ```python # note, that we need to call the "pint"-accessory every time to make the xarray object quantified_data = data.pint.quantify(unit_registry=h5tbx.get_ureg()) u_mm_s = quantified_data.pint.to('mm/s').pint.dequantify() u_mm_s.units ``` -------------------------------- ### Initialize ZenodoRecord with sandbox Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/repository/zenodo.ipynb Initializes a ZenodoRecord instance with sandbox=True to use the testing environment. ```python repo = zenodo.ZenodoRecord(None, sandbox=True) ``` -------------------------------- ### ModuleNotFoundError for kglab Source: https://h5rdmtoolbox.readthedocs.io/en/latest/practical_examples/knowledge_graph.html Error output showing that the kglab module is not installed. This occurs when running the import without installing kglab first. ```text --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[2], line 1 ----> 1 import kglab 2 import rdflib 3 import numpy as np ModuleNotFoundError: No module named 'kglab' ``` -------------------------------- ### Install h5RDMtoolbox with pip Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/gettingstarted/installation.rst Installs the h5RDMtoolbox package. Requires Python 3.9 or higher; automatic testing is performed for Python 3.9-3.13. ```sh pip install h5RDMtoolbox ``` -------------------------------- ### Get shape of inserted dataset Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/database/mongoDB.html Get the shape of the lazy dataset from the found document. Expected output: (1797, 8, 8). ```python res[()].shape ``` -------------------------------- ### Initialize h5rdmtoolbox with h5tbx.use(None) Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/database/hdfDB.ipynb Initializes the h5rdmtoolbox environment by disabling any default backend. Required before using tutorial data in this chapter. ```python import h5rdmtoolbox as h5tbx from h5rdmtoolbox import tutorial h5tbx.use(None) ``` -------------------------------- ### DownloadFileManager.__init__() Source: https://h5rdmtoolbox.readthedocs.io/en/latest/generated/h5rdmtoolbox.utils.DownloadFileManager.html Initializes the DownloadFileManager instance. This class is a singleton, so only one instance can be created. ```APIDOC ## DownloadFileManager.__init__() ### Description Initializes the DownloadFileManager instance. This constructor is part of the DownloadFileManager class, which manages downloading files by registering checksums and filenames. The class is a singleton, so only one instance can be created. ### Signatures - `__init__()` - `__init__(*args, **kwargs)` ### Usage Used to create or access the singleton instance of the DownloadFileManager. ``` -------------------------------- ### Import h5rdmtoolbox and use None Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/wrapper/NaturalNaming.html Initializes the h5rdmtoolbox library and sets the backend to None (default). ```python import h5rdmtoolbox as h5tbx h5tbx.use(None) ``` -------------------------------- ### YAML example for create_from_yaml Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_modules/h5rdmtoolbox/wrapper/core.html Example YAML content for create_from_yaml. Defines groups, datasets, and attributes relative to the current group level. Supports overwrite and num_dtype options. ```yaml >>> title: 'Title of the file' >>> contact: '0000-1234-1234-1234' >>> grp: >>> attrs: >>> comment: test >>> grp/subgrp/y: >>> data: 2 >>> overwrite: True >>> attrs: >>> units: 'm/s' >>> grp/subgrp: >>> attrs: >>> comment: This is a group comment >>> velocity: >>> data: [3.4, 1.1] >>> overwrite: True >>> attrs: >>> units: 'm/s' ``` -------------------------------- ### Find slice by digit and get shape Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/database/mongoDB.html Find one document where the 'digit' field equals 3 and get the shape of its dataset. Expected output: (1, 8, 8). ```python one_res = mdb.find_one({'digit': {'$eq': 3}}) one_res[()].shape ``` -------------------------------- ### Turtle RDF example of structural and semantic HDF5 metadata Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/ld/getting_started.html Shows a Turtle RDF example contrasting structural HDF5 metadata with semantic annotations. It defines an HDF5 file with a dataset for mean temperature, including attributes for description and units, and links to semantic terms like m4i:NumericalVariable and schema:description. The snippet is truncated at the end, so the full example is not shown. ```turtle @prefix hdf: . @prefix m4i: . @prefix schema: . @prefix xsd: . hdf:H5T_IEEE_F64LE a hdf:Datatype . [] a hdf:File ; hdf:rootGroup [ a hdf:Group ; hdf:member [ a hdf:Dataset, m4i:NumericalVariable ; hdf:attribute [ a hdf:StringAttribute ; hdf:data "Mean room temperature" ; hdf:name "description" ], [ a hdf:StringAttribute ; hdf:data "degree_Celsius" ; hdf:name "units" ] ; hdf:dataspace [ a hdf:ScalarDataspace ] ; hdf:datatype hdf:H5T_FLOAT, hdf:H5T_IEEE_F64LE ; hdf:layout hdf:H5D_CONTIGUOUS ; hdf:maximumSize -1 ; hdf:name "/mean_temperature" ; hdf:rank 0 ; hdf:size 1 ; hdf:value 2.05e+01 ; m4i:hasNumericalValue "20.5"^^xsd:float ; m4i:hasUnit ; schema:description "Mean room temperature" ], [ a hdf:Dataset ; hdf:attribute [ a hdf:StringAttribute ; hdf:data "Room temperature measurements" ; hdf:name "description" ], [ a hdf:StringAttribute ; hdf:data "degree_Celsius" ; hdf:name "units" ] ; hdf:dataspace [ a hdf:SimpleDataspace ; hdf:dimension [ a hdf:DataspaceDimension ; hdf:dimensionIndex 0 ; hdf:size 4 ] ] ; hdf:datatype hdf:H5T_FLOAT, ``` -------------------------------- ### Enable convention with h5tbx.use Source: https://h5rdmtoolbox.readthedocs.io/en/latest/gettingstarted/quickoverview.html Enables the loaded convention. The output confirms the convention is in use. ```python h5tbx.use(cv) ``` ```text using("h5rdmtoolbox-tutorial-convention") ``` -------------------------------- ### Import dependencies and select h5py backend Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/database/mongoDB.html Sets up the environment for the MongoDB tutorial: imports pymongo, mongomock (for docs/testing), h5rdmtoolbox, numpy, and pprint, then disables the default HDF5 backend with h5tbx.use(None). The second block selects the h5py backend via using("h5py"). ```python import pymongo # from pymongo import MongoClient from mongomock import MongoClient # for docs or testing only from h5rdmtoolbox import tutorial import h5rdmtoolbox as h5tbx import numpy as np from pprint import pprint h5tbx.use(None) ``` ```python using("h5py") ``` -------------------------------- ### h5rdmtoolbox package initialization and logging setup Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_modules/h5rdmtoolbox.html Initializes the h5rdmtoolbox package: configures logging with a stream handler and a rotating file handler, sets up the unit registry, registers the h5py convention, and imports core modules. The logger writes to USER_LOG_DIR/h5rdmtoolbox.log with DEBUG level for file and WARNING for console. ```python """h5rdmtoolbox repository""" import logging import pathlib from logging.handlers import RotatingFileHandler from typing import Optional, Dict import rdflib from ._version import __version__ from .user import USER_LOG_DIR, USER_DATA_DIR DEFAULT_LOGGING_LEVEL = logging.WARNING _formatter = logging.Formatter( '%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s', datefmt='%Y-%m-%d_%H:%M:%S') _stream_handler = logging.StreamHandler() _stream_handler.setLevel(DEFAULT_LOGGING_LEVEL) _stream_handler.setFormatter(_formatter) _file_handler = RotatingFileHandler(USER_LOG_DIR / 'h5rdmtoolbox.log', delay=True) _file_handler.setLevel(logging.DEBUG) # log everything to file! _file_handler.setFormatter(_formatter) logger = logging.getLogger(__package__) logger.addHandler(_stream_handler) logger.addHandler(_file_handler) import atexit # noinspection PyUnresolvedReferences import pint_xarray import shutil import xarray as xr from typing import Union, Callable from pydantic import HttpUrl from h5rdmtoolbox._cfg import set_config, get_config, get_ureg pint_xarray.unit_registry = get_ureg() from . import convention from .convention.core import Convention from . import wrapper from .user import UserDir from ._version import __version__ from . import utils from .wrapper.core import lower, Lower, File, Group, Dataset from . import errors from .wrapper import jsonld from .database.lazy import lazy from .wrapper.h5attr import Attribute import json from .wrapper.accessor import register_accessor from .ld.shacl import validate_hdf, ValidationResult from .ld._types import RDFMappingEntry # noinspection PyUnresolvedReferences from .utils import DownloadFileManager name = 'h5rdmtoolbox' __this_dir__ = pathlib.Path(__file__).parent __author__ = 'Matthias Probst' __author_orcid__ = 'https://orcid.org/0000-0001-8729-0482' def get_package_meta() -> Dict: """Reads codemeta.json and returns it as dict""" with open(__this_dir__ / '../codemeta.json', 'r') as f: codemeta = json.loads(f.read()) return codemeta cv_h5py = convention.Convention(name='h5py', contact=__author_orcid__) cv_h5py.register() use = convention.core.use use(None) ``` -------------------------------- ### Vector example output: xarray.Dataset, data arrays, and coordinate indexes Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/misc/Extensions.html Output of the Vector example: the xarray.Dataset representation, the data arrays for xvel and yvel, and the PandasIndex objects for the y and x coordinates. These are the printed results from the preceding Vector code block. ```text Size: 136B Dimensions: (y: 2, x: 3) Coordinates: * y (y) int64 16B 2 3 * x (x) int64 24B 1 2 3 Data variables: xvel (y, x) float64 48B 0.9919 0.7565 0.3806 0.6557 0.6515 0.01967 yvel (y, x) float64 48B 0.2993 0.8466 0.04372 0.88 0.8598 0.2207 Attributes: long_name: x vel units: m/s ``` ```text array([[0.99190512, 0.75645821, 0.38064616], [0.65569809, 0.65153778, 0.01966631]]) ``` ```text array([[0.29928468, 0.84656168, 0.04372209], [0.88003235, 0.85982443, 0.22072619]]) ``` ```text PandasIndex(Index([2, 3], dtype='int64', name='y')) ``` ```text PandasIndex(Index([1, 2, 3], dtype='int64', name='x')) ``` -------------------------------- ### FileDB.__init__ Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/generated/h5rdmtoolbox.database.FileDB.rst Initializes a new FileDB instance. The constructor is automatically documented and likely accepts parameters for database configuration. ```APIDOC ## FileDB.__init__ ### Description Initializes a new FileDB instance. The constructor is automatically documented and likely accepts parameters for database configuration. ### Method Constructor ### Signature `FileDB.__init__(...)` ### Parameters No explicit parameters are documented in the source. ### Returns A new FileDB instance. ``` -------------------------------- ### Metadata4Ing example in Turtle RDF Source: https://h5rdmtoolbox.readthedocs.io/en/latest/practical_examples/metadata4ing.html Turtle RDF describing a Metadata4Ing example with processing steps, tools, and a numerical variable. It defines a FileSet, a Person with ORCID, a Method, and a ProcessingStep for XRCT scanning, including a voltage variable with unit KiloV. ```turtle @prefix dcterms: . @prefix foaf: . @prefix m4i: . @prefix ns1: . @prefix rdfs: . @prefix schema: . @prefix xsd: . schema:about . schema:about . schema:about . schema:about . schema:about . schema:about . schema:about . schema:about . schema:about . a foaf:Person ; m4i:orcidId "0000-0000-0123-4567" ; foaf:lastName "Test" . a m4i:Method ; rdfs:label "scanning" ; dcterms:description "sample" ; m4i:hasParameter . a m4i:FileSet ; dcterms:description "image-files" ; m4i:includes "tiff" . a m4i:ProcessingStep ; rdfs:label "Processing" . a m4i:ProcessingStep ; rdfs:label "definition" ; m4i:hasParticipant "alex" ; m4i:startTime "2026-06-22T00:00:00"^^xsd:dateTime . a m4i:ProcessingStep ; rdfs:label "Reconstruction" ; ns1:RO_0002233 "xrct_data_0001" . a m4i:Tool ; rdfs:label "TT" . a m4i:ProcessingStep ; rdfs:label "XRCT-Scan" ; ns1:RO_0002234 "xrct-data" ; m4i:hasEmployedTool "xray_source_finetec_180.01ctt_0001" ; m4i:investigates ; m4i:investigatesProperty ; m4i:realizesMethod "cone_beam_scanning" . a m4i:NumericalVariable ; rdfs:label "Voltage" ; m4i:hasKindOfQuantity ; m4i:hasNumericalValue "140" ; m4i:hasUnit . ``` -------------------------------- ### Compare method signatures with and without convention Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/convention/creating_a_new_convention.ipynb Defines a helper to print method parameters and compares the signature of h5tbx.File.__init__ with no convention versus with the tutorial convention. The output shows that standard attributes like data_type and standard_name_table are added as bold parameters when the convention is active. ```python import inspect def print_method_parameters(method): print(f'\nParameters for "{method.__name__}":') for param in inspect.signature(method).parameters.values(): if not param.name == 'self': if param.name in h5tbx.convention.get_current_convention().methods[h5tbx.File].get('__init__', {}).keys(): print(f' - {h5tbx._repr.make_bold(param.name)}') else: print(f' - {param.name}') methods = (h5tbx.File.__init__, h5tbx.Group.create_group, h5tbx.Group.create_dataset) print('no convention: ') h5tbx.use(None) print_method_parameters(h5tbx.File.__init__) print(f'\n------------\nwith convention {cv.name}: (standard attributes are made bold)') h5tbx.use(cv) print_method_parameters(h5tbx.File.__init__) ``` -------------------------------- ### Output of get_checksum Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/misc/FileProperties.html Example output showing the checksum returned by the get_checksum function. ```text '6781e0baec8d65b9a95a3e879a5098d1' ``` -------------------------------- ### Create HDF5 file with datasets and scales Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/userguide/misc/Visualization.ipynb Creates an HDF5 file with datasets and scales, then dumps the structure. Use to set up data for visualization examples. ```python with h5tb.File() as h5: dsx = h5.create_dataset('x', data=np.linspace(0, 10, 20), attrs=dict(units='mm', long_name='x'), make_scale=True) dsy = h5.create_dataset('y', data=np.linspace(0, 5, 10), attrs=dict(units='mm', long_name='y'), make_scale=True) dsz = h5.create_dataset('z', data=np.linspace(0, 3, 4), attrs=dict(units='mm', long_name='z'), make_scale=True) h5.create_dataset('data', data=np.random.random((10, 20)), attrs=dict(units='m/s', long_name='velocity'), attach_scales=(dsy, dsx)) xx, yy, zz = np.meshgrid(dsy.values[:], dsz.values[:], dsx.values[:]) h5.create_dataset('u', data=np.sin(xx), attrs=dict(units='m/s', long_name='x_velocity'), attach_scales=(dsz, dsy, dsx)) h5.create_dataset('v', data=yy, attrs=dict(units='m/s', long_name='y_velocity'), attach_scales=(dsz, dsy, dsx)) h5.create_dataset('w', data=np.ones((4, 10, 20)), attrs=dict(units='m/s', long_name='z_velocity'), attach_scales=(dsz, dsy, dsx)) h5.dump() ``` -------------------------------- ### Get current convention property Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_modules/h5rdmtoolbox/wrapper/core.html Property that returns the currently enabled convention. ```python @property def convention(self): """Return the convention currently enabled.""" return self._convention ``` -------------------------------- ### FileDB.__init__() Source: https://h5rdmtoolbox.readthedocs.io/en/latest/generated/h5rdmtoolbox.database.FileDB.html Initializes a FileDB instance for a single HDF5 file, specifying the filename of the HDF5 file to interface with. ```APIDOC ## FileDB.__init__() ### Description Initializes a FileDB instance, creating a database interface for a single HDF5 file. ### Parameters - **filename** (string) - Required - The path to the HDF5 file for which the database interface is created. ### Method Signature ```python class h5rdmtoolbox.database.FileDB(filename) ``` ``` -------------------------------- ### File.get_groups Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/generated/h5rdmtoolbox.wrapper.core.File.rst Gets all groups in the file. This method is part of the File class API. ```APIDOC ## File.get_groups ### Description Gets all groups in the file. ### Method Method ### Signature `File.get_groups(...)` ### Parameters No parameters are explicitly documented in the source. ### Returns No return value is explicitly documented. ``` -------------------------------- ### Load and activate convention from YAML file Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/faq/faq004.ipynb Retrieves the filename of a tutorial convention YAML file, creates a Convention object from it using Convention.from_yaml(), and activates it with h5tbx.use(). The output shows the activated convention name. ```python yaml_filename = tutorial.get_convention_yaml_filename() cv = h5tbx.convention.Convention.from_yaml(yaml_filename) h5tbx.use(cv) ``` -------------------------------- ### File.get_datasets Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/generated/h5rdmtoolbox.wrapper.core.File.rst Gets all datasets in the file. This method is part of the File class API. ```APIDOC ## File.get_datasets ### Description Gets all datasets in the file. ### Method Method ### Signature `File.get_datasets(...)` ### Parameters No parameters are explicitly documented in the source. ### Returns No return value is explicitly documented. ``` -------------------------------- ### File.get Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/generated/h5rdmtoolbox.wrapper.core.File.rst Gets an item from the file. This method is part of the File class API. ```APIDOC ## File.get ### Description Gets an item from the file. ### Method Method ### Signature `File.get(...)` ### Parameters No parameters are explicitly documented in the source. ### Returns No return value is explicitly documented. ``` -------------------------------- ### Create layout and add specifications Source: https://h5rdmtoolbox.readthedocs.io/en/latest/gettingstarted/quickoverview.html Create a Layout instance and add specifications using FileDB.find queries. The first specification matches all datasets, and the second is added to the first, requiring the 'units' attribute to exist. The layout's specifications are then displayed. ```python lay = Layout() spec_all_dataset = lay.add( FileDB.find, # query function flt={}, objfilter='dataset', n=None ) # The following specification is added to the previous. # This will apply the query only on results found by the previous query spec_compression = spec_all_dataset.add( FileDB.find, flt={'units': {'$exists': True}}, # attribute "units" exists n=1 ) # we added one specification to the layout. let's check: lay.specifications # note, that the second specification is not shown, because it is part of the first one ``` -------------------------------- ### Pint-xarray output units Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/wrapper/DatasetSlicing.html Output of the pint-xarray example showing the resulting units string. ```text 'mm/s' ``` -------------------------------- ### Import rdflib Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/gettingstarted/quickoverview.ipynb Imports the rdflib library, which is used for RDF-related operations in the subsequent examples. ```python import rdflib ``` -------------------------------- ### Create dataset using __setitem__ with attributes and compression Source: https://h5rdmtoolbox.readthedocs.io/en/latest/userguide/wrapper/DatasetCreation.html Creates a dataset using the __setitem__ syntax, specifying data, attributes, and gzip compression. The dump() output shows the resulting dataset. ```python with h5tbx.File() as h5: h5['x'] = ([1,2,3], dict(attrs={'hello': 'world'}, compression='gzip')) h5.dump() ``` ```text * /(1) x (3) [int64] * hello: world ``` -------------------------------- ### File.get_tree_structure Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/generated/h5rdmtoolbox.wrapper.core.File.rst Gets the tree structure of the file. This method is part of the File class API. ```APIDOC ## File.get_tree_structure ### Description Gets the tree structure of the file. ### Method Method ### Signature `File.get_tree_structure(...)` ### Parameters No parameters are explicitly documented in the source. ### Returns No return value is explicitly documented. ``` -------------------------------- ### File.get_group_names Source: https://h5rdmtoolbox.readthedocs.io/en/latest/_sources/generated/h5rdmtoolbox.wrapper.core.File.rst Gets the names of all groups in the file. This method is part of the File class API. ```APIDOC ## File.get_group_names ### Description Gets the names of all groups in the file. ### Method Method ### Signature `File.get_group_names(...)` ### Parameters No parameters are explicitly documented in the source. ### Returns No return value is explicitly documented. ```