Skip to content

Commit

Permalink
Enable off-screen rendering of examples (#455)
Browse files Browse the repository at this point in the history
* add examples off_screen kwarg

* examples crs tidy
  • Loading branch information
bjlittle authored Sep 25, 2023
1 parent 5304f78 commit b65a927
Show file tree
Hide file tree
Showing 35 changed files with 99 additions and 84 deletions.
4 changes: 2 additions & 2 deletions src/geovista/examples/clouds.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create meshes from 1-D latitude and longitude unstructured cell points.
The resulting meshes contain quad cells and are constructed from CF UGRID
Expand All @@ -54,7 +54,7 @@ def main() -> None:
clim = (cmin := 0.3, 1.0)

# create the plotter
plotter = gv.GeoPlotter()
plotter = gv.GeoPlotter(off_screen=off_screen)

for i, cloud in enumerate(cmaps):
# load the sample data
Expand Down
7 changes: 4 additions & 3 deletions src/geovista/examples/clouds_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create meshes from 1-D latitude and longitude unstructured cell points.
The resulting meshes contain quad cells and are constructed from CF UGRID
Expand All @@ -54,7 +54,8 @@ def main() -> None:
clim = (cmin := 0.3, 1.0)

# create the plotter
plotter = gv.GeoPlotter(crs=(projection := "+proj=robin"))
crs = "+proj=robin"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)

for i, cloud in enumerate(cmaps):
# load the sample data
Expand Down Expand Up @@ -87,7 +88,7 @@ def main() -> None:
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
f"Low, Medium, High & Very High Cloud Amount ({projection})",
f"Low, Medium, High & Very High Cloud Amount ({crs})",
position="upper_left",
font_size=10,
shadow=True,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/earthquakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a point cloud from a USGS earthquakes dataset.
The resulting render contains a point cloud of M2.5+ earthquakes along
Expand Down Expand Up @@ -56,7 +56,7 @@ def main() -> None:
return

