Skip to content

Commit

Permalink
integrate2d_fiber
Browse files Browse the repository at this point in the history
  • Loading branch information
edgar committed Sep 19, 2024
1 parent 36c67b2 commit 2e9c6f1
Showing 1 changed file with 152 additions and 0 deletions.
152 changes: 152 additions & 0 deletions src/pyFAI/azimuthalIntegrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,158 @@ def integrate_grazing_incidence(self, data,
polarization_factor=polarization_factor, dark=dark, flat=flat,
method=method,
normalization_factor=normalization_factor)

def integrate2d_fiber(self, data,
npt_horizontal, horizontal_unit=units.Q_IP, horizontal_unit_range=None,
npt_vertical=100, vertical_unit=units.Q_OOP, vertical_unit_range=None,
sample_orientation=None,
filename=None,
correctSolidAngle=True,
mask=None, dummy=None, delta_dummy=None,
polarization_factor=None, dark=None, flat=None,
method=("no", "histogram", "cython"),
normalization_factor=1.0):
if isinstance(vertical_unit, units.UnitFiber):
sample_orientation = sample_orientation or vertical_unit.sample_orientation
else:
sample_orientation = sample_orientation or 1

reset = False
if isinstance(vertical_unit, units.UnitFiber):
if vertical_unit.sample_orientation != sample_orientation:
vertical_unit.set_sample_orientation(sample_orientation)
reset = True
else:
vertical_unit = units.to_unit(vertical_unit)
vertical_unit.set_sample_orientation(sample_orientation)
reset = True

if isinstance(horizontal_unit, units.UnitFiber):
if horizontal_unit.sample_orientation != sample_orientation:
horizontal_unit.set_sample_orientation(sample_orientation)
reset = True
else:
horizontal_unit = units.to_unit(horizontal_unit)
horizontal_unit.set_sample_orientation(sample_orientation)
reset = True

if reset:
self.reset()

if (isinstance(method, (tuple, list)) and method[0] != "no") or (isinstance(method, IntegrationMethod) and method.split != "no"):
logger.warning(f"Method {method} is using a pixel-splitting scheme. GI integration should be use WITHOUT PIXEL-SPLITTING! The results could be wrong!")

return self.integrate2d_ng(data, npt_rad=npt_horizontal, npt_azim=npt_vertical,
correctSolidAngle=correctSolidAngle,
mask=mask, dummy=dummy, delta_dummy=delta_dummy,
polarization_factor=polarization_factor,
dark=dark, flat=flat, method=method,
normalization_factor=normalization_factor,
radial_range=horizontal_unit_range,
azimuth_range=vertical_unit_range,
unit=(horizontal_unit, vertical_unit),
filename=filename)

def integrate2d_grazing_incidence(self, data,
npt_horizontal, horizontal_unit=units.Q_IP, horizontal_unit_range=None,
npt_vertical=100, vertical_unit=units.Q_OOP, vertical_unit_range=None,
incident_angle=None, tilt_angle=None, sample_orientation=None,
filename=None,
correctSolidAngle=True,
mask=None, dummy=None, delta_dummy=None,
polarization_factor=None, dark=None, flat=None,
method=("no", "histogram", "cython"),
normalization_factor=1.0):

reset = False

if isinstance(vertical_unit, units.UnitFiber):
incident_angle = incident_angle or vertical_unit.incident_angle
else:
incident_angle = incident_angle or 0.0

if isinstance(vertical_unit, units.UnitFiber):
if vertical_unit.incident_angle != incident_angle:
vertical_unit.set_incident_angle(incident_angle)
reset = True
else:
vertical_unit = units.to_unit(vertical_unit)
vertical_unit.set_incident_angle(incident_angle)
reset = True

if isinstance(horizontal_unit, units.UnitFiber):
if horizontal_unit.incident_angle != incident_angle:
horizontal_unit.set_incident_angle(incident_angle)
reset = True
else:
horizontal_unit = units.to_unit(horizontal_unit)
horizontal_unit.set_incident_angle(incident_angle)
reset = True

if isinstance(vertical_unit, units.UnitFiber):
tilt_angle = tilt_angle or vertical_unit.tilt_angle
else:
tilt_angle = tilt_angle or 0.0

if isinstance(vertical_unit, units.UnitFiber):
if vertical_unit.tilt_angle != tilt_angle:
vertical_unit.set_tilt_angle(tilt_angle)
reset = True
else:
vertical_unit = units.to_unit(vertical_unit)
vertical_unit.set_tilt_angle(tilt_angle)
reset = True

if isinstance(horizontal_unit, units.UnitFiber):
if horizontal_unit.tilt_angle != tilt_angle:
horizontal_unit.set_tilt_angle(tilt_angle)
reset = True
else:
horizontal_unit = units.to_unit(horizontal_unit)
horizontal_unit.set_tilt_angle(tilt_angle)
reset = True

if isinstance(vertical_unit, units.UnitFiber):
sample_orientation = sample_orientation or vertical_unit.sample_orientation
else:
sample_orientation = sample_orientation or 1

if isinstance(vertical_unit, units.UnitFiber):
if vertical_unit.sample_orientation != sample_orientation:
vertical_unit.set_sample_orientation(sample_orientation)
reset = True
else:
vertical_unit = units.to_unit(vertical_unit)
vertical_unit.set_sample_orientation(sample_orientation)
reset = True

if isinstance(horizontal_unit, units.UnitFiber):
if horizontal_unit.sample_orientation != sample_orientation:
horizontal_unit.set_sample_orientation(sample_orientation)
reset = True
else:
horizontal_unit = units.to_unit(horizontal_unit)
horizontal_unit.set_sample_orientation(sample_orientation)
reset = True

if reset:
self.reset()

if (isinstance(method, (tuple, list)) and method[0] != "no") or (isinstance(method, IntegrationMethod) and method.split != "no"):
logger.warning(f"Method {method} is using a pixel-splitting scheme. GI integration should be use WITHOUT PIXEL-SPLITTING! The results could be wrong!")

return self.integrate2d_fiber(data=data, npt_horizontal=npt_horizontal, npt_vertical=npt_vertical,
horizontal_unit=horizontal_unit, vertical_unit=vertical_unit,
horizontal_unit_range=horizontal_unit_range,
vertical_unit_range=vertical_unit_range,
sample_orientation=sample_orientation,
filename=filename,
correctSolidAngle=correctSolidAngle,
mask=mask, dummy=dummy, delta_dummy=delta_dummy,
polarization_factor=polarization_factor, dark=dark, flat=flat,
method=method,
normalization_factor=normalization_factor,
)

@deprecated(since_version="0.21", only_once=True, deprecated_since="0.21.0")
def integrate2d_legacy(self, data, npt_rad, npt_azim=360,
Expand Down

0 comments on commit 2e9c6f1

Please sign in to comment.