1818
1919
2020def _validate_params (
21- constantfill = None ,
22- gridfill = None ,
23- neighborfill = None ,
24- splinefill = None ,
21+ constant_fill = None ,
22+ grid_fill = None ,
23+ neighbor_fill = None ,
24+ spline_fill = None ,
2525 inquire = False ,
2626 mode = None ,
2727):
2828 """
2929 Validate the fill/inquire parameters.
3030
31- >>> _validate_params(constantfill =20.0)
31+ >>> _validate_params(constant_fill =20.0)
3232 >>> _validate_params(inquire=True)
3333 >>> _validate_params(mode="c20.0")
34- >>> _validate_params(constantfill =20.0, gridfill ="bggrid.nc")
34+ >>> _validate_params(constant_fill =20.0, grid_fill ="bggrid.nc")
3535 Traceback (most recent call last):
3636 ...
3737 pygmt.exceptions.GMTInvalidInput: Parameters ... are mutually exclusive.
38- >>> _validate_params(constantfill =20.0, inquire=True)
38+ >>> _validate_params(constant_fill =20.0, inquire=True)
3939 Traceback (most recent call last):
4040 ...
4141 pygmt.exceptions.GMTInvalidInput: Parameters ... are mutually exclusive.
@@ -44,7 +44,7 @@ def _validate_params(
4444 ...
4545 pygmt.exceptions.GMTInvalidInput: Need to specify parameter ...
4646 """
47- _fill_params = "'constantfill '/'gridfill '/'neighborfill '/'splinefill '"
47+ _fill_params = "'constant_fill '/'grid_fill '/'neighbor_fill '/'spline_fill '"
4848 # The deprecated 'mode' parameter is given.
4949 if mode is not None :
5050 msg = (
@@ -55,7 +55,14 @@ def _validate_params(
5555
5656 n_given = sum (
5757 param is not None and param is not False
58- for param in [constantfill , gridfill , neighborfill , splinefill , inquire , mode ]
58+ for param in [
59+ constant_fill ,
60+ grid_fill ,
61+ neighbor_fill ,
62+ spline_fill ,
63+ inquire ,
64+ mode ,
65+ ]
5966 )
6067 if n_given > 1 : # More than one mutually exclusive parameter is given.
6168 msg = f"Parameters { _fill_params } /'inquire'/'mode' are mutually exclusive."
@@ -71,15 +78,23 @@ def _validate_params(
7178@fmt_docstring
7279# TODO(PyGMT>=0.19.0): Remove the deprecated 'no_data' parameter.
7380# TODO(PyGMT>=0.19.0): Remove the deprecated 'mode' parameter.
74- @deprecate_parameter ("no_data" , "hole" , "v0.15.0" , remove_version = "v0.19.0" )
81+ @deprecate_parameter ("no_data" , "hole" , "v0.18.0" , remove_version = "v0.20.0" )
82+ @deprecate_parameter (
83+ "constantfill" , "constant_fill" , "v0.15.0" , remove_version = "v0.19.0"
84+ )
85+ @deprecate_parameter ("gridfill" , "grid_fill" , "v0.18.0" , remove_version = "v0.20.0" )
86+ @deprecate_parameter (
87+ "neighborfill" , "neighbor_fill" , "v0.18.0" , remove_version = "v0.20.0"
88+ )
89+ @deprecate_parameter ("splinefill" , "spline_fill" , "v0.18.0" , remove_version = "v0.20.0" )
7590@use_alias (f = "coltypes" )
7691def grdfill ( # noqa: PLR0913
7792 grid : PathLike | xr .DataArray ,
7893 outgrid : PathLike | None = None ,
79- constantfill : float | None = None ,
80- gridfill : PathLike | xr .DataArray | None = None ,
81- neighborfill : float | bool | None = None ,
82- splinefill : float | bool | None = None ,
94+ constant_fill : float | None = None ,
95+ grid_fill : PathLike | xr .DataArray | None = None ,
96+ neighbor_fill : float | bool | None = None ,
97+ spline_fill : float | bool | None = None ,
8398 inquire : bool = False ,
8499 hole : float | None = None ,
85100 mode : str | None = None ,
@@ -100,10 +115,10 @@ def grdfill( # noqa: PLR0913
100115 Full GMT docs at :gmt-docs:`grdfill.html`.
101116
102117 $aliases
103- - Ac = constantfill
104- - Ag = gridfill
105- - An = neighborfill
106- - As = splinefill
118+ - Ac = constant_fill
119+ - Ag = grid_fill
120+ - An = neighbor_fill
121+ - As = spline_fill
107122 - L = inquire
108123 - N = hole
109124 - R = region
@@ -113,17 +128,17 @@ def grdfill( # noqa: PLR0913
113128 ----------
114129 $grid
115130 $outgrid
116- constantfill
131+ constant_fill
117132 Fill the holes with a constant value. Specify the constant value to use.
118- gridfill
133+ grid_fill
119134 Fill the holes with values sampled from another (possibly coarser) grid. Specify
120135 the grid (a file name or an :class:`xarray.DataArray`) to use for the fill.
121- neighborfill
136+ neighbor_fill
122137 Fill the holes with the nearest neighbor. Specify the search radius in pixels.
123138 If set to ``True``, the default search radius will be used
124139 (:math:`r^2 = \sqrt{n^2 + m^2}`, where (*n,m*) are the node dimensions of the
125140 grid).
126- splinefill
141+ spline_fill
127142 Fill the holes with a bicubic spline. Specify the tension value to use. If set
128143 to ``True``, no tension will be used.
129144 hole
@@ -141,8 +156,9 @@ def grdfill( # noqa: PLR0913
141156 (optionally append a *tension* parameter [Default is no tension]).
142157
143158 .. deprecated:: 0.15.0
144- Use ``constantfill ``, ``gridfill ``, ``neighborfill ``, or ``splinefill ``
159+ Use ``constant_fill ``, ``grid_fill ``, ``neighbor_fill ``, or ``spline_fill ``
145160 instead. The parameter will be removed in v0.19.0.
161+
146162 $region
147163 $coltypes
148164 $verbose
@@ -165,7 +181,7 @@ def grdfill( # noqa: PLR0913
165181 >>> # Load a bathymetric grid with missing data
166182 >>> earth_relief_holes = pygmt.datasets.load_sample_data(name="earth_relief_holes")
167183 >>> # Fill the holes with a constant value of 20
168- >>> filled_grid = pygmt.grdfill(grid=earth_relief_holes, constantfill =20)
184+ >>> filled_grid = pygmt.grdfill(grid=earth_relief_holes, constant_fill =20)
169185
170186 Inquire the bounds of each hole.
171187
@@ -174,16 +190,18 @@ def grdfill( # noqa: PLR0913
174190 [6.16666667, 7.83333333, 0.5 , 2.5 ]])
175191 """
176192 # Validate the fill/inquire parameters.
177- _validate_params (constantfill , gridfill , neighborfill , splinefill , inquire , mode )
193+ _validate_params (
194+ constant_fill , grid_fill , neighbor_fill , spline_fill , inquire , mode
195+ )
178196
179197 # _validate_params has already ensured that only one of the parameters is set.
180198 aliasdict = AliasSystem (
181199 A = Alias (mode , name = "mode" ),
182- Ac = Alias (constantfill , name = "constantfill " ),
183- # For grdfill , append the actual or virtual grid file name later.
184- Ag = Alias (gridfill is not None , name = "gridfill " ),
185- An = Alias (neighborfill , name = "neighborfill " ),
186- As = Alias (splinefill , name = "splinefill " ),
200+ Ac = Alias (constant_fill , name = "constant_fill " ),
201+ # For grid_fill , append the actual or virtual grid file name later.
202+ Ag = Alias (grid_fill is not None , name = "grid_fill " ),
203+ An = Alias (neighbor_fill , name = "neighbor_fill " ),
204+ As = Alias (spline_fill , name = "spline_fill " ),
187205 L = Alias (inquire , name = "inquire" ),
188206 N = Alias (hole , name = "hole" ),
189207 ).add_common (
@@ -207,11 +225,11 @@ def grdfill( # noqa: PLR0913
207225 # Fill mode.
208226 with (
209227 lib .virtualfile_in (
210- check_kind = "raster" , data = gridfill , required = False
228+ check_kind = "raster" , data = grid_fill , required = False
211229 ) as vbggrd ,
212230 lib .virtualfile_out (kind = "grid" , fname = outgrid ) as voutgrd ,
213231 ):
214- if gridfill is not None :
232+ if grid_fill is not None :
215233 # Fill by a grid. Append the actual or virtual grid file name.
216234 aliasdict ["Ag" ] = vbggrd
217235 aliasdict ["G" ] = voutgrd
0 commit comments