Skip to content
Snippets Groups Projects
Commit 0332557d authored by Loïc Le Guyader's avatar Loïc Le Guyader
Browse files

Plot relative azimuthal integrated change option

parent 058c4c34
No related branches found
No related tags found
No related merge requests found
......@@ -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}')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment