This documentation page refers to a previous release of DIALS (2.2).
Click here to go to the corresponding page for the latest version of DIALS

Source code for dials.util.nexus

from __future__ import absolute_import, division, print_function

import h5py
from dials.util.nexus import nx_reflections, nx_mx
from time import strftime


[docs]def get_entry(filename, mode="a"): handle = h5py.File(filename, mode) if "entry" in handle: entry = handle["entry"] assert entry.attrs["NX_class"] == "NXentry" else: entry = handle.create_group("entry") entry.attrs["NX_class"] = "NXentry" handle.attrs["file_name"] = filename handle.attrs["file_time"] = strftime("%Y-%m-%dT%H:%M:%S") return entry
[docs]def load(filename): entry = get_entry(filename, "r") ref, exp_index = nx_reflections.load(entry) exp = nx_mx.load(entry, exp_index) return exp, ref
[docs]def dump(experiments, reflections, params): filename = params.hklout entry = get_entry(filename, "w") experiments = nx_mx.dump(entry, experiments, params) nx_reflections.dump(entry, reflections, experiments)