diff --git a/src/pyFAI/integrator/fiber.py b/src/pyFAI/integrator/fiber.py index 815a1b634..383c4ee8d 100644 --- a/src/pyFAI/integrator/fiber.py +++ b/src/pyFAI/integrator/fiber.py @@ -64,12 +64,20 @@ def sample_orientation(self): def parse_units(self, unit_ip, unit_oop, incident_angle=None, tilt_angle=None, sample_orientation=None): if unit_ip is None: - unit_ip = units.get_unit_fiber("qip_nm^-1") + unit_ip = units.get_unit_fiber(name="qip_nm^-1") + elif isinstance(unit_ip, str): + unit_ip = units.get_unit_fiber(name=unit_ip) + elif isinstance(unit_ip, units.UnitFiber): + ... else: unit_ip = units.to_unit(unit_ip) if unit_oop is None: - unit_oop = units.get_unit_fiber("qoop_nm^-1") + unit_oop = units.get_unit_fiber(name="qoop_nm^-1") + elif isinstance(unit_oop, str): + unit_oop = units.get_unit_fiber(name=unit_oop) + elif isinstance(unit_oop, units.UnitFiber): + ... else: unit_oop = units.to_unit(unit_oop) diff --git a/src/pyFAI/units.py b/src/pyFAI/units.py index 58ae3a93d..5c4515d9c 100644 --- a/src/pyFAI/units.py +++ b/src/pyFAI/units.py @@ -41,6 +41,7 @@ __status__ = "production" __docformat__ = 'restructuredtext' +import copy import logging logger = logging.getLogger(__name__) import numpy @@ -990,7 +991,8 @@ def get_unit_fiber(name, incident_angle:float =0.0, tilt_angle:float =0.0, sampl :param float tilt angle: roll angle. Its rotation axis is orthogonal to the beam, the horizontal axis of the lab frame :param sample_orientation: 1-4, four different orientation of the fiber axis regarding the detector main axis, from 1 to 4 is +90ยบ """ - unit = RADIAL_UNITS.get(name, None) + unit = copy.deepcopy(RADIAL_UNITS.get(name, None)) + if unit is not None: unit.set_incident_angle(incident_angle) unit.set_tilt_angle(tilt_angle)