def _goniometer_from_dict(obj): ''' Get the goniometer from a dictionary. ''' if 'axes' in obj and 'angles' in obj and 'scan_axis' in obj: from dxtbx.model import MultiAxisGoniometer return MultiAxisGoniometer.from_dict(obj) from dxtbx.model import Goniometer return Goniometer.from_dict(obj)
def test_goniometer(): # Construct the object g1 = Goniometer(rotation_axis=(1, 2, 3), fixed_rotation_matrix=(1, 2, 3, 4, 5, 6, 7, 8, 9)) # Create a dictionary and get the object back d = g1.to_dict() g2 = Goniometer.from_dict(d) assert g2 == g1
def __call__(self): from dxtbx.model import Goniometer # Construct the object g1 = Goniometer(rotation_axis=(1, 2, 3), fixed_rotation_matrix=(1, 2, 3, 4, 5, 6, 7, 8, 9)) # Create a dictionary and get the object back d = g1.to_dict() g2 = Goniometer.from_dict(d) assert (g2 == g1) print 'OK'
def __call__(self): from dxtbx.model import Goniometer # Construct the object g1 = Goniometer( rotation_axis=(1, 2, 3), fixed_rotation_matrix=(1, 2, 3, 4, 5, 6, 7, 8, 9)) # Create a dictionary and get the object back d = g1.to_dict() g2 = Goniometer.from_dict(d) assert(g2 == g1) print 'OK'
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
def from_dict(d, t=None): ''' Convert the dictionary to a goniometer model Params: d The dictionary of parameters t The template dictionary to use Returns: The goniometer model ''' from dxtbx.model import Goniometer # 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()) # Create the model from the dictionary return Goniometer.from_dict(d)
def from_dict(d, t=None): ''' Convert the dictionary to a goniometer model Params: d The dictionary of parameters t The template dictionary to use Returns: The goniometer model ''' from dxtbx.model import Goniometer, MultiAxisGoniometer # 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()) # Create the model from the dictionary if 'axes' in d and 'angles' in d and 'scan_axis' in d: return MultiAxisGoniometer.from_dict(d) return Goniometer.from_dict(d)
def _goniometer_from_dict(obj): ''' Get the goniometer from a dictionary. ''' from dxtbx.model import Goniometer return Goniometer.from_dict(obj)