Esempio n. 1
0
def test_multi_axis_goniometer_from_phil():
    params = goniometer_phil_scope.fetch(
        parse(
            """
    goniometer {
      axes = (1, 0, 0, 0, 1, 0, 0, 0, 1)
      scan_axis = 2
    }
  """
        )
    ).extract()

    g1 = GoniometerFactory.from_phil(params)
    assert tuple(g1.get_axes()) == ((1, 0, 0), (0, 1, 0), (0, 0, 1))
    assert g1.get_scan_axis() == 2

    # Test using a reference
    params = goniometer_phil_scope.fetch(
        parse(
            """
    goniometer {
      axes = (0, 1, 0, 1, 0, 0, 0, 0, 1)
    }
  """
        )
    ).extract()

    g2 = GoniometerFactory.from_phil(params, reference=g1)

    assert tuple(g2.get_axes()) == ((0, 1, 0), (1, 0, 0), (0, 0, 1))
Esempio n. 2
0
def test_single_axis_goniometer_with_fixed_rotation_and_reference_from_phil():
    params = goniometer_phil_scope.fetch(
        parse(
            """
    goniometer {
      axes = (1, 0, 0)
    }
  """
        )
    ).extract()

    g1 = GoniometerFactory.from_phil(params)

    params = goniometer_phil_scope.fetch(
        parse(
            """
    goniometer {
      axis = (0, 1, 0)
      fixed_rotation = (0, 1, 0, 1, 0, 0, 0, 0, 1)
    }
  """
        )
    ).extract()

    g2 = GoniometerFactory.from_phil(params, reference=g1)

    assert g2.get_rotation_axis() == (0, 1, 0)
    assert g2.get_fixed_rotation() == (0, 1, 0, 1, 0, 0, 0, 0, 1)
Esempio n. 3
0
def test_goniometer_from_phil():
    params = goniometer_phil_scope.fetch(
        parse(
            """
    goniometer {
      axes = (1, 0, 0)
    }
  """
        )
    ).extract()

    g1 = GoniometerFactory.from_phil(params)

    assert g1.get_rotation_axis() == (1, 0, 0)

    params = goniometer_phil_scope.fetch(
        parse(
            """
    goniometer {
      axes = (0, 1, 0)
      fixed_rotation = (0, 1, 0, 1, 0, 0, 0, 0, 1)
    }
  """
        )
    ).extract()

    g2 = GoniometerFactory.from_phil(params, reference=g1)

    assert g2.get_rotation_axis() == (0, 1, 0)
    assert g2.get_fixed_rotation() == (0, 1, 0, 1, 0, 0, 0, 0, 1)

    params = goniometer_phil_scope.fetch(
        parse(
            """
    goniometer {
      axes = (1, 0, 0, 0, 1, 0, 0, 0, 1)
      scan_axis = 2
    }
  """
        )
    ).extract()

    g3 = GoniometerFactory.from_phil(params)
    assert tuple(g3.get_axes()) == ((1, 0, 0), (0, 1, 0), (0, 0, 1))
    assert g3.get_scan_axis() == 2

    params = goniometer_phil_scope.fetch(
        parse(
            """
    goniometer {
      axes = (0, 1, 0, 1, 0, 0, 0, 0, 1)
    }
  """
        )
    ).extract()

    g4 = GoniometerFactory.from_phil(params, reference=g3)

    assert tuple(g4.get_axes()) == ((0, 1, 0), (1, 0, 0), (0, 0, 1))
Esempio n. 4
0
def test_goniometer_from_phil():
    from dxtbx.model.goniometer import GoniometerFactory
    from dxtbx.model.goniometer import goniometer_phil_scope
    from libtbx.phil import parse

    params = goniometer_phil_scope.fetch(
        parse('''
    goniometer {
      axes = (1, 0, 0)
    }
  ''')).extract()

    g1 = GoniometerFactory.from_phil(params)

    assert g1.get_rotation_axis() == (1, 0, 0)

    params = goniometer_phil_scope.fetch(
        parse('''
    goniometer {
      axes = (0, 1, 0)
      fixed_rotation = (0, 1, 0, 1, 0, 0, 0, 0, 1)
    }
  ''')).extract()

    g2 = GoniometerFactory.from_phil(params, reference=g1)

    assert g2.get_rotation_axis() == (0, 1, 0)
    assert g2.get_fixed_rotation() == (0, 1, 0, 1, 0, 0, 0, 0, 1)

    params = goniometer_phil_scope.fetch(
        parse('''
    goniometer {
      axes = (1, 0, 0, 0, 1, 0, 0, 0, 1)
      scan_axis = 2
    }
  ''')).extract()

    g3 = GoniometerFactory.from_phil(params)
    assert tuple(g3.get_axes()) == ((1, 0, 0), (0, 1, 0), (0, 0, 1))
    assert g3.get_scan_axis() == 2

    params = goniometer_phil_scope.fetch(
        parse('''
    goniometer {
      axes = (0, 1, 0, 1, 0, 0, 0, 0, 1)
    }
  ''')).extract()

    g4 = GoniometerFactory.from_phil(params, reference=g3)

    assert tuple(g4.get_axes()) == ((0, 1, 0), (1, 0, 0), (0, 0, 1))

    print 'OK'
Esempio n. 5
0
def test_single_axis_goniometer_using_axis_and_axes_from_phil_raises_error():
    """Supplying both the 'axis' and 'axes' parameters is ambiguous, so it should
    be mutually exclusive. This test ensures that is the case."""

    params = goniometer_phil_scope.fetch(
        parse("""
    goniometer {
      axis = (1, 0, 0)
      axes = (1, 0, 0)
    }
    """)).extract()

    with pytest.raises(ValueError):
        GoniometerFactory.from_phil(params)
Esempio n. 6
0
def test_single_axis_goniometer_using_axes_from_phil():
    params = goniometer_phil_scope.fetch(
        parse("""
    goniometer {
      axes = (1, 0, 0)
    }
  """)).extract()

    g1 = GoniometerFactory.from_phil(params)

    assert g1.get_rotation_axis() == (1, 0, 0)