Skip to content

Commit

Permalink
Fix several failures due to updates of earth relief data (#498)
Browse files Browse the repository at this point in the history
Update some numbers due to the recent changes in GMT earth relief data.
We don't update the failing baseline images to minimize images updates.

Partially address #451.
  • Loading branch information
seisman authored Jun 29, 2020
1 parent f7b6d6c commit cda1fe8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Session:
... )
... # Read the contents of the temp file before it's deleted.
... print(fout.read().strip())
-180 180 -90 90 -8592.14453125 5558.79248047 1 1 361 181
-180 180 -90 90 -8592.5 5559 1 1 361 181
"""

# The minimum version of GMT required
Expand Down Expand Up @@ -1225,15 +1225,15 @@ def virtualfile_from_grid(self, grid):
>>> print(data.lat.values.min(), data.lat.values.max())
-90.0 90.0
>>> print(data.values.min(), data.values.max())
-8592.145 5558.7925
-8592.5 5559.0
>>> with Session() as ses:
... with ses.virtualfile_from_grid(data) as fin:
... # Send the output to a file so that we can read it
... with GMTTempFile() as fout:
... args = '{} -L0 -Cn ->{}'.format(fin, fout.name)
... ses.call_module('grdinfo', args)
... print(fout.read().strip())
-180 180 -90 90 -8592.14453125 5558.79248047 1 1 361 181
-180 180 -90 90 -8592.5 5559 1 1 361 181
>>> # The output is: w e s n z0 z1 dx dy n_columns n_rows
"""
Expand Down
8 changes: 4 additions & 4 deletions pygmt/tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def test_earth_relief_01d():
assert data.shape == (181, 361)
npt.assert_allclose(data.lat, np.arange(-90, 91, 1))
npt.assert_allclose(data.lon, np.arange(-180, 181, 1))
npt.assert_allclose(data.min(), -8592.144531)
npt.assert_allclose(data.max(), 5558.79248)
npt.assert_allclose(data.min(), -8592.5)
npt.assert_allclose(data.max(), 5559.0)


def test_earth_relief_30m():
Expand All @@ -84,5 +84,5 @@ def test_earth_relief_30m():
assert data.shape == (361, 721)
npt.assert_allclose(data.lat, np.arange(-90, 90.5, 0.5))
npt.assert_allclose(data.lon, np.arange(-180, 180.5, 0.5))
npt.assert_allclose(data.min(), -9460.310547)
npt.assert_allclose(data.max(), 5887.60791)
npt.assert_allclose(data.min(), -9460.5)
npt.assert_allclose(data.max(), 5887.5)
4 changes: 2 additions & 2 deletions pygmt/tests/test_grdinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ def test_grdinfo():
"Make sure grd info works as expected"
grid = load_earth_relief()
result = grdinfo(grid, L=0, C="n")
assert result.strip() == "-180 180 -90 90 -8592.14453125 5558.79248047 1 1 361 181"
assert result.strip() == "-180 180 -90 90 -8592.5 5559 1 1 361 181"


def test_grdinfo_file():
"Test grdinfo with file input"
result = grdinfo("@earth_relief_01d", L=0, C="n")
assert result.strip() == "-180 180 -90 90 -8592.14465255 5558.79248047 1 1 361 181"
assert result.strip() == "-180 180 -90 90 -8592.5 5559 1 1 361 181"


def test_grdinfo_fails():
Expand Down
8 changes: 4 additions & 4 deletions pygmt/tests/test_grdtrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_grdtrack_input_dataframe_and_dataarray():
output = grdtrack(points=dataframe, grid=dataarray, newcolname="bathymetry")
assert isinstance(output, pd.DataFrame)
assert output.columns.to_list() == ["longitude", "latitude", "bathymetry"]
npt.assert_allclose(output.iloc[0], [-110.9536, -42.2489, -2797.497251])
npt.assert_allclose(output.iloc[0], [-110.9536, -42.2489, -2797.394987])

return output

Expand All @@ -46,7 +46,7 @@ def test_grdtrack_input_csvfile_and_dataarray():
assert os.path.exists(path=TEMP_TRACK) # check that outfile exists at path

track = pd.read_csv(TEMP_TRACK, sep="\t", header=None, comment=">")
npt.assert_allclose(track.iloc[0], [-110.9536, -42.2489, -2797.497251])
npt.assert_allclose(track.iloc[0], [-110.9536, -42.2489, -2797.394987])
finally:
os.remove(path=TEMP_TRACK)

Expand All @@ -63,7 +63,7 @@ def test_grdtrack_input_dataframe_and_ncfile():
output = grdtrack(points=dataframe, grid=ncfile, newcolname="bathymetry")
assert isinstance(output, pd.DataFrame)
assert output.columns.to_list() == ["longitude", "latitude", "bathymetry"]
npt.assert_allclose(output.iloc[0], [-32.2971, 37.4118, -1686.878079])
npt.assert_allclose(output.iloc[0], [-32.2971, 37.4118, -1686.748899])

return output

Expand All @@ -81,7 +81,7 @@ def test_grdtrack_input_csvfile_and_ncfile():
assert os.path.exists(path=TEMP_TRACK) # check that outfile exists at path

track = pd.read_csv(TEMP_TRACK, sep="\t", header=None, comment=">")
npt.assert_allclose(track.iloc[0], [-32.2971, 37.4118, -1686.878079])
npt.assert_allclose(track.iloc[0], [-32.2971, 37.4118, -1686.748899])
finally:
os.remove(path=TEMP_TRACK)

Expand Down

0 comments on commit cda1fe8

Please sign in to comment.