Exemplo n.º 1
0
def from_dict(d, t=None):
  ''' Convert the dictionary to a scan model

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

  Returns:
      The scan model

  '''
  from dxtbx.model import Scan
  from scitbx.array_family import flex # import dependency

  # If None, return None
  if d == None:
    if t == None: return None
    else: return from_dict(t, None)
  elif t != None:
    d = dict(t.items() + d.items())
  if not isinstance(d['exposure_time'], list):
    d['exposure_time'] = [d['exposure_time']]

  # Create the model from the dictionary
  return Scan.from_dict(d)
Exemplo n.º 2
0
def test_scan():
    from dxtbx.model import Scan
    from scitbx.array_family import flex
    s1 = Scan(image_range=(1, 20),
              oscillation=(5.0, 0.1),
              exposure_times=flex.double(range(20)),
              epochs=flex.double(range(20, 40)))

    d = s1.to_dict()
    s2 = Scan.from_dict(d)
    assert s1 == s2
Exemplo n.º 3
0
def test_scan():
    s1 = Scan(
        image_range=(1, 20),
        oscillation=(5.0, 0.1),
        exposure_times=flex.double(range(20)),
        epochs=flex.double(range(20, 40)),
    )
    s1.set_valid_image_ranges("0", [(1, 20)])

    d = s1.to_dict()
    s2 = Scan.from_dict(d)
    assert s1 == s2
Exemplo n.º 4
0
  def __call__(self):

    from dxtbx.model import Scan
    from scitbx.array_family import flex
    s1 = Scan(
      image_range=(1, 20),
      oscillation=(5.0, 0.1),
      exposure_times=flex.double(range(20)),
      epochs=flex.double(range(20,40)))

    d = s1.to_dict()
    s2 = Scan.from_dict(d)
    assert(s1 == s2)

    print 'OK'
Exemplo n.º 5
0
 def load_models(obj):
   try:
     beam = Beam.from_dict(blist[obj['beam']])
   except Exception:
     beam = None
   try:
     dobj = dlist[obj['detector']]
     detector = Detector.from_dict(dobj)
   except Exception:
     detector = None
   try:
     from dxtbx.serialize import goniometer
     gonio = goniometer.from_dict(glist[obj['goniometer']])
   except Exception:
     gonio = None
   try:
     scan = Scan.from_dict(slist[obj['scan']])
   except Exception:
     scan = None
   return beam, detector, gonio, scan
Exemplo n.º 6
0
 def load_models(obj):
   try:
     beam = Beam.from_dict(blist[obj['beam']])
   except Exception:
     beam = None
   try:
     dobj = dlist[obj['detector']]
     if 'hierarchy' in dobj:
       detector = HierarchicalDetector.from_dict(dobj)
     else:
       detector = Detector.from_dict(dobj)
   except Exception:
     detector = None
   try:
     gonio = Goniometer.from_dict(glist[obj['goniometer']])
   except Exception:
     gonio = None
   try:
     scan = Scan.from_dict(slist[obj['scan']])
   except Exception:
     scan = None
   return beam, detector, gonio, scan
Exemplo n.º 7
0
 def _scan_from_dict(obj):
   ''' Get the scan from a dictionary. '''
   from dxtbx.model import Scan
   return Scan.from_dict(obj)