Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions pygmt/src/grdtrack.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
"""
grdtrack - Sample grids at specified (x,y) locations.
"""
import warnings

import pandas as pd
import xarray as xr
from pygmt.clib import Session
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers import (
Expand All @@ -14,7 +11,6 @@
kwargs_to_strings,
use_alias,
)
from pygmt.src.which import which

__doctest_skip__ = ["grdtrack"]

Expand Down Expand Up @@ -297,29 +293,6 @@ def grdtrack(grid, points=None, newcolname=None, outfile=None, **kwargs):
if hasattr(points, "columns") and newcolname is None:
raise GMTInvalidInput("Please pass in a str to 'newcolname'")

# Backward compatibility with old parameter order "points, grid".
# deprecated_version="0.7.0", remove_version="v0.9.0"
is_a_grid = True
if not isinstance(grid, (xr.DataArray, str)):
is_a_grid = False
elif isinstance(grid, str):
try:
xr.open_dataarray(which(grid, download="a"), engine="netcdf4").close()
is_a_grid = True
except (ValueError, OSError):
is_a_grid = False
if not is_a_grid:
msg = (
"Positional parameters 'points, grid' of pygmt.grdtrack() has changed "
"to 'grid, points=None' since v0.7.0. It's likely that you're NOT "
"passing a valid grid as the first positional argument or "
"are passing an invalid grid to the 'grid' parameter. "
"Please check the order of arguments with the latest documentation. "
"This warning will be removed in v0.9.0."
)
grid, points = points, grid
warnings.warn(msg, category=FutureWarning, stacklevel=1)

with GMTTempFile(suffix=".csv") as tmpfile:
with Session() as lib:
# Store the xarray.DataArray grid in virtualfile
Expand Down
15 changes: 0 additions & 15 deletions pygmt/tests/test_grdtrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,3 @@ def test_grdtrack_set_points_and_profile(dataarray, dataframe):
"""
with pytest.raises(GMTInvalidInput):
grdtrack(grid=dataarray, points=dataframe, profile="BL/TR")


def test_grdtrack_old_parameter_order(dataframe, dataarray, expected_array):
"""
Run grdtrack with the old parameter order 'points, grid'.

This test should be removed in v0.9.0.
"""
for points in (POINTS_DATA, dataframe):
for grid in ("@static_earth_relief.nc", dataarray):
with pytest.warns(expected_warning=FutureWarning) as record:
output = grdtrack(points, grid)
assert len(record) == 1
assert isinstance(output, pd.DataFrame)
npt.assert_allclose(np.array(output), expected_array)