Beispiel #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
Beispiel #2
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
Beispiel #3
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