pyextal.acom.datfile

Writing a .dat for a solved orientation.

The crystal block is copied verbatim from a template file rather than regenerated, so cell, atoms and space group cannot drift. Only the orientation and the two beam blocks are rewritten.

Functions

_fmt(rows)

write_dat(template, dst, zone, xaxis, beams, out_beams)

Writes a .dat for one orientation, with explicit beam and output blocks.

write_oriented_dat(template, dst, zone, xaxis[, kt, norm])

Copies a .dat, changing only the orientation.

read_dat_beams(path)

Reads the explicit hkl and out blocks back out of a .dat.

Module Contents

pyextal.acom.datfile._fmt(rows)
pyextal.acom.datfile.write_dat(template, dst, zone, xaxis, beams, out_beams, kt=(0, 0, 0), norm=None, conv=None, samp=None, sgmax=None, sgmin=None, omeg=None, abs_=None)

Writes a .dat for one orientation, with explicit beam and output blocks.

The output beams are written as a prefix of the beam list, so hkl[:nout] == hklout and the engine’s idptr mapping is the identity. That is not cosmetic: bloch_parse resolves each out entry against hkl and appends any it cannot find, writing past the array it already allocated from the declared beam count.

Parameters:
  • template (str | Path) – Existing .dat supplying the crystal block.

  • dst (str | Path) – File to write.

  • zone (tuple[int, int, int]) – Zone axis.

  • xaxis (tuple[int, int, int]) – Reflection defining the horizontal axis.

  • beams (array-like) – (n, 3) every beam in the calculation.

  • out_beams (array-like) – (m, 3) reflections to output.

  • kt (tuple, optional) – Tangential incident wavevector. Defaults to (0,0,0).

  • norm (tuple, optional) – Surface normal; zone is used when None.

  • conv (float, optional) – Convergence angle; the template’s value is kept when None.

  • samp (int, optional) – Sampling; the template’s value is kept when None.

  • sgmax (float, optional) – Maximum excitation error. Defaults to 3.5 when the template used sele and gave no standalone value.

  • sgmin (float, optional) – Minimum excitation error; template value kept when None.

  • omeg (float, optional) – Bethe parameter; template value kept when None.

  • abs (float, optional) – Mean absorption; template value kept when None.

Returns:

The file written.

Return type:

Path

Raises:

ValueError – If an output beam is missing from beams, or the template lacks a block that has to be replaced.

pyextal.acom.datfile.write_oriented_dat(template, dst, zone, xaxis, kt=(0, 0, 0), norm=None)

Copies a .dat, changing only the orientation.

The beam-selection blocks are left exactly as the template had them, so a template using sele/aper still selects its beams geometrically – at the new orientation. That makes it the natural reference to compare an explicit ACOM beam list against: same crystal, same cutoffs, same engine, only the zone axis replaced.

Parameters:
  • template (str | Path) – Existing .dat.

  • dst (str | Path) – File to write.

  • zone (tuple[int, int, int]) – Zone axis.

  • xaxis (tuple[int, int, int]) – Reflection defining the horizontal axis.

  • kt (tuple, optional) – Tangential incident wavevector. Defaults to (0,0,0).

  • norm (tuple, optional) – Surface normal; zone is used when None.

Returns:

The file written.

Return type:

Path

pyextal.acom.datfile.read_dat_beams(path)

Reads the explicit hkl and out blocks back out of a .dat.

Lets downstream code take its reflection list from the file the engine will actually parse, rather than from a variable that may have drifted from it.

Parameters:

path (str | Path) – A .dat with explicit blocks, as written by write_dat().

Returns:

(beams, out_beams) as (h, k, l) tuples.

Return type:

tuple[list, list]

Raises:

ValueError – If either block is missing, or a declared count does not match the rows that follow it.