{ "cells": [ { "cell_type": "markdown", "id": "0052861b-12a3-4960-9279-7b8d03752a9d", "metadata": {}, "source": [ "# Creating HDF Datasets\n", "\n", "Dataset creation works almost as known from `h5py`. However, to facilitate and streamline the work with HDF5 files further some featurs are added." ] }, { "cell_type": "code", "execution_count": 1, "id": "7e7ee488-fc61-4edd-a944-d5613969c769", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "using(\"h5py\")" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import h5rdmtoolbox as h5tbx\n", "import numpy as np\n", "import xarray as xr\n", "\n", "h5tbx.use(None)" ] }, { "cell_type": "markdown", "id": "a6baa8c7-9bc8-4c45-9632-9322c72cda9d", "metadata": {}, "source": [ "Obligatory parameters during dataset creation know from the base package `h5py` are `name` and `data` or `shape`. Additionally, attributes can be passed during dataset creation right away:" ] }, { "cell_type": "code", "execution_count": 2, "id": "0bf9a1d3-5af4-46f1-8954-38dc7d1d0542", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "<xarray.DataArray (dim_0: 3)>\n",
"2024-06-18T12:26:35.885516 2024-06-18T12:26:36.885516 2024-06-18T12:26:37.885516\n",
"Dimensions without coordinates: dim_0\n",
"Attributes:\n",
" @TYPE: https://schema.org/DateTime\n",
" RDF_PREDICATE: {'time_format': 'https://matthiasprobst.github.io/pivmeta...\n",
" time_format: %Y-%m-%dT%H:%M:%S.%f<xarray.Dataset>\n",
"Dimensions: (foo: 3, x: 2)\n",
"Coordinates:\n",
" * foo (foo) int32 1 2 3\n",
"Dimensions without coordinates: x\n",
"Data variables:\n",
" bar (x) int32 1 2\n",
" baz float64 3.142<xarray.Dataset>\n",
"Dimensions: (foo: 3, x: 2)\n",
"Coordinates:\n",
" * foo (foo) int32 1 2 3\n",
"Dimensions without coordinates: x\n",
"Data variables:\n",
" bar (x) int32 1 2\n",
" baz float64 3.142