def test_beam(): # Construct the object b1 = Beam( direction=(1, 2, 3), wavelength=1.1, divergence=0.01, sigma_divergence=0.01, polarization_normal=(4, 5, 6), polarization_fraction=0.9, flux=1.0, transmission=1.0, ) # Create a dictionary and get the beam back d = b1.to_dict() b2 = Beam.from_dict(d) assert b2 == b1
def __call__(self): from dxtbx.model import Beam # Construct the object b1 = Beam(direction=(1, 2, 3), wavelength=1.1, divergence=0.01, sigma_divergence=0.01, polarization_normal=(4, 5, 6), polarization_fraction=0.9) # Create a dictionary and get the beam back d = b1.to_dict() b2 = Beam.from_dict(d) assert (b2 == b1) print 'OK'
def __call__(self): from dxtbx.model import Beam # Construct the object b1 = Beam( direction=(1, 2, 3), wavelength=1.1, divergence=0.01, sigma_divergence=0.01, polarization_normal=(4, 5, 6), polarization_fraction=0.9) # Create a dictionary and get the beam back d = b1.to_dict() b2 = Beam.from_dict(d) assert(b2 == b1) print 'OK'
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
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 beam model Params: d The dictionary of parameters t The template dictionary to use Returns: The beam model ''' from dxtbx.model import Beam # 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 Beam.from_dict(d)
def _beam_from_dict(obj): ''' Get a beam from a dictionary. ''' from dxtbx.model import Beam return Beam.from_dict(obj)