From 0332557d28dfb9e8384a5a1b5d2217ba52a65428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Le=20Guyader?= <loic.le.guyader@xfel.eu> Date: Sat, 26 Oct 2019 06:27:27 +0200 Subject: [PATCH] Plot relative azimuthal integrated change option --- DSSC.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/DSSC.py b/DSSC.py index 89cae9e..eeea314 100644 --- a/DSSC.py +++ b/DSSC.py @@ -330,7 +330,7 @@ class DSSC: if do_pulse_mean: self.module_data = xr.merge([self.module_data, self.scan.groupby('scan_variable').mean('trainId')]) - else: + elif self.xgm is not None: xgm_pumped = self.xgm[:, :self.nbunches:2].mean('trainId').to_dataset(name='xgm_pumped').rename({'dim_0':'scan_variable'}) xgm_unpumped = self.xgm[:, 1:self.nbunches:2].mean('trainId').to_dataset(name='xgm_unpumped').rename({'dim_0':'scan_variable'}) self.module_data = xr.merge([self.module_data, xgm_pumped, xgm_unpumped]) @@ -527,17 +527,32 @@ class DSSC: self.azimuthal = azimuthal.swap_dims({'distance': 'delta_q (1/nm)'}) - def plot_azimuthal_int(self): + def plot_azimuthal_int(self, kind='difference', lim=None): """ Plot a computed azimuthal integration. + + inputs: + kind: (str) either 'difference' or 'relative' to change the type of plot. """ fig, [ax1, ax2] = plt.subplots(nrows=2, sharex=True, sharey=True) xr.plot.imshow(self.azimuthal.pumped, ax=ax1, vmin=0, robust=True) ax1.set_title('pumped') ax1.set_xlabel(self.scan_vname) - xr.plot.imshow(self.azimuthal.pumped - self.azimuthal.unpumped, ax=ax2, robust=True) - ax2.set_title('pumped - unpumped') + + if kind == 'difference': + val = self.azimuthal.pumped - self.azimuthal.unpumped + ax2.set_title('pumped - unpumped') + elif kind == 'relative': + val = (self.azimuthal.pumped - self.azimuthal.unpumped)/self.azimuthal.unpumped + ax2.set_title('(pumped - unpumped)/unpumped') + else: + raise ValueError('kind should be either difference or relative') + if lim is None: + xr.plot.imshow(val, ax=ax2, robust=True) + else: + xr.plot.imshow(val, ax=ax2, vmin=lim[0], vmax=lim[1]) + ax2.set_xlabel(self.scan_vname) fig.suptitle(f'{self.plot_title}') -- GitLab