Skip to content

Commit c0413f8

Browse files
authored
Merge branch 'main' into static-earth-relief/grdview
2 parents 37e5985 + 8e1e110 commit c0413f8

7 files changed

+36
-54
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
outs:
2-
- md5: 9366e405a1be22b4c2515f24a3acae69
3-
size: 217638
2+
- md5: 3a660b618cc84791f6dc85d67b6b10b8
3+
size: 107934
44
path: test_grdcontour.png

pygmt/tests/baseline/test_grdcontour_file.png.dvc

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
outs:
2-
- md5: 25125246f541652071fac1771e5d7e88
3-
size: 33966
2+
- md5: 8983696dc93da77fc1e9d7e8d8920836
3+
size: 30055
44
path: test_grdcontour_interval_file_full_opts.png
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
outs:
2-
- md5: 03a7cc6dea35f9383cbfb2683d7b7c1b
3-
size: 223421
2+
- md5: cce113a8d8a9ba54c3bf08827b518287
3+
size: 112762
44
path: test_grdcontour_labels.png
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
outs:
2-
- md5: 48070d23c538d26eb96b5caaf440513a
3-
size: 97314
2+
- md5: 66f1c57afea5075a02f5f90b2c225185
3+
size: 53984
44
path: test_grdcontour_slice.png

pygmt/tests/data/contours.txt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
-6000 C
2-
-5000 C
3-
-4000 A
4-
-3000 C
5-
-2000 C
6-
-1000 C
7-
0 A
8-
1000 C
9-
2000 A
10-
3000 C
1+
200 A
2+
300 C
3+
400 A
4+
500 C
5+
600 A
6+
700 C
7+
800 A
8+
900 C

pygmt/tests/test_grdcontour.py

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import numpy as np
77
import pytest
88
from pygmt import Figure
9-
from pygmt.datasets import load_earth_relief
109
from pygmt.exceptions import GMTInvalidInput
10+
from pygmt.helpers.testing import load_static_earth_relief
1111

1212
TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
1313
TEST_CONTOUR_FILE = os.path.join(TEST_DATA_DIR, "contours.txt")
@@ -16,9 +16,9 @@
1616
@pytest.fixture(scope="module", name="grid")
1717
def fixture_grid():
1818
"""
19-
Load the grid data from the sample earth_relief file.
19+
Load the grid data from the static_earth_relief file.
2020
"""
21-
return load_earth_relief(registration="gridline")
21+
return load_static_earth_relief()
2222

2323

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

3335

@@ -39,10 +41,10 @@ def test_grdcontour_labels(grid):
3941
"""
4042
fig = Figure()
4143
fig.grdcontour(
42-
grid,
43-
interval="1000",
44-
annotation="5000",
45-
projection="W0/15c",
44+
grid=grid,
45+
interval=50,
46+
annotation=200,
47+
projection="M10c",
4648
pen=["a1p,red", "c0.5p,black"],
4749
label_placement="d6c",
4850
frame=True,
@@ -55,28 +57,10 @@ def test_grdcontour_slice(grid):
5557
"""
5658
Plot an contour image using an xarray grid that has been sliced.
5759
"""
58-
grid_ = grid.sel(lat=slice(-30, 30))
60+
grid_ = grid.sel(lat=slice(-20, -10))
5961

6062
fig = Figure()
61-
fig.grdcontour(grid=grid_, interval="1000", projection="M15c", frame=True)
62-
return fig
63-
64-
65-
@pytest.mark.mpl_image_compare
66-
def test_grdcontour_file():
67-
"""
68-
Plot a contour image using grid file input.
69-
"""
70-
fig = Figure()
71-
fig.grdcontour(
72-
"@earth_relief_01d_g",
73-
interval="1000",
74-
limit="0",
75-
pen="0.5p,black",
76-
region=[-180, 180, -70, 70],
77-
projection="M15c",
78-
frame=True,
79-
)
63+
fig.grdcontour(grid=grid_, interval=100, projection="M10c", frame=True)
8064
return fig
8165

8266

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

9074
comargs = {
91-
"region": [-161.5, -154, 18.5, 23],
75+
"region": [-53, -49, -20, -17],
9276
"interval": TEST_CONTOUR_FILE,
9377
"grid": grid,
94-
"resample": "100",
78+
"resample": 100,
9579
"projection": "M10c",
9680
"cut": 10,
9781
}
98-
fig.grdcontour(**comargs, limit=(-25000, -1), pen=["a1p,blue", "c0.5p,blue"])
99-
fig.grdcontour(**comargs, limit=0, pen=["a1p,black", "c0.5p,black"], frame=True)
82+
# Plot contours below 650 in blue
83+
fig.grdcontour(
84+
**comargs, limit=(0, 649), pen=["a1p,blue", "c0.5p,blue"], frame=True
85+
)
86+
# Plot contours above 650 in black
87+
fig.grdcontour(**comargs, limit=(650, 1000), pen=["a1p,black", "c0.5p,black"])
10088

10189
return fig
10290

0 commit comments

Comments
 (0)