Skip to content

Commit ae65cfc

Browse files
committed
Refactor grdmix implementation to use pygmt.io.load_dataarray
1 parent 68dc74a commit ae65cfc

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

pygmt/src/grdmix.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
grdmix - Blending and transforming grids and images.
33
"""
4-
import xarray as xr
54
from pygmt.clib import Session
65
from pygmt.helpers import (
76
GMTTempFile,
@@ -10,6 +9,7 @@
109
kwargs_to_strings,
1110
use_alias,
1211
)
12+
from pygmt.io import load_dataarray
1313

1414

1515
@fmt_docstring
@@ -90,11 +90,4 @@ def grdmix(grid=None, outgrid=None, **kwargs):
9090
arg_str = " ".join([infile, build_arg_string(kwargs)])
9191
lib.call_module("grdmix", arg_str)
9292

93-
if outgrid == tmpfile.name: # if user did not set outgrid, return DataArray
94-
with xr.open_dataarray(outgrid) as dataarray:
95-
result = dataarray.load()
96-
_ = result.gmt # load GMTDataArray accessor information
97-
else:
98-
result = None # if user sets an outgrid, return None
99-
100-
return result
93+
return load_dataarray(outgrid) if outgrid == tmpfile.name else None

0 commit comments

Comments
 (0)