Skip to content

Commit

Permalink
Tidy up grdview docstrings
Browse files Browse the repository at this point in the history
Wrap grdview docstrings to 79 characters as per #384 and make alias formatting nicer after #383.
  • Loading branch information
weiji14 committed Dec 6, 2019
1 parent 6af9784 commit 28c09db
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 63 deletions.
72 changes: 38 additions & 34 deletions pygmt/base_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,59 +336,63 @@ def grdview(self, reliefgrid, **kwargs):
"""
Create 3-D perspective image or surface mesh from a grid.
Reads a 2-D grid file and produces a 3-D perspective plot by drawing a mesh,
painting a colored/gray-shaded surface made up of polygons, or by scanline
conversion of these polygons to a raster image. Options include draping a data
set on top of a surface, plotting of contours on top of the surface, and apply
artificial illumination based on intensities provided in a separate grid file.
Reads a 2-D grid file and produces a 3-D perspective plot by drawing a
mesh, painting a colored/gray-shaded surface made up of polygons, or by
scanline conversion of these polygons to a raster image. Options
include draping a data set on top of a surface, plotting of contours on
top of the surface, and apply artificial illumination based on
intensities provided in a separate grid file.
Full option list at :gmt-docs:`grdview.html`
Parameters
----------
reliefgrid : str or xarray.DataArray
The file name of the input relief grid or the grid loaded as a DataArray.
The file name of the input relief grid or the grid loaded as a
DataArray.
zscale (Jz) or zsize (JZ) : float or str
zscale/zsize : float or str
Set z-axis scaling or z-axis size.
cmap (C) : str
cmap : str
The name of the color palette table to use.
drapegrid (G) : str or xarray.DataArray
The file name or a DataArray of the image grid to be draped on top of the
relief provided by reliefgrid. [Default determines colors from reliefgrid].
Note that -Jz and -N always refers to the reliefgrid. The drapegrid only
provides the information pertaining to colors, which (if drapegrid is a
grid) will be looked-up via the CPT (see -C).
drapegrid : str or xarray.DataArray
The file name or a DataArray of the image grid to be draped on top
of the relief provided by reliefgrid. [Default determines colors
from reliefgrid]. Note that -Jz and -N always refers to the
reliefgrid. The drapegrid only provides the information pertaining
to colors, which (if drapegrid is a grid) will be looked-up via the
CPT (see -C).
plane (N) : float or str
plane : float or str
``level[+gfill]``.
Draws a plane at this z-level. If the optional color is provided via the +g
modifier, and the projection is not oblique, the frontal facade between the
plane and the data perimeter is colored.
Draws a plane at this z-level. If the optional color is provided
via the +g modifier, and the projection is not oblique, the frontal
facade between the plane and the data perimeter is colored.
surftype (Q) : str
Specifies cover type of the reliefgrid. Select one of following settings:
surftype : str
Specifies cover type of the reliefgrid.
Select one of following settings:
1. 'm' for mesh plot [Default].
2. 'mx' or 'my' for waterfall plots (row or column profiles).
3. 's' for surface plot.
4. 'i' for image plot.
5. 'c'. Same as 'i' but will make nodes with z = NaN transparent.
For any of these choices, you may force a monochrome image by appending the
modifier +m.
contourpen (Wc) : str
Draw contour lines on top of surface or mesh (not image). Append pen
attributes used for the contours.
meshpen (Wm) : str
Sets the pen attributes used for the mesh. You must also select -Qm or -Qsm
for meshlines to be drawn.
facadepen (Wf) :str
Sets the pen attributes used for the facade. You must also select -N for the
facade outline to be drawn.
perspective (p) : list or str
For any of these choices, you may force a monochrome image by
appending the modifier +m.
contourpen : str
Draw contour lines on top of surface or mesh (not image). Append
pen attributes used for the contours.
meshpen : str
Sets the pen attributes used for the mesh. You must also select -Qm
or -Qsm for meshlines to be drawn.
facadepen :str
Sets the pen attributes used for the facade. You must also select
-N for the facade outline to be drawn.
perspective : list or str
``'[x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0]'``.
Select perspective view.
Expand Down
60 changes: 31 additions & 29 deletions pygmt/tests/test_grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def test_grdview_reliefgrid_dataarray(grid):
@pytest.mark.mpl_image_compare
def test_grdview_reliefgrid_file_with_region_subset():
"""
Run grdview by passing in a reliefgrid filename, and cropping it to a region.
Run grdview by passing in a reliefgrid filename, and cropping it to a
region.
"""
gridfile = which("@earth_relief_60m", download="c")

Expand All @@ -53,8 +54,9 @@ def test_grdview_wrong_kind_of_reliefgrid(grid):
@pytest.mark.mpl_image_compare
def test_grdview_with_perspective(grid):
"""
Run grdview by passing in a reliefgrid and setting a perspective viewpoint with an
azimuth from the SouthEast and an elevation angle 15 degrees from the z-plane.
Run grdview by passing in a reliefgrid and setting a perspective viewpoint
with an azimuth from the SouthEast and an elevation angle 15 degrees from
the z-plane.
"""
fig = Figure()
fig.grdview(reliefgrid=grid, perspective=[135, 15])
Expand All @@ -64,9 +66,9 @@ def test_grdview_with_perspective(grid):
@pytest.mark.mpl_image_compare
def test_grdview_with_perspective_and_zscale(grid):
"""
Run grdview by passing in a reliefgrid and setting a perspective viewpoint with an
azimuth from the SouthWest and an elevation angle 30 degrees from the z-plane, plus
a z-axis scaling factor of 0.005.
Run grdview by passing in a reliefgrid and setting a perspective viewpoint
with an azimuth from the SouthWest and an elevation angle 30 degrees from
the z-plane, plus a z-axis scaling factor of 0.005.
"""
fig = Figure()
fig.grdview(reliefgrid=grid, perspective=[225, 30], zscale=0.005)
Expand All @@ -76,9 +78,9 @@ def test_grdview_with_perspective_and_zscale(grid):
@pytest.mark.mpl_image_compare
def test_grdview_with_perspective_and_zsize(grid):
"""
Run grdview by passing in a reliefgrid and setting a perspective viewpoint with an
azimuth from the SouthWest and an elevation angle 30 degrees from the z-plane, plus
a z-axis size of 10cm.
Run grdview by passing in a reliefgrid and setting a perspective viewpoint
with an azimuth from the SouthWest and an elevation angle 30 degrees from
the z-plane, plus a z-axis size of 10cm.
"""
fig = Figure()
fig.grdview(reliefgrid=grid, perspective=[225, 30], zsize="10c")
Expand All @@ -88,8 +90,8 @@ def test_grdview_with_perspective_and_zsize(grid):
@pytest.mark.mpl_image_compare
def test_grdview_with_cmap_for_image_plot(grid):
"""
Run grdview by passing in a reliefgrid and setting a colormap for producing an image
plot.
Run grdview by passing in a reliefgrid and setting a colormap for producing
an image plot.
"""
fig = Figure()
fig.grdview(reliefgrid=grid, cmap="oleron", surftype="i")
Expand All @@ -99,8 +101,8 @@ def test_grdview_with_cmap_for_image_plot(grid):
@pytest.mark.mpl_image_compare
def test_grdview_with_cmap_for_surface_monochrome_plot(grid):
"""
Run grdview by passing in a reliefgrid and setting a colormap for producing a
surface monochrome plot.
Run grdview by passing in a reliefgrid and setting a colormap for producing
a surface monochrome plot.
"""
fig = Figure()
fig.grdview(reliefgrid=grid, cmap="oleron", surftype="s+m")
Expand All @@ -110,8 +112,8 @@ def test_grdview_with_cmap_for_surface_monochrome_plot(grid):
@pytest.mark.mpl_image_compare
def test_grdview_with_cmap_for_perspective_surface_plot(grid):
"""
Run grdview by passing in a reliefgrid and setting a colormap for producing a
surface plot with a 3D perspective viewpoint.
Run grdview by passing in a reliefgrid and setting a colormap for producing
a surface plot with a 3D perspective viewpoint.
"""
fig = Figure()
fig.grdview(
Expand All @@ -127,8 +129,8 @@ def test_grdview_with_cmap_for_perspective_surface_plot(grid):
@pytest.mark.mpl_image_compare
def test_grdview_on_a_plane(grid):
"""
Run grdview by passing in a reliefgrid and plotting it on a z-plane, while settings
a 3D perspective viewpoint.
Run grdview by passing in a reliefgrid and plotting it on a z-plane, while
setting a 3D perspective viewpoint.
"""
fig = Figure()
fig.grdview(reliefgrid=grid, plane=-4000, perspective=[225, 30], zscale=0.005)
Expand All @@ -138,8 +140,8 @@ def test_grdview_on_a_plane(grid):
@pytest.mark.mpl_image_compare
def test_grdview_on_a_plane_with_colored_frontal_facade(grid):
"""
Run grdview by passing in a reliefgrid and plotting it on a z-plane whose frontal
facade is colored gray, while setting a 3D perspective viewpoint.
Run grdview by passing in a reliefgrid and plotting it on a z-plane whose
frontal facade is colored gray, while setting a 3D perspective viewpoint.
"""
fig = Figure()
fig.grdview(
Expand All @@ -151,8 +153,8 @@ def test_grdview_on_a_plane_with_colored_frontal_facade(grid):
@pytest.mark.mpl_image_compare
def test_grdview_with_perspective_and_zaxis_frame(grid):
"""
Run grdview by passing in a reliefgrid and plotting an annotated vertical z-axis
frame.
Run grdview by passing in a reliefgrid and plotting an annotated vertical
z-axis frame.
"""
fig = Figure()
fig.grdview(reliefgrid=grid, perspective=[225, 30], zscale=0.005, frame="zaf")
Expand All @@ -162,8 +164,8 @@ def test_grdview_with_perspective_and_zaxis_frame(grid):
@pytest.mark.mpl_image_compare
def test_grdview_surface_plot_styled_with_contourpen(grid):
"""
Run grdview by passing in a reliefgrid with styled contour lines plotted on top of a
surface plot.
Run grdview by passing in a reliefgrid with styled contour lines plotted on
top of a surface plot.
"""
fig = Figure()
fig.grdview(
Expand All @@ -175,8 +177,8 @@ def test_grdview_surface_plot_styled_with_contourpen(grid):
@pytest.mark.mpl_image_compare
def test_grdview_surface_mesh_plot_styled_with_meshpen(grid):
"""
Run grdview by passing in a reliefgrid with styled mesh lines plotted on top of a
surface mesh plot.
Run grdview by passing in a reliefgrid with styled mesh lines plotted on
top of a surface mesh plot.
"""
fig = Figure()
fig.grdview(
Expand All @@ -188,8 +190,8 @@ def test_grdview_surface_mesh_plot_styled_with_meshpen(grid):
@pytest.mark.mpl_image_compare
def test_grdview_on_a_plane_styled_with_facadepen(grid):
"""
Run grdview by passing in a reliefgrid and plotting it on a z-plane with styled
lines for the frontal facade.
Run grdview by passing in a reliefgrid and plotting it on a z-plane with
styled lines for the frontal facade.
"""
fig = Figure()
fig.grdview(
Expand All @@ -205,8 +207,8 @@ def test_grdview_on_a_plane_styled_with_facadepen(grid):
@pytest.mark.mpl_image_compare
def test_grdview_drapegrid_dataarray(grid):
"""
Run grdview by passing in both a reliefgrid and drapegrid as an xarray.DataArray,
setting a colormap for producing an image plot.
Run grdview by passing in both a reliefgrid and drapegrid as an
xarray.DataArray, setting a colormap for producing an image plot.
"""
drapegrid = 1.1 * grid

Expand Down

0 comments on commit 28c09db

Please sign in to comment.