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

Explicitly use netcdf4 engine in xarray.open_dataarray to read grd files #1264

Merged
merged 1 commit into from
May 7, 2021
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
2 changes: 1 addition & 1 deletion pygmt/datasets/earth_relief.py
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ def load_earth_relief(resolution="01d", region=None, registration=None, use_srtm
f"'region' is required for Earth relief resolution '{resolution}'."
)
fname = which(f"@earth_relief_{resolution}{reg}", download="a")
with xr.open_dataarray(fname) as dataarray:
with xr.open_dataarray(fname, engine="netcdf4") as dataarray:
grid = dataarray.load()
_ = grid.gmt # load GMTDataArray accessor information
else:
2 changes: 1 addition & 1 deletion pygmt/tests/test_accessor.py
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ def test_accessor_pixel_geographic():
and a gtype value of 0 when using Cartesian coordinates.
"""
fname = which(fname="@earth_relief_01d_p", download="a")
grid = xr.open_dataarray(fname)
grid = xr.open_dataarray(fname, engine="netcdf4")
assert grid.gmt.registration == 1 # pixel registration
assert grid.gmt.gtype == 1 # geographic coordinate type

2 changes: 1 addition & 1 deletion pygmt/tests/test_clib_put_matrix.py
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ def test_put_matrix_grid():
npt.assert_allclose(newdata, data)

# Save the data to a netCDF grid and check that xarray can load it
with GMTTempFile() as tmp_grid:
with GMTTempFile(suffix=".nc") as tmp_grid:
lib.write_data(
"GMT_IS_MATRIX",
"GMT_IS_SURFACE",