From 28c09db2a993bead7fd3ea206f14969d5eaa1db7 Mon Sep 17 00:00:00 2001 From: Wei Ji Date: Fri, 6 Dec 2019 15:41:43 +1300 Subject: [PATCH] Tidy up grdview docstrings Wrap grdview docstrings to 79 characters as per #384 and make alias formatting nicer after #383. --- pygmt/base_plotting.py | 72 +++++++++++++++++++------------------ pygmt/tests/test_grdview.py | 60 ++++++++++++++++--------------- 2 files changed, 69 insertions(+), 63 deletions(-) diff --git a/pygmt/base_plotting.py b/pygmt/base_plotting.py index 9b231082a61..a47bfb41e55 100644 --- a/pygmt/base_plotting.py +++ b/pygmt/base_plotting.py @@ -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. diff --git a/pygmt/tests/test_grdview.py b/pygmt/tests/test_grdview.py index de408412880..9105b6a3b11 100644 --- a/pygmt/tests/test_grdview.py +++ b/pygmt/tests/test_grdview.py @@ -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") @@ -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]) @@ -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) @@ -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") @@ -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") @@ -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") @@ -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( @@ -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) @@ -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( @@ -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") @@ -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( @@ -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( @@ -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( @@ -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