Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This script lives in in /reg/g/psdm/tutorials/examplePythonexamplePython3/radInteg.py and demonstrates how to do an angular integration of a 2D area-detector image.  If you don't have a 2D image, but instead have pixel values and positions, consider using the more general BinnedStatistic1D/BinnedStatistic2D/BinnedStatisticDD classes in skbeam.core.accumulators.binned_statistic (not documented here, but documentation is available within IPython).

...

Code Block
from skbeam.core.accumulators.binned_statistic import RadialBinnedStatistic, RPhiBinnedStatistic
import numpy as np
img = np.reshape(np.arange(9),(3,3))
print 'Image:\n',img
mask = np.ones_like(img)
mask[1][1]=0
print (f'\nMask:\n{mask}',mask)
radbinstat = RadialBinnedStatistic(img.shape, bins=3,
                                   statistic='sum',
                                   origin=(0,0),
                                   range = (0,2),
                                   mask=mask)
rphibinstat = RPhiBinnedStatistic(img.shape, bins=(3,1),
                                  statistic='sum',
                                  origin=(0,0),
                                  range = ((0,2),(0,np.pi/3)))
rphibinstat_mask = RPhiBinnedStatistic(img.shape, bins=(3,1),
                                       statistic='sum',
                                       origin=(0,0),
                                       range = ((0,2),(0,np.pi/3)),
                                       mask=mask)
print ('\nAngular integration with mask:')
print (radbinstat(img))
print ('\nBin edges and centers:')
print (radbinstat.bin_edges)
print (radbinstat.bin_centers)
print ('\n2D R/Phi Angular integration (1 phi bin) with phi range and mask:')
print (rphibinstat_mask(img))
print ('\n2D R/Phi Angular integration (1 phi bin) with phi range and no mask:')
print (rphibinstat(img))
print ('\nR/Phi bin edges:')
print (rphibinstat.bin_edges[0])
print (rphibinstat.bin_edges[1])

The output of running this script is below.  It attempts to demonstrate:

...