gstools.tools

GStools subpackage providing miscellaneous tools.

Export

to_vtk_structured
vtk_export_structured(filename, pos, fields) Export a field to vtk structured rectilinear grid file.
to_vtk_unstructured
vtk_export_unstructured(filename, pos, fields) Export a field to vtk unstructured grid file.
to_vtk
vtk_export(filename, pos, fields[, mesh_type]) Export a field to vtk.

Special functions

inc_gamma(s, x) The (upper) incomplete gamma function.
exp_int(s, x) The exponential integral E_s(x).
inc_beta(a, b, x) The incomplete Beta function.
tplstable_cor(r, len_scale, hurst, alpha) The correlation function of the TPLStable model.

Geometric

xyz2pos(x[, y, z, dtype, max_dim]) Convert x, y, z to postional arguments.
pos2xyz(pos[, dtype, calc_dim, max_dim]) Convert postional arguments to x, y, z.
r3d_x(theta) Rotation matrix about x axis.
r3d_y(theta) Rotation matrix about y axis.
r3d_z(theta) Rotation matrix about z axis.

gstools.tools.vtk_export_structured(filename, pos, fields)[source]

Export a field to vtk structured rectilinear grid file.

Parameters:
  • filename (str) – Filename of the file to be saved, including the path. Note that an ending (.vtr) will be added to the name.
  • pos (list) – the position tuple, containing main direction and transversal directions
  • fields (dict or numpy.ndarray) – Structured fields to be saved. Either a single numpy array as returned by SRF, or a dictionary of fields with theirs names as keys.
gstools.tools.vtk_export_unstructured(filename, pos, fields)[source]

Export a field to vtk unstructured grid file.

Parameters:
  • filename (str) – Filename of the file to be saved, including the path. Note that an ending (.vtu) will be added to the name.
  • pos (list) – the position tuple, containing main direction and transversal directions
  • fields (dict or numpy.ndarray) – Unstructured fields to be saved. Either a single numpy array as returned by SRF, or a dictionary of fields with theirs names as keys.
gstools.tools.vtk_export(filename, pos, fields, mesh_type='unstructured')[source]

Export a field to vtk.

Parameters:
  • filename (str) – Filename of the file to be saved, including the path. Note that an ending (.vtr or .vtu) will be added to the name.
  • pos (list) – the position tuple, containing main direction and transversal directions
  • fields (dict or numpy.ndarray) – [Un]structured fields to be saved. Either a single numpy array as returned by SRF, or a dictionary of fields with theirs names as keys.
  • mesh_type (str, optional) – ‘structured’ / ‘unstructured’. Default: structured
gstools.tools.inc_gamma(s, x)[source]

The (upper) incomplete gamma function.

Given by: \Gamma(s,x) = \int_x^{\infty} t^{s-1}\,e^{-t}\,{\rm d}t

Parameters:
gstools.tools.exp_int(s, x)[source]

The exponential integral E_s(x).

Given by: E_s(x) = \int_1^\infty \frac{e^{-xt}}{t^s}\,\mathrm dt

Parameters:
  • s (float) – exponent in the integral (should be > -100)
  • x (numpy.ndarray) – input values
gstools.tools.inc_beta(a, b, x)[source]

The incomplete Beta function.

Given by: B(a,b;\,x) = \int_0^x t^{a-1}\,(1-t)^{b-1}\,dt

Parameters:
  • a (float) – first exponent in the integral
  • b (float) – second exponent in the integral
  • x (numpy.ndarray) – input values
gstools.tools.tplstable_cor(r, len_scale, hurst, alpha)[source]

The correlation function of the TPLStable model.

Given by

\mathrm{cor}(r) =
\frac{2H}{\alpha} \cdot
E_{1+\frac{2H}{\alpha}}
\left(\left(\frac{r}{\ell}\right)^{\alpha} \right)

Parameters:
  • r (numpy.ndarray) – input values
  • len_scale (float) – length-scale of the model.
  • hurst (float) – Hurst coefficient of the power law.
  • alpha (float, optional) – Shape parameter of the stable model.
gstools.tools.xyz2pos(x, y=None, z=None, dtype=None, max_dim=3)[source]

Convert x, y, z to postional arguments.

Parameters:
  • x (numpy.ndarray) – grid axis in x-direction if structured, or first components of position vectors if unstructured
  • y (numpy.ndarray, optional) – analog to x
  • z (numpy.ndarray, optional) – analog to x
  • dtype (data-type, optional) – The desired data-type for the array. If not given, then the type will be determined as the minimum type required to hold the objects in the sequence. Default: None
  • max_dim (int, optional) – Cut of information above the given dimension. Default: 3
Returns:

pos – the position tuple

Return type:

numpy.ndarray

gstools.tools.pos2xyz(pos, dtype=None, calc_dim=False, max_dim=3)[source]

Convert postional arguments to x, y, z.

Parameters:
  • pos (iterable) – the position tuple, containing main direction and transversal directions
  • dtype (data-type, optional) – The desired data-type for the array. If not given, then the type will be determined as the minimum type required to hold the objects in the sequence. Default: None
  • calc_dim (bool, optional) – State if the dimension should be returned. Default: False
  • max_dim (int, optional) – Cut of information above the given dimension. Default: 3
Returns:

Notes

If len(pos) > 3, everything after pos[2] will be ignored.

gstools.tools.r3d_x(theta)[source]

Rotation matrix about x axis.

Parameters:theta (float) – Rotation angle
Returns:Rotation matrix.
Return type:numpy.ndarray
gstools.tools.r3d_y(theta)[source]

Rotation matrix about y axis.

Parameters:theta (float) – Rotation angle
Returns:Rotation matrix.
Return type:numpy.ndarray
gstools.tools.r3d_z(theta)[source]

Rotation matrix about z axis.

Parameters:theta (float) – Rotation angle
Returns:Rotation matrix.
Return type:numpy.ndarray