Skip to content

Commit

Permalink
Add an easy wind vector example (#387)
Browse files Browse the repository at this point in the history
* Copy arrows from cartopy

* Rename

* Add vectors.py

* Update vectors.py

* Update vectors.py

* Update vectors.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Bill Little <[email protected]>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bill Little <[email protected]>
  • Loading branch information
3 people authored Jul 16, 2023
1 parent 500fbd2 commit bbfad38
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/geovista/examples/vectors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
"""Importable and runnable geovista example.
Notes
-----
.. versionadded:: 0.4.0
"""
from __future__ import annotations

import numpy as np
import pyvista as pv

import geovista
import geovista as gv
import geovista.theme


def main() -> None:
"""Create vectors plotting inspired by cartopy."""
# make cool swirly pattern
sphere = pv.Sphere(gv.common.RADIUS)
vectors = np.vstack(
(
-sphere.points[:, 1],
sphere.points[:, 0],
sphere.points[:, 2] * 0.0,
)
).T
sphere["vectors"] = vectors * 0.1
sphere.set_active_vectors("vectors")

# plot mesh
plotter = gv.GeoPlotter()
plotter.enable_anti_aliasing("ssaa")
plotter.add_base_layer(lighting=False)
plotter.add_coastlines(color="black", lighting=False)
plotter.add_mesh(sphere.arrows, lighting=False)
plotter.camera.zoom(1.5)
plotter.add_axes()
plotter.show()


if __name__ == "__main__":
main()

0 comments on commit bbfad38

Please sign in to comment.