geovista.common#
Provision common geovista infra-structure and utilities.
ノート#
Added in version 0.1.0.
属性#
Default base for wrapped longitude half-open interval, in degrees. |
|
Default central meridian. |
|
Default Natural Earth coastline resolution. |
|
Name of the geovista cell indices array. |
|
The field array name of the CF serialized pyproj CRS. |
|
The field array name of the mesh containing field, point and/or cell data. |
|
The field array name of the mesh radius. |
|
The field array name of the mesh resolution e.g., coastlines. |
|
The field array name of the mesh proportional multiplier for z-axis levels. |
|
Name of the geovista manifold cell indices/marker array. |
|
Name of the geovista point indices array. |
|
Name of the geovista remesh point indices/marker array. |
|
Default jupyter plotting backend for pyvista. |
|
LRU cache size, which is auto-disabled for testing. |
|
Default period for wrapped longitude half-open interval, in degrees. |
|
Default radius of a spherical mesh. |
|
Marker for remesh filter cell join point. |
|
Marker for remesh filter western cell boundary point. |
|
Name of the VTK cell indices array. |
|
Name of the VTK point indices array. |
|
Type alias for 2D vector components. |
|
Type alias for 3D vector components. |
|
Type alias for 2D or 3D vector components. |
|
Absolute tolerance for longitudes close to 'wrap meridian'. |
|
Relative tolerance for longitudes close to 'wrap meridian'. |
|
Proportional multiplier for z-axis levels/offsets. |
|
The zlevel scaling to be applied when transforming to a projection. |
Classes#
Enumeration of common mesh geometry preferences. |
|
Convenience behaviour for a string enumeration. |
Functions#
Determine whether we are executing within an |
|
|
Convert a |
|
Calculate the mean distance from the origin to the points of the mesh. |
|
Convert cartesian |
|
Find all submodule names relative to the root package. |
|
Replace any masked array values with NaNs. |
|
Determine whether the mesh is a point-cloud. |
|
Purge standard helper cell and point data index arrays. |
|
Purge standard VTK helper cell and point data index arrays. |
|
Configure the jupyter plotting backend for pyvista. |
|
Convert geographic longitudes and latitudes to cartesian |
|
Convert cartesian xyz point on sphere to geographic longitude and latitude. |
|
Convert cartesian xyz points on sphere to geographic longitudes and latitudes. |
|
Determine whether the provided mesh is triangulated. |
|
Transform geographic-oriented vector components |
Disable vtkLogger warning messages. |
|
Enable vtkLogger warning messages. |
|
|
Transform longitudes to be in the half-open interval |
モジュール内容#
- class geovista.common.Preference[ソース]#
Bases:
StrEnumPlusEnumeration of common mesh geometry preferences.
ノート#
Added in version 0.3.0.
Initialize self. See help(type(self)) for accurate signature.
- CELL = 'cell'#
Preference for cell geometry.
- POINT = 'point'#
Preference for point geometry.
- class geovista.common.StrEnumPlus[ソース]#
Bases:
enum.StrEnumConvenience behaviour for a string enumeration.
ノート#
Added in version 0.6.0.
Previously called MixinStrEnum.
Initialize self. See help(type(self)) for accurate signature.
- classmethod valid(item)[ソース]#
Determine whether the provided item is a valid enumeration member.
- Parameters:
- item
strorPreference The candidate preference enumeration member.
- item
- Returns:
boolWhether the preference enumeration member is valid.
ノート
Added in version 0.3.0.
- geovista.common.active_kernel()[ソース]#
Determine whether we are executing within an
IPythonkernel.- Returns:
boolWhether there is an active
IPythonkernel.
ノート
Added in version 0.1.0.
- geovista.common.cast_UnstructuredGrid_to_PolyData(mesh, /, *, clean=False)[ソース]#
Convert a
UnstructuredGridto aPolyData.- Parameters:
- mesh
UnstructuredGrid The unstructured grid to be converted.
- clean
bool, default=False Specify whether to merge duplicate points, remove unused points, and/or remove degenerate cells in the resultant mesh. See
pyvista.PolyDataFilters.clean().
- mesh
- Returns:
PolyDataThe resultant mesh.
ノート
Added in version 0.1.0.
- geovista.common.distance(mesh, /, *, origin=None, mean=True)[ソース]#
Calculate the mean distance from the origin to the points of the mesh.
Note that given a spherical mesh the distance calculated is the radius.
- Parameters:
- mesh
PolyData The surface that requires its distance to be calculated, relative to the origin.
- origin
ArrayLike, default=(0, 0, 0) The (x, y, z) cartesian center of the spheroid mesh.
- mean
bool, default=True Calculate the mean distance to the points of the mesh. Otherwise, calculate the distance to each point from the origin.
- mesh
- Returns:
ノート
Added in version 0.1.0.
- geovista.common.from_cartesian(mesh, /, *, stacked=True, closed_interval=False, rtol=None, atol=None)[ソース]#
Convert cartesian
xyzspherical mesh to geographic longitude and latitude.- Parameters:
- mesh
PolyData The mesh containing the cartesian (x, y, z) points to be converted to longitude and latitude coordinates.
- stacked
bool, default=True Specify whether the resultant xy0 coordinates have shape (N, 3). Otherwise, they will have shape (3, N).
- closed_interval
bool, default=False Longitude values will be in the half-closed interval [-180, 180). However, if the mesh has a seam at the 180th meridian and closed_interval is
True, then longitudes will be in the closed interval [-180, 180].- rtol
float, optional The relative tolerance for longitudes close to the 'wrap meridian' - see
geovista.common.wrap()for more.- atol
float, optional The absolute tolerance for longitudes close to the 'wrap meridian' - see
geovista.common.wrap()for more.
- mesh
- Returns:
ndarrayThe longitude and latitude coordinates, in degrees.
ノート
Added in version 0.1.0.
- geovista.common.get_modules(root, /, *, base=True)[ソース]#
Find all submodule names relative to the root package.
Recursively searches down from the root to find all child (leaf) modules.
The names of the modules will be relative to the root.
- Parameters:
- Returns:
ノート
Added in version 0.5.0.
- geovista.common.nan_mask(data)[ソース]#
Replace any masked array values with NaNs.
As a consequence of filling the mask with NaNs, non-float arrays will be cast to float.
- Parameters:
- data
ArrayLike The masked array to be filled with NaNs.
- data
- Returns:
ndarrayThe data with masked values replaced with NaNs.
ノート
Added in version 0.1.0.
- geovista.common.point_cloud(mesh)[ソース]#
Determine whether the mesh is a point-cloud.
ノート
Added in version 0.2.0.
- geovista.common.sanitize(*meshes, extra=None, vtk=True)[ソース]#
Purge standard helper cell and point data index arrays.
- Parameters:
ノート
Added in version 0.6.0.
- geovista.common.sanitize_vtk(*meshes)[ソース]#
Purge standard VTK helper cell and point data index arrays.
ノート
Added in version 0.1.0.
- geovista.common.set_jupyter_backend(*, backend=None)[ソース]#
Configure the jupyter plotting backend for pyvista.
- Parameters:
- backend
str, optional The pyvista plotting backend. For further details see
pyvista.set_jupyter_backend(). IfNone, defaults toJUPYTER_BACKEND.
- backend
- Returns:
boolWhether the jupyter backend was successfully configured.
ノート
Added in version 0.1.0.
- geovista.common.to_cartesian(lons, lats, *, radius=None, zlevel=None, zscale=None, stacked=True)[ソース]#
Convert geographic longitudes and latitudes to cartesian
xyzpoints.- Parameters:
- lons
ArrayLike The longitude values (degrees) to be converted.
- lats
ArrayLike The latitude values (degrees) to be converted.
- radius
float, optional The radius of the sphere. Defaults to
RADIUS.- zlevel
floatorArrayLike, default=0.0 The z-axis level. Used in combination with the zscale to offset the radius by a proportional amount i.e.,
radius * zlevel * zscale. If zlevel is not a scalar, then its shape must match or broadcast with the shape of lons and lats.- zscale
float, optional The proportional multiplier for z-axis zlevel. Defaults to
ZLEVEL_SCALE.- stacked
bool, default=True Specify whether the resultant xyz points have shape (N, 3). Otherwise, they will have shape (3, N).
- lons
- Returns:
ndarrayThe
xyzspherical cartesian points.
ノート
Added in version 0.1.0.
- geovista.common.to_lonlat(xyz, /, *, radians=False, radius=None, rtol=None, atol=None)[ソース]#
Convert cartesian xyz point on sphere to geographic longitude and latitude.
- Parameters:
- xyz
ArrayLike The cartesian (x, y, z) point to be converted.
- radians
bool, default=False Convert resultant longitude and latitude values to radians. Default units are degrees.
- radius
float, optional The radius of the sphere. Defaults to
RADIUS.- rtol
float, optional The relative tolerance for longitudes close to the 'wrap meridian' - see
geovista.common.wrap()for more.- atol
float, optional The absolute tolerance for longitudes close to the 'wrap meridian' - see
geovista.common.wrap()for more.
- xyz
- Returns:
ndarrayThe longitude and latitude values.
ノート
Added in version 0.1.0.
- geovista.common.to_lonlats(xyz, /, *, radians=False, radius=None, stacked=True, rtol=None, atol=None)[ソース]#
Convert cartesian xyz points on sphere to geographic longitudes and latitudes.
- Parameters:
- xyz
ArrayLike The cartesian (x, y, z) points to be converted.
- radians
bool, default=False Convert resultant longitude and latitude values to radians. Default units are degrees.
- radius
floatorArrayLike, optional The radius of the sphere. If radius is not a scalar, then its shape must match the number of xyz points i.e., radii with shape
(N,)for xyz points with shape(N, 3). Defaults toRADIUS.- stacked
bool, default=True Default the resultant shape to be
(N, 2), otherwise(2, N).- rtol
float, optional The relative tolerance for longitudes close to the 'wrap meridian' - see
geovista.common.wrap()for more.- atol
float, optional The absolute tolerance for longitudes close to the 'wrap meridian' - see
geovista.common.wrap()for more.
- xyz
- Returns:
ndarrayThe longitude and latitude values.
ノート
Added in version 0.1.0.
- geovista.common.triangulated(surface)[ソース]#
Determine whether the provided mesh is triangulated.
- Parameters:
- surface
PolyData The surface mesh to check whether the geometry of all its cells are triangles.
- surface
- Returns:
boolWhether the surface is fully triangulated.
ノート
Added in version 0.1.0.
- geovista.common.vectors_to_cartesian(lons, lats, vectors, *, radius=None, zlevel=None, zscale=None)[ソース]#
Transform geographic-oriented vector components
uvwto cartesianxyz.- Parameters:
- lons
ArrayLike The longitude points of the vectors (in degrees). Must be the same shape as lats.
- lats
ArrayLike The latitude points of the vectors (in degrees). Must be the same shape as lons.
- vectors
Vector3DLike The eastward (
U), northward (V) and upward (W) vector components. All shapes must be the same as lons and lats.- radius
float, optional The radius of the sphere. Defaults to
RADIUS.- zlevel
intorArrayLike, default=0.0 The z-axis level. Used in combination with the zscale to offset the radius by a proportional amount i.e.,
radius * zlevel * zscale. NOTE : non-scalar zlevel is not actually supported, since it is planned to drop support for this fromfrom_points(). It will raise an error.- zscale
float, optional The proportional multiplier for z-axis zlevel. Defaults to
ZLEVEL_SCALE.
- lons
- Returns:
Vector3DLikeThe corresponding
xyzcartesian vector components.
ノート
Added in version 0.6.0.
- geovista.common.vtk_warnings_off()[ソース]#
Disable vtkLogger warning messages.
ノート
Added in version 0.1.0.
- geovista.common.vtk_warnings_on()[ソース]#
Enable vtkLogger warning messages.
ノート
Added in version 0.1.0.
- geovista.common.wrap(lons, *, base=None, period=None, rtol=None, atol=None, dtype=None)[ソース]#
Transform longitudes to be in the half-open interval
[base, base + period).- Parameters:
- lons
ArrayLike One or more longitude values to be wrapped in the interval.
- base
float, optional The start limit of the half-open interval. Defaults to
BASE.- period
float, optional The end limit of the half-open interval expressed as a length from the base, in the same units. Defaults to
PERIOD.- rtol
float, optional The relative tolerance for longitudes close to the 'wrap meridian' - that is
base + period- to be considered equal to the wrap meridian. Necessary to prevent cell smearing. See rtol innumpy.isclose(). Defaults toWRAP_RTOL.- atol
float, optional The absolute tolerance for longitudes close to the 'wrap meridian' - that is
base + period- to be considered equal to the wrap meridian. Necessary to prevent cell smearing. See atol innumpy.isclose(). Defaults toWRAP_ATOL.- dtypedata-type, default=float64
The resultant longitude dtype.
- lons
- Returns:
ndarrayThe transformed longitude values.
ノート
Added in version 0.1.0.
Examples
>>> from geovista.common import wrap >>> import numpy as np >>> wrap([179.0, 179.999, 180.0, 181.0]) array([ 179., -180., -180., -179.])
>>> wrap([179, 180, 181], period=90) array([ -91., -180., -179.])
>>> wrap([179, 180, 181], base=0, period=90) array([89., 0., 1.])
- geovista.common.BASE: float = -180.0#
Default base for wrapped longitude half-open interval, in degrees.
- geovista.common.GV_FIELD_NAME: str = 'gvName'#
The field array name of the mesh containing field, point and/or cell data.
- geovista.common.GV_FIELD_RESOLUTION: str = 'gvResolution'#
The field array name of the mesh resolution e.g., coastlines.
- geovista.common.GV_FIELD_ZSCALE: str = 'gvZScale'#
The field array name of the mesh proportional multiplier for z-axis levels.
- geovista.common.GV_MANIFOLD_CELL_IDS: str = 'gvManifoldCellIds'#
Name of the geovista manifold cell indices/marker array.
- geovista.common.GV_REMESH_POINT_IDS: str = 'gvRemeshPointIds'#
Name of the geovista remesh point indices/marker array.
- geovista.common.PERIOD: float = 360.0#
Default period for wrapped longitude half-open interval, in degrees.
- type geovista.common.Vector2DLike = tuple[ArrayLike, ArrayLike]#
Type alias for 2D vector components.
- type geovista.common.Vector3DLike = tuple[ArrayLike, ArrayLike, ArrayLike]#
Type alias for 3D vector components.
- type geovista.common.VectorLike = Vector2DLike | Vector3DLike#
Type alias for 2D or 3D vector components.
- geovista.common.WRAP_ATOL: float = 1e-08#
Absolute tolerance for longitudes close to 'wrap meridian'.