def _plot_cal_sample(self, index): """ Plots a single calibration sample. """ self._axL.cla() self._axR.cla() if (index < 0) or (index >= self.num_samples): print "Cannot access sample: %d" % index print "Total %d samples available" % self.num_samples return print print "Plotting calibration sample: %d" % index print " (may take a moment)" # load up the calibration sample requested fn = self.calibration_samples[index]['filename'] d = self.calibration_samples[index]['distance'] + self.distance_offset print " distance: %.2f mm" % d # -- plot left panel, the assemled image with ring predictions overlaid img = read.load_raw_image(fn) plot.imshow_cspad( self.cspad(img), vmin=0, ax=self._axL ) # plot circles on the image, over where the powder rings should be # note that (1000,1000) is where the center is in pixel units # for our fxn imshow_cspads real_expected = self.real_space(self.expected, d) / 0.10992 for r in real_expected: blob_circ = plt_patches.Circle((1000,1000), r, fill=False, lw=1, ec='white') self._axL.add_patch(blob_circ) # plot beam center beam_center = plt_patches.Circle((1000,1000), 2, fill=True, lw=1, color='r') self._axL.add_patch(beam_center) # --- plot the right image n_bins = 800 bin_centers, a = self.cspad.intensity_profile(img, n_bins=n_bins) q_bin_centers = self.reciprocal(bin_centers, d) self._axR.plot(q_bin_centers, a / a.max(), color='orange', lw=4) for i in range(4): bin_centers, a = self.cspad.intensity_profile(img, n_bins=n_bins, quad=i) a /= a.max() a += 1.0 * i + 1.0 q_bin_centers = self.reciprocal(bin_centers, d) self._axR.plot(q_bin_centers, a, color=plot.quad_colors[i], lw=2) self._axR.text(0.5, -0.2, 'All Quads') self._axR.text(0.5, 0.8, 'Quad 0') self._axR.text(0.5, 1.8, 'Quad 1') self._axR.text(0.5, 2.8, 'Quad 2') self._axR.text(0.5, 3.8, 'Quad 3') self._axR.set_ylim([-0.3, 5.3]) self._axR.vlines(self.expected, 0, a.max()*1.2, color='k', linestyles='dashed') # self._axR.vlines(self.observed[index,:], 0, a.max(), color='r', linestyles='dashed') self._axR.set_xlabel(r'q ($\AA^{-1}$)') self._axR.set_ylabel('Intensity') plt.show() print return
#!/usr/bin/local/python import numpy as np import matplotlib.pyplot as plt import matplotlib.patches as plt_patches from pypad import cspad from pypad import utils from pypad import read from pypad import plot cs1 = cspad.CSPad.load("examples/my_cspad.cspad") cs2 = cspad.CSPad.default() cs3 = cspad.CSPad.default() cs3.quad_rotation[0] = 10. cs3.quad_rotation[1] = 0. cs3.quad_rotation[2] = 2. cs3.quad_rotation[3] = -10. raw_image = read.load_raw_image("examples/gold-minus490mm.h5") fig = plt.figure() ax = plt.subplot(121) plot.imshow_cspad(cs3(raw_image), ax=ax, scrollable=True) ax = plt.subplot(122) plot.sketch_2x1s(cs3.pixel_positions, ax) plt.show()
def _plot_cal_sample(self, index): """ Plots a single calibration sample. """ self._axL.cla() self._axR.cla() if (index < 0) or (index >= self.num_samples): print "Cannot access sample: %d" % index print "Total %d samples available" % self.num_samples return print print "Plotting calibration sample: %d" % index print " (may take a moment)" # load up the calibration sample requested fn = self.calibration_samples[index]['filename'] d = self.calibration_samples[index]['distance'] + self.distance_offset print " distance: %.2f mm" % d # -- plot left panel, the assemled image with ring predictions overlaid img = read.load_raw_image(fn) plot.imshow_cspad(self.cspad(img), vmin=0, ax=self._axL) # plot circles on the image, over where the powder rings should be # note that (1000,1000) is where the center is in pixel units # for our fxn imshow_cspads real_expected = self.real_space(self.expected, d) / 0.10992 for r in real_expected: blob_circ = plt_patches.Circle((1000, 1000), r, fill=False, lw=1, ec='white') self._axL.add_patch(blob_circ) # plot beam center beam_center = plt_patches.Circle((1000, 1000), 2, fill=True, lw=1, color='r') self._axL.add_patch(beam_center) # --- plot the right image n_bins = 800 bin_centers, a = self.cspad.intensity_profile(img, n_bins=n_bins) q_bin_centers = self.reciprocal(bin_centers, d) self._axR.plot(q_bin_centers, a / a.max(), color='orange', lw=4) for i in range(4): bin_centers, a = self.cspad.intensity_profile(img, n_bins=n_bins, quad=i) a /= a.max() a += 1.0 * i + 1.0 q_bin_centers = self.reciprocal(bin_centers, d) self._axR.plot(q_bin_centers, a, color=plot.quad_colors[i], lw=2) self._axR.text(0.5, -0.2, 'All Quads') self._axR.text(0.5, 0.8, 'Quad 0') self._axR.text(0.5, 1.8, 'Quad 1') self._axR.text(0.5, 2.8, 'Quad 2') self._axR.text(0.5, 3.8, 'Quad 3') self._axR.set_ylim([-0.3, 5.3]) self._axR.vlines(self.expected, 0, a.max() * 1.2, color='k', linestyles='dashed') # self._axR.vlines(self.observed[index,:], 0, a.max(), color='r', linestyles='dashed') self._axR.set_xlabel(r'q ($\AA^{-1}$)') self._axR.set_ylabel('Intensity') plt.show() print return