gstools.tools¶
GStools subpackage providing miscellaneous tools.
Export¶
|
Export a field to vtk. |
|
Export a field to vtk structured rectilinear grid file. |
|
Export a field to vtk unstructured grid file. |
|
Create a VTK/PyVista grid. |
|
Create a vtk structured rectilinear grid from a field. |
|
Export a field to vtk structured rectilinear grid file. |
Special functions¶
|
Scaling of standard deviation to get the desired confidence interval. |
|
Calculate the (upper) incomplete gamma function. |
|
Calculate the exponential integral . |
|
Calculate the incomplete Beta function. |
|
Calculate the correlation function of the TPLStable model. |
|
Spectal density of the TPLExponential covariance model. |
|
Spectal density of the TPLGaussian covariance model. |
Geometric¶
|
Create list of the main axis defined by the given system rotations. |
|
Set the angles for the given dimension. |
|
Set the anisotropy ratios for the given dimension. |
|
Calculate number of rotation angles depending on the dimension. |
|
Get all 2D sub-planes for rotation. |
|
Givens rotation matrix in arbitrary dimensions. |
|
Create a matrix to rotate points to the target coordinate-system. |
|
Create a matrix to derotate points to the initial coordinate-system. |
|
Create a stretching matrix to make things isotrope. |
|
Create a stretching matrix to make things anisotrope. |
|
Create a matrix to derotate points and make them isotrope. |
|
Create a matrix to rotate points and make them anisotrope. |
|
Convert n-D spherical coordinates to Euclidean direction vectors. |
|
Generate grid from a structured position tuple. |
|
Generate spatio-temporal grid from a position tuple and time array. |
Misc¶
earth radius for WGS84 ellipsoid in km |
-
gstools.tools.
ang2dir
(angles, dtype=<class 'numpy.float64'>, dim=None)[source]¶ Convert n-D spherical coordinates to Euclidean direction vectors.
- Parameters
angles (
list
ofnumpy.ndarray
) – spherical coordinates given as angles.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
dim (
int
, optional) – Cut of information above the given dimension. Otherwise, dimension is determined by number of angles Default: None
- Returns
the array of direction vectors
- Return type
-
gstools.tools.
confidence_scaling
(per=0.95)[source]¶ Scaling of standard deviation to get the desired confidence interval.
-
gstools.tools.
exp_int
(s, x)[source]¶ Calculate the exponential integral .
Given by:
- Parameters
s (
float
) – exponent in the integral (should be > -100)x (
numpy.ndarray
) – input values
-
gstools.tools.
generate_grid
(pos)[source]¶ Generate grid from a structured position tuple.
- Parameters
pos (
tuple
ofnumpy.ndarray
) – The structured position tuple.- Returns
Unstructured position tuple.
- Return type
-
gstools.tools.
generate_st_grid
(pos, time, mesh_type='unstructured')[source]¶ Generate spatio-temporal grid from a position tuple and time array.
- Parameters
pos (
tuple
ofnumpy.ndarray
) – The (un-)structured position tuple.time (
iterable
) – The time array.mesh_type (
str
, optional) – ‘structured’ / ‘unstructured’ Default: “unstructured”
- Returns
Unstructured spatio-temporal point tuple.
- Return type
Notes
Time dimension will be the last one.
-
gstools.tools.
givens_rotation
(dim, plane, angle)[source]¶ Givens rotation matrix in arbitrary dimensions.
-
gstools.tools.
inc_beta
(a, b, x)[source]¶ Calculate the incomplete Beta function.
Given by:
- Parameters
a (
float
) – first exponent in the integralb (
float
) – second exponent in the integralx (
numpy.ndarray
) – input values
-
gstools.tools.
inc_gamma
(s, x)[source]¶ Calculate the (upper) incomplete gamma function.
Given by:
- Parameters
s (
float
) – exponent in the integralx (
numpy.ndarray
) – input values
-
gstools.tools.
matrix_anisometrize
(dim, angles, anis)[source]¶ Create a matrix to rotate points and make them anisotrope.
-
gstools.tools.
matrix_anisotropify
(dim, anis)[source]¶ Create a stretching matrix to make things anisotrope.
- Parameters
- Returns
Stretching matrix.
- Return type
-
gstools.tools.
matrix_derotate
(dim, angles)[source]¶ Create a matrix to derotate points to the initial coordinate-system.
- Parameters
- Returns
Rotation matrix.
- Return type
-
gstools.tools.
matrix_isometrize
(dim, angles, anis)[source]¶ Create a matrix to derotate points and make them isotrope.
-
gstools.tools.
matrix_isotropify
(dim, anis)[source]¶ Create a stretching matrix to make things isotrope.
- Parameters
- Returns
Stretching matrix.
- Return type
-
gstools.tools.
matrix_rotate
(dim, angles)[source]¶ Create a matrix to rotate points to the target coordinate-system.
- Parameters
- Returns
Rotation matrix.
- Return type
-
gstools.tools.
no_of_angles
(dim)[source]¶ Calculate number of rotation angles depending on the dimension.
-
gstools.tools.
rotated_main_axes
(dim, angles)[source]¶ Create list of the main axis defined by the given system rotations.
- Parameters
- Returns
Main axes of the target coordinate-system.
- Return type
-
gstools.tools.
set_angles
(dim, angles)[source]¶ Set the angles for the given dimension.
- Parameters
- Returns
angles – the angles fitting to the dimension
- Return type
Notes
If too few angles are given, they are filled up with 0.
-
gstools.tools.
set_anis
(dim, anis)[source]¶ Set the anisotropy ratios for the given dimension.
- Parameters
- Returns
anis – the anisotropy of length scales fitting the dimensions
- Return type
Notes
If too few anisotropy ratios are given, they are filled up with 1.
-
gstools.tools.
to_vtk
(pos, fields, mesh_type='unstructured')[source]¶ Create a VTK/PyVista grid.
- Parameters
pos (
list
) – the position tuple, containing main direction and transversal directionsfields (
dict
ornumpy.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
- Returns
This will return a PyVista object for the given field data in its appropriate type. Structured meshes will return a
pyvista.RectilinearGrid
and unstructured meshes will return anpyvista.UnstructuredGrid
object.- Return type
pyvista.RectilinearGrid
orpyvista.UnstructuredGrid
-
gstools.tools.
to_vtk_structured
(pos, fields)[source]¶ Create a vtk structured rectilinear grid from a field.
- Parameters
pos (
list
) – the position tuple, containing main direction and transversal directionsfields (
dict
ornumpy.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.
- Returns
A PyVista rectilinear grid of the structured field data. Data arrays live on the point data of this PyVista dataset.
- Return type
pyvista.RectilinearGrid
-
gstools.tools.
to_vtk_unstructured
(pos, fields)[source]¶ Export a field to vtk structured rectilinear grid file.
- Parameters
pos (
list
) – the position tuple, containing main direction and transversal directionsfields (
dict
ornumpy.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.
- Returns
A PyVista unstructured grid of the unstructured field data. Data arrays live on the point data of this PyVista dataset. This is essentially a point cloud with no topology.
- Return type
pyvista.UnstructuredGrid
-
gstools.tools.
tpl_exp_spec_dens
(k, dim, len_scale, hurst, len_low=0.0)[source]¶ Spectal density of the TPLExponential covariance model.
- Parameters
- Returns
spectal density of the TPLExponential model
- Return type
-
gstools.tools.
tpl_gau_spec_dens
(k, dim, len_scale, hurst, len_low=0.0)[source]¶ Spectal density of the TPLGaussian covariance model.
- Parameters
- Returns
spectal density of the TPLExponential model
- Return type
-
gstools.tools.
tplstable_cor
(r, len_scale, hurst, alpha)[source]¶ Calculate the correlation function of the TPLStable model.
Given by the following correlation function:
- Parameters
r (
numpy.ndarray
) – input valueslen_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.
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 directionsfields (
dict
ornumpy.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.
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 directionsfields (
dict
ornumpy.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 directionsfields (
dict
ornumpy.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.