20
20
V = "verbose" ,
21
21
)
22
22
@kwargs_to_strings (R = "sequence" )
23
- def xyz2grd (data , ** kwargs ):
23
+ def xyz2grd (data = None , x = None , y = None , z = None , ** kwargs ):
24
24
"""
25
25
Create a grid file from table data.
26
26
@@ -34,9 +34,10 @@ def xyz2grd(data, **kwargs):
34
34
Parameters
35
35
----------
36
36
data : str or {table-like}
37
- Pass in either a file name to an ASCII data table, a 1D/2D
38
- {table-classes}.
39
-
37
+ Pass in (x, y, z) or (longitude, latitude, elevation) values by
38
+ providing a file name to an ASCII data table, a 2D {table-classes}.
39
+ x/y/z : 1d arrays
40
+ The arrays of x and y coordinates and z data points.
40
41
outgrid : str or None
41
42
Optional. The name of the output netCDF file with extension .nc to
42
43
store the grid in.
@@ -51,17 +52,18 @@ def xyz2grd(data, **kwargs):
51
52
52
53
- :class:`xarray.DataArray`: if ``outgrid`` is not set
53
54
- None if ``outgrid`` is set (grid output will be stored in file set by
54
- ``outgrid``)```
55
+ ``outgrid``)
55
56
"""
56
57
with GMTTempFile (suffix = ".nc" ) as tmpfile :
57
58
with Session () as lib :
58
- file_context = lib .virtualfile_from_data (check_kind = "vector" , data = data )
59
+ file_context = lib .virtualfile_from_data (
60
+ check_kind = "vector" , data = data , x = x , y = y , z = z , required_z = True
61
+ )
59
62
with file_context as infile :
60
63
if "G" not in kwargs .keys (): # if outgrid is unset, output to tempfile
61
64
kwargs .update ({"G" : tmpfile .name })
62
65
outgrid = kwargs ["G" ]
63
- arg_str = build_arg_string (kwargs )
64
- arg_str = " " .join ([infile , arg_str ])
66
+ arg_str = " " .join ([infile , build_arg_string (kwargs )])
65
67
lib .call_module ("xyz2grd" , arg_str )
66
68
67
69
return load_dataarray (outgrid ) if outgrid == tmpfile .name else None
0 commit comments