pyextal.jaxGeo.io

Finding and loading a dataset: the .h5, the .dat it was built against.

Functions

to_wsl_path(path)

Accepts a Windows path as well as a WSL one.

resolve_h5(path)

The dataset file, given the file itself or the folder holding it.

_out_count(dat)

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

resolve_dat(h5, n_beams)

Finds the .dat a dataset file was built against.

check_pre_refinement(h5)

Raises if the file lacks the /pre_refinement group this needs.

load_dataset(h5[, subsample])

The refinement inputs from a dataset file, spatially subsampled.

Module Contents

pyextal.jaxGeo.io.to_wsl_path(path)

Accepts a Windows path as well as a WSL one.

C:\Users\<user>\Box\... maps to /mnt/box/... (where Box is mounted under WSL) and any other X:\... to /mnt/x/.... POSIX paths pass through unchanged.

Parameters:

path (str | Path) – The path as typed.

Returns:

A path usable from WSL.

Return type:

Path

pyextal.jaxGeo.io.resolve_h5(path)

The dataset file, given the file itself or the folder holding it.

Parameters:

path (Path) – A .h5 file, or a folder containing exactly one.

Returns:

The .h5 file.

Return type:

Path

Raises:

SetupError – If path does not exist, or a folder holds no .h5 or several.

pyextal.jaxGeo.io._out_count(dat)

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

pyextal.jaxGeo.io.resolve_dat(h5, n_beams)

Finds the .dat a dataset file was built against.

In order: the dat recorded in the file’s /paths group (relative to the file’s folder, or to the recorded base); otherwise the one .dat beside the file whose out block lists exactly n_beams reflections – the experimental beam axis must match it one to one.

Parameters:
  • h5 (Path) – The dataset file.

  • n_beams (int) – Reflections on its experimental beam axis.

Returns:

(Path, str) – the .dat and how it was chosen.

Return type:

tuple

Raises:

SetupError – If no single .dat qualifies.

pyextal.jaxGeo.io.check_pre_refinement(h5)

Raises if the file lacks the /pre_refinement group this needs.

Parameters:

h5 (Path) – The dataset file.

Raises:

SetupError – With a message naming what the file holds instead.

pyextal.jaxGeo.io.load_dataset(h5, subsample=1)

The refinement inputs from a dataset file, spatially subsampled.

Parameters:
  • h5 (Path) – The dataset file.

  • subsample (int) – Take every Nth scan point in each direction.

Returns:

(data, g_include). data holds tilts (rows, cols, 3), experimental_data and variance (rows, cols, n_beams) and the pre-refined geometry dict; g_include (n_beams, 3) labels the experimental beam axis.

Return type:

tuple