Skip to content

Commit b1f5cc7

Browse files
Figure.grdcontour: Deprecate parameter "interval" to "levels" (FutureWarning since v0.12.0, will be removed in v0.16.0) (#3209)
1 parent d58720a commit b1f5cc7

File tree

4 files changed

+22
-26
lines changed

4 files changed

+22
-26
lines changed

examples/get_started/02_contour_map.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
# :meth:`pygmt.Figure.grdcontour` method is used. The ``frame`` and
8383
# ``projection`` are already set using :meth:`pygmt.Figure.grdimage` and are
8484
# not needed again. However, the same input for ``grid`` (in this case, the
85-
# variable named "grid") must be input again. The ``interval`` parameter sets
85+
# variable named "grid") must be input again. The ``levels`` parameter sets
8686
# the spacing between adjacent contour lines (in this case, 500 meters). The
8787
# ``annotation`` parameter annotates the contour lines corresponding to the
8888
# given interval (in this case, 1,000 meters) with the related values, here
@@ -93,7 +93,7 @@
9393

9494
fig = pygmt.Figure()
9595
fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron")
96-
fig.grdcontour(grid=grid, interval=500, annotation=1000)
96+
fig.grdcontour(grid=grid, levels=500, annotation=1000)
9797
fig.colorbar(frame=["a1000", "x+lElevation", "y+lm"])
9898
fig.show()
9999

@@ -109,7 +109,7 @@
109109

110110
fig = pygmt.Figure()
111111
fig.grdimage(grid=grid, frame="a", projection="M10c", cmap="oleron")
112-
fig.grdcontour(grid=grid, interval=500, annotation=1000)
112+
fig.grdcontour(grid=grid, levels=500, annotation=1000)
113113
fig.coast(shorelines="2p", land="lightgray")
114114
fig.colorbar(frame=["a1000", "x+lElevation", "y+lm"])
115115
fig.show()

examples/tutorials/advanced/contour_map.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,12 @@
3333
# Contour line settings
3434
# ---------------------
3535
#
36-
# Use the ``annotation`` and ``interval`` parameters to adjust contour line
36+
# Use the ``annotation`` and ``levels`` parameters to adjust contour line
3737
# intervals. In the example below, there are contour intervals every 250 meters
3838
# and annotated contour lines every 1,000 meters.
3939

4040
fig = pygmt.Figure()
41-
fig.grdcontour(
42-
annotation=1000,
43-
interval=250,
44-
grid=grid,
45-
)
41+
fig.grdcontour(annotation=1000, levels=250, grid=grid)
4642
fig.show()
4743

4844

@@ -57,7 +53,7 @@
5753
fig = pygmt.Figure()
5854
fig.grdcontour(
5955
annotation=1000,
60-
interval=250,
56+
levels=250,
6157
grid=grid,
6258
limit=[-4000, -2000],
6359
)
@@ -74,7 +70,7 @@
7470
fig = pygmt.Figure()
7571
fig.grdcontour(
7672
annotation=1000,
77-
interval=250,
73+
levels=250,
7874
grid=grid,
7975
limit=[-4000, -2000],
8076
projection="M10c",
@@ -104,7 +100,7 @@
104100
)
105101
fig.grdcontour(
106102
annotation=1000,
107-
interval=250,
103+
levels=250,
108104
grid=grid,
109105
limit=[-4000, -2000],
110106
)

pygmt/src/grdcontour.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pygmt.clib import Session
88
from pygmt.helpers import (
99
build_arg_list,
10+
deprecate_parameter,
1011
fmt_docstring,
1112
is_nonstr_iter,
1213
kwargs_to_strings,
@@ -17,10 +18,11 @@
1718

1819

1920
@fmt_docstring
21+
@deprecate_parameter("interval", "levels", "v0.12.0", remove_version="v0.16.0")
2022
@use_alias(
2123
A="annotation",
2224
B="frame",
23-
C="interval",
25+
C="levels",
2426
G="label_placement",
2527
J="projection",
2628
L="limit",
@@ -49,7 +51,7 @@ def grdcontour(self, grid, **kwargs):
4951
Parameters
5052
----------
5153
{grid}
52-
interval : float, list, or str
54+
levels : float, list, or str
5355
Specify the contour lines to generate.
5456
5557
- The file name of a CPT file where the color boundaries will be used as
@@ -60,7 +62,7 @@ def grdcontour(self, grid, **kwargs):
6062
- A list of contour levels.
6163
annotation : float, list, or str
6264
Specify or disable annotated contour levels, modifies annotated
63-
contours specified in ``interval``.
65+
contours specified in ``levels``.
6466
6567
- Specify a fixed annotation interval.
6668
- Specify a list of annotation levels.
@@ -116,7 +118,7 @@ def grdcontour(self, grid, **kwargs):
116118
... # Pass in the grid downloaded above
117119
... grid=grid,
118120
... # Set the interval for contour lines at 250 meters
119-
... interval=250,
121+
... levels=250,
120122
... # Set the interval for annotated contour lines at 1,000 meters
121123
... annotation=1000,
122124
... # Add a frame for the plot
@@ -143,7 +145,7 @@ def grdcontour(self, grid, **kwargs):
143145
warnings.warn(msg, category=FutureWarning, stacklevel=2)
144146
kwargs["A"] = "+".join(f"{item}" for item in kwargs["A"])
145147

146-
# Specify levels for the annotation and interval parameters.
148+
# Specify levels for the annotation and levels parameters.
147149
# One level is converted to a string with a trailing comma to separate it from
148150
# specifying an interval.
149151
# Multiple levels are concatenated to a comma-separated string.

pygmt/tests/test_grdcontour.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def test_grdcontour(grid):
2828
annotation intervals.
2929
"""
3030
fig = Figure()
31-
fig.grdcontour(
32-
grid=grid, interval=50, annotation=200, projection="M10c", frame=True
33-
)
31+
fig.grdcontour(grid=grid, levels=50, annotation=200, projection="M10c", frame=True)
3432
return fig
3533

3634

@@ -42,7 +40,7 @@ def test_grdcontour_one_level(grid):
4240
"""
4341
fig = Figure()
4442
fig.grdcontour(
45-
grid=grid, interval=[400], annotation=[570], projection="M10c", frame=True
43+
grid=grid, levels=[400], annotation=[570], projection="M10c", frame=True
4644
)
4745
return fig
4846

@@ -56,7 +54,7 @@ def test_grdcontour_old_annotations(grid):
5654
fig = Figure()
5755
fig.grdcontour(
5856
grid=grid,
59-
interval=[400],
57+
levels=[400],
6058
annotation=["570,", "gwhite"],
6159
projection="M10c",
6260
frame=True,
@@ -73,7 +71,7 @@ def test_grdcontour_multiple_levels(grid):
7371
fig = Figure()
7472
fig.grdcontour(
7573
grid=grid,
76-
interval=[400, 450, 500],
74+
levels=[400, 450, 500],
7775
annotation=[400, 570],
7876
projection="M10c",
7977
frame=True,
@@ -90,7 +88,7 @@ def test_grdcontour_labels(grid):
9088
fig = Figure()
9189
fig.grdcontour(
9290
grid=grid,
93-
interval=50,
91+
levels=50,
9492
annotation=200,
9593
projection="M10c",
9694
pen=["a1p,red", "c0.5p,black"],
@@ -108,7 +106,7 @@ def test_grdcontour_slice(grid):
108106
grid_ = grid.sel(lat=slice(-20, -10))
109107

110108
fig = Figure()
111-
fig.grdcontour(grid=grid_, interval=100, projection="M10c", frame=True)
109+
fig.grdcontour(grid=grid_, levels=100, projection="M10c", frame=True)
112110
return fig
113111

114112

@@ -121,7 +119,7 @@ def test_grdcontour_interval_file_full_opts(grid):
121119

122120
comargs = {
123121
"region": [-53, -49, -20, -17],
124-
"interval": TEST_CONTOUR_FILE,
122+
"levels": TEST_CONTOUR_FILE,
125123
"grid": grid,
126124
"resample": 100,
127125
"projection": "M10c",

0 commit comments

Comments
 (0)