notebook for plotting 4 dimensional datasets collected at Diamond Light source on I07¶
steps to use this notebook:
to run a cell use shift+enter
run the first cell with 'import …' to import the relevant packages
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
Use the sliders created below the cell to alter the slicing indices.
[1]:
#run this cell to import required packages
import h5py
import numpy as np
import os
import matplotlib.pyplot as plt
import pandas as pd
import ipywidgets as wg
from ipywidgets import HBox, Label
from pathlib import Path
[3]:
#edit the directory value to be the path where your data is stored
directory=Path('/dls/science/groups/das/ExampleData/i07/fast_rsm_example_data/v1.3.0_2025-08-19')
qmaps=[file for file in os.listdir(directory) if file.startswith('Qmap')]
plotmap=directory /qmaps[0]
data=h5py.File(plotmap)
qmapdata=data['qpara_qperp']
%matplotlib qt
def plot_map(ind1,ind2):
axs.clear()
limits_para=qmapdata['map_para'][ind1][ind2]
limits_perp=-qmapdata['map_perp'][ind1][ind2]
axs.imshow(qmapdata['qpara_qperp_map'][ind1][ind2],vmax=5500,extent=[limits_para.min(),limits_para.max(),limits_perp.min(),limits_perp.max()])
axs.set_xlabel('q$_{para}$ (\u212B$^{-1}$)')
axs.set_ylabel('q$_{perp}$ (\u212B$^{-1}$)')
plt.show()
fig,axs=plt.subplots(1,1,figsize=(10,10))
scanfields=list(data['scanfields'].keys())
style = {'description_width': 'initial'}
ind1slide=wg.IntSlider(value=1,min=1,max=np.shape(qmapdata['map_para'])[0]-1,description=scanfields[0],style=style)
ind2slide=wg.IntSlider(value=1,min=1,max=np.shape(qmapdata['map_para'])[1]-1,description=scanfields[1],style=style)
wg.interact(plot_map,ind1=ind1slide,ind2=ind2slide)
[3]:
<function __main__.plot_map(ind1, ind2)>
[ ]:
[ ]:
[ ]: