silx-kit / pyFAI

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

Problems in function integrate_radial #1978

Open alvescassio opened 11 months ago

alvescassio commented 11 months ago

I'm motivated about pyfai, but I am a problem in the function integrate_radial, as shown below

q_I = self.poni.integrate_radial(self.img.data, radial_range= radial_range, npt=npt_azim, npt_rad=npt_rad, azimuth_range= azimuth_range, correctSolidAngle=True,mask=self.mask, dummy=None, delta_dummy=None, polarization_factor= None, dark=None, flat=None, unit='chi_deg', radial_unit=self.unit, normalization_factor=1.0,method="cython")

The problem is file azimuthalIntegrator.py in line: intensity = sum_signal / sum_normalization

output of error: azimuthalIntegrator.py:1672: RuntimeWarning: invalid value encountered in true_divide intensity = sum_signal / sum_normalization

This problem happens when I use radial_range with -9 to 9 degrees, using self.poni.setChiDiscAtPi();

When I use angles between 170 to 190 or 350 and 10, the problem appears.

Please, could you help me?

kif commented 11 months ago

Hi Alves,

I guess self.poni is an instance of AzimuthalIntegrator, but I don't quite understand what you are willing to achieve. The error message you obtain is linked to this division (by zero) which comes down to "no pixel contributed to at least one bin". The problem is why is this bin empty.

The radial range you wish is (-9°, +9°) but by default the radial unit is "q_nm^-1". To me, it makes little sense to have q<0 (same for 2θ). Did you mean azimuth_range since you are referring to the position of the discontinuity ?

If you are willing to integrate several sectors in an image, I would recommand you to use integrate2d once and slice out the different region of interest. This will be much faster because integrate_radial will call anyway integrate2d each time. Furthermore, changing the origin of the azimuthal angle will reset all arrays which take ~1s to be reinitialized.