pyextal.hdf5io.crystal ====================== .. py:module:: pyextal.hdf5io.crystal .. autoapi-nested-parse:: The crystal ``.dat`` a dataset was built against, embedded in the file. The Fortran engine reads a ``.dat`` from disk, and the right one is not always beside the ``.h5``: pre-refinement and refinement often use different beam sets of the same crystal. So each stage stores the text of the ``.dat`` it used, as a string dataset ``crystal_dat`` (attrs ``name``, ``sha1``): - ``/crystal_dat`` written by `save_raw` - ``/pre_refinement/crystal_dat`` written by `save_pre_refinement` - ``/refinement/run_NNN/crystal_dat`` written by `save_refinement` `locate_dat` finds one, writing embedded text to a short temporary path (the Fortran reader takes paths under ~120 characters). Attributes ---------- .. autoapisummary:: pyextal.hdf5io.crystal.DATASET Functions --------- .. autoapisummary:: pyextal.hdf5io.crystal.store_dat pyextal.hdf5io.crystal.read_dat pyextal.hdf5io.crystal.materialize_dat pyextal.hdf5io.crystal.out_count pyextal.hdf5io.crystal._n_beams pyextal.hdf5io.crystal._run_key pyextal.hdf5io.crystal.embedded_dat pyextal.hdf5io.crystal.locate_dat pyextal.hdf5io.crystal.dat_for Module Contents --------------- .. py:data:: DATASET :value: 'crystal_dat' .. py:function:: store_dat(group, dat_path) Embeds a ``.dat`` file's text in an open HDF5 group, replacing any copy. :param group: Open, writable group (or the file itself). :type group: h5py.Group :param dat_path: The ``.dat``. :type dat_path: path-like .. py:function:: read_dat(group) ``(name, text)`` of the ``.dat`` embedded in an open group, or None. .. py:function:: materialize_dat(name, text) Writes embedded ``.dat`` text to a short temporary path and returns it. .. py:function:: out_count(text) Number of output reflections in a ``.dat``'s ``out`` block, or None. .. py:function:: _n_beams(f) Experimental beam count recorded in an open file, or None. .. py:function:: _run_key(run) .. py:function:: embedded_dat(h5, run=None, n_beams=None, stage=None) The embedded ``.dat`` `locate_dat` would pick, or None. Args and order as in `locate_dat`, without its on-disk fallbacks. :returns: ``(Path, str)``. :rtype: tuple or None .. py:function:: locate_dat(h5, run=None, n_beams=None, stage=None) Finds the ``.dat`` for a dataset file, and says how it was chosen. In order: the copy embedded in refinement ``run``; the one embedded for ``stage`` ('pre_refinement'); the root copy; the ``dat`` named in a legacy ``/paths`` group; the one ``.dat`` beside the file whose ``out`` block lists ``n_beams`` reflections. File-level candidates (all but the run's own copy) must list ``n_beams`` reflections when that is known, since pre-refinement and refinement can use different beam sets. ``n_beams`` defaults to the file's experimental beam count. :param h5: The dataset file. :type h5: path-like :param run: Refinement run key ('run_003') or number. :type run: str or int, optional :param n_beams: Reflections the ``.dat`` must output. :type n_beams: int, optional :param stage: Also look in this group's embedded copy. :type stage: str, optional :returns: ``(Path, str)``. :rtype: tuple :raises FileNotFoundError: If nothing qualifies. .. py:function:: dat_for(h5, run=None, n_beams=None, stage=None) The path of `locate_dat`'s choice.