def from_dict(d): ''' Convert the dictionary to a crystal model Params: d The dictionary of parameters Returns: The crystal model ''' from dxtbx.model import Crystal # If None, return None if d is None: return None # Check the version and id if str(d['__id__']) != "crystal": raise ValueError("\"__id__\" does not equal \"crystal\"") # Extract from the dictionary real_space_a = d['real_space_a'] real_space_b = d['real_space_b'] real_space_c = d['real_space_c'] # str required to force unicode to ascii conversion space_group = str("Hall:" + d['space_group_hall_symbol']) xl = Crystal(real_space_a, real_space_b, real_space_c, space_group_symbol=space_group) # Isoforms used for stills try: xl.identified_isoform = d['identified_isoform'] except KeyError: pass # Extract scan point setting matrices, if present try: A_at_scan_points = d['A_at_scan_points'] xl.set_A_at_scan_points(A_at_scan_points) except KeyError: pass # Extract covariance of B, if present try: cov_B = d['B_covariance'] xl.set_B_covariance(cov_B) except KeyError: pass # Extract covariance of B at scan points, if present cov_B_at_scan_points = d.get('B_covariance_at_scan_points') if cov_B_at_scan_points is not None: from scitbx.array_family import flex cov_B_at_scan_points = flex.double(cov_B_at_scan_points).as_1d() cov_B_at_scan_points.reshape(flex.grid(xl.num_scan_points, 9, 9)) xl.set_B_covariance_at_scan_points(cov_B_at_scan_points) return xl
def from_dict(d): ''' Convert the dictionary to a crystal model Params: d The dictionary of parameters Returns: The crystal model ''' from dxtbx.model import Crystal # If None, return None if d is None: return None # Check the version and id if str(d['__id__']) != "crystal": raise ValueError("\"__id__\" does not equal \"crystal\"") # Extract from the dictionary real_space_a = d['real_space_a'] real_space_b = d['real_space_b'] real_space_c = d['real_space_c'] # str required to force unicode to ascii conversion space_group = str("Hall:" + d['space_group_hall_symbol']) xl = Crystal(real_space_a, real_space_b, real_space_c, space_group_symbol=space_group) # New parameters for maximum likelihood values try: xl._ML_half_mosaicity_deg = d['ML_half_mosaicity_deg'] except KeyError: pass try: xl._ML_domain_size_ang = d['ML_domain_size_ang'] except KeyError: pass # Isoforms used for stills try: xl.identified_isoform = d['identified_isoform'] except KeyError: pass # Extract scan point setting matrices, if present try: A_at_scan_points = d['A_at_scan_points'] xl.set_A_at_scan_points(A_at_scan_points) except KeyError: pass # Extract covariance of B, if present try: cov_B = d['B_covariance'] xl.set_B_covariance(cov_B) except KeyError: pass # Extract mosaicity, if present try: mosaicity = d['mosaicity'] xl.set_mosaicity(mosaicity) except KeyError: pass return xl