Skip to content

Add static_earth_relief to grdclip tests #1738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 11, 2022
Merged
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
22 changes: 11 additions & 11 deletions pygmt/tests/test_grdclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import pytest
import xarray as xr
from pygmt import grdclip, load_dataarray
from pygmt.datasets import load_earth_relief
from pygmt.helpers import GMTTempFile
from pygmt.helpers.testing import load_static_earth_relief


@pytest.fixture(scope="module", name="grid")
def fixture_grid():
"""
Load the grid data from the sample earth_relief file.
Load the grid data from the static_earth_relief file.
"""
return load_earth_relief(resolution="01d", region=[-5, 5, -5, 5])
return load_static_earth_relief()


@pytest.fixture(scope="module", name="expected_grid")
Expand All @@ -25,11 +25,11 @@ def fixture_grid_result():
"""
return xr.DataArray(
data=[
[-1800.0, -1800.0, -1800.0, -1800.0],
[-1800.0, -1800.0, -1800.0, -1800.0],
[-656.0, 40.0, -1800.0, -1800.0],
[1000.0, 570.5, -1000.0, -1000.0],
[1000.0, 1000.0, 571.5, 638.5],
[555.5, 556.0, 580.0, 1000.0],
],
coords=dict(lon=[-2.5, -1.5, -0.5, 0.5], lat=[2.5, 3.5, 4.5]),
coords=dict(lon=[-52.5, -51.5, -50.5, -49.5], lat=[-18.5, -17.5, -16.5]),
dims=["lat", "lon"],
)

Expand All @@ -42,9 +42,9 @@ def test_grdclip_outgrid(grid, expected_grid):
result = grdclip(
grid=grid,
outgrid=tmpfile.name,
below=[-1500, -1800],
above=[-200, 40],
region=[-3, 1, 2, 5],
below=[550, -1000],
above=[700, 1000],
region=[-53, -49, -19, -16],
)
assert result is None # return value is None
assert os.path.exists(path=tmpfile.name) # check that outgrid exists
Expand All @@ -60,7 +60,7 @@ def test_grdclip_no_outgrid(grid, expected_grid):
Test the below and above parameters for grdclip with no set outgrid.
"""
temp_grid = grdclip(
grid=grid, below=[-1500, -1800], above=[-200, 40], region=[-3, 1, 2, 5]
grid=grid, below=[550, -1000], above=[700, 1000], region=[-53, -49, -19, -16]
)
assert temp_grid.dims == ("lat", "lon")
assert temp_grid.gmt.gtype == 1 # Geographic grid
Expand Down