# plot the mesh
plotter = gv.GeoPlotter()
plotter = gv.GeoPlotter(off_screen=off_screen)
sargs = {"title": "Magnitude", "shadow": True}
plotter.add_points(
xs=sample.lons,
Expand Down
7 changes: 4 additions & 3 deletions src/geovista/examples/earthquakes_wink1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a point cloud from a USGS earthquakes dataset.
The resulting render contains a point cloud of M2.5+ earthquakes along
Expand Down Expand Up @@ -57,7 +57,8 @@ def main() -> None:
return

# plot the mesh
plotter = gv.GeoPlotter(crs=(projection := "+proj=wink1 +lon_0=180"))
crs = "+proj=wink1 +lon_0=180"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
sargs = {"title": "Magnitude", "shadow": True}
plotter.add_points(
xs=sample.lons,
Expand All @@ -74,7 +75,7 @@ def main() -> None:
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
f"USGS M2.5+ Earthquakes, 2000-2018 ({projection})",
f"USGS M2.5+ Earthquakes, 2000-2018 ({crs})",
position="upper_left",
font_size=10,
shadow=True,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_1d__oisst.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -39,7 +39,7 @@ def main() -> None:
mesh = mesh.threshold()

# plot the mesh
plotter = gv.GeoPlotter()
plotter = gv.GeoPlotter(off_screen=off_screen)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(mesh, scalar_bar_args=sargs)
plotter.add_base_layer(texture=gv.blue_marble())
Expand Down
7 changes: 4 additions & 3 deletions src/geovista/examples/from_1d__oisst_eqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand Down Expand Up @@ -41,14 +41,15 @@ def main() -> None:
mesh = mesh.threshold()

# plot the mesh
plotter = gv.GeoPlotter(crs=(projection := "+proj=eqc"))
crs = "+proj=eqc"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(mesh, scalar_bar_args=sargs)
plotter.add_base_layer(texture=gv.blue_marble())
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
f"NOAA/NCEI OISST AVHRR ({projection})",
f"NOAA/NCEI OISST AVHRR ({crs})",
position="upper_left",
font_size=10,
shadow=True,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_1d__synthetic_face_m1_n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -38,7 +38,7 @@ def main() -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter()
plotter = gv.GeoPlotter(off_screen=off_screen)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="ice", scalar_bar_args=sargs, show_edges=True
Expand Down
7 changes: 4 additions & 3 deletions src/geovista/examples/from_1d__synthetic_face_m1_n1_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -39,15 +39,16 @@ def main() -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter(crs=(projection := "+proj=robin"))
crs = "+proj=robin"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="ice", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
f"1-D Synthetic Face Data ({projection})",
f"1-D Synthetic Face Data ({crs})",
position="upper_left",
font_size=10,
shadow=True,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_1d__synthetic_node_m1_n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -38,7 +38,7 @@ def main() -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter()
plotter = gv.GeoPlotter(off_screen=off_screen)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="ice", scalar_bar_args=sargs, show_edges=True
Expand Down
7 changes: 4 additions & 3 deletions src/geovista/examples/from_1d__synthetic_node_m1_n1_moll.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 1-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -39,7 +39,8 @@ def main() -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter(crs=(projection := "+proj=moll"))
crs = "+proj=moll"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh,
Expand All @@ -51,7 +52,7 @@ def main() -> None:
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
f"1-D Synthetic Node Data ({projection})",
f"1-D Synthetic Node Data ({crs})",
position="upper_left",
font_size=10,
shadow=True,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__orca.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 2-D latitude and longitude curvilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -38,7 +38,7 @@ def main() -> None:
mesh = mesh.threshold()

# plot the mesh
plotter = gv.GeoPlotter()
plotter = gv.GeoPlotter(off_screen=off_screen)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(mesh, show_edges=True, scalar_bar_args=sargs)
plotter.add_base_layer(texture=gv.natural_earth_1())
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__orca_moll.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from geovista.transform import transform_mesh


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 2-D latitude and longitude curvilinear cell bounds.
The resulting mesh contains quad cells.
Expand Down Expand Up @@ -51,7 +51,7 @@ def main() -> None:
mesh.extrude((0, 0, -1000000), capping=True, inplace=True)

# plot the mesh
plotter = gv.GeoPlotter(crs=crs)
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(mesh, scalar_bar_args=sargs)
plotter.add_coastlines(color="black")
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__synthetic_face_m1n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 2-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -39,7 +39,7 @@ def main() -> None:
gv.logger.info("%s", mesh)

# plot the data
plotter = gv.GeoPlotter()
plotter = gv.GeoPlotter(off_screen=off_screen)
sargs = sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="tempo", scalar_bar_args=sargs, show_edges=True
Expand Down
7 changes: 4 additions & 3 deletions src/geovista/examples/from_2d__synthetic_face_m1n1_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 2-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -40,15 +40,16 @@ def main() -> None:
gv.logger.info("%s", mesh)

# plot the data
plotter = gv.GeoPlotter(crs=(projection := "+proj=robin"))
crs = "+proj=robin"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
sargs = sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh, clim=(0, 1), cmap="tempo", scalar_bar_args=sargs, show_edges=True
)
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
f"2-D Synthetic Face Data ({projection})",
f"2-D Synthetic Face Data ({crs})",
position="upper_left",
font_size=10,
shadow=True,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_2d__synthetic_node_m1n1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 2-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -39,7 +39,7 @@ def main() -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter()
plotter = gv.GeoPlotter(off_screen=off_screen)
plotter.add_mesh(mesh, clim=(0, 1), cmap="tempo", show_edges=True)
plotter.add_coastlines()
plotter.add_axes()
Expand Down
7 changes: 4 additions & 3 deletions src/geovista/examples/from_2d__synthetic_node_m1n1_moll.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a mesh from 2-D latitude and longitude rectilinear cell bounds.
The resulting mesh contains quad cells.
Expand All @@ -40,7 +40,8 @@ def main() -> None:
gv.logger.info("%s", mesh)

# plot the mesh
plotter = gv.GeoPlotter(crs=(projection := "+proj=moll"))
crs = "+proj=moll"
plotter = gv.GeoPlotter(crs=crs, off_screen=off_screen)
sargs = {"title": f"{name} / 1", "shadow": True}
plotter.add_mesh(
mesh,
Expand All @@ -52,7 +53,7 @@ def main() -> None:
plotter.add_coastlines()
plotter.add_axes()
plotter.add_text(
f"2-D Synthetic Node Data ({projection})",
f"2-D Synthetic Node Data ({crs})",
position="upper_left",
font_size=10,
shadow=True,
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/examples/from_points__orca_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import geovista.theme # noqa: F401


def main() -> None:
def main(off_screen: bool = False) -> None:
"""Create a point-cloud from 1-D latitude, longitude and z-levels.
The resulting mesh contains only points.
Expand Down Expand Up @@ -43,7 +43,7 @@ def main() -> None:
gv.logger.info("%s", cloud)

# plot the point-cloud
plotter = gv.GeoPlotter()
plotter = gv.GeoPlotter(off_screen=off_screen)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
plotter.add_mesh(
cloud,
Expand Down
Loading

0 comments on commit b65a927

Please sign in to comment.