{ "cells": [ { "cell_type": "markdown", "id": "5479dfdd-1e32-4d5f-b8d4-53420048d810", "metadata": {}, "source": [ "# ... load a convention from a local YAML file?\n", "\n", "Yes you can. To demonstrate this, let's take a convention file, which comes with the `h5RDMtoolbox`" ] }, { "cell_type": "code", "execution_count": 1, "id": "12f7590c-36f0-4778-90fa-aa4abb3cfe00", "metadata": {}, "outputs": [], "source": [ "import h5rdmtoolbox as h5tbx\n", "from h5rdmtoolbox import tutorial" ] }, { "cell_type": "code", "execution_count": 2, "id": "d63db892-87e4-4f24-bfc8-7732cf3ff08b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Convention \"h5rdmtoolbox-tutorial-convention\" filename: C:\\Users\\da4323\\Documents\\programming\\GitHub\\h5RDMtoolbox\\h5rdmtoolbox\\data\\tutorial_convention.yaml\n", "creating directory for the convention\n", "No special functions defined\n", "Found 0 function(s) in C:\\Users\\da4323\\AppData\\Local\\h5rdmtoolbox\\h5rdmtoolbox\\conventions\\h5rdmtoolbox_tutorial_convention\\h5rdmtoolbox_tutorial_convention.py\n" ] }, { "data": { "text/plain": [ "using(\"h5rdmtoolbox-tutorial-convention\")" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "yaml_filename = tutorial.get_convention_yaml_filename()\n", "\n", "cv = h5tbx.convention.Convention.from_yaml(yaml_filename)\n", "h5tbx.use(cv)" ] }, { "cell_type": "markdown", "id": "c9f9e7fe-977a-4e7b-b914-76ca62be87df", "metadata": {}, "source": [ "The convention requires a standard name table. It comes with a default one, but let's also load a local one:" ] }, { "cell_type": "code", "execution_count": 3, "id": "7ae5e6c2-a2d0-4c36-b0d1-f13301b0b951", "metadata": {}, "outputs": [], "source": [ "snt_yaml_filename = tutorial.get_standard_name_table_yaml_file()" ] }, { "cell_type": "code", "execution_count": 4, "id": "dfbb4a76-72cc-43d0-81a5-2416f7805bc0", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "\n", " \n", "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "with h5tbx.File(data_type='experimental', contact=h5tbx.__author_orcid__,\n", " standard_name_table=snt_yaml_filename) as h5:\n", " snt = h5.standard_name_table\n", " c = h5.contact\n", " h5.dump()" ] }, { "cell_type": "code", "execution_count": null, "id": "66ffcdbb-95e9-49ea-9642-6e0ee597e96a", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8.18" } }, "nbformat": 4, "nbformat_minor": 5 }