{ "cells": [ { "cell_type": "markdown", "id": "b570aefb-f909-4779-ad1d-f37cdc42df78", "metadata": {}, "source": [ "# Example: Inspecting a NeXus file\n", "\n", "To demonstrate that the `h5rdmtoolbox` works with [NeXus](https://manual.nexusformat.org/fileformat.html) files, we download a file and inspect it. Note that by \"works\" we don't mean that the data model of NeXus is understood by the toolbox. Rather, we want to demonstrate that we can identify specific data in the file, plot it, and apply a minimal example of convention and layout validation that we will quickly design here." ] }, { "cell_type": "code", "execution_count": 1, "id": "ce843cf0-50f9-4f7f-9160-2fcae3425503", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Failed to import module h5tbx\n" ] } ], "source": [ "import h5rdmtoolbox as h5tbx" ] }, { "cell_type": "markdown", "id": "c9f2432b-cd6a-40a2-ae7a-9eae5010de7d", "metadata": {}, "source": [ "## 1. Get the file" ] }, { "cell_type": "code", "execution_count": 2, "id": "4f6cf57c-dfcc-4ebc-9c6f-b84214c724e0", "metadata": {}, "outputs": [], "source": [ "import requests\n", "import pathlib\n", "\n", "if not pathlib.Path('file.nxs').exists():\n", " r = requests.get('https://github.com/nexusformat/exampledata/raw/master/Soleil/hdf5/file_1.nxs')\n", " with open('file.nxs', 'wb') as f:\n", " f.write(r.content)" ] }, { "cell_type": "markdown", "id": "4c3f18be-ce47-4fec-a061-b6f6ba7c27f9", "metadata": {}, "source": [ "## 2. Visit (Dump) the file" ] }, { "cell_type": "code", "execution_count": 3, "id": "8c16217f-d920-4dc4-b4c5-5b46a2aab5f9", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\Matthias\\Documents\\programming\\GitHub\\h5RDMtoolbox\\h5rdmtoolbox\\_repr.py:552: RuntimeWarning: Cannot decode attribute value for units\n", " warnings.warn(f'Cannot decode attribute value for {name}', RuntimeWarning)\n" ] }, { "data": { "text/html": [ "
\n", "