Skip to content

Commit 623fe21

Browse files
willschlitzerseismanMeghan Jonesweiji14
authored
Update grdfill parameters for GMT 6.2.0 (#1283)
Add an additional `verbose` (-V) parameter to the `grdfill` module, include the new mode='s' option, and set 'mode' and 'L' as required parameters. * fix top docstring * make A/L required arguments * add s option in docs for mode in grdfill Co-authored-by: Dongdong Tian <[email protected]> Co-authored-by: Meghan Jones <[email protected]> Co-authored-by: Wei Ji <[email protected]>
1 parent e3510ad commit 623fe21

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pygmt/src/grdfill.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import xarray as xr
66
from pygmt.clib import Session
7+
from pygmt.exceptions import GMTInvalidInput
78
from pygmt.helpers import (
89
GMTTempFile,
910
build_arg_string,
@@ -18,6 +19,7 @@
1819
A="mode",
1920
G="outgrid",
2021
R="region",
22+
V="verbose",
2123
)
2224
@kwargs_to_strings(R="sequence")
2325
def grdfill(grid, **kwargs):
@@ -45,8 +47,12 @@ def grdfill(grid, **kwargs):
4547
constant fill and append the constant value, **n** for nearest
4648
neighbor (and optionally append a search radius in
4749
pixels [default radius is :math:`r^2 = \sqrt{{ X^2 + Y^2 }}`,
48-
where (*X,Y*) are the node dimensions of the grid]).
50+
where (*X,Y*) are the node dimensions of the grid]), or
51+
**s** for bicubic spline (optionally append a *tension*
52+
parameter [Default is no tension]).
53+
4954
{R}
55+
{V}
5056
5157
Returns
5258
-------
@@ -57,6 +63,8 @@ def grdfill(grid, **kwargs):
5763
- None if ``outgrid`` is set (grid output will be stored in file set by
5864
``outgrid``)
5965
"""
66+
if "A" not in kwargs.keys() and "L" not in kwargs.keys():
67+
raise GMTInvalidInput("At least parameter 'mode' or 'L' must be specified.")
6068
with GMTTempFile(suffix=".nc") as tmpfile:
6169
with Session() as lib:
6270
file_context = lib.virtualfile_from_data(check_kind="raster", data=grid)

pygmt/tests/test_grdfill.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Tests for grdclip.
2+
Tests for grdfill.
33
"""
44
import os
55

@@ -8,6 +8,7 @@
88
import xarray as xr
99
from pygmt import grdfill, grdinfo
1010
from pygmt.datasets import load_earth_relief
11+
from pygmt.exceptions import GMTInvalidInput
1112
from pygmt.helpers import GMTTempFile
1213

1314

@@ -47,3 +48,11 @@ def test_grdfill_file_out(grid):
4748
assert os.path.exists(path=tmpfile.name) # check that outgrid exists
4849
result = grdinfo(tmpfile.name, per_column=True).strip()
4950
assert result == "-5 5 -5 5 -5130.5 inf 1 1 10 10 1 1"
51+
52+
53+
def test_grdfill_required_args(grid):
54+
"""
55+
Test that grdfill fails without arguments for `mode` and `L`.
56+
"""
57+
with pytest.raises(GMTInvalidInput):
58+
grdfill(grid=grid)

0 commit comments

Comments
 (0)