Skip to content

Commit 855f6fa

Browse files
yvonnefroehlichweiji14michaelgrund
authored
pygmt.grdfilter: Improve documentation (#2617)
Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Michael Grund <[email protected]>
1 parent f94ddd6 commit 855f6fa

File tree

1 file changed

+39
-42
lines changed

1 file changed

+39
-42
lines changed

pygmt/src/grdfilter.py

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,17 @@
2525
V="verbose",
2626
f="coltypes",
2727
r="registration",
28+
x="cores",
2829
)
2930
@kwargs_to_strings(I="sequence", R="sequence")
3031
def grdfilter(grid, **kwargs):
3132
r"""
3233
Filter a grid in the space (or time) domain.
3334
34-
Filter a grid file in the time domain using one of the selected convolution
35-
or non-convolution isotropic or rectangular filters and compute distances
36-
using Cartesian or Spherical geometries. The output grid file can
37-
optionally be generated as a sub-region of the input (via ``region``)
35+
Filter a grid file in the space (or time) domain using one of the selected
36+
convolution or non-convolution isotropic or rectangular filters and compute
37+
distances using Cartesian or Spherical geometries. The output grid file
38+
can optionally be generated as a sub-region of the input (via ``region``)
3839
and/or with new increment (via ``spacing``) or registration
3940
(via ``toggle``). In this way, one may have "extra space" in the input
4041
data so that the edges will not be used and the output can be within one
@@ -48,67 +49,63 @@ def grdfilter(grid, **kwargs):
4849
Parameters
4950
----------
5051
grid : str or xarray.DataArray
51-
The file name of the input grid or the grid loaded as a DataArray.
52+
The file name of the input grid or the grid loaded as a
53+
:class:`xarray.DataArray`.
5254
outgrid : str or None
5355
The name of the output netCDF file with extension .nc to store the grid
5456
in.
5557
filter : str
56-
**b**\|\ **c**\|\ **g**\|\ **o**\|\ **m**\|\ **p**\|\ **h**\ *xwidth*\
58+
**b**\|\ **c**\|\ **g**\|\ **o**\|\ **m**\|\ **p**\|\ **h**\ *width*\
5759
[/*width2*\][*modifiers*].
58-
Name of filter type you which to apply, followed by the width:
60+
Name of the filter type you wish to apply, followed by the *width*:
5961
60-
b: Box Car
62+
- **b** - Box Car
63+
- **c** - Cosine Arch
64+
- **g** - Gaussian
65+
- **o** - Operator
66+
- **m** - Median
67+
- **p** - Maximum Likelihood probability
68+
- **h** - Histogram
6169
62-
c: Cosine Arch
63-
64-
g: Gaussian
65-
66-
o: Operator
67-
68-
m: Median
69-
70-
p: Maximum Likelihood probability
71-
72-
h: histogram
7370
distance : str
74-
Distance *flag* tells how grid (x,y) relates to filter width as
75-
follows:
71+
State how the grid (x,y) relates to the filter *width*:
7672
77-
p: grid (px,py) with *width* an odd number of pixels; Cartesian
78-
distances.
79-
80-
0: grid (x,y) same units as *width*, Cartesian distances.
81-
82-
1: grid (x,y) in degrees, *width* in kilometers, Cartesian distances.
83-
84-
2: grid (x,y) in degrees, *width* in km, dx scaled by cos(middle y),
85-
Cartesian distances.
73+
- ``"p"``: grid (px,py) with *width* an odd number of pixels,
74+
Cartesian distances.
75+
- ``"0"``: grid (x,y) same units as *width*, Cartesian distances.
76+
- ``"1"``: grid (x,y) in degrees, *width* in kilometers, Cartesian
77+
distances.
78+
- ``"2"``: grid (x,y) in degrees, *width* in km, dx scaled by
79+
cos(middle y), Cartesian distances.
8680
8781
The above options are fastest because they allow weight matrix to be
8882
computed only once. The next three options are slower because they
8983
recompute weights for each latitude.
9084
91-
3: grid (x,y) in degrees, *width* in km, dx scaled by cosine(y),
92-
Cartesian distance calculation.
93-
94-
4: grid (x,y) in degrees, *width* in km, Spherical distance
95-
calculation.
96-
97-
5: grid (x,y) in Mercator ``projection="m1"`` img units, *width* in km,
98-
Spherical distance calculation.
85+
- ``"3"``: grid (x,y) in degrees, *width* in km, dx scaled by cos(y),
86+
Cartesian distance calculation.
87+
- ``"4"``: grid (x,y) in degrees, *width* in km, Spherical distance
88+
calculation.
89+
- ``"5"``: grid (x,y) in Mercator ``projection="m1"`` img units,
90+
*width* in km, Spherical distance calculation.
9991
10092
{spacing}
10193
nans : str or float
10294
**i**\|\ **p**\|\ **r**.
103-
Determine how NaN-values in the input grid affects the filtered output.
95+
Determine how NaN-values in the input grid affect the filtered output.
96+
Use **i** to ignore all NaNs in the calculation of the filtered value
97+
[Default]. **r** is same as **i** except if the input node was NaN then
98+
the output node will be set to NaN (only applies if both grids are
99+
co-registered). **p** will force the filtered value to be NaN if any
100+
grid nodes with NaN-values are found inside the filter circle.
104101
{region}
105102
toggle : bool
106-
Toggle the node registration for the output grid so as to become the
107-
opposite of the input grid. [Default gives the same registration as the
108-
input grid].
103+
Toggle the node registration for the output grid to get the opposite of
104+
the input grid [Default gives the same registration as the input grid].
109105
{verbose}
110106
{coltypes}
111107
{registration}
108+
{cores}
112109
113110
Returns
114111
-------

0 commit comments

Comments
 (0)