Skip to content

Commit 529eed7

Browse files
willschlitzerMeghan Jonesseisman
authored
Update the docstrings in the non-plotting modules (#882)
* Update docstrings for makecpt.py * Update docstrings for savefig in figure.py * Update docstrings for psconvert in figure.py * Update docstrings in blockmedian.py * Update docstrings in surface.py * Update docstrings in grdcut.py * Update docstrings in grdfilter.py * Update docstrings in x2sys.py * Update docstrings for x2sys_cross in x2sys.py * Update docstrings for info.py * Update output docstring in info.py * Update formatting in makecpt.py Co-authored-by: Meghan Jones <[email protected]> Co-authored-by: Dongdong Tian <[email protected]>
1 parent a2628e6 commit 529eed7

File tree

8 files changed

+108
-85
lines changed

8 files changed

+108
-85
lines changed

pygmt/figure.py

+21-18
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def region(self):
115115
)
116116
@kwargs_to_strings()
117117
def psconvert(self, **kwargs):
118-
"""
118+
r"""
119119
Convert [E]PS file(s) to other formats.
120120
121121
Converts one or more PostScript files to other formats (BMP, EPS, JPEG,
@@ -149,20 +149,22 @@ def psconvert(self, **kwargs):
149149
icc_gray : bool
150150
Enforce gray-shades by using ICC profiles.
151151
anti_aliasing : str
152-
Set the anti-aliasing options for graphics or text. Append the size
153-
of the subsample box (1, 2, or 4) [4]. Default is no anti-aliasing
154-
(same as bits = 1).
152+
[**g**\|\ **p**\|\ **t**\][**1**\|\ **2**\|\ **4**].
153+
Set the anti-aliasing options for **g**\ raphics or **t**\ ext.
154+
Append the size of the subsample box (1, 2, or 4) [4]. [Default is
155+
no anti-aliasing (same as bits = 1)].
155156
fmt : str
156-
Sets the output format, where *b* means BMP, *e* means EPS, *E*
157-
means EPS with PageSize command, *f* means PDF, *F* means
158-
multi-page PDF, *j* means JPEG, *g* means PNG, *G* means
159-
transparent PNG (untouched regions are transparent), *m* means PPM,
160-
*s* means SVG, and *t* means TIFF [default is JPEG]. To ``'bjgt'``
161-
you can append ``'+m'`` in order to get a monochrome (grayscale)
162-
image. The EPS format can be combined with any of the other
163-
formats. For example, ``'ef'`` creates both an EPS and a PDF file.
164-
Using ``'F'`` creates a multi-page PDF file from the list of input
165-
PS or PDF files. It requires the *prefix* option.
157+
Sets the output format, where **b** means BMP, **e** means EPS,
158+
**E** means EPS with PageSize command, **f** means PDF, **F** means
159+
multi-page PDF, **j** means JPEG, **g** means PNG, **G** means
160+
transparent PNG (untouched regions are transparent), **m** means
161+
PPM, **s** means SVG, and **t** means TIFF [default is JPEG]. To
162+
**b**\|\ **j**\|\ **g**\|\ **t**\ , optionally append **+m** in
163+
order to get a monochrome (grayscale) image. The EPS format can be
164+
combined with any of the other formats. For example, **ef** creates
165+
both an EPS and a PDF file. Using **F** creates a multi-page PDF
166+
file from the list of input PS or PDF files. It requires the
167+
``prefix`` parameter.
166168
"""
167169
kwargs = self._preprocess(**kwargs)
168170
# Default cropping the figure to True
@@ -178,7 +180,7 @@ def savefig(
178180
Save the figure to a file.
179181
180182
This method implements a matplotlib-like interface for
181-
:meth:`~gmt.Figure.psconvert`.
183+
:meth:`pygmt.Figure.psconvert`.
182184
183185
Supported formats: PNG (``.png``), JPEG (``.jpg``), PDF (``.pdf``),
184186
BMP (``.bmp``), TIFF (``.tif``), EPS (``.eps``), and KML (``.kml``).
@@ -199,9 +201,10 @@ def savefig(
199201
If True, will crop the figure canvas (page) to the plot area.
200202
anti_alias: bool
201203
If True, will use anti aliasing when creating raster images (PNG,
202-
JPG, TIf). More specifically, uses options ``Qt=2, Qg=2`` in
203-
:meth:`~gmt.Figure.psconvert`. Ignored if creating vector graphics.
204-
Overrides values of ``Qt`` and ``Qg`` passed in through ``kwargs``.
204+
JPG, TIFF). More specifically, it passes arguments ``t2``
205+
and ``g2`` to the ``anti_aliasing`` parameter of
206+
:meth:`pygmt.Figure.psconvert`. Ignored if creating vector
207+
graphics.
205208
show: bool
206209
If True, will open the figure in an external viewer.
207210
dpi : int

pygmt/src/blockmedian.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@use_alias(I="spacing", R="region", V="verbose")
2020
@kwargs_to_strings(R="sequence")
2121
def blockmedian(table, outfile=None, **kwargs):
22-
"""
22+
r"""
2323
Block average (x,y,z) data tables by median estimation.
2424
2525
Reads arbitrarily located (x,y,z) triples [or optionally weighted
@@ -39,15 +39,17 @@ def blockmedian(table, outfile=None, **kwargs):
3939
ASCII data table.
4040
4141
spacing : str
42-
``'xinc[unit][+e|n][/yinc[unit][+e|n]]'``.
43-
x_inc [and optionally y_inc] is the grid spacing.
42+
*xinc*\[\ *unit*\][**+e**\|\ **n**]
43+
[/*yinc*\ [*unit*][**+e**\|\ **n**]].
44+
*xinc* [and optionally *yinc*] is the grid spacing.
4445
4546
region : str or list
46-
``'xmin/xmax/ymin/ymax[+r][+uunit]'``.
47+
*xmin/xmax/ymin/ymax*\[\ **+r**\][**+u**\ *unit*].
4748
Specify the region of interest.
4849
4950
outfile : str
50-
Required if 'table' is a file. The file name for the output ASCII file.
51+
Required if ``table`` is a file. The file name for the output ASCII
52+
file.
5153
5254
{V}
5355

pygmt/src/grdcut.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
)
2929
@kwargs_to_strings(R="sequence")
3030
def grdcut(grid, **kwargs):
31-
"""
31+
r"""
3232
Extract subregion from a grid.
3333
34-
Produce a new *outgrid* file which is a subregion of *grid*. The
34+
Produce a new ``outgrid`` file which is a subregion of ``grid``. The
3535
subregion is specified with *region*; the specified range must not exceed
3636
the range of *grid* (but see *extend*). If in doubt, run
3737
:meth:`pygmt.grdinfo` to check range. Alternatively, define the subregion
@@ -54,16 +54,16 @@ def grdcut(grid, **kwargs):
5454
{J}
5555
{R}
5656
extend : bool or int or float
57-
Allow grid to be extended if new *region* exceeds existing boundaries.
58-
Give a value to initialize nodes outside current region.
57+
Allow grid to be extended if new ``region`` exceeds existing
58+
boundaries. Give a value to initialize nodes outside current region.
5959
circ_subregion : str
60-
``'lon/lat/radius[unit][+n]'``.
60+
*lon/lat/radius*\[\ *unit*\][**+n**].
6161
Specify an origin (*lon* and *lat*) and *radius*; append a distance
6262
*unit* and we determine the corresponding rectangular region so that
6363
all grid nodes on or inside the circle are contained in the subset.
6464
If **+n** is appended we set all nodes outside the circle to NaN.
6565
z_subregion : str
66-
``'[min/max][+n|N|r]'``.
66+
[*min/max*\][**+n**\|\ **N**\|\ **r**].
6767
Determine a new rectangular region so that all nodes outside this
6868
region are also outside the given z-range [-inf/+inf]. To indicate no
6969
limit on *min* or *max* only, specify a hyphen (-). Normally, any NaNs

pygmt/src/grdfilter.py

+28-15
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@
2929
)
3030
@kwargs_to_strings(R="sequence")
3131
def grdfilter(grid, **kwargs):
32-
"""
32+
r"""
3333
Filter a grid in the space (or time) domain.
3434
3535
Filter a grid file in the time domain using one of the selected convolution
3636
or non-convolution isotropic or rectangular filters and compute distances
3737
using Cartesian or Spherical geometries. The output grid file can
38-
optionally be generated as a sub-region of the input (via *region*) and/or
39-
with new increment (via *spacing*) or registration (via *toggle*). In this
40-
way, one may have "extra space" in the input data so that the edges will
41-
not be used and the output can be within one half-width of the input edges.
42-
If the filter is low-pass, then the output may be less frequently sampled
43-
than the input.
38+
optionally be generated as a sub-region of the input (via ``region``)
39+
and/or with new increment (via ``spacing``) or registration
40+
(via ``toggle``). In this way, one may have "extra space" in the input
41+
data so that the edges will not be used and the output can be within one
42+
half-width of the input edges. If the filter is low-pass, then the output
43+
may be less frequently sampled than the input.
4444
4545
Full option list at :gmt-docs:`grdfilter.html`
4646
@@ -54,11 +54,23 @@ def grdfilter(grid, **kwargs):
5454
The name of the output netCDF file with extension .nc to store the grid
5555
in.
5656
filter : str
57-
``xwidth[/width2][modifiers]``.
58-
Name of filter type you which to apply, followed by the width
59-
b: Box Car; c: Cosine Arch; g: Gaussian; o: Operator; m: Median;
60-
p: Maximum Likelihood probability; h: histogram
61-
Example: F='m600' for a median filter with width of 600
57+
**b**\|\ **c**\|\ **g**\|\ **o**\|\ **m**\|\ **p**\|\ **h**\ *xwidth*\
58+
[/*width2*\][*modifiers*].
59+
Name of filter type you which to apply, followed by the width:
60+
61+
b: Box Car
62+
63+
c: Cosine Arch
64+
65+
g: Gaussian
66+
67+
o: Operator
68+
69+
m: Median
70+
71+
p: Maximum Likelihood probability
72+
73+
h: histogram
6274
distance : str
6375
Distance *flag* tells how grid (x,y) relates to filter width as
6476
follows:
@@ -87,10 +99,11 @@ def grdfilter(grid, **kwargs):
8799
Spherical distance calculation.
88100
89101
spacing : str
90-
``xinc[+e|n][/yinc[+e|n]]``.
91-
x_inc [and optionally y_inc] is the grid spacing.
102+
*xinc*\[\ *unit*\][**+e**\|\ **n**]
103+
[/*yinc*\ [*unit*][**+e**\|\ **n**]].
104+
*xinc* [and optionally *yinc*] is the grid spacing.
92105
nans : str or float
93-
``i|p|r``.
106+
**i**\|\ **p**\|\ **r**.
94107
Determine how NaN-values in the input grid affects the filtered output.
95108
{R}
96109
toggle : bool

pygmt/src/info.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,21 @@
1717
@fmt_docstring
1818
@use_alias(C="per_column", I="spacing", T="nearest_multiple", V="verbose")
1919
def info(table, **kwargs):
20-
"""
20+
r"""
2121
Get information about data tables.
2222
2323
Reads from files and finds the extreme values in each of the columns
2424
reported as min/max pairs. It recognizes NaNs and will print warnings if
2525
the number of columns vary from record to record. As an option, it will
2626
find the extent of the first two columns rounded up and down to the nearest
27-
multiple of the supplied increments given by *spacing*. Such output will be
28-
in a numpy.ndarray form ``[w, e, s, n]``, which can be used directly as the
29-
*region* argument for other modules (hence only dx and dy are needed). If
30-
the *per_column* option is combined with *spacing*, then the numpy.ndarray
31-
output will be rounded up/down for as many columns as there are increments
32-
provided in *spacing*. A similar option *nearest_multiple* option will
33-
provide a numpy.ndarray in the form of ``[zmin, zmax, dz]`` for makecpt.
27+
multiple of the supplied increments given by ``spacing``. Such output will
28+
be in a numpy.ndarray form [*w*, *e*, *s*, *n*], which can be used
29+
directly as the ``region`` parameter for other modules (hence only *dx*
30+
and *dy* are needed). If the ``per_column`` parameter is combined with
31+
``spacing``, then the numpy.ndarray output will be rounded up/down for as
32+
many columns as there are increments provided in ``spacing``. A similar
33+
parameter ``nearest_multiple`` option will provide a numpy.ndarray in the
34+
form of [*zmin*, *zmax*, *dz*]`` for makecpt.
3435
3536
Full option list at :gmt-docs:`gmtinfo.html`
3637
@@ -45,12 +46,12 @@ def info(table, **kwargs):
4546
per_column : bool
4647
Report the min/max values per column in separate columns.
4748
spacing : str
48-
``'[b|p|f|s]dx[/dy[/dz...]]'``.
49+
[**b**\|\ **p**\|\ **f**\|\ **s**]\ *dx*\[/*dy*\[/*dz*...]].
4950
Report the min/max of the first n columns to the nearest multiple of
5051
the provided increments and output results in the form
5152
``[w, e, s, n]``.
5253
nearest_multiple : str
53-
``'dz[+ccol]'``
54+
**dz**\[\ **+c**\ *col*].
5455
Report the min/max of the first (0'th) column to the nearest multiple
5556
of dz and output this in the form ``[zmin, zmax, dz]``.
5657
@@ -59,8 +60,8 @@ def info(table, **kwargs):
5960
Returns
6061
-------
6162
output : np.ndarray or str
62-
Return type depends on whether any of the 'per_column', 'spacing', or
63-
'nearest_multiple' parameters are set.
63+
Return type depends on whether any of the ``per_column``,
64+
``spacing``, or ``nearest_multiple`` parameters are set.
6465
6566
- np.ndarray if either of the above parameters are used.
6667
- str if none of the above parameters are used.

pygmt/src/makecpt.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
)
2727
@kwargs_to_strings(T="sequence", G="sequence")
2828
def makecpt(**kwargs):
29-
"""
29+
r"""
3030
Make GMT color palette tables.
3131
3232
This is a module that will help you make static color palette tables
3333
(CPTs). By default, the CPT will simply be saved to the current session,
34-
but you can use *output* to save it to a file. You define an equidistant
34+
but you can use ``output`` to save it to a file. You define an equidistant
3535
set of contour intervals or pass your own z-table or list, and create a new
3636
CPT based on an existing master (dynamic) CPT. The resulting CPT can be
3737
reversed relative to the master cpt, and can be made continuous or
@@ -49,8 +49,8 @@ def makecpt(**kwargs):
4949
the new master file. If not, the parameters :gmt-term:`COLOR_BACKGROUND`,
5050
:gmt-term:`COLOR_FOREGROUND`, and :gmt-term:`COLOR_NAN` from the
5151
:gmt-docs:`gmt.conf <gmt.conf>` file or the command line will be used. This
52-
default behavior can be overruled using the options *background*,
53-
*overrule_bg* or *no_bg*.
52+
default behavior can be overruled using the parameters ``background``,
53+
``overrule_bg`` or ``no_bg``.
5454
5555
The color model (RGB, HSV or CMYK) of the palette created by **makecpt**
5656
will be the same as specified in the header of the master CPT. When there
@@ -81,7 +81,7 @@ def makecpt(**kwargs):
8181
``background='i'`` to match the colors for the lowest and highest
8282
values in the input (instead of the output) CPT.
8383
color_model :
84-
``[R|r|h|c][+c[label]]``.
84+
[**R**\|\ **r**\|\ **h**\|\ **c**][**+c**\ [*label*]].
8585
Force output CPT to be written with r/g/b codes, gray-scale values or
8686
color name (**R**, default) or r/g/b codes only (**r**), or h-s-v codes
8787
(**h**), or c/m/y/k codes (**c**). Optionally or alternatively, append
@@ -93,7 +93,7 @@ def makecpt(**kwargs):
9393
labels from *start* (a single letter or an integer). Append - to build
9494
ranges *start*-*start+1* instead.
9595
series : list or str
96-
``[min/max/inc[+b|l|n]|file|list]``.
96+
[*min/max/inc*\[**+b**\|\ **l**\|\ **n**]\|\ *file*\|\ *list*].
9797
Defines the range of the new CPT by giving the lowest and highest
9898
z-value (and optionally an interval). If this is not given, the
9999
existing range in the master CPT will be used intact. The values
@@ -102,21 +102,22 @@ def makecpt(**kwargs):
102102
For details on array creation, see
103103
:gmt-docs:`makecpt.html#generate-1d-array`.
104104
truncate : list or str
105-
``zlo/zhi``.
105+
*zlow/zhigh*.
106106
Truncate the incoming CPT so that the lowest and highest z-levels are
107-
to *zlo* and *zhi*. If one of these equal NaN then we leave that end of
108-
the CPT alone. The truncation takes place before any resampling. See
107+
to *zlow* and *zhigh*. If one of these equal NaN then we leave that
108+
end of the CPT alone. The truncation takes place before any
109+
resampling. See
109110
also :gmt-docs:`cookbook/features.html#manipulating-cpts`.
110111
output : str
111112
Optional. The file name with extension .cpt to store the generated CPT
112113
file. If not given or False (default), saves the CPT as the session
113114
current CPT.
114115
reverse : str
115-
Set this to True or c [Default] to reverse the sense of color
116+
Set this to True or **c**\ [Default] to reverse the sense of color
116117
progression in the master CPT. Set this to z to reverse the sign of
117118
z-values in the color table. Note that this change of z-direction
118-
happens before *truncate* and *series* values are used so the latter
119-
must be compatible with the changed *z*-range. See also
119+
happens before ``truncate`` and ``series`` values are used so the
120+
latter must be compatible with the changed *z*-range. See also
120121
:gmt-docs:`cookbook/features.html#manipulating-cpts`.
121122
overrule_bg : str
122123
Overrule background, foreground, and NaN colors specified in the master

pygmt/src/surface.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
@use_alias(I="spacing", R="region", G="outfile", V="verbose")
2121
@kwargs_to_strings(R="sequence")
2222
def surface(x=None, y=None, z=None, data=None, **kwargs):
23-
"""
23+
r"""
2424
Grids table data using adjustable tension continuous curvature splines.
2525
2626
Surface reads randomly-spaced (x,y,z) triples and produces gridded values
@@ -47,11 +47,12 @@ def surface(x=None, y=None, z=None, data=None, **kwargs):
4747
Either a data file name or a 2d numpy array with the tabular data.
4848
4949
spacing : str
50-
``'xinc[unit][+e|n][/yinc[unit][+e|n]]'``.
51-
x_inc [and optionally y_inc] is the grid spacing.
50+
*xinc*\[\ *unit*\][**+e**\|\ **n**]\
51+
[/*yinc*\ [*unit*][**+e**\|\ **n**]].
52+
*xinc* [and optionally *yinc*] is the grid spacing.
5253
5354
region : str or list
54-
``'xmin/xmax/ymin/ymax[+r][+uunit]'``.
55+
*xmin/xmax/ymin/ymax*\[**+r**][**+u**\ *unit*].
5556
Specify the region of interest.
5657
5758
outfile : str

0 commit comments

Comments
 (0)