pyextal.hdf5io.crystal

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

Functions

store_dat(group, dat_path)

Embeds a .dat file's text in an open HDF5 group, replacing any copy.

read_dat(group)

(name, text) of the .dat embedded in an open group, or None.

materialize_dat(name, text)

Writes embedded .dat text to a short temporary path and returns it.

out_count(text)

Number of output reflections in a .dat's out block, or None.

_n_beams(f)

Experimental beam count recorded in an open file, or None.

_run_key(run)

embedded_dat(h5[, run, n_beams, stage])

The embedded .dat locate_dat would pick, or None.

locate_dat(h5[, run, n_beams, stage])

Finds the .dat for a dataset file, and says how it was chosen.

dat_for(h5[, run, n_beams, stage])

The path of locate_dat's choice.

Module Contents

pyextal.hdf5io.crystal.DATASET = 'crystal_dat'
pyextal.hdf5io.crystal.store_dat(group, dat_path)

Embeds a .dat file’s text in an open HDF5 group, replacing any copy.

Parameters:
  • group (h5py.Group) – Open, writable group (or the file itself).

  • dat_path (path-like) – The .dat.

pyextal.hdf5io.crystal.read_dat(group)

(name, text) of the .dat embedded in an open group, or None.

pyextal.hdf5io.crystal.materialize_dat(name, text)

Writes embedded .dat text to a short temporary path and returns it.

pyextal.hdf5io.crystal.out_count(text)

Number of output reflections in a .dat’s out block, or None.

pyextal.hdf5io.crystal._n_beams(f)

Experimental beam count recorded in an open file, or None.

pyextal.hdf5io.crystal._run_key(run)
pyextal.hdf5io.crystal.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).

Return type:

tuple or None

pyextal.hdf5io.crystal.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.

Parameters:
  • h5 (path-like) – The dataset file.

  • run (str or int, optional) – Refinement run key (‘run_003’) or number.

  • n_beams (int, optional) – Reflections the .dat must output.

  • stage (str, optional) – Also look in this group’s embedded copy.

Returns:

(Path, str).

Return type:

tuple

Raises:

FileNotFoundError – If nothing qualifies.

pyextal.hdf5io.crystal.dat_for(h5, run=None, n_beams=None, stage=None)

The path of locate_dat’s choice.