silx-kit / pyFAI

Fast Azimuthal Integration in Python
Other
104 stars 94 forks source link

advanced use of azimuth_range parameter for integration1d/2d methode #79

Open gbenecke opened 10 years ago

gbenecke commented 10 years ago

The azimuth_range parameter currently only allows to select a range from small to big angles in the azimuthal range. With this definition some cases of integration ranges are not possible (see image). I suggest to redefine the use of the azimuth_range parameter:

azimuth_range

Attached is a script implementing this suggested method.

import pyFAI
import pylab
import numpy

def mask(chi, c0, c1):
    chi = numpy.copy(chi)
    if c0 >= c1:
        m = (chi <= c0) & (chi >= c1)
    else:
        m = (chi <= c0) | (chi >= c1)

    chi[~m] = 0
    return chi

ai = pyFAI.AzimuthalIntegrator(poni1=250, poni2=250, pixel1=1, pixel2=1)
chi = numpy.rad2deg(ai.chiArray((500,500)))

fig = pylab.gcf()

pylab.subplot(2,3,1)
pylab.title("c0=-45, c1=-135")
pylab.imshow(mask(chi, -45, -135), vmin=-180, vmax=180)
pylab.colorbar()

pylab.subplot(2,3,2)
pylab.title("c0=-135, c1=-45")
pylab.imshow(mask(chi, -135, -45), vmin=-180, vmax=180)
pylab.colorbar()

pylab.subplot(2,3,3)
pylab.title("c0=-135, c1=135")
pylab.imshow(mask(chi, -135, 135), vmin=-180, vmax=180)
pylab.colorbar()

pylab.subplot(2,3,4)
pylab.title("c0=135, c1=45")
pylab.imshow(mask(chi, 135, 45), vmin=-180, vmax=180)
pylab.colorbar()

pylab.subplot(2,3,5)
pylab.title("c0=45, c1=135")
pylab.imshow(mask(chi, 45, 135), vmin=-180, vmax=180)
pylab.colorbar()

pylab.subplot(2,3,6)
pylab.title("c0=45, c1=-45")
pylab.imshow(mask(chi, 45, -45), vmin=-180, vmax=180)
pylab.colorbar()

pylab.show()
kif commented 10 years ago

Hi Gunthard,

Could you explain a bit more what is the problem ?

gbenecke commented 10 years ago

There are two configuration for azimuthal angle: from -180 -> +180° (default disc@pi) and from 0->360° (disc@0). While those cover most configuration, they cannot integrate +100 -> 450° for example (unless one perform post-processing of the data).

Sorry for not being precise enough in the first post, but this is exactly what I meant. Integration over the border of the azimuthal angle (-180/180 or 0/360) is not possible in the current implementation. I noticed that masking big parts is quite expensive, but due to the problem of beam stops, shadows and other distortion it is quite often necessary to only cake integrate. So this is only a suggestion for a future release.

kif commented 10 years ago

On Thu, 24 Oct 2013 04:23:20 -0700 gbenecke notifications@github.com wrote:

There are two configuration for azimuthal angle: from -180 -> +180° (default disc@pi) and from 0->360° (disc@0). While those cover most configuration, they cannot integrate +100 -> 450° for example (unless one perform post-processing of the data).

Sorry for not being precise enough in the first post, but this is exactly what I meant. Integration over the border of the azimuthal angle (-180/180 or 0/360) is not possible in the current implementation. I noticed that masking big parts is quite expensive, but due to the problem of beam stops, shadows and other distortion it is quite often necessary to only cake integrate. So this is only a suggestion for a future release.

Do you see a solution for offering providing this discontinuity at any position ?

Jérôme Kieffer On-Line Data analysis / Software Group ISDD / ESRF tel +33 476 882 445