diff --git a/DSSC.py b/DSSC.py index 18743bac9be0ba20b64cf4ec330d1d896c820841..8f05bb7d6e08eb3398fe2412205498feb403dfd8 100644 --- a/DSSC.py +++ b/DSSC.py @@ -411,8 +411,8 @@ class DSSC: im_pump_mean, _ = self.geom.position_modules_fast(self.binned['pumped'].mean('scan_variable')) im_unpump_mean, _ = self.geom.position_modules_fast(self.binned['unpumped'].mean('scan_variable')) - im_pump_mean = mask*im_pump_mean - im_unpump_mean = mask*im_unpump_mean + self.im_pump_mean = mask*im_pump_mean + self.im_unpump_mean = mask*im_unpump_mean fig = plt.figure(figsize=(9, 4)) grid = ImageGrid(fig, 111, @@ -425,16 +425,16 @@ class DSSC: cbar_pad=0.15, ) - _vmin, _vmax = np.percentile(im_pump_mean[~np.isnan(im_pump_mean)], [p_low, p_high]) + _vmin, _vmax = np.percentile(self.im_pump_mean[~np.isnan(self.im_pump_mean)], [p_low, p_high]) if vmin is None: vmin = _vmin if vmax is None: vmax = _vmax - im = grid[0].imshow(im_pump_mean, vmin=vmin, vmax=vmax, aspect=self.aspect) + im = grid[0].imshow(self.im_pump_mean, vmin=vmin, vmax=vmax, aspect=self.aspect) grid[0].set_title('pumped' + mask_txt) - im = grid[1].imshow(im_unpump_mean, vmin=vmin, vmax=vmax, aspect=self.aspect) + im = grid[1].imshow(self.im_unpump_mean, vmin=vmin, vmax=vmax, aspect=self.aspect) grid[1].set_title('unpumped' + mask_txt) grid[-1].cax.colorbar(im) @@ -443,7 +443,7 @@ class DSSC: fig.suptitle(self.plot_title) - def azimuthal_int(self, wl, center=None, angle_range=[0, 360], dr=1, use_mask=True): + def azimuthal_int(self, wl, center=None, angle_range=[0, 180-1e-6], dr=1, use_mask=True): """ Perform azimuthal integration of 1D binned DSSC run. inputs: diff --git a/azimuthal_integrator.py b/azimuthal_integrator.py index 0b51176eecc9a0b632a46fabd6a140b52880663d..e064a392c2aaf497a365b17a25b3df5461c1f753 100644 --- a/azimuthal_integrator.py +++ b/azimuthal_integrator.py @@ -32,6 +32,7 @@ class azimuthal_integrator(object): ''' self.shape = imageshape cx, cy = center + print(f'azimuthal center: {center}') sx, sy = imageshape xcoord, ycoord = np.ogrid[:sx, :sy] xcoord -= cx @@ -41,6 +42,12 @@ class azimuthal_integrator(object): dist_array = np.hypot(xcoord * 204 / 236, ycoord) # array of polar angles + if np.abs(polar_range[1]-polar_range[0]) > 180: + raise ValueError('Integration angle too wide, should be within 180 degrees') + + if np.abs(polar_range[1]-polar_range[0]) < 1e-6: + raise ValueError('Integration angle too narrow') + tmin, tmax = np.deg2rad(np.sort(polar_range)) % np.pi polar_array = np.arctan2(xcoord, ycoord) polar_array = np.mod(polar_array, np.pi)