Skip to content

Commit

Permalink
Change test_grdcontour.py to use static_earth_relief (GenericMappingT…
Browse files Browse the repository at this point in the history
…ools#1741)

Co-authored-by: Dongdong Tian <[email protected]>
  • Loading branch information
2 people authored and Josh Sixsmith committed Dec 21, 2022
1 parent 65520ee commit 8b35c96
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 54 deletions.
4 changes: 2 additions & 2 deletions pygmt/tests/baseline/test_grdcontour.png.dvc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
outs:
- md5: 9366e405a1be22b4c2515f24a3acae69
size: 217638
- md5: 3a660b618cc84791f6dc85d67b6b10b8
size: 107934
path: test_grdcontour.png
4 changes: 0 additions & 4 deletions pygmt/tests/baseline/test_grdcontour_file.png.dvc

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
outs:
- md5: 25125246f541652071fac1771e5d7e88
size: 33966
- md5: 8983696dc93da77fc1e9d7e8d8920836
size: 30055
path: test_grdcontour_interval_file_full_opts.png
4 changes: 2 additions & 2 deletions pygmt/tests/baseline/test_grdcontour_labels.png.dvc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
outs:
- md5: 03a7cc6dea35f9383cbfb2683d7b7c1b
size: 223421
- md5: cce113a8d8a9ba54c3bf08827b518287
size: 112762
path: test_grdcontour_labels.png
4 changes: 2 additions & 2 deletions pygmt/tests/baseline/test_grdcontour_slice.png.dvc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
outs:
- md5: 48070d23c538d26eb96b5caaf440513a
size: 97314
- md5: 66f1c57afea5075a02f5f90b2c225185
size: 53984
path: test_grdcontour_slice.png
18 changes: 8 additions & 10 deletions pygmt/tests/data/contours.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
-6000 C
-5000 C
-4000 A
-3000 C
-2000 C
-1000 C
0 A
1000 C
2000 A
3000 C
200 A
300 C
400 A
500 C
600 A
700 C
800 A
900 C
52 changes: 20 additions & 32 deletions pygmt/tests/test_grdcontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import numpy as np
import pytest
from pygmt import Figure
from pygmt.datasets import load_earth_relief
from pygmt.exceptions import GMTInvalidInput
from pygmt.helpers.testing import load_static_earth_relief

TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
TEST_CONTOUR_FILE = os.path.join(TEST_DATA_DIR, "contours.txt")
Expand All @@ -16,9 +16,9 @@
@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(registration="gridline")
return load_static_earth_relief()


@pytest.mark.mpl_image_compare
Expand All @@ -27,7 +27,9 @@ def test_grdcontour(grid):
Plot a contour image using an xarray grid with fixed contour interval.
"""
fig = Figure()
fig.grdcontour(grid, interval="1000", projection="W0/15c", frame=True)
fig.grdcontour(
grid=grid, interval=50, annotation=200, projection="M10c", frame=True
)
return fig


Expand All @@ -39,10 +41,10 @@ def test_grdcontour_labels(grid):
"""
fig = Figure()
fig.grdcontour(
grid,
interval="1000",
annotation="5000",
projection="W0/15c",
grid=grid,
interval=50,
annotation=200,
projection="M10c",
pen=["a1p,red", "c0.5p,black"],
label_placement="d6c",
frame=True,
Expand All @@ -55,28 +57,10 @@ def test_grdcontour_slice(grid):
"""
Plot an contour image using an xarray grid that has been sliced.
"""
grid_ = grid.sel(lat=slice(-30, 30))
grid_ = grid.sel(lat=slice(-20, -10))

fig = Figure()
fig.grdcontour(grid=grid_, interval="1000", projection="M15c", frame=True)
return fig


@pytest.mark.mpl_image_compare
def test_grdcontour_file():
"""
Plot a contour image using grid file input.
"""
fig = Figure()
fig.grdcontour(
"@earth_relief_01d_g",
interval="1000",
limit="0",
pen="0.5p,black",
region=[-180, 180, -70, 70],
projection="M15c",
frame=True,
)
fig.grdcontour(grid=grid_, interval=100, projection="M10c", frame=True)
return fig


Expand All @@ -88,15 +72,19 @@ def test_grdcontour_interval_file_full_opts(grid):
fig = Figure()

comargs = {
"region": [-161.5, -154, 18.5, 23],
"region": [-53, -49, -20, -17],
"interval": TEST_CONTOUR_FILE,
"grid": grid,
"resample": "100",
"resample": 100,
"projection": "M10c",
"cut": 10,
}
fig.grdcontour(**comargs, limit=(-25000, -1), pen=["a1p,blue", "c0.5p,blue"])
fig.grdcontour(**comargs, limit=0, pen=["a1p,black", "c0.5p,black"], frame=True)
# Plot contours below 650 in blue
fig.grdcontour(
**comargs, limit=(0, 649), pen=["a1p,blue", "c0.5p,blue"], frame=True
)
# Plot contours above 650 in black
fig.grdcontour(**comargs, limit=(650, 1000), pen=["a1p,black", "c0.5p,black"])

return fig

Expand Down

0 comments on commit 8b35c96

Please sign in to comment.