Skip to content

Commit ed9001b

Browse files
authored
Merge pull request #2410 from EdgarGF93/polarangle_api
API for exit and polar angles
2 parents 38c9975 + 38e41f2 commit ed9001b

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

src/pyFAI/integrator/fiber.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,88 @@ def integrate2d_fiber(self, data,
376376
filename=filename)
377377

378378
integrate2d_grazing_incidence = integrate2d_fiber
379+
380+
def integrate2d_polar(self, polar_degrees=True, radial_unit="nm^-1", rotate=False, **kwargs):
381+
"""Reshapes the data pattern as a function of polar angle=arctan(qOOP / qIP) versus q modulus.
382+
383+
:param polar_degrees bool: if True, polar angle in degrees, else in radians
384+
:param radial_unit str: unit of q modulus: nm^-1 or A^-1
385+
:param rotate bool: if False, polar_angle vs q, if True q vs polar_angle
386+
387+
Calls method integrate2d_fiber ->
388+
"""
389+
unit_oop = "chigi_deg" if polar_degrees else "chigi_rad"
390+
unit_ip = "qtot_A^-1" if radial_unit == "A^-1" else "qtot_nm^-1"
391+
392+
if rotate:
393+
kwargs["unit_ip"] = unit_oop
394+
kwargs["unit_oop"] = unit_ip
395+
else:
396+
kwargs["unit_ip"] = unit_ip
397+
kwargs["unit_oop"] = unit_oop
398+
return self.integrate2d_fiber(**kwargs)
399+
400+
integrate2d_polar.__doc__ += "\n" + integrate2d_fiber.__doc__
401+
402+
def integrate2d_exitangles(self, angle_degrees=True, **kwargs):
403+
"""Reshapes the data pattern as a function of exit angles with the origin at the sample horizon
404+
405+
:param angle_degrees bool: if True, exit angles in degrees, else in radians
406+
407+
Calls method integrate2d_fiber ->
408+
"""
409+
if angle_degrees:
410+
unit_ip = "exit_angle_horz_deg"
411+
unit_oop = "exit_angle_vert_deg"
412+
else:
413+
unit_ip = "exit_angle_horz_rad"
414+
unit_oop = "exit_angle_vert_rad"
415+
416+
kwargs["unit_ip"] = unit_ip
417+
kwargs["unit_oop"] = unit_oop
418+
return self.integrate2d_fiber(**kwargs)
419+
420+
integrate2d_exitangles.__doc__ += "\n" + integrate2d_fiber.__doc__
421+
422+
def integrate1d_polar(self, polar_degrees=True, radial_unit="nm^-1", radial_integration=False, **kwargs):
423+
"""Calculate the integrated profile curve along the polar angle=arctan(qOOP / qIP) or as a function of the polar angle along q modulus
424+
425+
:param polar_degrees bool: if True, polar angle in degrees, else in radians
426+
:param radial_unit str: unit of q modulus: nm^-1 or A^-1
427+
:param radial_integration bool: if False, the output profile is I vs q, if True (I vs polar_angle)
428+
429+
Calls method integrate_fiber ->
430+
"""
431+
unit_oop = "chigi_deg" if polar_degrees else "chigi_rad"
432+
unit_ip = "qtot_A^-1" if radial_unit == "A^-1" else "qtot_nm^-1"
433+
kwargs["unit_ip"] = unit_ip
434+
kwargs["unit_oop"] = unit_oop
435+
if radial_integration:
436+
kwargs["vertical_integration"] = True
437+
else:
438+
kwargs["vertical_integration"] = False
439+
return self.integrate_fiber(**kwargs)
440+
441+
integrate1d_polar.__doc__ += "\n" + integrate_fiber.__doc__
442+
443+
def integrate1d_exitangles(self, angle_degrees=True, vertical_integration=True, **kwargs):
444+
"""Calculate the integrated profile curve along the one of the exit angles (with the origin at the sample horizon)
445+
446+
:param angle_degrees bool: if True, exit angles in degrees, else in radians
447+
:param vertical_integration bool: if True, the output profile is I vs vertical_angle, if False (I vs horizontal_angle)
448+
449+
Calls method integrate_fiber ->
450+
"""
451+
if angle_degrees:
452+
unit_ip = "exit_angle_horz_deg"
453+
unit_oop = "exit_angle_vert_deg"
454+
else:
455+
unit_ip = "exit_angle_horz_rad"
456+
unit_oop = "exit_angle_vert_rad"
457+
458+
kwargs["unit_ip"] = unit_ip
459+
kwargs["unit_oop"] = unit_oop
460+
kwargs["vertical_integration"] = vertical_integration
461+
return self.integrate_fiber(**kwargs)
462+
463+
integrate1d_exitangles.__doc__ += "\n" + integrate_fiber.__doc__

0 commit comments

Comments
 (0)