示例#1
0
def tst_from_phil():

  from libtbx.phil import parse
  from dxtbx.model.beam import beam_phil_scope, BeamFactory
  from scitbx import matrix
  direction = matrix.col((0.013142, 0.002200, 1.450476))
  unit_direction = direction.normalize()
  wavelength = 0.689400

  reference = Beam(direction, wavelength)

  params1 = beam_phil_scope.fetch(parse("""
    beam {
      wavelength = 1.0
      direction = (0, 0, 1)
    }
  """)).extract()

  params2 = beam_phil_scope.fetch(parse("""
    beam {
      wavelength = 1.0
    }
  """)).extract()

  # Create the beam
  b1 = BeamFactory.from_phil(params1)
  b2 = BeamFactory.from_phil(params2, reference)
  try:
    b3 = BeamFactory.from_phil(params2)
    passed = True
  except Exception:
    passed = False
  assert passed == False

  print 'OK'
示例#2
0
def test_from_phil():
    from libtbx.phil import parse
    from dxtbx.model.beam import beam_phil_scope, BeamFactory
    from scitbx import matrix
    direction = matrix.col((0.013142, 0.002200, 1.450476))
    unit_direction = direction.normalize()
    wavelength = 0.689400

    reference = Beam(direction, wavelength)

    params1 = beam_phil_scope.fetch(
        parse("""
    beam {
      wavelength = 1.0
      direction = (0, 0, 1)
    }
  """)).extract()

    params2 = beam_phil_scope.fetch(
        parse("""
    beam {
      wavelength = 1.0
    }
  """)).extract()

    # Create the beam
    b1 = BeamFactory.from_phil(params1)
    b2 = BeamFactory.from_phil(params2, reference)
    with pytest.raises(RuntimeError):
        b3 = BeamFactory.from_phil(params2)
示例#3
0
def test_from_phil():
    direction = matrix.col((0.013142, 0.002200, 1.450476))
    unit_direction = direction.normalize()
    wavelength = 0.689400

    reference = Beam(direction, wavelength)

    params1 = beam_phil_scope.fetch(
        parse(
            """
    beam {
      wavelength = 1.0
      direction = (0, 0, 1)
    }
  """
        )
    ).extract()

    params2 = beam_phil_scope.fetch(
        parse(
            """
    beam {
      wavelength = 1.0
    }
  """
        )
    ).extract()

    # Create the beam
    b1 = BeamFactory.from_phil(params1)
    b2 = BeamFactory.from_phil(params2, reference)
    with pytest.raises(RuntimeError):
        b3 = BeamFactory.from_phil(params2)

    params3 = beam_phil_scope.fetch(
        parse(
            """
    beam {
      polarization_normal = 1,0,0
      polarization_fraction = 0.5
    }
  """
        )
    ).extract()
    b3 = BeamFactory.from_phil(params3, reference)
    assert b3.get_polarization_fraction() == 0.5
    assert b3.get_polarization_normal() == (1.0, 0.0, 0.0)