コード例 #1
0
def tst_hierarchical_detector():
  '''Test pickling the detector object.'''
  p = Panel()
  p.set_local_frame((1, 0, 0), (0, 1, 0), (0, 0, 1))
  obj1 = HierarchicalDetector(p)
  root = obj1.hierarchy()
  root.add_panel(obj1[0])
  root.add_group()
  obj2 = pickle_then_unpickle(obj1)
  assert(obj2.hierarchy()._container == obj2)
  assert(obj2.hierarchy()[0] == obj2[0])
  assert(obj2.hierarchy()[0] in obj2)
  assert(type(obj2.hierarchy()[1]) == PanelGroup)
  assert(obj1 == obj2)
  print "OK"
コード例 #2
0
def from_dict(d, t=None):
  ''' Convert the dictionary to a detector model

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

  Returns:
      The detector model

  '''
  from dxtbx.model import Detector, HierarchicalDetector

  # If None, return None
  if d == None:
    if t == None: return None
    else: return from_dict(t, None)
  elif t != None:
    if isinstance(d, list):
      d = { 'panels' : d }
    d2 = dict(t.items() + d.items())
  else:
    if isinstance(d, list):
      d = { 'panels' : d }

  # Create the model from the dictionary
  if "hierarchy" in d:
    return HierarchicalDetector.from_dict(d)
  else:
    return Detector.from_dict(d)
コード例 #3
0
 def _detector_from_dict(obj):
   ''' Get the detector from a dictionary. '''
   from dxtbx.model import Detector, HierarchicalDetector
   if 'hierarchy' in obj:
     return HierarchicalDetector.from_dict(obj)
   else:
     return Detector.from_dict(obj)
コード例 #4
0
  def __init__(self):
    detector = HierarchicalDetector()
    panel1 = detector.add_panel()
    panel1.set_name("P1")
    panel1.set_type("P")

    panel2 = detector.add_panel()
    panel2.set_name("P2")
    panel2.set_type("P")

    panel3 = detector.add_panel()
    panel3.set_name("P3")
    panel3.set_type("P")

    panel4 = detector.add_panel()
    panel4.set_name("P4")
    panel4.set_type("P")

    root = detector.hierarchy()
    root.set_name("D1")
    root.set_type("D")

    quad1 = root.add_group()
    quad1.set_name("Q1")
    quad1.set_type("Q")
    quad1.add_panel(panel1)
    quad1.add_panel(panel2)

    quad2 = root.add_group()
    quad2.set_name("Q2")
    quad2.set_type("Q")
    quad2.add_panel(panel3)
    quad2.add_panel(panel4)

    self.detector = detector
コード例 #5
0
ファイル: datablock.py プロジェクト: keitaroyam/cctbx_fork
 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