コード例 #1
0
  def single_axis_goniometer_from_phil(params, reference=None):
    '''
    Generate or overwrite a single axis goniometer

    '''

    # Check the axes parameter
    if params.goniometer.axes is not None and len(params.goniometer.axes) != 3:
      raise RuntimeError('Single axis goniometer requires 3 axes parameters')

    # Check the angles parameter
    if params.goniometer.angles is not None:
      raise RuntimeError('Single axis goniometer requires angles == None')

    # Check the names parameter
    if params.goniometer.names is not None:
      raise RuntimeError('Single axis goniometer requires names == None')

    # Init the gonionmeter
    if reference is None:
      goniometer = Goniometer()
    else:
      goniometer = reference

    # Set the parameters
    if params.goniometer.axes is not None:
      goniometer.set_rotation_axis_datum(params.goniometer.axes)
    if params.goniometer.fixed_rotation is not None:
      goniometer.set_fixed_rotation(params.goniometer.fixed_rotation)
    if params.goniometer.setting_rotation is not None:
      goniometer.set_setting_rotation(params.goniometer.setting_rotation)

    # Return the model
    return goniometer
コード例 #2
0
    def from_dict(d, t=None):
        """Convert the dictionary to a goniometer model

        Params:
            d The dictionary of parameters
            t The template dictionary to use

        Returns:
            The goniometer model

        """
        from dxtbx.model import Goniometer, MultiAxisGoniometer

        # If None, return None
        if d is None:
            if t is None:
                return None
            else:
                return from_dict(t, None)
        elif t != None:
            d = dict(t.items() + d.items())

        # Create the model from the dictionary
        if "axes" in d and "angles" in d and "scan_axis" in d:
            return MultiAxisGoniometer.from_dict(d)
        return Goniometer.from_dict(d)
コード例 #3
0
    def known_axis(axis):
        """Return an goniometer instance for a known rotation axis, assuming
        that nothing is known about the fixed element of the rotation axis."""

        assert len(axis) == 3

        fixed = (1, 0, 0, 0, 1, 0, 0, 0, 1)

        return Goniometer(axis, fixed)
コード例 #4
0
    def from_dict(d, t=None):
        """Convert the dictionary to a goniometer model

        Params:
            d The dictionary of parameters
            t The template dictionary to use

        Returns:
            The goniometer model
        """
        if d is None and t is None:
            return None
        joint = t.copy() if t else {}
        joint.update(d)

        # Create the model from the joint dictionary
        if {"axes", "angles", "scan_axis"}.issubset(joint):
            return MultiAxisGoniometer.from_dict(joint)
        return Goniometer.from_dict(joint)
コード例 #5
0
    def single_axis_goniometer_from_phil(params, reference=None):
        """
        Generate or overwrite a single axis goniometer

        """

        # Check the axis parameter and copy from axes if required
        if params.goniometer.axis is None:
            params.goniometer.axis = params.goniometer.axes
        if params.goniometer.axis is not None and len(
                params.goniometer.axis) != 3:
            raise RuntimeError("Single axis goniometer requires 3 axis values")

        # Check the angles parameter
        if params.goniometer.angles is not None:
            raise RuntimeError(
                "Single axis goniometer requires angles == None")

        # Check the names parameter
        if params.goniometer.names is not None:
            raise RuntimeError("Single axis goniometer requires names == None")

        # Init the gonionmeter
        if reference is None:
            goniometer = Goniometer()
        else:
            goniometer = reference

        # Set the parameters
        if params.goniometer.axis is not None:
            goniometer.set_rotation_axis_datum(params.goniometer.axis)
        if params.goniometer.fixed_rotation is not None:
            goniometer.set_fixed_rotation(params.goniometer.fixed_rotation)
        if params.goniometer.setting_rotation is not None:
            goniometer.set_setting_rotation(params.goniometer.setting_rotation)
        if params.goniometer.invert_rotation_axis is True:
            rotation_axis = goniometer.get_rotation_axis_datum()
            goniometer.set_rotation_axis_datum([-x for x in rotation_axis])

        return goniometer
コード例 #6
0
 def make_goniometer(rotation_axis, fixed_rotation):
     return Goniometer(tuple(map(float, rotation_axis)),
                       tuple(map(float, fixed_rotation)))
コード例 #7
0
    def single_axis_goniometer_from_phil(params, reference=None):
        """
        Generate or overwrite a single axis goniometer

        """

        # Check the axes parameter
        if params.goniometer.axes is not None and len(
                params.goniometer.axes) != 3:
            raise RuntimeError(
                "Single axis goniometer requires 3 axes parameters")

        # Check the angles parameter
        if params.goniometer.angles is not None:
            raise RuntimeError(
                "Single axis goniometer requires angles == None")

        # Check the names parameter
        if params.goniometer.names is not None:
            raise RuntimeError("Single axis goniometer requires names == None")

        # Init the gonionmeter
        if reference is None:
            goniometer = Goniometer()
        else:
            goniometer = reference

        # Set the parameters
        if params.goniometer.axes is not None:
            goniometer.set_rotation_axis_datum(params.goniometer.axes)
        if params.goniometer.fixed_rotation is not None:
            goniometer.set_fixed_rotation(params.goniometer.fixed_rotation)
        if params.goniometer.setting_rotation is not None:
            goniometer.set_setting_rotation(params.goniometer.setting_rotation)
        if params.goniometer.invert_rotation_axis == True:
            rotation_axis = goniometer.get_rotation_axis_datum()
            goniometer.set_rotation_axis_datum(map(lambda x: -x,
                                                   rotation_axis))

        # Return the model
        return goniometer