eturb.util

Miscellaneous utilities

Functions

activate_paths()

Setup environment variables in preparation for Nek5000 build.

docstring_params(Class[, sections, indent_len])

Creates a parameter instance and generate formatted docs for it.

get_status(path)

Get status of a simulation run by verifying its contents.

init_params(Class[, isolated_unit])

Instantiate an isolated params for a specific class.

isoformat(dt)

Returns timestamp in modified isoformat from a datetime object (- instead of :).

last_modified(path)

Find the last modified file in a directory tree.

modification_date(path)

Modification date of a file or directory.

now()

The current timestamp.

prepare_for_restart(path[, chkp_fnumber, …])

Takes a directory in which a simulation was executed.

scantree(path)

Recursively yield DirEntry objects for given directory.

tar_info(filename)

Contents of a tar file.

timestamp(path)

Modification date of a file or directory as a timestamp.

zip_info(filename)

Contents of a zip file.

eturb.util.activate_paths()[source]

Setup environment variables in preparation for Nek5000 build.

eturb.util.docstring_params(Class, sections=False, indent_len=4)[source]

Creates a parameter instance and generate formatted docs for it. The docs are defined by the params.<child>._set_doc method. Done only when sphinx is already imported.

eturb.util.get_status(path)[source]

Get status of a simulation run by verifying its contents.

Returns tuple(int, str)

status code and message

eturb.util.init_params(Class, isolated_unit=False)[source]

Instantiate an isolated params for a specific class.

eturb.util.isoformat(dt)[source]

Returns timestamp in modified isoformat from a datetime object (- instead of :). Accurate upto seconds.

Note

The modified ISO format is YYYY-MM-DDTHH-MM-SS

eturb.util.last_modified(path)[source]

Find the last modified file in a directory tree.

Returns DirEntry

eturb.util.modification_date(path)[source]

Modification date of a file or directory. Returns empty string if does not exist.

eturb.util.now()[source]

The current timestamp.

Returns str

eturb.util.prepare_for_restart(path, chkp_fnumber=1, verify_contents=True)[source]

Takes a directory in which a simulation was executed.

  • If verify contents: - check if snakemake was ever executed or check if directory is locked by snakemake - ensures simulation files exist - ensures restart files exist

  • Reads params.xml if it exists, and if not falls back to abl.par. Hardcoded!

  • Modifies checkpoint parameters with appropriate chkp_fnumber to restart from KTH framework.

eturb.util.scantree(path)[source]

Recursively yield DirEntry objects for given directory.

Courtesy: https://stackoverflow.com/a/33135143

Returns generator

A generator for DirEntry objects.

eturb.util.tar_info(filename)[source]

Contents of a tar file.

eturb.util.timestamp(path)[source]

Modification date of a file or directory as a timestamp.

Returns str

eturb.util.zip_info(filename)[source]

Contents of a zip file.