gstools.tools

GStools subpackage providing miscellaneous tools.

Export

vtk_export(filename, pos, field[, …]) Export a field to vtk
vtk_export_structured(filename, pos, field) Export a field to vtk structured rectilinear grid file
vtk_export_unstructured(filename, pos, field) Export a field to vtk structured rectilinear grid file

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
stable_cov_norm(r, len_scale, hurst, alpha) The normalized covariance function of the stable model

Geometric

xyz2pos(x[, y, z, dtype]) Convert postional arguments to x, y, z
pos2xyz(pos[, dtype, calc_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, field, fieldname='field')[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 or *.vtu) will be added to the name.
  • pos (list) – the position tuple, containing main direction and transversal directions
  • field (numpy.ndarray) – Structured field to be saved. As returned by SRF.
  • fieldname (str, optional) – Name of the field in the VTK file. Default: “field”
gstools.tools.vtk_export_unstructured(filename, pos, field, fieldname='field')[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 or *.vtu) will be added to the name.
  • pos (list) – the position tuple, containing main direction and transversal directions
  • field (numpy.ndarray) – Unstructured field to be saved. As returned by SRF.
  • fieldname (str, optional) – Name of the field in the VTK file. Default: “field”
gstools.tools.vtk_export(filename, pos, field, fieldname='field', 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
  • field (numpy.ndarray) – Unstructured field to be saved. As returned by SRF.
  • fieldname (str, optional) – Name of the field in the VTK file. Default: “field”
  • 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:
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.stable_cov_norm(r, len_scale, hurst, alpha)[source]

The normalized covariance function of the stable model

Given by

\tilde{C}(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)[source]

Convert postional arguments to x, y, z

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
Returns:

pos – the position tuple

Return type:

numpy.ndarray

gstools.tools.pos2xyz(pos, dtype=None, calc_dim=False)[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) – State if the dimension should be returned
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