55import numpy as np
66import matplotlib .pyplot as plt
77import hdfmap
8- from ..utils .experiment import Experiment
8+ from ..utils .experiment import Experiment , ScanFile
99from .matplotlib import (
1010 set_plot_defaults , generate_subplots , plot_lines , plot_2d_surface , plot_3d_surface , plot_3d_lines ,
1111 FIG_SIZE , FIG_DPI , DEFAULT_CMAP , Axes3D
@@ -32,7 +32,7 @@ def __init__(self, experiment: Experiment):
3232 def __call__ (self , * args , ** kwargs ):
3333 return self .plot (* args , ** kwargs )
3434
35- def plot (self , * scan_files : int | str , hdf_map : hdfmap .NexusMap | None = None ,
35+ def plot (self , * scan_files : ScanFile , hdf_map : hdfmap .NexusMap | None = None ,
3636 xaxis : str = 'axes' , yaxis : str | list [str ] = 'signal' , axes : plt .Axes | None = None , ** kwargs ) -> plt .Axes :
3737 """
3838 Create matplotlib figure with a line plot from a or several scans
@@ -57,7 +57,7 @@ def plot(self, *scan_files: int | str, hdf_map: hdfmap.NexusMap | None = None,
5757 axes .set_title (self .exp .generate_scans_title (* scan_files ))
5858 return axes
5959
60- def image (self , scan_file : int | str = - 1 , hdf_map : hdfmap .NexusMap | None = None ,
60+ def image (self , scan_file : ScanFile = - 1 , hdf_map : hdfmap .NexusMap | None = None ,
6161 index : int | tuple | slice | None = None , xaxis : str = 'axes' ,
6262 axes : plt .Axes | None = None , clim : tuple [float , float ] | None = None ,
6363 cmap : str = DEFAULT_CMAP , colorbar : bool = False , ** kwargs ) -> plt .Axes | None :
@@ -79,7 +79,7 @@ def image(self, scan_file: int | str = -1, hdf_map: hdfmap.NexusMap | None = No
7979 return scan .plot .image (index , xaxis , axes , clim , cmap , colorbar , ** kwargs )
8080 return None
8181
82- def detail (self , scan_file : int | str = - 1 , hdf_map : hdfmap .NexusMap | None = None ,
82+ def detail (self , scan_file : ScanFile = - 1 , hdf_map : hdfmap .NexusMap | None = None ,
8383 xaxis : str = 'axes' , yaxis : str | list [str ] = 'signal' ,
8484 index : int | tuple | slice | None = None , clim : tuple [float , float ] | None = None ,
8585 cmap : str = DEFAULT_CMAP , ** kwargs ) -> plt .Figure :
@@ -107,8 +107,9 @@ def detail(self, scan_file: int | str = -1, hdf_map: hdfmap.NexusMap | None = No
107107 lt .set_title (None )
108108
109109 # Top right - image plot
110- scan .plot .image (index , xaxis , cmap = cmap , clim = clim , axes = rt )
111- rt .set_title (None )
110+ if scan .map .image_data :
111+ scan .plot .image (index , xaxis , cmap = cmap , clim = clim , axes = rt )
112+ rt .set_title (None )
112113
113114 # Bottom-Left - details
114115 details = self .exp .scan_str (scan_file , hdf_map = hdf_map )
@@ -122,7 +123,7 @@ def detail(self, scan_file: int | str = -1, hdf_map: hdfmap.NexusMap | None = No
122123 rb .text (- 0.2 , 1 , fit_report , ha = 'left' , va = 'top' , multialignment = "left" , fontsize = 12 , wrap = True )
123124 return fig
124125
125- def multi_lines (self , * scan_files : int | str , hdf_map : hdfmap .NexusMap | None = None ,
126+ def multi_lines (self , * scan_files : ScanFile , hdf_map : hdfmap .NexusMap | None = None ,
126127 xaxis : str = 'axes' , yaxis : str = 'signal' , value : str | None = None ,
127128 axes : plt .Axes | None = None , ** kwargs ) -> plt .Axes :
128129 """
@@ -162,7 +163,7 @@ def multi_lines(self, *scan_files: int | str, hdf_map: hdfmap.NexusMap | None =
162163 plt .colorbar (sm , ax = axes , label = value_label )
163164 return axes
164165
165- def multi_plot (self , * scan_files : int | str , hdf_map : hdfmap .NexusMap | None = None ,
166+ def multi_plot (self , * scan_files : ScanFile , hdf_map : hdfmap .NexusMap | None = None ,
166167 xaxis : str = 'axes' , yaxis : str | list [str ] = 'signal' , value : str | None = None ,
167168 subplots : tuple [int , int ] = (4 , 4 ), ** kwargs ) -> list [tuple [plt .Figure , plt .Axes ]]:
168169 """
@@ -190,7 +191,29 @@ def multi_plot(self, *scan_files: int | str, hdf_map: hdfmap.NexusMap | None = N
190191 ax .set_title (ttl_exp )
191192 return fig_ax
192193
193- def surface_2d (self , * scan_files : int | str , hdf_map : hdfmap .NexusMap | None = None ,
194+ def multi_image (self , * scan_files : ScanFile , hdf_map : hdfmap .NexusMap | None = None ,
195+ index : int | tuple | slice | None = None , xaxis : str = 'axes' ,
196+ clim : tuple [float , float ] | None = None , cmap : str = DEFAULT_CMAP ,
197+ colorbar : bool = False , ** kwargs ) -> list [tuple [plt .Figure , plt .Axes ]]:
198+ """
199+ Plot scan images in matplotlib figure (if available)
200+ :param scan_files: scan number or filename (multiple allowed)
201+ :param hdf_map: hdfmap object or None
202+ :param index: int, detector image index, 0-length of scan, if None, use centre index
203+ :param xaxis: name or address of xaxis dataset
204+ :param clim: [min, max] colormap cut-offs (None for auto)
205+ :param cmap: str colormap name (None for auto)
206+ :param colorbar: False/ True add colorbar to plot
207+ :param kwargs: additional arguments for plot_detector_image
208+ :return: [(Figure, Axes)] for each scan
209+ """
210+ fig_axes = generate_subplots (len (scan_files ))
211+ for scan , (fig , axes ) in zip (scan_files , fig_axes ):
212+ self .image (scan , axes = axes , hdf_map = hdf_map , index = index , xaxis = xaxis ,
213+ clim = clim , cmap = cmap , colorbar = colorbar , ** kwargs )
214+ return fig_axes
215+
216+ def surface_2d (self , * scan_files : ScanFile , hdf_map : hdfmap .NexusMap | None = None ,
194217 xaxis : str = 'axes' , signal : str = 'signal' , values : str | None = None ,
195218 axes : plt .Axes | None = None , clim : tuple [float , float ] | None = None ,
196219 axlim : str = 'image' , ** kwargs ) -> plt .Axes :
@@ -226,7 +249,7 @@ def surface_2d(self, *scan_files: int | str, hdf_map: hdfmap.NexusMap | None = N
226249 axes .figure .colorbar (surf , ax = axes , label = signal )
227250 return axes
228251
229- def lines_3d (self , * scan_files : int | str , hdf_map : hdfmap .NexusMap | None = None ,
252+ def lines_3d (self , * scan_files : ScanFile , hdf_map : hdfmap .NexusMap | None = None ,
230253 xaxis : str = 'axes' , signal : str = 'signal' , values : str | None = None ,
231254 axes : Axes3D | None = None , legend : bool = False , ** kwargs ) -> Axes3D :
232255 """
@@ -265,7 +288,7 @@ def lines_3d(self, *scan_files: int | str, hdf_map: hdfmap.NexusMap | None = Non
265288 axes .legend ()
266289 return axes
267290
268- def surface_3d (self , * scan_files : int | str , hdf_map : hdfmap .NexusMap | None = None ,
291+ def surface_3d (self , * scan_files : ScanFile , hdf_map : hdfmap .NexusMap | None = None ,
269292 xaxis : str = 'axes' , signal : str = 'signal' , values : str | None = None ,
270293 axes : Axes3D | None = None , clim : tuple [float , float ] | None = None ,
271294 axlim : str = 'image' , ** kwargs ) -> Axes3D :
@@ -302,7 +325,7 @@ def surface_3d(self, *scan_files: int | str, hdf_map: hdfmap.NexusMap | None = N
302325 axes .set_zlabel (signal_label )
303326 return axes
304327
305- def metadata (self , * scan_files : int | str , values : str | list [str ], hdf_map : hdfmap .NexusMap | None = None ,
328+ def metadata (self , * scan_files : ScanFile , values : str | list [str ], hdf_map : hdfmap .NexusMap | None = None ,
306329 axes : plt .Axes | None = None ) -> plt .Axes :
307330 """
308331 Create matplotlib figure with plot of metadata vs scan number
0 commit comments