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

Adds line scan plots

parent a387117a
No related branches found
No related tags found
No related merge requests found
...@@ -501,6 +501,8 @@ class DSSC: ...@@ -501,6 +501,8 @@ class DSSC:
azimuthal['delta_q (1/nm)'] = 2e-9 * np.pi * np.sin( azimuthal['delta_q (1/nm)'] = 2e-9 * np.pi * np.sin(
np.arctan(azimuthal.distance * self.px_pitch_v*1e-6 / self.distance)) / wl np.arctan(azimuthal.distance * self.px_pitch_v*1e-6 / self.distance)) / wl
azimuthal.attrs = self.binned.attrs
self.azimuthal = azimuthal.swap_dims({'distance': 'delta_q (1/nm)'}) self.azimuthal = azimuthal.swap_dims({'distance': 'delta_q (1/nm)'})
...@@ -511,12 +513,42 @@ class DSSC: ...@@ -511,12 +513,42 @@ class DSSC:
xr.plot.imshow(self.azimuthal.pumped, ax=ax1, robust=True) xr.plot.imshow(self.azimuthal.pumped, ax=ax1, robust=True)
ax1.set_title('unpumped') ax1.set_title('unpumped')
ax1.set_xlabel(self.scan_vname)
xr.plot.imshow(self.azimuthal.pumped - self.azimuthal.unpumped, ax=ax2, robust=True) xr.plot.imshow(self.azimuthal.pumped - self.azimuthal.unpumped, ax=ax2, robust=True)
ax2.set_title('pumped - unpumped') ax2.set_title('pumped - unpumped')
ax2.set_xlabel(self.scan_vname) ax2.set_xlabel(self.scan_vname)
fig.suptitle(f'{self.plot_title}') fig.suptitle(f'{self.plot_title}')
def plot_azimuthal_line_cut(self, data, qranges, qwidths):
""" Plot line scans on top of the data.
inputs:
data: an azimuthal integrated xarray DataArray with 'delta_q (1/nm)' as one of its dimension.
qranges: a list of q-range
qwidth: a list of q-width, same length as qranges
"""
fig, [ax1, ax2] = plt.subplots(nrows=2, sharex=True, figsize=[8, 7])
xr.plot.imshow(data, ax=ax1, robust=True)
# attributes are not propagated during xarray mathematical operation https://github.com/pydata/xarray/issues/988
# so we might not have in data the scan vaiable name anymore
ax1.set_xlabel(self.scan_vname)
fig.suptitle(f'{self.plot_title}')
for i, (qr, qw) in enumerate(zip(qranges, qwidths)):
sel = (data['delta_q (1/nm)'] > (qr - qw/2)) * (data['delta_q (1/nm)'] < (qr + qw/2))
val = data.where(sel).mean('delta_q (1/nm)')
ax2.plot(data.scan_variable, val, c=f'C{i}', label=f'q = {qr:.2f}')
ax1.axhline(qr - qw/2, c=f'C{i}', lw=1)
ax1.axhline(qr + qw/2, c=f'C{i}', lw=1)
ax2.legend()
ax2.set_xlabel(self.scan_vname)
# since 'self' is not pickable, this function has to be outside the DSSC class so that it can be used # since 'self' is not pickable, this function has to be outside the DSSC class so that it can be used
# by the multiprocessing pool.map function # by the multiprocessing pool.map function
def process_one_module(job): def process_one_module(job):
......
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