Skip to content
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

Fix several failures due to updates of earth relief data #498

Merged
merged 1 commit into from
Jun 29, 2020
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
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