FABLE-3DXRD / ImageD11

ImageD11 is a python code for identifying individual grains in spotty area detector X-ray diffraction images.
https://imaged11.readthedocs.io/
GNU General Public License v2.0
15 stars 25 forks source link

Read unitcell from cif file in unitcell.py #344

Open CharlesRmn opened 4 weeks ago

CharlesRmn commented 4 weeks ago

def unitcell_from_cif(pars): import re regex_a = r'_cell_length_a\s+([\d.]+)' regex_b = r'_cell_length_b\s+([\d.]+)' regex_c = r'_cell_length_c\s+([\d.]+)' regex_alpha = r'_cell_angle_alpha\s+([\d.]+)' regex_beta = r'_cell_angle_beta\s+([\d.]+)' regex_gamma = r'_cell_angle_gamma\s+([\d.]+)' regex_space_group = r'_symmetry_space_group_name_H-M\s\'\".[\'\"]' with open(pars, 'r') as pars: pars = pars.read() cell = unitcell([ float(re.search(regex_a, pars).group(1)), float(re.search(regex_b, pars).group(1)), float(re.search(regex_c, pars).group(1)), float(re.search(regex_alpha, pars).group(1)), float(re.search(regex_beta, pars).group(1)), float(re.search(regex_gamma, pars).group(1)), ], re.search(regex_space_group, pars).group(1)) return cell