Skip to content

Commit 5a685b2

Browse files
committed
Deep copy grid using xarray.DataArray.copy instead of numpy.copy
After flipping the grid, try doing the deep copy on xarray (which should return a c_contiguous array) before retrieving the data (i.e. the numpy array).
1 parent 5a0c639 commit 5a685b2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pygmt/clib/conversion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def dataarray_to_matrix(grid):
113113
inc = [abs(i) for i in inc]
114114
grid = grid.sortby(variables=list(grid.dims), ascending=True)
115115

116-
matrix = as_c_contiguous(grid[::-1].values)
116+
matrix = as_c_contiguous(grid[::-1].copy(deep=True).data)
117117
return matrix, region, inc
118118

119119

0 commit comments

Comments
 (0)