{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## H5Glance demo" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import h5py" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create some example HDF5 data to show\n", "f = h5py.File(\"example.h5\", \"w\")\n", "f.create_dataset(\"/group1/subgroup1/dataset1\", (200,), dtype='u8')\n", "f.create_dataset(\"/group1/subgroup1/dataset2\", (2, 128, 500), dtype='f4')\n", "f.create_dataset(\"/group1/subgroup2/dataset1\", (12,), dtype='i2')\n", "\n", "# Basic h5py repr\n", "f" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Use H5Glance explicitly" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from h5glance import H5Glance\n", "H5Glance(f)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H5Glance(f['group1/subgroup1'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### View all h5py objects\n", "\n", "Install a display hook for IPython so all `h5py` files & groups are viewed this way." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "import h5glance\n", "h5glance.install_ipython_h5py_display()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "f['group1']" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 2 }