{ "cells": [ { "cell_type": "markdown", "id": "9acfb438-b43c-4042-a9eb-982da0528bff", "metadata": {}, "source": [ "# edit an NXtomo\n", "\n", "The general pipeline to edit an NXtomo is:\n", "\n", "```\n", "load it from disk -> modify it 'in memory' -> save it to disk\n", "```\n", "In this example we will edit the `dummy_nxtomo.nx` file. which is the outcome of the 'create_from_scratch' tutorial" ] }, { "cell_type": "code", "execution_count": null, "id": "4ccc9c2c-cacf-423d-aa44-c8958c9b8f57", "metadata": {}, "outputs": [], "source": [ "import os\n", "from nxtomo import NXtomo\n", "\n", "nx_tomo_file_path = os.path.join(\"resources\", \"dummy_nxtomo.nx\")\n", "nx_tomo = NXtomo().load(nx_tomo_file_path, \"entry\", detector_data_as=\"as_numpy_array\")\n", "print(\"nx_tomo type is\", type(nx_tomo))\n", "print(\"nx_tomo energy is\", nx_tomo.energy)" ] }, { "cell_type": "markdown", "id": "5978b2db-900f-4b46-ae6b-28d8d4c01958", "metadata": {}, "source": [ "Then you can modify your values as it was presented previously and overwrite the file." ] }, { "cell_type": "code", "execution_count": null, "id": "b35f9b9b-d80d-4b51-814c-bb829d7d6b94", "metadata": {}, "outputs": [], "source": [ "nx_tomo.energy = 13.6\n", "nx_tomo.save(\n", " file_path=nx_tomo_file_path,\n", " data_path=\"entry\",\n", " overwrite=True,\n", ")\n", "print(\"new energy is\", NXtomo().load(nx_tomo_file_path, \"entry\").energy)" ] }, { "cell_type": "markdown", "id": "2c6ace38-4ab9-4efb-961c-ec7afb6b4751", "metadata": {}, "source": [ "