{ "cells": [ { "cell_type": "markdown", "id": "8f0c64c1-69a5-448e-b0cd-a6d523984bfb", "metadata": {}, "source": [ "# notebook for plotting 4 dimensional datasets collected at Diamond Light source on I07\n", "\n", "steps to use this notebook:\n", "- to run a cell use shift+enter\n", "- run the first cell with 'import ...' to import the relevant packages\n", "- edit the directory variable to be the path where your data is stored, and then run the cell. This should open up a new window with the qmap plot\n", "- Use the sliders created below the cell to alter the slicing indices.\n", "- " ] }, { "cell_type": "code", "execution_count": 1, "id": "cd603ec0-e89c-41bb-929b-e85fd6f8ae87", "metadata": {}, "outputs": [], "source": [ "#run this cell to import required packages\n", "import h5py\n", "import numpy as np\n", "import os\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import ipywidgets as wg\n", "from ipywidgets import HBox, Label\n", "from pathlib import Path\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "7b032d2d-5248-49c7-89db-6831f064946c", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8b286be4da5841fcb8fe80977f837595", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(IntSlider(value=1, description='dim0_testMotor1', max=25, min=1, style=SliderStyle(descr…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#edit the directory value to be the path where your data is stored\n", "directory=Path('/dls/science/groups/das/ExampleData/i07/fast_rsm_example_data/v1.3.0_2025-08-19')\n", "\n", "qmaps=[file for file in os.listdir(directory) if file.startswith('Qmap')]\n", "\n", "plotmap=directory /qmaps[0]\n", "data=h5py.File(plotmap)\n", "qmapdata=data['qpara_qperp'] \n", "%matplotlib qt\n", "def plot_map(ind1,ind2):\n", " axs.clear()\n", " limits_para=qmapdata['map_para'][ind1][ind2]\n", " limits_perp=-qmapdata['map_perp'][ind1][ind2]\n", " axs.imshow(qmapdata['qpara_qperp_map'][ind1][ind2],vmax=5500,extent=[limits_para.min(),limits_para.max(),limits_perp.min(),limits_perp.max()])\n", " axs.set_xlabel('q$_{para}$ (\\u212B$^{-1}$)')\n", " axs.set_ylabel('q$_{perp}$ (\\u212B$^{-1}$)')\n", " plt.show()\n", "fig,axs=plt.subplots(1,1,figsize=(10,10))\n", "scanfields=list(data['scanfields'].keys())\n", "style = {'description_width': 'initial'}\n", "ind1slide=wg.IntSlider(value=1,min=1,max=np.shape(qmapdata['map_para'])[0]-1,description=scanfields[0],style=style)\n", "ind2slide=wg.IntSlider(value=1,min=1,max=np.shape(qmapdata['map_para'])[1]-1,description=scanfields[1],style=style)\n", "\n", "\n", "wg.interact(plot_map,ind1=ind1slide,ind2=ind2slide)" ] }, { "cell_type": "code", "execution_count": null, "id": "b0ebab96-150d-4021-8605-852f5def0da1", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "0d2f4cec-5f48-4774-b774-19ded724cf2d", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "abc62a1d-b4e6-4d19-9ccc-f69ab86283d5", "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.10.0" } }, "nbformat": 4, "nbformat_minor": 5 }